Skip to content

Commit 68f6ec3

Browse files
committed
Additional minor fixes
1 parent 0809c37 commit 68f6ec3

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/BaseStar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,8 @@ void BaseStar::CalculateAnCoefficients(DBL_VECTOR &p_AnCoefficients,
578578
RConstants(C_BETA_R) = (a[69] * 16384.0) / (a[70] + PPOW(16.0, a[71])); // Hurley et al. 2000, eq 22a
579579
RConstants(B_DELTA_R) = (a[38] + a[39] * 8.0 * M_SQRT2) / (a[40] * 8.0 + PPOW(2.0, a[41])) - 1.0; // Hurley et al. 2000, eq 17
580580

581-
GammaConstants(B_GAMMA) = max(0.0, a[76] + (a[77] * PPOW((1.0 - a[78]), a[79]))); // Hurley et al. 2000, eq 23
582-
GammaConstants(C_GAMMA) = (utils::Compare(a[75], 1.0) <= 0) ? GammaConstants(B_GAMMA) : a[80]; // Hurley et al. 2000, eq 23
581+
GammaConstants(B_GAMMA) = max(0.0, a[76] + (a[77] * PPOW((1.0 - a[78]), a[79]))); // Hurley et al. 2000, eq 23 and discussion immediately following - max() confirmed in BSE Fortran code
582+
GammaConstants(C_GAMMA) = (utils::Compare(a[75], 1.0) <= 0) ? GammaConstants(B_GAMMA) : a[80]; // Hurley et al. 2000, eq 23 and discussion immediately following - <= 1.0 confirmed in BSE Fortran code
583583

584584
#undef GammaConstants
585585
#undef RConstants

src/MainSequence.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,14 @@ double MainSequence::CalculateGamma(const double p_Mass) const {
228228
#define B_GAMMA m_GammaConstants[static_cast<int>(GAMMA_CONSTANTS::B_GAMMA)] // for convenience and readability - undefined at end of function
229229
#define C_GAMMA m_GammaConstants[static_cast<int>(GAMMA_CONSTANTS::C_GAMMA)] // for convenience and readability - undefined at end of function
230230

231-
double gamma;
231+
double gamma = 0.0; // default return value
232232

233-
if (utils::Compare(p_Mass, 1.0) <= 0) gamma = a[76] + (a[77] * PPOW(p_Mass - a[78], a[79]));
234-
else if (utils::Compare(p_Mass, a[75]) <= 0) gamma = B_GAMMA + (a[80] - B_GAMMA) * PPOW((p_Mass - 1.0) / (a[75] - 1.0), a[81]);
235-
else if (utils::Compare(p_Mass, (a[75] + 0.1)) <= 0) gamma = C_GAMMA - (10.0 * (p_Mass - a[75]) * C_GAMMA); // included = case, missing from Hurley+ 2000
236-
else gamma = 0.0; // this really is zero
233+
if (utils::Compare(p_Mass, 1.0) <= 0) gamma = an[76] + (an[77] * PPOW(std::abs(p_Mass - an[78]), an[79])); // BSE Fortran code has abs()
234+
else if (utils::Compare(p_Mass, an[75]) <= 0) gamma = B_GAMMA + (an[80] - B_GAMMA) * PPOW((p_Mass - 1.0) / (an[75] - 1.0), an[81]);
235+
else if (utils::Compare(p_Mass, (an[75] + 0.1)) <= 0) gamma = C_GAMMA - (10.0 * (p_Mass - an[75]) * C_GAMMA); // see discussion just prior to eq 23 - the end point is wrong in the arxiv version of Hurley et al. 2000 (should be 0.1, not 1.0) - confirmed in BSE Fortran code
236+
else gamma = 0.0; // see discussion just prior to eq 23 - confirmed in BSE Fortran code
237237

238-
return gamma;
238+
return std::max(0.0, gamma); // see discussion following eq 23 - confirmed in BSE Fortran code
239239

240240
#undef C_GAMMA
241241
#undef B_GAMMA

src/changelog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,8 @@
16621662
// 03.25.02 JR - August 20, 2025 - Defect repairs:
16631663
// - Clamped B_GAMMA to [0.0, B_GAMMA] (per discussion just after eq 23 - confirmed in BSE Fortran source)
16641664
// - Corrected calculation for Hurley Gamma constant C (C_GAMMA - see Hurley et al. 2000, just after eq 23, should use a(75) <= 1.0, not a(75) == 1.0 - confirmed in BSE Fortran source)
1665+
// - Added abs() to gamma calculation in Mainsequence.cpp::CalculateGamma() (per BSE Fortran source)
1666+
// - Clamped gamma to [0.0, gamma] in Mainsequence.cpp::CalculateGamma() (per discussion just after eq 23 - confirmed in BSE Fortran source)
16651667
//
16661668
// Version string format is MM.mm.rr, where
16671669
//

0 commit comments

Comments
 (0)