Skip to content

Commit d224356

Browse files
authored
Merge pull request #1432 from TeamCOMPAS/minor-fix
Defect repairs
2 parents 4941c41 + 4c5ad6b commit d224356

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
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) = 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 = a[76] + (a[77] * PPOW(std::abs(p_Mass - a[78]), a[79])); // BSE Fortran code has abs()
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); // 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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,11 @@
16591659
// - Corrected calculations for Hurley A(n) and B(n) coefficients (see Hurley et al. 2000, appendix)
16601660
// - Changed utils::GetGSLVersion() to avoid compiler warning "warning: ignoring attributes on template argument ‘int (*)(FILE*)’ [-Wignored-attributes]"
16611661
// - Reverted Makefile line "SOURCES := $(wildcard *.cpp)" to listing actual source files
1662+
// 03.25.02 JR - August 20, 2025 - Defect repairs:
1663+
// - Clamped B_GAMMA to [0.0, B_GAMMA] (per discussion just after eq 23 - confirmed in BSE Fortran source)
1664+
// - 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)
16621667
//
16631668
// Version string format is MM.mm.rr, where
16641669
//
@@ -1669,7 +1674,7 @@
16691674
// if MM is incremented, set mm and rr to 00, even if defect repairs and minor enhancements were also made
16701675
// if mm is incremented, set rr to 00, even if defect repairs were also made
16711676

1672-
const std::string VERSION_STRING = "03.25.01";
1677+
const std::string VERSION_STRING = "03.25.02";
16731678

16741679

16751680
# endif // __changelog_h__

0 commit comments

Comments
 (0)