Skip to content

Commit

Permalink
A few minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
brcekadam committed Jan 16, 2025
1 parent 58912d1 commit 1deda5d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion compas_python_utils/preprocessing/compasConfigDefault.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ stringChoices:
# --initial-mass-function: 'KROUPA' # Default: 'KROUPA' # Options: ['KROUPA','UNIFORM','POWERLAW','SALPETER']
# --LBV-mass-loss-prescription: 'HURLEY_ADD' # Default: 'HURLEY_ADD' # Options: ['BELCZYNSKI','HURLEY','HURLEY_ADD','ZERO','NONE']
# --luminous-blue-variable-prescription: 'HURLEY_ADD' # Default: 'HURLEY_ADD' # Options: ['BELCZYNSKI','HURLEY','HURLEY_ADD','ZERO','NONE']
# --main-sequence-core-mass-prescription: 'MANDEL' # Default: 'MANDEL' # Options: ['SHIKAUCHI','MANDEL','NONE']
# --main-sequence-core-mass-prescription: 'MANDEL' # Default: 'MANDEL' # Options: ['SHIKAUCHI','MANDEL','ZERO']
# --mass-loss-prescription: 'MERRITT2024' # Default: 'MERRITT2024' # Options: ['MERRITT2024','BELCZYNSKI2010','HURLEY','ZERO','NONE']
# --OB-mass-loss: 'VINK2021' # Default: 'VINK2021' # Options: ['KRTICKA2018','BJORKLUND2022','VINK2021','VINK2001','ZERO','NONE']
# --OB-mass-loss-prescription: 'VINK2021' # Default: 'VINK2021' # Options: ['KRTICKA2018','BJORKLUND2022','VINK2021','VINK2001','ZERO','NONE']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,8 +797,8 @@ Default = 4.2

**--main-sequence-core-mass-prescription** |br|
Main sequence core mass prescription. |br|
Options: {NONE, MANDEL, SHIKAUCHI} |br|
``NONE`` : No core mass treatment |br|
Options: {ZERO, MANDEL, SHIKAUCHI} |br|
``ZERO`` : No core mass treatment, set to zero |br|
``MANDEL`` : The core following case A mass transfer is set equal to the expected core mass of a newly formed HG star
with mass equal to that of the donor, scaled by the fraction of the donor's MS lifetime at mass transfer |br|
``SHIKAUCHI`` : Core mass according to Shikauchi et al. (2024) |br|
Expand Down
6 changes: 6 additions & 0 deletions online-docs/pages/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ What's new

Following is a brief list of important updates to the COMPAS code. A complete record of changes can be found in the file ``changelog.h``.

**03.12.00 Jan 16, 2025**
* Added convective core mass prescription for main sequence stars from Shikauchi+ (2024), describing how the core mass evolves under mass loss and mass gain.
* New command line option ``--main-sequence-core-mass-prescription`` with arguments ``SHIKAUCHI`` (new prescription), ``MANDEL`` (replaces the functionality of ``--retain-core-mass-during-caseA-mass-transfer``), and ``ZERO`` (core mass set to zero, no treatment).
* Added new luminosity prescription for main sequence stars from Shikauchi+ (2024).
* Added treatment for rejuvenation of main sequence accretors when the new prescription is used.

**03.10.00 Nov 29, 2024**

