Skip to content

Commit

Permalink
Added more columns to the .geography file. Updated calculation of Lan…
Browse files Browse the repository at this point in the history
…dFracGlobal, but the

mods didn't change the result.
  • Loading branch information
RoryBarnes committed Sep 30, 2024
1 parent 3bcdcbd commit e70b0a8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
46 changes: 33 additions & 13 deletions src/poise.c
Original file line number Diff line number Diff line change
Expand Up @@ -2085,15 +2085,28 @@ void VerifyNStepSeasonal(BODY *body, int iBody) {
}

void InitializeLatGrid(BODY *body, int iBody) {
double dDelta_x, SinLat;
int iLats;
dDelta_x = 2.0 / body[iBody].iNumLats;
double dInterval, dSinMinLat, dSinMidLat, dSinMaxLat, dMaxLat;
int iLat;

body[iBody].daLats = malloc(body[iBody].iNumLats * sizeof(double));
body[iBody].daLatsMin = malloc((body[iBody].iNumLats) * sizeof(double));
body[iBody].daLatsWidth = malloc((body[iBody].iNumLats) * sizeof(double));
body[iBody].daLatsArea = malloc((body[iBody].iNumLats) * sizeof(double));

body[iBody].daLats = malloc(body[iBody].iNumLats * sizeof(double));
dInterval = 2.0 / body[iBody].iNumLats;
for (iLat = 0; iLat < body[iBody].iNumLats; iLat++) {
dSinMinLat = -1.0 + iLat * dInterval;
body[iBody].daLatsMin[iLat] = asin(dSinMinLat);

dSinMidLat = (-1.0 + 0.5 * dInterval) + iLat * dInterval;
body[iBody].daLats[iLat] = asin(dSinMidLat);

for (iLats = 0; iLats < body[iBody].iNumLats; iLats++) {
SinLat = (-1.0 + dDelta_x / 2.) + iLats * dDelta_x;
body[iBody].daLats[iLats] = asin(SinLat);
dSinMaxLat = -1 + (iLat + 1) * dInterval;
dMaxLat = asin(dSinMaxLat);
body[iBody].daLatsWidth[iLat] = dMaxLat - body[iBody].daLatsMin[iLat];
body[iBody].daLatsArea[iLat] = 2 * PI * body[iBody].dRadius *
body[iBody].dRadius *
(dSinMaxLat - dSinMinLat);
}
}

Expand Down Expand Up @@ -2185,13 +2198,20 @@ void fvInitializeGeographyEquatorial(BODY *body, int iBody) {
void fvWriteGeographyFile(BODY *body, int iBody) {
int iLat;
FILE *fp;
char *cOut = NULL;
char *cOut = NULL;
double dRad2Deg = 180 / PI;

fvFormattedString(&cOut, "%s.geography", body[iBody].cName);
fp = fopen(cOut, "w");
fprintf(fp,
"MidLat[deg] LandFrac WaterFrac MinLat[deg] Width[deg] Area[km^2]\n");
for (iLat = 0; iLat < body[iBody].iNumLats; iLat++) {
fprintf(fp, "%.5lf %.5lf %.5lf\n", (body[iBody].daLats[iLat] * 180. / PI),
body[iBody].daLandFrac[iLat], body[iBody].daWaterFrac[iLat]);
fprintf(fp, "%.5lf %.5lf %.5lf %.5lf %lf %lf\n",
(body[iBody].daLats[iLat] * dRad2Deg), body[iBody].daLandFrac[iLat],
body[iBody].daWaterFrac[iLat],
(body[iBody].daLatsMin[iLat] * dRad2Deg),
(body[iBody].daLatsWidth[iLat] * dRad2Deg),
body[iBody].daLatsArea[iLat] / 1e6);
}
fclose(fp);
}
Expand Down Expand Up @@ -8233,11 +8253,11 @@ void PoiseIceSheets(BODY *body, EVOLVE *evolve, int iBody) {

double fdLandFracGlobal(BODY *body, int iBody) {
int iLat;
double dLandFrac = 0;
double dLandFrac, dLandArea = 0;

for (iLat = 0; iLat < body[iBody].iNumLats; iLat++) {
dLandFrac += body[iBody].daLandFrac[iLat];
dLandArea += (body[iBody].daLandFrac[iLat] * body[iBody].daLatsArea[iLat]);
}
dLandFrac /= body[iBody].iNumLats;
dLandFrac = dLandArea / (4 * PI * body[iBody].dRadius * body[iBody].dRadius);
return dLandFrac;
}
7 changes: 5 additions & 2 deletions src/vplanet.h
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,11 @@ struct BODY {
double *daFlux; /**< Meridional surface heat flux */
double *daFluxIn; /**< Incoming surface flux (insolation) */
double *daFluxOut; /**< Outgoing surface flux (longwave) */
double *daLats; /**< Latitude of each cell (centered), assuming equal areas
per bin; South Pole is 0 */
double *daLats; /**< Latitude of each cell (centered), assuming equal areas
per bin; South Pole is 0 */
double *daLatsMin; /**< Lower bound of each latitudinal bin */
double *daLatsWidth; /**< Angular width of each latitudinal bin */
double *daLatsArea; /**< Total area of each latitudinal bin */
double *daPeakInsol; /**< Annually averaged insolation at each latitude */
double *daTGrad; /**< Gradient of temperature (meridional) */

Expand Down

0 comments on commit e70b0a8

Please sign in to comment.