Skip to content

Commit f35975f

Browse files
authored
Merge pull request #721 from TeamCOMPAS/Mass0
Updates to ResolveEnvelopeLoss
2 parents 58175c7 + 68d4c80 commit f35975f

File tree

20 files changed

+108
-249
lines changed

20 files changed

+108
-249
lines changed

docs/online-docs/pages/User guide/Post-processing/post-processing-h5copy.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
h5copy.py
22
=========
33

4-
This program copies ``HDF5`` file(s) to a designated output ``HDF5`` file. If the output file is an existing ``HDF5`` file,
5-
the user can specify whether the existing content should be erased before copying begins, or whether the copied data should
6-
be appended to the existing data. If multiple files are given as input files, the resultant ``HDF5`` file is the concatenation
7-
of the input files.
4+
This program copies ``COMPAS_Output.h5`` ``HDF5`` file(s) [but not ``Detailed_Ouput`` files] to a designated output ``HDF5`` file.
5+
If the output file is an existing ``HDF5`` file, the user can specify whether the existing content should be erased before copying
6+
begins, or whether the copied data should be appended to the existing data. If multiple files are given as input files, the
7+
resultant ``HDF5`` file is the concatenation of the input files.
88

99

1010
Some nomenclature
-370 Bytes
Loading

src/BaseStar.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ class BaseStar {
201201

202202
virtual void ResolveMassLoss();
203203

204-
virtual STELLAR_TYPE ResolveRemnantAfterEnvelopeLoss() { return m_StellarType; }
205-
206204
void SetStellarTypePrev(const STELLAR_TYPE p_StellarTypePrev) { m_StellarTypePrev = p_StellarTypePrev; }
207205

208206
void StashSupernovaDetails(const STELLAR_TYPE p_StellarType) { LOGGING->StashSSESupernovaDetails(this, p_StellarType); }

src/CHeB.cpp

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,8 +1101,11 @@ double CHeB::ChooseTimestep(const double p_Time) const {
11011101
}
11021102

11031103

1104+
11041105
/*
1105-
* Resolve changes to the remnant after the star loses its envelope
1106+
* Modify the star after it loses its envelope
1107+
*
1108+
* Hurley et al. 2000, section 6 just before eq 76 and after Eq. 105
11061109
*
11071110
* Where necessary updates attributes of star (depending upon stellar type):
11081111
*
@@ -1118,50 +1121,6 @@ double CHeB::ChooseTimestep(const double p_Time) const {
11181121
* - m_COCoreMass
11191122
* - m_Age
11201123
*
1121-
* Hurley et al. 2000, just after eq 105
1122-
*
1123-
* JR: todo: why is this different from ResolveEnvelopeLoss()?
1124-
* JR: todo: original code: Star::radiusRemnantStarAfterLosingEnvelope() vs Star::modifyStarAfterLosingEnvelope(int stellarType, double mass)
1125-
* JR: todo: why is stellar type changed for some types, but not others? CheB and EAGB stars have stellar type changed, but no other types do...
1126-
*
1127-
*
1128-
* STELLAR_TYPE ResolveRemnantAfterEnvelopeLoss()
1129-
*
1130-
* @return Stellar type to which star should evolve
1131-
*/
1132-
STELLAR_TYPE CHeB::ResolveRemnantAfterEnvelopeLoss() {
1133-
#define timescales(x) m_Timescales[static_cast<int>(TIMESCALE::x)] // for convenience and readability - undefined at end of function
1134-
1135-
m_CoreMass = m_Mass;
1136-
m_Mass0 = m_Mass;
1137-
m_HeCoreMass = m_CoreMass;
1138-
m_COCoreMass = 0.0;
1139-
1140-
// set evolved time for naked helium star since already has some core mass.
1141-
// Coen 10-01-2016 added prime parameters
1142-
double tHeIPrime = timescales(tHeI);
1143-
double tHePrime = timescales(tHe);
1144-
1145-
m_Tau = ((m_Age - tHeIPrime) / tHePrime); // Hurley et al. 2000, just after eq 81: tau = t/tHeMS
1146-
m_Age = m_Tau * HeMS::CalculateLifetimeOnPhase_Static(m_Mass0); // JR: see Hurley et al. 2000, eq 76 and following discussion
1147-
1148-
CalculateTimescales(m_Mass0, m_Timescales); // JR: todo: not sure this is actually necessary here
1149-
CalculateGBParams(m_Mass0, m_GBParams); // Mass or Mass0 for GBParams? JR: doesn't matter here (Mass0 = Mass above)
1150-
1151-
m_Luminosity = HeMS::CalculateLuminosityOnPhase_Static(m_Mass, m_Tau);
1152-
m_Radius = HeMS::CalculateRadiusOnPhase_Static(m_Mass, m_Tau);
1153-
1154-
return STELLAR_TYPE::NAKED_HELIUM_STAR_MS; // will evolve to an evolved helium star
1155-
1156-
#undef timescales
1157-
}
1158-
1159-
1160-
/*
1161-
* Modify the star after it loses its envelope
1162-
*
1163-
* Hurley et al. 2000, section 6 just before eq 76
1164-
*
11651124
*
11661125
* STELLAR_TYPE ResolveEnvelopeLoss()
11671126
*
@@ -1172,23 +1131,22 @@ STELLAR_TYPE CHeB::ResolveEnvelopeLoss(bool p_NoCheck) {
11721131

11731132
STELLAR_TYPE stellarType = m_StellarType;
11741133

1175-
if (p_NoCheck || utils::Compare(m_CoreMass, m_Mass) >= 0) { // Envelope loss JR: todo: >= in original code - not consistent?
1134+
if (p_NoCheck || utils::Compare(m_CoreMass, m_Mass) >= 0) { // Envelope loss
11761135

1177-
// reset total mass to be core mass
1178-
m_CoreMass = m_HeCoreMass;
1179-
m_Mass = m_CoreMass;
1136+
m_CoreMass = m_Mass;
11801137
m_Mass0 = m_Mass;
1138+
m_HeCoreMass = m_CoreMass;
11811139
m_COCoreMass = 0.0;
11821140

11831141
// set evolved time for naked helium star since already has some core mass.
1184-
// Coen 10-01-2016 added prime parameters
11851142
double tHeIPrime = timescales(tHeI);
11861143
double tHePrime = timescales(tHe);
11871144

11881145
m_Tau = ((m_Age - tHeIPrime) / tHePrime); // Hurley et al. 2000, just after eq 81: tau = t/tHeMS
1189-
m_Age = m_Tau * HeMS::CalculateLifetimeOnPhase_Static(m_Mass0); // JR: see Hurley et al. 2000, eq 76 and following discussion
1146+
m_Age = m_Tau * HeMS::CalculateLifetimeOnPhase_Static(m_Mass0); // see Hurley et al. 2000, eq 76 and following discussion
11901147

1191-
CalculateGBParams(m_Mass0, m_GBParams); // Mass or Mass0 for GBParams? JR: doesn't matter here (Mass0 = Mass above)
1148+
CalculateTimescales(m_Mass0, m_Timescales);
1149+
CalculateGBParams(m_Mass0, m_GBParams);
11921150

11931151
m_Luminosity = HeMS::CalculateLuminosityOnPhase_Static(m_Mass, m_Tau);
11941152
m_Radius = HeMS::CalculateRadiusOnPhase_Static(m_Mass, m_Tau);

src/CHeB.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ class CHeB: virtual public BaseStar, public FGB {
116116

117117
STELLAR_TYPE ResolveEnvelopeLoss(bool p_NoCheck = false);
118118
void ResolveHeliumFlash() { } // NO-OP
119-
STELLAR_TYPE ResolveRemnantAfterEnvelopeLoss();
120119

121120
bool ShouldEvolveOnPhase() const;
122121
bool ShouldSkipPhase() const { return false; } // Never skip CHeB phase

src/EAGB.cpp

Lines changed: 7 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,9 @@ double EAGB::ChooseTimestep(const double p_Time) const {
670670

671671

672672
/*
673-
* Resolve changes to the remnant after the star loses its envelope
673+
* Modify the star after it loses its envelope
674+
*
675+
* Hurley et al. 2000, section 6 just before eq 76 and after Eq. 105
674676
*
675677
* Where necessary updates attributes of star (depending upon stellar type):
676678
*
@@ -686,68 +688,6 @@ double EAGB::ChooseTimestep(const double p_Time) const {
686688
* - m_COCoreMass
687689
* - m_Age
688690
*
689-
* Hurley et al. 2000, just after eq 105
690-
*
691-
* JR: todo: why is this different from ResolveEnvelopeLoss()?
692-
* JR: todo: original code: Star::radiusRemnantStarAfterLosingEnvelope() vs Star::modifyStarAfterLosingEnvelope(int stellarType, double mass)
693-
* JR: todo: why is stellar type changed for some types, but not others? CheB and EAGB stars have stellar type changed, but no other types do...
694-
*
695-
*
696-
* STELLAR_TYPE ResolveRemnantAfterEnvelopeLoss()
697-
*
698-
* @return Stellar type to which star should evolve
699-
*/
700-
STELLAR_TYPE EAGB::ResolveRemnantAfterEnvelopeLoss() {
701-
#define timescales(x) m_Timescales[static_cast<int>(TIMESCALE::x)] // for convenience and readability - undefined at end of function
702-
#define gbParams(x) m_GBParams[static_cast<int>(GBP::x)] // for convenience and readability - undefined at end of function
703-
704-
m_Mass = m_HeCoreMass;
705-
m_Mass0 = m_Mass;
706-
m_CoreMass = m_COCoreMass;
707-
708-
double p1 = gbParams(p) - 1.0;
709-
double q1 = gbParams(q) - 1.0;
710-
double p1_p = p1 / gbParams(p);
711-
double q1_q = q1 / gbParams(q);
712-
713-
timescales(tHeMS) = HeMS::CalculateLifetimeOnPhase_Static(m_Mass); // calculate common values
714-
715-
double LTHe = HeMS::CalculateLuminosityAtPhaseEnd_Static(m_Mass);
716-
717-
timescales(tinf1_HeGB) = timescales(tHeMS) + (1.0 / ((p1 * gbParams(AHe) * gbParams(D))) * PPOW((gbParams(D) / LTHe), p1_p));
718-
timescales(tx_HeGB) = timescales(tinf1_HeGB) - (timescales(tinf1_HeGB) - timescales(tHeMS)) * PPOW((LTHe / gbParams(Lx)), p1_p);
719-
timescales(tinf2_HeGB) = timescales(tx_HeGB) + ((1.0 / (q1 * gbParams(AHe) * gbParams(B))) * PPOW((gbParams(B) / gbParams(Lx)), q1_q));
720-
721-
m_Age = HeGB::CalculateAgeOnPhase_Static(m_Mass, m_COCoreMass, timescales(tHeMS), m_GBParams);
722-
723-
CalculateGBParams(m_Mass0, m_GBParams); // Mass or Mass0 for GBParams? JR: doesn't matter here (Mass0 = Mass above)
724-
725-
m_Luminosity = HeGB::CalculateLuminosityOnPhase_Static(m_COCoreMass, gbParams(B), gbParams(D));
726-
727-
STELLAR_TYPE stellarType;
728-
double R1, R2;
729-
std::tie(R1, R2) = HeGB::CalculateRadiusOnPhase_Static(m_Mass, m_Luminosity);
730-
if (utils::Compare(R1, R2) < 0) {
731-
m_Radius = R1;
732-
stellarType = STELLAR_TYPE::NAKED_HELIUM_STAR_HERTZSPRUNG_GAP;
733-
}
734-
else {
735-
m_Radius = R2;
736-
stellarType = STELLAR_TYPE::NAKED_HELIUM_STAR_GIANT_BRANCH; // Has a deep convective envelope
737-
}
738-
739-
return stellarType;
740-
741-
#undef gbParams
742-
#undef timescales
743-
}
744-
745-
746-
/*
747-
* Modify the star after it loses its envelope
748-
*
749-
* Hurley et al. 2000, section 6 just before eq 76
750-
*
751691
*
752692
* STELLAR_TYPE ResolveEnvelopeLoss()
753693
*
@@ -759,9 +699,9 @@ STELLAR_TYPE EAGB::ResolveEnvelopeLoss(bool p_NoCheck) {
759699

760700
STELLAR_TYPE stellarType = m_StellarType;
761701

762-
if (p_NoCheck || utils::Compare(m_CoreMass, m_Mass) > 0) { // Envelope lost, form an evolved naked helium giant
702+
if (p_NoCheck || utils::Compare(m_HeCoreMass, m_Mass) >= 0) { // Envelope lost, form an evolved naked helium giant
763703

764-
m_Mass = m_HeCoreMass;
704+
m_HeCoreMass = m_Mass;
765705
m_Mass0 = m_Mass;
766706
m_CoreMass = m_COCoreMass;
767707

@@ -778,16 +718,8 @@ STELLAR_TYPE EAGB::ResolveEnvelopeLoss(bool p_NoCheck) {
778718
timescales(tx_HeGB) = timescales(tinf1_HeGB) - (timescales(tinf1_HeGB) - timescales(tHeMS)) * PPOW((LTHe / gbParams(Lx)), p1_p);
779719
timescales(tinf2_HeGB) = timescales(tx_HeGB) + ((1.0 / (q1 * gbParams(AHe) * gbParams(B))) * PPOW((gbParams(B) / gbParams(Lx)), q1_q));
780720

781-
782-
// Need to calculate gbParams for new stellar type - calculations of stellar attributes below depend
783-
// on new gbParams.
784-
// JR: This really needs to be revisited one day - these calculations should really be performed after
785-
// switching to the new stellar type, but other calculations are done (in the legacy code) before the switch
786-
// (see evolveOneTimestep() in star.cpp for EAGB stars in the legacy code)
787-
788-
HeHG::CalculateGBParams_Static(m_Mass0, m_Mass, m_LogMetallicityXi, m_MassCutoffs, m_AnCoefficients, m_BnCoefficients, m_GBParams);
789-
790-
m_Age = HeGB::CalculateAgeOnPhase_Static(m_Mass, m_COCoreMass, timescales(tHeMS), m_GBParams);
721+
m_Age = HeGB::CalculateAgeOnPhase_Static(m_Mass, m_COCoreMass, timescales(tHeMS), m_GBParams);
722+
HeHG::CalculateGBParams_Static(m_Mass0, m_Mass, m_LogMetallicityXi, m_MassCutoffs, m_AnCoefficients, m_BnCoefficients, m_GBParams); // IM: order of type change and parameter updates to be revisited (e.g., why not just CalculateGBParams(m_Mass0, m_GBParams)?)
791723
m_Luminosity = HeGB::CalculateLuminosityOnPhase_Static(m_COCoreMass, gbParams(B), gbParams(D));
792724

793725
double R1, R2;

src/EAGB.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ class EAGB: virtual public BaseStar, public CHeB {
9696

9797
STELLAR_TYPE ResolveEnvelopeLoss(bool p_NoCheck = false);
9898
void ResolveHeliumFlash() { } // NO-OP
99-
STELLAR_TYPE ResolveRemnantAfterEnvelopeLoss();
10099
STELLAR_TYPE ResolveSkippedPhase() { return m_StellarType; } // NO-OP
101100

102101
bool ShouldEvolveOnPhase() const;

src/FGB.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,21 @@ double FGB::ChooseTimestep(const double p_Time) const {
150150
/*
151151
* Modify the star after it loses its envelope
152152
*
153-
* Hurley et al. 2000, section 6 just before eq 76
154-
*
153+
* Hurley et al. 2000, section 6 just before eq 76 (see also after Eq. 105)
154+
*
155+
* Where necessary updates attributes of star (depending upon stellar type):
156+
*
157+
* - m_StellarType
158+
* - m_Timescales
159+
* - m_GBParams
160+
* - m_Luminosity
161+
* - m_Radius
162+
* - m_Mass
163+
* - m_Mass0
164+
* - m_CoreMass
165+
* - m_HeCoreMass
166+
* - m_COCoreMass
167+
* - m_Age
155168
*
156169
* STELLAR_TYPE ResolveEnvelopeLoss()
157170
*
@@ -165,7 +178,7 @@ STELLAR_TYPE FGB::ResolveEnvelopeLoss(bool p_NoCheck) {
165178

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

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

170183
stellarType = STELLAR_TYPE::HELIUM_WHITE_DWARF;
171184

src/GiantBranch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ double GiantBranch::CalculateRemnantRadius() const {
693693
double GiantBranch::CalculateRadialExtentConvectiveEnvelope() const{
694694

695695
BaseStar clone = *this; // clone this star so can manipulate without changes persisiting
696-
clone.ResolveRemnantAfterEnvelopeLoss(); // update clone's attributes after envelope is lost
696+
clone.ResolveEnvelopeLoss(true); // update clone's attributes after envelope is lost
697697

698698
return m_Radius - clone.Radius();
699699
}

src/HG.cpp

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ double HG::CalculateRadiusOnPhase(const double p_Mass, const double p_Tau, const
515515
double HG::CalculateRadialExtentConvectiveEnvelope() const {
516516

517517
BaseStar clone = *this; // clone this star so can manipulate without changes persisiting
518-
clone.ResolveRemnantAfterEnvelopeLoss(); // update clone's attributes after envelope is lost
518+
clone.ResolveEnvelopeLoss(true); // update clone's attributes after envelope is lost
519519

520520
return PPOW(m_Tau, 1.0 / 2.0) * (m_Radius - clone.Radius());
521521
}
@@ -800,7 +800,9 @@ double HG::ChooseTimestep(const double p_Time) const {
800800

801801

802802
/*
803-
* Resolve changes to the remnant after the star loses its envelope
803+
* Modify the star after it loses its envelope
804+
*
805+
* Hurley et al. 2000, section 6 just before eq 76 and after Eq. 105
804806
*
805807
* Where necessary updates attributes of star (depending upon stellar type):
806808
*
@@ -816,33 +818,6 @@ double HG::ChooseTimestep(const double p_Time) const {
816818
* - m_COCoreMass
817819
* - m_Age
818820
*
819-
* Hurley et al. 2000, just after eq 105
820-
*
821-
* JR: todo: why is this different from ResolveEnvelopeLoss()?
822-
* JR: todo: original code: Star::radiusRemnantStarAfterLosingEnvelope() vs Star::modifyStarAfterLosingEnvelope(int stellarType, double mass)
823-
* JR: todo: why is stellar type changed for some types, but not others? CheB and EAGB stars have stellar type changed, but no other types do...
824-
*
825-
*
826-
* STELLAR_TYPE ResolveRemnantAfterEnvelopeLoss()
827-
*
828-
* @return Stellar type to which star should evolve
829-
*/
830-
STELLAR_TYPE HG::ResolveRemnantAfterEnvelopeLoss() {
831-
832-
m_Radius = utils::Compare(m_Mass, m_MassCutoffs[static_cast<int>(MASS_CUTOFF::MHook)]) < 0
833-
? HeWD::CalculateRadiusOnPhase_Static(m_Mass) // reset mass/age parameters JR: todo: why does the comment refer to mass/age? Leftover from modifyStarAfterLosingEnvelope()?
834-
: HeMS::CalculateRadiusAtZAMS_Static(m_Mass); // star evolves to Zero age Naked Helium Main Star and reset parameters
835-
836-
return m_StellarType; // no change
837-
}
838-
839-
840-
/*
841-
* Modify the star after it loses its envelope
842-
*
843-
* Hurley et al. 2000, section 6 just before eq 76
844-
*
845-
*
846821
* STELLAR_TYPE ResolveEnvelopeLoss()
847822
*
848823
* @return Stellar Type to which star shoule evolve after losing envelope
@@ -855,13 +830,13 @@ STELLAR_TYPE HG::ResolveEnvelopeLoss(bool p_NoCheck) {
855830

856831
if (p_NoCheck || utils::Compare(m_CoreMass, m_Mass) > 0) { // envelope loss
857832

858-
if (utils::Compare(m_Mass, massCutoffs(MHeF)) < 0) { // star evolves to Helium White Dwarf
833+
if (utils::Compare(m_Mass0, massCutoffs(MHeF)) < 0) { // star evolves to Helium White Dwarf
859834

860835
stellarType = STELLAR_TYPE::HELIUM_WHITE_DWARF;
861836

862837
m_Mass = m_CoreMass;
863838
m_Radius = HeWD::CalculateRadiusOnPhase_Static(m_Mass);
864-
m_Age = 0.0; // JR: see Hurley et al. 2000, discussion after eq 76
839+
m_Age = 0.0; // see Hurley et al. 2000, discussion after eq 76
865840
}
866841
else { // star evolves to Zero age Naked Helium Main Star
867842

@@ -871,7 +846,7 @@ STELLAR_TYPE HG::ResolveEnvelopeLoss(bool p_NoCheck) {
871846
m_Mass0 = m_Mass;
872847
m_Radius = HeMS::CalculateRadiusAtZAMS_Static(m_Mass);
873848
m_Luminosity = HeMS::CalculateLuminosityAtZAMS_Static(m_Mass);
874-
m_Age = 0.0; // JR: can't use Hurley et al. 2000, eq 76 here - timescales(tHe) not calculated yet
849+
m_Age = 0.0; // can't use Hurley et al. 2000, eq 76 here - timescales(tHe) not calculated yet
875850
}
876851

877852
}

0 commit comments

Comments
 (0)