diff --git a/src/BaseBinaryStar.cpp b/src/BaseBinaryStar.cpp index 44aff43a7..bb435e0ac 100644 --- a/src/BaseBinaryStar.cpp +++ b/src/BaseBinaryStar.cpp @@ -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"<Mass()<<" "<Mass()<SetMassLossDiff(mWinds1 - m_Star1->Mass()); // JR: todo: find a better way? m_Star2->SetMassLossDiff(mWinds2 - m_Star2->Mass()); // JR: todo: find a better way? diff --git a/src/BaseStar.cpp b/src/BaseStar.cpp index fa0273cef..f29ecfd9e 100755 --- a/src/BaseStar.cpp +++ b/src/BaseStar.cpp @@ -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 diff --git a/src/GiantBranch.cpp b/src/GiantBranch.cpp index fb48a2e0b..df159baad 100644 --- a/src/GiantBranch.cpp +++ b/src/GiantBranch.cpp @@ -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 @@ -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; } @@ -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 diff --git a/src/TPAGB.cpp b/src/TPAGB.cpp index fb137a6f7..a72465c10 100755 --- a/src/TPAGB.cpp +++ b/src/TPAGB.cpp @@ -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; @@ -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(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 +} diff --git a/src/TPAGB.h b/src/TPAGB.h index 59b8f9f67..d979ff9fc 100755 --- a/src/TPAGB.h +++ b/src/TPAGB.h @@ -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(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 diff --git a/src/changelog.h b/src/changelog.h index f6e40f14f..4d9fcae31 100644 --- a/src/changelog.h +++ b/src/changelog.h @@ -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__