Skip to content

Commit

Permalink
Complete fix to #1305
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Mandel committed Dec 12, 2024
1 parent 3f33a58 commit 39b47e0
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 41 deletions.
3 changes: 0 additions & 3 deletions src/BaseBinaryStar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1926,9 +1926,6 @@ void BaseBinaryStar::CalculateWindsMassLoss() {
double mWinds2 = m_Star2->CalculateMassLossValues(true); // calculate new values assuming mass loss applied

double aWinds = m_SemiMajorAxisPrev * (m_Star1->Mass() + m_Star2->Mass()) / (mWinds1 + mWinds2); // new semi-major axis after wind mass loss, integrated to ensure a*M conservation

std::cout<<"Types"<<(int)m_Star1->StellarType()<<" "<<(int)m_Star2->StellarType()<<"prev masses"<<m_Star1->Mass()<<" "<<m_Star2->Mass()<<std::endl;
std::cout<<" new masses"<<mWinds1<<" "<<mWinds2<<"old a "<<m_SemiMajorAxisPrev<<"new a "<<aWinds<<std::endl;

m_Star1->SetMassLossDiff(mWinds1 - m_Star1->Mass()); // JR: todo: find a better way?
m_Star2->SetMassLossDiff(mWinds2 - m_Star2->Mass()); // JR: todo: find a better way?
Expand Down
2 changes: 1 addition & 1 deletion src/BaseStar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4530,7 +4530,7 @@ STELLAR_TYPE BaseStar::UpdateAttributesAndAgeOneTimestep(const double p_DeltaMas
stellarType = STELLAR_TYPE::MASSLESS_REMNANT;
}
else {
stellarType = ResolveSupernova(); // handle supernova
stellarType = ResolveSupernova(); // handle supernova
if (stellarType == m_StellarType) { // still on phase?

UpdateAttributesAndAgeOneTimestepPreamble(p_DeltaMass, p_DeltaMass0, p_DeltaTime); // apply mass changes and save current values if required
Expand Down
45 changes: 11 additions & 34 deletions src/GiantBranch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1991,7 +1991,7 @@ STELLAR_TYPE GiantBranch::ResolveCoreCollapseSN() {


/*
* Resolve Electron capture Supernova
* Resolve Electron Capture Supernova
*
* Calculate the mass of the remnant and set remnant type - always a Neutron Star
* Updates attributes of star; sets SN flags
Expand All @@ -2007,39 +2007,16 @@ STELLAR_TYPE GiantBranch::ResolveCoreCollapseSN() {
* @return Stellar type of remnant (always STELLAR_TYPE::NEUTRON_STAR)
*/
STELLAR_TYPE GiantBranch::ResolveElectronCaptureSN() {

STELLAR_TYPE stellarType = m_StellarType; // remnant stellar type

if (!m_MassTransferDonorHistory.empty() || (OPTIONS->AllowNonStrippedECSN())) { // if progenitor has never been a MT donor, is it allowed to ECSN?
// yes
m_Mass = MECS_REM; // defined in constants.h
m_CoreMass = m_Mass;
m_HeCoreMass = m_Mass;
m_COCoreMass = m_Mass;
m_Mass0 = m_Mass;

stellarType = STELLAR_TYPE::NEUTRON_STAR;

SetSNCurrentEvent(SN_EVENT::ECSN); // electron capture SN happening now
SetSNPastEvent(SN_EVENT::ECSN); // ... and will be a past event
}
else { // not allowed to ECSN, treat as ONeWD
m_Mass = MECS_REM; // defined in constants.h
m_CoreMass = m_Mass;
m_HeCoreMass = m_Mass;
m_COCoreMass = m_Mass;
m_Mass0 = m_Mass;

if (utils::Compare(m_COCoreMass, MCH) > 0) {
SHOW_WARN(ERROR::WHITE_DWARF_TOO_MASSIVE, "Setting mass to Chandraskhar mass.");
}
m_Mass = std::min(m_COCoreMass, MCH); // no WD masses above Chandrasekhar mass
m_CoreMass = m_Mass;
m_HeCoreMass = m_Mass;
m_COCoreMass = m_Mass;
m_Mass0 = m_Mass;
m_Radius = WhiteDwarfs::CalculateRadiusOnPhase_Static(m_Mass); // radius is defined equivalently for all WDs
m_Luminosity = ONeWD::CalculateLuminosityOnPhase_Static(m_Mass, m_Time, m_Metallicity); // need to set the luminosity for ONeWD specifically

stellarType = STELLAR_TYPE::OXYGEN_NEON_WHITE_DWARF;
}
SetSNCurrentEvent(SN_EVENT::ECSN); // electron capture SN happening now
SetSNPastEvent(SN_EVENT::ECSN); // ... and will be a past event

return stellarType;
return STELLAR_TYPE::NEUTRON_STAR;
}


Expand Down Expand Up @@ -2252,8 +2229,8 @@ STELLAR_TYPE GiantBranch::ResolveSupernova() {

stellarType = ResolvePairInstabilitySN(); // MR
}
else if (utils::Compare(snMass, MCBUR2) < 0) { // Electron Capture Supernova
stellarType = ResolveElectronCaptureSN(); // NS or ONeWD
else if (utils::Compare(snMass, MCBUR2) < 0 && (!m_MassTransferDonorHistory.empty() || OPTIONS->AllowNonStrippedECSN())) {
stellarType = ResolveElectronCaptureSN(); // electron capture SN; requires progenitor to have been a MT donor unless non-stripped ECSN are allowed; forms NS
}
else { // Core Collapse Supernova
stellarType = ResolveCoreCollapseSN(); // BH or NS
Expand Down
18 changes: 17 additions & 1 deletion src/TPAGB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ STELLAR_TYPE TPAGB::ResolveEnvelopeLoss(bool p_Force) {
if (ShouldEnvelopeBeExpelledByPulsations()) m_EnvelopeJustExpelledByPulsations = true;

if (p_Force || (utils::Compare(m_CoreMass, m_Mass)) >= 0 || m_EnvelopeJustExpelledByPulsations) { // envelope loss

m_Mass = std::min(m_CoreMass, m_Mass);
m_CoreMass = m_Mass;
m_HeCoreMass = m_Mass;
Expand Down Expand Up @@ -967,3 +967,19 @@ double TPAGB::ChooseTimestep(const double p_Time) const {

#undef timescales
}

/*
* Determine if star should continue evolution as a Supernova
*
*
* bool IsSupernova()
*
* @return Boolean flag: true if star has gone Supernova, false if not
*/
bool TPAGB::IsSupernova() const {
if(utils::SNEventType(m_SupernovaDetails.events.current) != SN_EVENT::NONE)
return true; // already labeled as going through a SN right now
double snMass = CalculateInitialSupernovaMass(); // calculate SN initial mass
return ( utils::Compare(m_COCoreMass, m_GBParams[static_cast<int>(GBP::McSN)]) >=0 && utils::Compare(snMass, OPTIONS->MCBUR1()) >= 0 && utils::Compare(m_COCoreMass, m_Mass) < 0 );
// no supernova if CO core mass is too low or helium core mass is too low at base of AGB or the envelope has already been removed
}
2 changes: 1 addition & 1 deletion src/TPAGB.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class TPAGB: virtual public BaseStar, public EAGB {
STELLAR_TYPE EvolveToNextPhase() { return m_StellarType; } // NO-OP

bool IsEndOfPhase() const { return !ShouldEvolveOnPhase(); } // Phase ends when envelope loss or going supernova
bool IsSupernova() const { return (utils::Compare(m_COCoreMass, m_GBParams[static_cast<int>(GBP::McSN)]) >= 0 && utils::Compare(CalculateInitialSupernovaMass(), OPTIONS->MCBUR1()) >= 0 && utils::Compare(m_COCoreMass, m_Mass) < 0); } // Going supernova if still has envelope and core mass large enough
bool IsSupernova() const;

STELLAR_TYPE ResolveEnvelopeLoss(bool p_Force = false);
void ResolveHeliumFlash() { } // NO-OP
Expand Down
5 changes: 4 additions & 1 deletion src/changelog.h
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,9 @@
// - fixed issue with updating helium giants that manifested as supernovae with nan core mass (see #1245)
// - added check for exceeding Chandrasekhar mass when computing white dwarf radius (resolves issue #1264)
// - added check to only compute McBGB for stars with mass above MHeF, following text above Eq. 44 in Hurley+, 2000 (resolves issue #1256)
const std::string VERSION_STRING = "03.10.01";
// 03.10.02 IM - Dec 13, 2024 - Defect repair:
// - if the Hurley supernova criteria are met yet ECSN criteria based on mass transfer history are not met, a normal CCSN ensues as opposed to an ONeWD
// - exactly preserve the product of semi-major axis * total mass on wind mass loss
const std::string VERSION_STRING = "03.10.02";

# endif // __changelog_h__

0 comments on commit 39b47e0

Please sign in to comment.