diff --git a/src/BaseBinaryStar.cpp b/src/BaseBinaryStar.cpp index 70d8ee41a..951daddd0 100644 --- a/src/BaseBinaryStar.cpp +++ b/src/BaseBinaryStar.cpp @@ -1692,10 +1692,7 @@ void BaseBinaryStar::ResolveCommonEnvelopeEvent() { m_Flags.stellarMerger = true; } } - -/* Ilya - should we execute the following statement if a stellar merger has occurred - we won't have stored post CEE stellar values for the stars... */ -/* I suppose we could still execute line 1688 above sto set the binary values */ -/* note we could have set the stellar merger flag as late as line 1692 above */ + (void)PrintCommonEnvelope(); // print (log) common envelope details } @@ -1721,9 +1718,8 @@ void BaseBinaryStar::ResolveMainSequenceMerger() { double tau1 = m_Star1->Tau(); double tau2 = m_Star2->Tau(); - // /*ILYA*/ temporary solution, should use TAMS core mass - double TAMSCoreMass1 = 0.3 * mass1; - double TAMSCoreMass2 = 0.3 * mass2; + double TAMSCoreMass1 = m_Star1->TAMSCoreMass(); + double TAMSCoreMass2 = m_Star2->TAMSCoreMass(); double q = std::min(mass1 / mass2, mass2 / mass1); double phi = 0.3 * q / (1.0 + q) / (1.0 + q); // fraction of mass lost in merger, Wang+ 2022, https://www.nature.com/articles/s41550-021-01597-5 @@ -3088,8 +3084,12 @@ EVOLUTION_STATUS BaseBinaryStar::Evolve() { if (StellarMerger() && !HasOneOf({ STELLAR_TYPE::MASSLESS_REMNANT })) { // have stars merged without merger already being resolved? if (m_Star1->IsOneOf(MAIN_SEQUENCE) && m_Star2->IsOneOf(MAIN_SEQUENCE) && OPTIONS->EvolveMainSequenceMergers()) // yes - both MS and evolving MS merger products? ResolveMainSequenceMerger(); // yes - handle main sequence mergers gracefully; no need to change evolution status - else + else { + // make both stars massless remnants if merging during CE, so this is recorded in the Switch log; eventually, will want to implement a more careful prescription for the merger product, perhaps allowing further evolution of the merger product + m_Star1->SwitchTo(STELLAR_TYPE::MASSLESS_REMNANT); + m_Star2->SwitchTo(STELLAR_TYPE::MASSLESS_REMNANT); evolutionStatus = EVOLUTION_STATUS::STELLAR_MERGER; // no - for now, stop evolution + } } else if (HasStarsTouching()) { // binary components touching? (should usually be avoided as MT or CE or merger should happen prior to this) evolutionStatus = EVOLUTION_STATUS::STARS_TOUCHING; // yes - stop evolution diff --git a/src/BaseStar.h b/src/BaseStar.h index bb8bff218..7830fe9f4 100644 --- a/src/BaseStar.h +++ b/src/BaseStar.h @@ -343,6 +343,8 @@ class BaseStar { void StashSupernovaDetails(const STELLAR_TYPE p_StellarType, const SSE_SN_RECORD_TYPE p_RecordType = SSE_SN_RECORD_TYPE::DEFAULT) { LOGGING->StashSSESupernovaDetails(this, p_StellarType, p_RecordType); } + virtual double TAMSCoreMass() const { return 0.0; } // except MS stars + virtual void UpdateAfterMerger(double p_Mass, double p_HydrogenMass) { } // Default is NO-OP virtual void UpdateAgeAfterMassLoss() { } // Default is NO-OP diff --git a/src/HG.h b/src/HG.h index 5c2a0ea9e..cf23a5fc6 100755 --- a/src/HG.h +++ b/src/HG.h @@ -138,6 +138,7 @@ class HG: virtual public BaseStar, public GiantBranch { bool ShouldEvolveOnPhase() const { return (utils::Compare(m_Age, m_Timescales[static_cast(TIMESCALE::tBGB)]) < 0); } // Evolve on HG phase if age < Base Giant Branch timescale bool ShouldSkipPhase() const { return false; } // Never skip HG phase + double TAMSCoreMass() const { return 0.0; } void UpdateAfterMerger(double p_Mass, double p_HydrogenMass) { } // Nothing to do for stars beyond the Main Sequence for now void UpdateAgeAfterMassLoss(); // Per Hurley et al. 2000, section 7.1 diff --git a/src/MainSequence.cpp b/src/MainSequence.cpp index fe69f6f3f..0836ece16 100644 --- a/src/MainSequence.cpp +++ b/src/MainSequence.cpp @@ -636,20 +636,7 @@ double MainSequence::CalculateConvectiveCoreRadius() const { * @return Mass of convective core in Msol */ double MainSequence::CalculateConvectiveCoreMass() const { - - // We need TAMSCoreMass, which is just the core mass at the start of the HG phase. - // Since we are on the main sequence here, we can clone this object as an HG object - // and, as long as it is initialised (to correctly set Tau to 0.0 on the HG phase), - // we can query the cloned object for its core mass. - // - // The clone should not evolve, and so should not log anything, but to be sure the - // clone does not participate in logging, we set its persistence to EPHEMERAL. - - HG *clone = HG::Clone(static_cast(const_cast(*this)), OBJECT_PERSISTENCE::EPHEMERAL); - double TAMSCoreMass = clone->CoreMass(); // get core mass from clone - delete clone; clone = nullptr; // return the memory allocated for the clone - - double finalConvectiveCoreMass = TAMSCoreMass; + double finalConvectiveCoreMass = TAMSCoreMass(); // core mass at TAMS double initialConvectiveCoreMass = finalConvectiveCoreMass / 0.6; return (initialConvectiveCoreMass - m_Tau * (initialConvectiveCoreMass - finalConvectiveCoreMass)); } @@ -849,23 +836,34 @@ STELLAR_TYPE MainSequence::ResolveEnvelopeLoss(bool p_Force) { */ void MainSequence::UpdateMinimumCoreMass() { if (OPTIONS->RetainCoreMassDuringCaseAMassTransfer()) { - - // We need TAMSCoreMass, which is just the core mass at the start of the HG phase. - // Since we are on the main sequence here, we can clone this object as an HG object - // and, as long as it is initialised (to correctly set Tau to 0.0 on the HG phase), - // we can query the cloned object for its core mass. - // - // The clone should not evolve, and so should not log anything, but to be sure the - // clone does not participate in logging, we set its persistence to EPHEMERAL. - - HG *clone = HG::Clone(static_cast(const_cast(*this)), OBJECT_PERSISTENCE::EPHEMERAL); - double TAMSCoreMass = clone->CoreMass(); // get core mass from clone - delete clone; clone = nullptr; // return the memory allocated for the clone - - m_MinimumCoreMass = std::max(m_MinimumCoreMass, CalculateTauOnPhase() * TAMSCoreMass); // update minimum core mass + m_MinimumCoreMass = std::max(m_MinimumCoreMass, CalculateTauOnPhase() * TAMSCoreMass()); // update minimum core mass } } +/* + * Return the expected core mass at terminal age main sequence, i.e., at the start of the HG phase + * + * double TAMSCoreMass() const + * + * + * @return TAMS core Mass (Msol) + * + */ +double MainSequence::TAMSCoreMass() const { + // Since we are on the main sequence here, we can clone this object as an HG object + // and, as long as it is initialised (to correctly set Tau to 0.0 on the HG phase), + // we can query the cloned object for its core mass. + // + // The clone should not evolve, and so should not log anything, but to be sure the + // clone does not participate in logging, we set its persistence to EPHEMERAL. + + HG *clone = HG::Clone(static_cast(const_cast(*this)), OBJECT_PERSISTENCE::EPHEMERAL); + double TAMSCoreMass = clone->CoreMass(); // get core mass from clone + delete clone; clone = nullptr; // return the memory allocated for the clone + + return TAMSCoreMass; +} + /* * Sets the mass and age of a merge product of two main sequence stars diff --git a/src/MainSequence.h b/src/MainSequence.h index a83b4cbe7..36aa11b2c 100644 --- a/src/MainSequence.h +++ b/src/MainSequence.h @@ -107,6 +107,8 @@ class MainSequence: virtual public BaseStar { STELLAR_TYPE ResolveEnvelopeLoss(bool p_Force = false); bool ShouldEvolveOnPhase() const { return (m_Age < m_Timescales[static_cast(TIMESCALE::tMS)]); } // Evolve on MS phase if age in MS timescale + + double TAMSCoreMass() const; void UpdateInitialMass() { m_Mass0 = m_Mass; } // Per Hurley et al. 2000, section 7.1 diff --git a/src/Star.h b/src/Star.h index 16ef92323..c486cc1a9 100755 --- a/src/Star.h +++ b/src/Star.h @@ -262,6 +262,8 @@ class Star { STELLAR_TYPE SwitchTo(const STELLAR_TYPE p_StellarType, bool p_SetInitialType = false); + + double TAMSCoreMass() const { return m_Star->TAMSCoreMass(); } void UpdateAfterMerger(double p_Mass, double p_HydrogenMass) { m_Star->UpdateAfterMerger(p_Mass, p_HydrogenMass); } void UpdateAgeAfterMassLoss() { m_Star->UpdateAgeAfterMassLoss(); } diff --git a/src/changelog.h b/src/changelog.h index deb5f6fb3..975cb42be 100644 --- a/src/changelog.h +++ b/src/changelog.h @@ -1405,7 +1405,9 @@ // - Fixed bugs in vector3d related to indexing and rotation // - Added tweak for circular systems at first SN, to fix the x-axis along the separation vector // 03.09.03 IM - Nov 28, 2024 - Enhancement, defect repair: -// - Delay changing stellar types until after checking for whether remnant cores would touch in a common enevelope, use core radii instead (fix to #1286) +// - Delay changing stellar types until after checking for whether remnant cores would touch in a common enevelope, use core radii instead (partial fix to #1286) +// - Define a new function MainSequence::TAMSCoreMass(); use it for determining the amount of He in a star during MS mergers +// - Switch both stars to Massless remnants during a CE merger, resolve #1265 const std::string VERSION_STRING = "03.09.03"; # endif // __changelog_h__