@@ -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;
0 commit comments