Skip to content

Commit c4f5c4a

Browse files
committed
Resolve sudden mass drop at end of HG
1 parent 7b4f2aa commit c4f5c4a

File tree

10 files changed

+41
-33
lines changed

10 files changed

+41
-33
lines changed

src/BaseBinaryStar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,14 +2132,14 @@ void BaseBinaryStar::ResolveMassChanges() {
21322132

21332133
// update mass of star1 according to mass loss and mass transfer, then update age accordingly
21342134
(void)m_Star1->UpdateAttributes(m_Star1->MassPrev() - m_Star1->Mass() + m_Star1->MassLossDiff() + m_Star1->MassTransferDiff(), 0.0); // update mass for star1
2135-
m_Star1->UpdateInitialMass(); // update initial mass of star1 (MS, HG & HeMS) JR: todo: fix this kludge one day - mass0 is overloaded, and isn't always "initial mass"
2135+
m_Star1->UpdateInitialMass(); // update effective initial mass of star1 (MS, HG & HeMS, HeHG)
21362136
m_Star1->UpdateAgeAfterMassLoss(); // update age of star1
21372137
m_Star1->ApplyMassTransferRejuvenationFactor(); // apply age rejuvenation factor for star1
21382138
m_Star1->UpdateAttributes(0.0, 0.0, true);
21392139

21402140
// rinse and repeat for star2
21412141
(void)m_Star2->UpdateAttributes(m_Star2->MassPrev() - m_Star2->Mass() + m_Star2->MassLossDiff() + m_Star2->MassTransferDiff(), 0.0); // update mass for star2
2142-
m_Star2->UpdateInitialMass(); // update initial mass of star 2 (MS, HG & HeMS) JR: todo: fix this kludge one day - mass0 is overloaded, and isn't always "initial mass"
2142+
m_Star2->UpdateInitialMass(); // update effective initial mass of star 2 (MS, HG & HeMS, HeHG)
21432143
m_Star2->UpdateAgeAfterMassLoss(); // update age of star2
21442144
m_Star2->ApplyMassTransferRejuvenationFactor(); // apply age rejuvenation factor for star2
21452145
m_Star2->UpdateAttributes(0.0, 0.0, true);

src/BaseBinaryStar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ class BaseBinaryStar {
543543
(void)donorCopy->UpdateAttributes(-dM, -dM*donorCopy->Mass0()/donorCopy->Mass());
544544

545545
// Modify donor Mass0 and Age for MS (including HeMS) and HG stars
546-
donorCopy->UpdateInitialMass(); // update initial mass (MS, HG & HeMS) JR: todo: fix this kludge - mass0 is overloaded, and isn't always "initial mass"
546+
donorCopy->UpdateInitialMass(); // update initial mass (MS, HG & HeMS)
547547
donorCopy->UpdateAgeAfterMassLoss(); // update age (MS, HG & HeMS)
548548

549549
(void)donorCopy->AgeOneTimestep(0.0); // recalculate radius of star - don't age - just update values

src/BaseStar.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ double BaseStar::CalculateLogBindingEnergyLoveridge(bool p_IsMassLoss) const {
10551055
logBindingEnergy += lCoefficients.alpha_mr * utils::intPow(log10(m_Mass), lCoefficients.m) * utils::intPow(log10(m_Radius + deltaR), lCoefficients.r);
10561056
}
10571057

1058-
double MZAMS_Mass = (m_MZAMS - m_Mass) / m_MZAMS;
1058+
double MZAMS_Mass = (m_MZAMS - m_Mass) / m_MZAMS; // Should m_ZAMS really be m_Mass0 (i.e., account for change in effective mass through mass loss in winds, MS mass transfer?)
10591059
logBindingEnergy *= p_IsMassLoss ? 1.0 + (0.25 * MZAMS_Mass * MZAMS_Mass) : 1.0; // apply mass-loss correction factor (lambda)
10601060

10611061
constexpr double logBE0 = 33.29866; // JR: todo: what is this for? Should it be in constants.h?
@@ -1239,7 +1239,7 @@ double BaseStar::CalculateLuminosityAtZAMS(const double p_MZAMS) {
12391239
*
12401240
* double CalculateLuminosityAtBAGB(double p_Mass)
12411241
*
1242-
* @param [IN] p_Mass Mass in Msol
1242+
* @param [IN] p_Mass (Effective) mass in Msol
12431243
* @return Luminosity at BAGB in Lsol
12441244
*/
12451245
double BaseStar::CalculateLuminosityAtBAGB(double p_Mass) const {
@@ -1842,7 +1842,7 @@ void BaseStar::ResolveMassLoss() {
18421842
m_COCoreMass=std::min(m_COCoreMass,m_Mass); // Not expected, only a precaution to avoid inconsistencies
18431843
m_CoreMass=std::min(m_CoreMass, m_Mass);
18441844

1845-
UpdateInitialMass(); // update initial mass (MS, HG & HeMS) JR: todo: fix this kludge one day - mass0 is overloaded, and isn't always "initial mass"
1845+
UpdateInitialMass(); // update effective initial mass (MS, HG & HeMS, HeHG)
18461846
UpdateAgeAfterMassLoss(); // update age (MS, HG & HeMS)
18471847
ApplyMassTransferRejuvenationFactor(); // apply age rejuvenation factor
18481848
}
@@ -2964,14 +2964,10 @@ void BaseStar::UpdateAttributesAndAgeOneTimestepPreamble(const double p_DeltaMas
29642964
* attributes are updated. The p_DeltaMass parameter may be zero, in which case no change is made to the
29652965
* star's mass before the attributes of the star are calculated.
29662966
*
2967-
* - if required, the star's initial mass is changed by the amount passed as the p_DeltaMass0 parameter before
2968-
* other attributes are updated. The p_DeltaMass parameter may be zero, in which case no change is made to
2969-
* the star's mass before the attributes of the star are calculated. This should be used infrequently, and
2970-
* is really a kludge because the Mass0 attribute in Hurley et al. 2000 was overloaded after the introduction
2971-
* of mass loss (see section 7.1). We should really separate the different uses of Mass0 in the code and
2972-
* use a different variable - initial mass shouldn't change (other than to initial mass upon entering a
2973-
* stellar phase - it doesn't make a lot of sense for initial mass to change during evolution through the
2974-
* phase). JR: todo: action this paragraph.
2967+
* - if required, the star's effective initial mass is changed by the amount passed as the p_DeltaMass0 parameter before
2968+
* other attributes are updated. The p_DeltaMass0 parameter may be zero, in which case no change is made to
2969+
* the star's mass before the attributes of the star are calculated. The Mass0 attribute in Hurley et al. 2000 is overloaded by the introduction
2970+
* of mass loss (see section 7.1).
29752971
*
29762972
* - if required, the star is aged by the amount passed as the p_DeltaTime parameter, and the simulation time is
29772973
* advanced by the same amount, before other attributes are updated. The p_deltaTime parameter may be zero,

src/EAGB.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ double EAGB::CalculateLambdaNanjing() const {
8282
DBL_VECTOR b = {}; // 0..5 b_coefficients
8383

8484
if (utils::Compare(m_Metallicity, LAMBDA_NANJING_ZLIMIT) > 0) { // Z>0.5 Zsun: popI
85-
if (utils::Compare(m_MZAMS, 1.5) < 0) {
85+
if (utils::Compare(m_MZAMS, 1.5) < 0) { // Should probably use effective mass m_Mass0 instead for Lambda calculations
8686
maxBG = { 2.5, 1.5 };
8787
if (utils::Compare(m_Radius, 200.0) > 0) lambdaBG = { 0.05, 0.05 };
8888
else {
@@ -408,7 +408,7 @@ double EAGB::CalculateLambdaNanjing() const {
408408
/*
409409
* Calculate luminosity on the Early Asymptotic Giant Branch
410410
*
411-
* Hurley et al. 2000, eqs 61, 62 & 63
411+
* Hurley et al. 2000, eq 37
412412
*
413413
*
414414
* double CalculateLuminosityOnPhase(const double p_CoreMass)

src/FGB.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ STELLAR_TYPE FGB::ResolveEnvelopeLoss(bool p_NoCheck) {
165165

166166
if (p_NoCheck || utils::Compare(m_CoreMass, m_Mass) > 0) { // Envelope loss
167167

168-
if (utils::Compare(m_Mass, massCutoffs(MHeF)) < 0) { // Star evolves to Helium White Dwarf
168+
if (utils::Compare(m_Mass0, massCutoffs(MHeF)) < 0) { // Star evolves to Helium White Dwarf
169169

170170
stellarType = STELLAR_TYPE::HELIUM_WHITE_DWARF;
171171

@@ -200,13 +200,10 @@ STELLAR_TYPE FGB::ResolveEnvelopeLoss(bool p_NoCheck) {
200200
/*
201201
* Modify the star due to (possible) helium flash
202202
*
203-
* JR: Is this described in Hurley et al. 2000?
204-
*
205203
*
206204
* void ResolveHeliumFlash()
207205
*
208-
* Deletermine if Helium Flash occurs, and if so modify the star accordingly.
209-
* The attributes of the star are updated.
206+
* Deletermine if Helium Flash occurs, and if so set m_Mass0 equal to current mass as described in Hurley+ (2000), last paragraph before start of 7.1.1.
210207
*/
211208
void FGB::ResolveHeliumFlash() {
212209
#define timescales(x) m_Timescales[static_cast<int>(TIMESCALE::x)] // for convenience and readability - undefined at end of function

src/GiantBranch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ double GiantBranch::CalculateLuminosityAtHeIgnition_Static(const double p_M
530530
double GiantBranch::CalculateRemnantLuminosity() const {
531531
#define massCutoffs(x) m_MassCutoffs[static_cast<int>(MASS_CUTOFF::x)] // for convenience and readability - undefined at end of function
532532

533-
return (utils::Compare(m_Mass, massCutoffs(MHeF)) < 0)
533+
return (utils::Compare(m_Mass0, massCutoffs(MHeF)) < 0)
534534
? HeMS::CalculateLuminosityAtZAMS_Static(m_CoreMass)
535535
: WhiteDwarfs::CalculateLuminosityOnPhase_Static(m_CoreMass, 0.0, m_Metallicity, WD_Baryon_Number.at(STELLAR_TYPE::HELIUM_WHITE_DWARF));
536536

@@ -670,7 +670,7 @@ double GiantBranch::CalculateRadiusAtHeIgnition(const double p_Mass) const {
670670
double GiantBranch::CalculateRemnantRadius() const {
671671
#define massCutoffs(x) m_MassCutoffs[static_cast<int>(MASS_CUTOFF::x)] // for convenience and readability - undefined at end of function
672672

673-
return (utils::Compare(m_Mass, massCutoffs(MHeF)) < 0)
673+
return (utils::Compare(m_Mass0, massCutoffs(MHeF)) < 0)
674674
? HeMS::CalculateRadiusAtZAMS_Static(m_CoreMass)
675675
: WhiteDwarfs::CalculateRadiusOnPhase_Static(m_CoreMass);
676676

src/HG.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -594,11 +594,8 @@ double HG::CalculateCoreMassOnPhase(const double p_Mass, const double p_Time) co
594594
/*
595595
* Calculate rejuvenation factor for stellar age based on mass lost/gained during mass transfer
596596
*
597-
* JR: Description?
598-
*
599-
* Always returns 1.0 for HG - the rejuvenation factor is unity for convective main sequence stars.
600-
* The rest of the code is here so sanity checks can be made and an error displayed if a bad prescription
601-
* was specified in the program options
597+
* Always returns 1.0 for HG
598+
* The rest of the code is here so sanity checks can be made and an error displayed if a bad prescription was specified in the program options
602599
*
603600
*
604601
* double CalculateMassTransferRejuvenationFactor()
@@ -904,9 +901,23 @@ STELLAR_TYPE HG::EvolveToNextPhase() {
904901
}
905902
else {
906903
stellarType = STELLAR_TYPE::CORE_HELIUM_BURNING;
907-
}
908-
904+
}
909905
return stellarType;
910906

911907
#undef massCutoffs
912908
}
909+
910+
/*
911+
* Update effective initial mass
912+
*
913+
* Per Hurley et al. 2000, section 7.1, the effective initial mass on the HG tracks the stellar mass -- unless it would yield an unphysical decrease in the core mass
914+
*
915+
*
916+
* void UpdateInitialMass()
917+
*
918+
*/
919+
void HG::UpdateInitialMass() {
920+
if (utils::Compare(m_CoreMass,HG::CalculateCoreMassOnPhase(m_Mass, m_Age)) < 0 ) { //The current mass would yield a core mass larger than the current core mass -- i.e., no unphysical core mass decrease would ensure
921+
m_Mass0 = m_Mass;
922+
}
923+
}

src/HG.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class HG: virtual public BaseStar, public GiantBranch {
108108

109109
void UpdateAgeAfterMassLoss(); // Per Hurley et al. 2000, section 7.1
110110

111-
void UpdateInitialMass() { if (m_Mass0 > m_CoreMass) m_Mass0 = m_Mass; } // Per Hurley et al. 2000, section 7.1
111+
void UpdateInitialMass(); // Per Hurley et al. 2000, section 7.1
112112

113113
};
114114

src/MainSequence.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ double MainSequence::CalculateDeltaL(const double p_Mass) const {
5757

5858
double deltaL;
5959

60-
if (utils::Compare(p_Mass, massCutoffs(MHook)) <= 0) { // JR: todo: added "=" per Hurley et al. 2000, eq 16
60+
if (utils::Compare(p_Mass, massCutoffs(MHook)) <= 0) { // per Hurley et al. 2000, eq 16
6161
deltaL = 0.0; // this really is supposed to be zero
6262
}
6363
else if (utils::Compare(p_Mass, a[33]) < 0) {

src/changelog.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,11 @@
848848
// 02.25.10 JR - Nov 19, 2021 - Defect repairs:
849849
// - clamp timestep returned in BaseStar::CalculateTimestep() to NUCLEAR_MINIMUM_TIMESTEP
850850
// - change NUCLEAR_MINIMUM_TIMESTEP to 1 year (from 100 years) in constants.h
851+
// 02.26.00 IM - Nov 30, 2021 - Defect repairs:
852+
// - only decrease effective initial mass for HG and HeHG stars on mass loss when this decrease would not drive an unphysical decrease in the core mass
853+
// - change mass comparisons (e.g., mass vs. He flash mass threshold) to compare effective initial mass rather than current mass
854+
// - minor code and comment cleanup
851855

852-
const std::string VERSION_STRING = "02.25.10";
856+
const std::string VERSION_STRING = "02.26.00";
853857

854858
# endif // __changelog_h__

0 commit comments

Comments
 (0)