Added functionality to log stellar mergers in the BSE switchlog file.
Expand Down
30 changes: 14 additions & 16 deletions src/MainSequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,9 @@ double MainSequence::CalculateConvectiveCoreMass() const {
* Based on section 7.2 (after Eq. 111) of Hurley, Pols, Tout (2000)
*
*
* double CalculateConvectiveEnvelopeMass() const
* DBL_DBL CalculateConvectiveEnvelopeMass() const
*
* @return Mass of convective envelope in Msol
* @return Tuple containing current mass of convective envelope and mass at ZAMS in Msol
*/
DBL_DBL MainSequence::CalculateConvectiveEnvelopeMass() const {
if (utils::Compare(m_Mass, 1.25) > 0) return std::tuple<double, double> (0.0, 0.0);
Expand Down Expand Up @@ -765,8 +765,6 @@ DBL_DBL MainSequence::CalculateConvectiveEnvelopeMass() const {
*/
DBL_DBL MainSequence::CalculateMainSequenceCoreMassShikauchi(const double p_Dt, const double p_MassLossRate) {

static double heliumAbundanceCoreOut{ m_InitialHeliumAbundance }; // Helium abundance just outside the core - initially m_InitialHeliumAbundance

// get Shikauchi coefficients
DBL_VECTOR ALPHA_COEFFICIENTS = std::get<0>(SHIKAUCHI_COEFFICIENTS);
DBL_VECTOR FMIX_COEFFICIENTS = std::get<1>(SHIKAUCHI_COEFFICIENTS);
Expand Down Expand Up @@ -798,41 +796,41 @@ DBL_DBL MainSequence::CalculateMainSequenceCoreMassShikauchi(const double p_Dt,
if (deltaCoreMass > 0.0) { // If the core grows, we need to account for rejuvenation
if (utils::Compare(newMixingCoreMass, m_InitialMainSequenceCoreMass) < 0) { // New core mass less than initial core mass?
// Common factors
double f1 = heliumAbundanceCoreOut - m_InitialHeliumAbundance;
double f1 = m_HeliumAbundanceCoreOut - m_InitialHeliumAbundance;
double f2 = m_MainSequenceCoreMass - m_InitialMainSequenceCoreMass;
double f3 = m_MainSequenceCoreMass + deltaCoreMass;

// Calculate change in helium abundance just outside the core
double deltaYout = f1 / f2 * deltaCoreMass;

// Calculate the change in core helium abundance, assuming linear profile between Yc and Y0, and that the the accreted gas has helium fraction Y0
double deltaY = (heliumAbundanceCoreOut - m_HeliumAbundanceCore) / f3 * deltaCoreMass + 0.5 / f3 * f1 / f2 * deltaCoreMass * deltaCoreMass;
double deltaY = (m_HeliumAbundanceCoreOut - m_HeliumAbundanceCore) / f3 * deltaCoreMass + 0.5 / f3 * f1 / f2 * deltaCoreMass * deltaCoreMass;
newCentralHeliumFraction = m_HeliumAbundanceCore + deltaY;
heliumAbundanceCoreOut += deltaYout;
m_HeliumAbundanceCoreOut += deltaYout;
}
else { // New core mass greater or equal to the initial core mass?
double deltaCoreMass1 = m_InitialMainSequenceCoreMass - m_MainSequenceCoreMass; // Mass accreted up to the initial core mass
double deltaCoreMass2 = deltaCoreMass - deltaCoreMass1; // Remaining accreted mass
newCentralHeliumFraction = (m_MainSequenceCoreMass * m_HeliumAbundanceCore + 0.5 * (heliumAbundanceCoreOut + m_InitialHeliumAbundance) * deltaCoreMass1 + deltaCoreMass2 * m_InitialHeliumAbundance) / (m_MainSequenceCoreMass + deltaCoreMass);
heliumAbundanceCoreOut = m_InitialHeliumAbundance;
newCentralHeliumFraction = (m_MainSequenceCoreMass * m_HeliumAbundanceCore + 0.5 * (m_HeliumAbundanceCoreOut + m_InitialHeliumAbundance) * deltaCoreMass1 + deltaCoreMass2 * m_InitialHeliumAbundance) / (m_MainSequenceCoreMass + deltaCoreMass);
m_HeliumAbundanceCoreOut = m_InitialHeliumAbundance;
m_InitialMainSequenceCoreMass = newMixingCoreMass;
}
}
else
heliumAbundanceCoreOut = newCentralHeliumFraction; // If core did not grow, Y_out = Y_c
m_HeliumAbundanceCoreOut = newCentralHeliumFraction; // If core did not grow, Y_out = Y_c

return std::tuple<double, double> (newMixingCoreMass, std::min(newCentralHeliumFraction, 1.0 - m_Metallicity));
}


/*
* Calculate the initial core mass of a main sequence star using Equation (A3) from Shikauchi et al. (2024)
*
* Calculate the initial convective core mass of a main sequence star using Equation (A3) from Shikauchi et al. (2024),
* also used for calculating core mass after MS merger
*
* double CalculateInitialMainSequenceCoreMass(const double p_MZAMS)
*
* @param [IN] p_MZAMS Mass at ZAMS in Msol
* @return Mass of the convective core in Msol at ZAMS
* @param [IN] p_MZAMS Mass at ZAMS or after merger in Msol
* @return Mass of the convective core at ZAMS or after merger in Msol
*/
double MainSequence::CalculateInitialMainSequenceCoreMass(const double p_MZAMS) const {
DBL_VECTOR fmixCoefficients = std::get<1>(SHIKAUCHI_COEFFICIENTS);
Expand All @@ -858,7 +856,7 @@ void MainSequence::UpdateMainSequenceCoreMass(const double p_Dt, const double p_
double age = m_Age; // default is no change

switch (OPTIONS->MainSequenceCoreMassPrescription()) {
case CORE_MASS_PRESCRIPTION::NONE:
case CORE_MASS_PRESCRIPTION::ZERO:
mainSequenceCoreMass = 0.0;
break;

Expand All @@ -881,7 +879,7 @@ void MainSequence::UpdateMainSequenceCoreMass(const double p_Dt, const double p_
std::tie(mainSequenceCoreMass, heliumAbundanceCore) = CalculateMainSequenceCoreMassShikauchi(p_Dt, p_MassLossRate); // calculate and update the core mass and central helium fraction

double tMS = m_Timescales[static_cast<int>(TIMESCALE::tMS)];
age = (m_HeliumAbundanceCore - m_InitialHeliumAbundance) / m_InitialHydrogenAbundance * 0.99 * tMS; // update the effective age based on central helium fraction
age = (heliumAbundanceCore - m_InitialHeliumAbundance) / m_InitialHydrogenAbundance * 0.99 * tMS; // update the effective age based on central helium fraction
}
}
// MZAMS less than the limit? MANDEL prescription used
Expand Down
3 changes: 2 additions & 1 deletion src/MainSequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ class MainSequence: virtual public BaseStar {

MT_CASE DetermineMassTransferTypeAsDonor() const { return MT_CASE::A; } // Always case A

const std::tuple <DBL_VECTOR, DBL_VECTOR, DBL_VECTOR> SHIKAUCHI_COEFFICIENTS = InterpolateShikauchiCoefficients(m_Metallicity); // Interpolate Shikauchi coefficients for the given metallicity;
const std::tuple <DBL_VECTOR, DBL_VECTOR, DBL_VECTOR> SHIKAUCHI_COEFFICIENTS = InterpolateShikauchiCoefficients(m_Metallicity); // Interpolate Shikauchi coefficients for the given metallicity

protected:

// member variables

double m_InitialMainSequenceCoreMass = 0.0; // Initial mass of the mixing core is initialised in MS_gt_07 class
double m_HeliumAbundanceCoreOut = m_InitialHeliumAbundance; // Helium abundance just outside the core, used for rejuvenation calculations

// member functions - alphabetically
double CalculateAlphaL(const double p_Mass) const;
Expand Down
4 changes: 2 additions & 2 deletions src/typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ const COMPASUnorderedMap<CHE_MODE, std::string> CHE_MODE_LABEL = {
};

// main sequence core mass prescription
enum class CORE_MASS_PRESCRIPTION: int { NONE, MANDEL, SHIKAUCHI };
enum class CORE_MASS_PRESCRIPTION: int { ZERO, MANDEL, SHIKAUCHI };
const COMPASUnorderedMap<CORE_MASS_PRESCRIPTION, std::string> CORE_MASS_PRESCRIPTION_LABEL = {
{ CORE_MASS_PRESCRIPTION::NONE, "NONE" },
{ CORE_MASS_PRESCRIPTION::ZERO, "ZERO" },
{ CORE_MASS_PRESCRIPTION::MANDEL, "MANDEL" },
{ CORE_MASS_PRESCRIPTION::SHIKAUCHI, "SHIKAUCHI" }
};
Expand Down

0 comments on commit 1deda5d

Please sign in to comment.