Tracked down issue to atmesc.c:fdHZRG14. Looks like a memort leak.
@@ -2237,17 +2237,22 @@ The rate of change of the envelope mass.
double fdDEnvelopeMassDt(BODY *body,SYSTEM *system,int *iaBody) {
// TODO: This needs to be moved. Ideally we'd just remove this equation from the matrix.
+ // RB: move to ForceBehaviorAtmesc
if ((body[iaBody[0]].dEnvelopeMass <= 0) || (body[iaBody[0]].dAge > body[iaBody[0]].dJeansTime)) {
- return 0;
+ return TINY;
}
if (body[iaBody[0]].iPlanetRadiusModel == ATMESC_LEHMER17) {
- return -body[iaBody[0]].dAtmXAbsEffH * PI * body[iaBody[0]].dFXUV * pow(body[iaBody[0]].dRadXUV, 3.0) / ( BIGG * (body[iaBody[0]].dMass - body[iaBody[0]].dEnvelopeMass));
+ return -body[iaBody[0]].dAtmXAbsEffH * PI * body[iaBody[0]].dFXUV
+ * pow(body[iaBody[0]].dRadXUV, 3.0) / ( BIGG * (body[iaBody[0]].dMass
+ - body[iaBody[0]].dEnvelopeMass));
- }
- else{
- return -body[iaBody[0]].dFHRef * (body[iaBody[0]].dAtmXAbsEffH / body[iaBody[0]].dAtmXAbsEffH2O) * (4 * ATOMMASS * PI * body[iaBody[0]].dRadius * body[iaBody[0]].dRadius * body[iaBody[0]].dXFrac * body[iaBody[0]].dXFrac);
+ } else {
+ return -body[iaBody[0]].dFHRef * (body[iaBody[0]].dAtmXAbsEffH
+ / body[iaBody[0]].dAtmXAbsEffH2O) * (4 * ATOMMASS * PI
+ * body[iaBody[0]].dRadius * body[iaBody[0]].dRadius
+ * body[iaBody[0]].dXFrac * body[iaBody[0]].dXFrac);
}
}
@@ -2381,6 +2386,8 @@ runaway greenhouse limit.
@param dEcc The planet's eccentricity -- RB: Why is ecc passed?
@param dPlanetMass The planet mass
*/
+
+// Why isn't this in system.c?
double fdHZRG14(double dLuminosity, double dTeff, double dEcc, double dPlanetMass) {
// Do a simple log-linear fit to the Kopparapu+14 mass-dependent RG limit
int i;
@@ -2457,6 +2464,8 @@ Performs a really simple linear least-squares fit on data.
@param iLen The length of the arrays
@param daCoeffs The slope and the intercept of the fit
*/
+
+// should be in another file. control?
void fvLinearFit(double *x, double *y, int iLen, double *daCoeffs){
// Simple least squares linear regression, y(x) = mx + b
// from http://en.wikipedia.org/wiki/Simple_linear_regression
