Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8b371f3
Attempted updates to NS.cpp to solve the issues with NS recycling
yuzhesong Feb 27, 2024
3e88fd3
Corrected P-dot calculation to use the CalculateSpinDownRate() functi…
yuzhesong Feb 28, 2024
b3a0dd2
Added an option for how NS would accrete in commone envelope phase
yuzhesong Mar 6, 2024
2806c6f
code clean-up
yuzhesong Mar 31, 2024
9bb2b4a
Merge branch 'dev' into MSP
yuzhesong Mar 31, 2024
c59a3b7
update changelog.h
yuzhesong Mar 31, 2024
0841735
Code clean-up in response to reviews
yuzhesong Apr 3, 2024
023cb97
merge latest dev
yuzhesong Apr 3, 2024
24d15ed
Updates to NS.cpp per reviews and BaseB^CaryStar.cpp for issue #1076
yuzhesong Apr 19, 2024
c820189
Revert "Updates to NS.cpp per reviews and BaseB^CaryStar.cpp for issu…
yuzhesong Apr 19, 2024
744d90d
Revert "Revert "Updates to NS.cpp per reviews and BaseB^CaryStar.cpp …
yuzhesong Apr 19, 2024
0f68c81
remove extra file
yuzhesong Apr 19, 2024
2c59717
merge to latest dev & update changelog.h
yuzhesong Apr 21, 2024
ed897f2
fixing typos
yuzhesong Apr 21, 2024
cd62aa0
changes to BaseBinaryStar.cpp
yuzhesong May 16, 2024
67c0f12
changes to changelog.h to avoid conflict
yuzhesong May 16, 2024
3ae4603
Resolve merge conflicts in program-options-list-defaults
yuzhesong May 16, 2024
bc9cab8
merge from lates dev on may 21
yuzhesong May 21, 2024
8102751
commenting out Simon's MT treatments
yuzhesong May 21, 2024
781d84d
Update to Pdot calculations in NS.cpp
yuzhesong Jun 24, 2024
cd9b74b
Merge branch 'dev' into MSP
yuzhesong Jun 24, 2024
27dc8cc
incorporating latest mass transfer fixes
yuzhesong Jun 27, 2024
64b22f3
Merge branch 'dev' into MSP
yuzhesong Jul 3, 2024
d72d3a7
changes to MSP branch before switching branches. Will continue to wor…
yuzhesong Aug 29, 2024
c294724
trial for using BOOST ODE integrator in NS accretion
yuzhesong Sep 28, 2024
cb33d16
further changes made to use BOOST ODE integrator for MSP recycling
yuzhesong Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,11 @@ Default = FIXED_MASS
Amount of mass lost in neutrinos during BH formation (either as fraction or in solar masses, depending on the value of ``--neutrino-mass-loss-bh-formation``). |br|
Default = 0.1

**--neutron-star-accretion-in-ce** |br|
Neutron star accretion behavior in common envelope. |br|
Options: { ZERO, DISK, SURFACE } |br|
Default = ZERO

**--neutron-star-equation-of-state** |br|
Neutron star equation of state. |br|
Options: { SSE, ARP3 } |br|
Expand Down
16 changes: 8 additions & 8 deletions src/BaseBinaryStar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,11 @@ void BaseBinaryStar::SetRemainingValues() {
m_Flags.mergesInHubbleTime = false;
m_Unbound = false;

m_SystemicVelocity = Vector3d();
m_NormalizedOrbitalAngularMomentumVector = Vector3d();
m_ThetaE = DEFAULT_INITIAL_DOUBLE_VALUE;
m_PhiE = DEFAULT_INITIAL_DOUBLE_VALUE;
m_PsiE = DEFAULT_INITIAL_DOUBLE_VALUE;
m_SystemicVelocity = Vector3d();
m_NormalizedOrbitalAngularMomentumVector = Vector3d();
m_ThetaE = DEFAULT_INITIAL_DOUBLE_VALUE;
m_PhiE = DEFAULT_INITIAL_DOUBLE_VALUE;
m_PsiE = DEFAULT_INITIAL_DOUBLE_VALUE;

m_SynchronizationTimescale = DEFAULT_INITIAL_DOUBLE_VALUE;
m_CircularizationTimescale = DEFAULT_INITIAL_DOUBLE_VALUE;
Expand Down Expand Up @@ -1363,7 +1363,7 @@ bool BaseBinaryStar::ResolveSupernova() {
Vector3d relativeVelocityVector = relativeVelocityVectorPrev + (natalKickVector - companionRecoilVector); // km/s - PostSN relative velocity vector

Vector3d orbitalAngularMomentumVector = cross(separationVectorPrev, relativeVelocityVector); // km^2 s^-1 - PostSN specific orbital angular momentum vector
double orbitalAngularMomentum = orbitalAngularMomentumVector.mag; // km^2 s^-1 - PostSN specific orbital angular momentum
double orbitalAngularMomentum = orbitalAngularMomentumVector.mag; // km^2 s^-1 - PostSN specific orbital angular momentum
m_NormalizedOrbitalAngularMomentumVector = orbitalAngularMomentumVector/orbitalAngularMomentum; // set unit vector here to make printing out the inclination vector easier

Vector3d eccentricityVector = cross(relativeVelocityVector, orbitalAngularMomentumVector) /
Expand Down Expand Up @@ -2166,8 +2166,8 @@ void BaseBinaryStar::CalculateMassTransfer(const double p_Dt) {
}
}

// Check for recycled pulsars. Not considering CEE as a way of recycling NSs.
if (!m_CEDetails.CEEnow && m_Accretor->IsOneOf({ STELLAR_TYPE::NEUTRON_STAR })) { // accretor is a neutron star
// Check for recycled pulsars.
if ((!m_CEDetails.CEEnow || OPTIONS->NeutronStarAccretionInCE() != NS_ACCRETION_IN_CE::ZERO) && m_Accretor->IsOneOf({ STELLAR_TYPE::NEUTRON_STAR })) {
m_Donor->SetRLOFOntoNS(); // donor donated mass to a neutron star
m_Accretor->SetRecycledNS(); // accretor is (was) a recycled NS
}
Expand Down
495 changes: 495 additions & 0 deletions src/Mode

Large diffs are not rendered by default.

319 changes: 254 additions & 65 deletions src/NS.cpp

Large diffs are not rendered by default.

29 changes: 24 additions & 5 deletions src/NS.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "Remnants.h"
#include "BH.h"

#include <boost/numeric/odeint.hpp>

class BaseStar;
class Remnants;
Expand Down Expand Up @@ -46,8 +46,17 @@ class NS: virtual public BaseStar, public Remnants {
static double CalculateRadiusOnPhase_Static(const double p_Mass) { return CalculateRadiusOnPhaseInKM_Static(p_Mass) * KM_TO_RSOL; } // Radius on phase in Rsol

static double CalculateRemnantMass_Static(const double p_COCoreMass) { return 1.17 + (0.09 * p_COCoreMass); } // Hurley et al., eq 92


static DBL_DBL_DBL_DBL deltaAngularMomentumByPulsarAccretion(const double p_MassGainPerTimeStep,
const double p_MagField,
const double p_Mass,
const double p_Radius,
const double p_SpinFrequency,
const double p_AngularMomentum,
const double p_Stepsize,
const double p_Kappa,
const double p_Epsilon,
const double p_MoI
) ;
protected:

void Initialise() {
Expand Down Expand Up @@ -86,12 +95,22 @@ class NS: virtual public BaseStar, public Remnants {

double CalculateSpinDownRate(const double p_Omega, const double p_MomentOfInteria, const double p_MagField, const double p_Radius) const;

double ChooseTimestep(const double p_Time) const;
double ChooseTimestep(const double p_Time) const;



STELLAR_TYPE EvolveToNextPhase() { return STELLAR_TYPE::BLACK_HOLE; }

bool ShouldEvolveOnPhase() const { return (m_Mass <= OPTIONS->MaximumNeutronStarMass()); } // Evolve as a neutron star unless mass > maximum neutron star mass (e.g. through accretion)
void SpinDownIsolatedPulsar(const double p_Stepsize);
DBL_DBL_DBL_DBL PulsarAccretion(const double p_MagField,
const double p_SpinPeriod,
const double p_AngularMomentum,
const double p_Stepsize,
const double p_MassGainPerTimeStep,
const double kappa,
const double p_Epsilon);

void UpdateMagneticFieldAndSpin(const bool p_CommonEnvelope,
const bool p_RecycledNS,
const double p_Stepsize,
Expand All @@ -100,4 +119,4 @@ class NS: virtual public BaseStar, public Remnants {

};

#endif // __NS_h__
#endif // __NS_h__
16 changes: 15 additions & 1 deletion src/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@ void Options::OptionValues::Initialise() {
m_NeutronStarEquationOfState.type = NS_EOS::SSE;
m_NeutronStarEquationOfState.typeString = NS_EOSLabel.at(m_NeutronStarEquationOfState.type);

// Neutron star accretion in common envelope
m_NSAccretionInCE.type = NS_ACCRETION_IN_CE::ZERO;
m_NSAccretionInCE.typeString = NS_ACCRETION_IN_CELabel.at(m_NSAccretionInCE.type) ;

// Pulsar birth magnetic field distribution
m_PulsarBirthMagneticFieldDistribution.type = PULSAR_BIRTH_MAGNETIC_FIELD_DISTRIBUTION::ZERO;
Expand Down Expand Up @@ -1807,7 +1810,11 @@ bool Options::AddOptions(OptionValues *p_Options, po::options_description *p_Opt
po::value<std::string>(&p_Options->m_NeutronStarEquationOfState.typeString)->default_value(p_Options->m_NeutronStarEquationOfState.typeString),
("Neutron star equation of state to use (" + AllowedOptionValuesFormatted("neutron-star-equation-of-state") + ", default = '" + p_Options->m_NeutronStarEquationOfState.typeString + "')").c_str()
)

(
"neutron-star-accretion-in-CE",
po::value<std::string>(&p_Options->m_NSAccretionInCE.typeString)->default_value(p_Options->m_NSAccretionInCE.typeString),
("Neutron star accretion in CE to use (" + AllowedOptionValuesFormatted("neutron-star-accretion-in-CE") + ", default = '" + p_Options->m_NSAccretionInCE.typeString + "')").c_str()
)
(
"OB-mass-loss",
po::value<std::string>(&p_Options->m_OBMassLoss.typeString)->default_value(p_Options->m_OBMassLoss.typeString),
Expand Down Expand Up @@ -2247,6 +2254,11 @@ std::string Options::OptionValues::CheckAndSetOptions() {
COMPLAIN_IF(!found, "Unknown Neutron Star Equation of State");
}

if (!DEFAULTED("neutron-star-accretion-in-ce")) { // neutron star accretion in ce
std::tie(found, m_NSAccretionInCE.type) = utils::GetMapKey(m_NSAccretionInCE.typeString, NS_ACCRETION_IN_CELabel, m_NSAccretionInCE.type);
COMPLAIN_IF(!found, "Unknown Neutron Star Accretion in CE");
}

if (!DEFAULTED("OB-mass-loss")) { // OB (main sequence) loss prescription
std::tie(found, m_OBMassLoss.type) = utils::GetMapKey(m_OBMassLoss.typeString, OB_MASS_LOSS_LABEL, m_OBMassLoss.type);
COMPLAIN_IF(!found, "Unknown OB Mass Loss Prescription");
Expand Down Expand Up @@ -2546,6 +2558,7 @@ std::vector<std::string> Options::AllowedOptionValues(const std::string p_Option
case _("mode") : POPULATE_RET(EVOLUTION_MODE_LABEL); break;
case _("neutrino-mass-loss-BH-formation") : POPULATE_RET(NEUTRINO_MASS_LOSS_PRESCRIPTION_LABEL); break;
case _("neutron-star-equation-of-state") : POPULATE_RET(NS_EOSLabel); break;
case _("neutron-star-accretion-in-CE") : POPULATE_RET(NS_ACCRETION_IN_CELabel); break;
case _("OB-mass-loss") : POPULATE_RET(OB_MASS_LOSS_LABEL); break;
case _("orbital-period-distribution") : POPULATE_RET(ORBITAL_PERIOD_DISTRIBUTION_LABEL); break;
case _("pulsar-birth-magnetic-field-distribution") : POPULATE_RET(PULSAR_BIRTH_MAGNETIC_FIELD_DISTRIBUTION_LABEL); break;
Expand Down Expand Up @@ -4624,6 +4637,7 @@ COMPAS_VARIABLE Options::OptionValue(const T_ANY_PROPERTY p_Property) const {
case PROGRAM_OPTION::NOTES : value = Notes(); break;

case PROGRAM_OPTION::NS_EOS : value = static_cast<int>(NeutronStarEquationOfState()); break;
case PROGRAM_OPTION::NS_ACCRETION_IN_CE : value = static_cast<int>(NeutronStarAccretionInCE()); break;

case PROGRAM_OPTION::ORBITAL_PERIOD : value = OrbitalPeriod(); break;
case PROGRAM_OPTION::ORBITAL_PERIOD_DISTRIBUTION : value = static_cast<int>(OrbitalPeriodDistribution()); break;
Expand Down
6 changes: 6 additions & 0 deletions src/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ class Options {
"maximum-mass-donor-nandez-ivanova",
"minimum-secondary-mass",

"neutron-star-accretion-in-ce",

"orbital-period",
"orbital-period-distribution",
"orbital-period-max",
Expand Down Expand Up @@ -510,6 +512,7 @@ class Options {
"notes-hdrs",
"neutrino-mass-loss-BH-formation",
"neutron-star-equation-of-state",
"neutron-star-accretion-in-CE",

"OB-mass-loss",
"orbital-period-distribution",
Expand Down Expand Up @@ -965,6 +968,8 @@ class Options {
// Neutron star equation of state
ENUM_OPT<NS_EOS> m_NeutronStarEquationOfState; // NS EOS

// Neutron star accretion in common envelope
ENUM_OPT<NS_ACCRETION_IN_CE> m_NSAccretionInCE; // NS Accretion In CE

// Pulsar birth magnetic field distribution string
ENUM_OPT<PULSAR_BIRTH_MAGNETIC_FIELD_DISTRIBUTION> m_PulsarBirthMagneticFieldDistribution; // Birth magnetic field distribution for pulsars
Expand Down Expand Up @@ -1425,6 +1430,7 @@ class Options {
double NeutrinoMassLossValueBH() const { return OPT_VALUE("neutrino-mass-loss-BH-formation-value", m_NeutrinoMassLossValueBH, true); }

NS_EOS NeutronStarEquationOfState() const { return OPT_VALUE("neutron-star-equation-of-state", m_NeutronStarEquationOfState.type, true); }
NS_ACCRETION_IN_CE NeutronStarAccretionInCE() const { return OPT_VALUE("neutron-star-accretion-in-ce", m_NSAccretionInCE.type, true); }

std::string Notes(const size_t p_Idx) const { return OPT_VALUE("notes", m_Notes[p_Idx], true); }
std::vector<std::string> Notes() const { return OPT_VALUE("notes", m_Notes, true); }
Expand Down
10 changes: 9 additions & 1 deletion src/changelog.h
Original file line number Diff line number Diff line change
Expand Up @@ -1225,8 +1225,16 @@
// - Change TPAGB::IsSupernova() so that stars with base of AGB core masses below MCBUR1 remain on the TPAGB until they make WDs; remove ResolveTypeIIaSN() functionality.
// - Add --evolve-main-sequence-mergers option which allows for main sequence merger products to continue evolution
// - Update HG::CalculateRadialExtentConvectiveEnvelope() to use a combination of Hurley & Picker to avoid excessively high convective envelope densities
// 02.51.00 YS - Jul 03, 2024 - Update to neutron star accretion treatments:
// - Fixes to MSP formation/NS in mass transfer treatments:
// 1). Created a new function NS::PulsarAccretion() to calculate the pulsar evolution in stable mass transfer.
// 2). In UpdateMagneticFieldAndSpin(), splitting stable mass transfer into smaller steps so that no negative spin period is present.
// 3). Adding a new programming option "NS-ACCRETION-IN-CE" for different treatment of how neutron star would behave when in CE.


const std::string VERSION_STRING = "02.51.00";


const std::string VERSION_STRING = "02.50.00";


# endif // __changelog_h__
1 change: 1 addition & 0 deletions src/compasConfigDefault.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ stringChoices:
# --fryer-supernova-engine: 'DELAYED' # Default: 'DELAYED' # Options: ['DELAYED','RAPID']
# --kick-magnitude-distribution: 'MULLERMANDEL' # Default: 'MULLERMANDEL' # Options: ['MULLERMANDEL','MULLER2016MAXWELLIAN','MULLER2016','BRAYELDRIDGE','MAXWELLIAN','FLAT','FIXED','ZERO']
# --kick-direction: 'ISOTROPIC' # Default: 'ISOTROPIC' # Options: ['POLES','WEDGE','POWERLAW','PERPENDICULAR','INPLANE','ISOTROPIC']
# --neutron-star-accretion-in-ce: 'ZERO' # Default: 'ZERO' # Options: ['ZERO', 'DISK', 'SURFACE']
# --neutron-star-equation-of-state: 'SSE' # Default: 'SSE' # Options: ['ARP3','SSE']
# --neutrino-mass-loss-BH-formation: 'FIXED_MASS' # Default: 'FIXED_MASS' # Options: ['FIXED_MASS','FIXED_FRACTION']
# --pulsar-birth-magnetic-field-distribution: 'ZERO' # Default: 'ZERO' # Options: ['LOGNORMAL','UNIFORM','FLATINLOG','FIXED','ZERO']
Expand Down
11 changes: 11 additions & 0 deletions src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ enum class ERROR: int {
UNKNOWN_MT_THERMALLY_LIMITED_VARIATION, // unknown mass transfer thermally limited variation
UNKNOWN_NEUTRINO_MASS_LOSS_PRESCRIPTION, // unknown neutrino mass loss prescription
UNKNOWN_NS_EOS, // unknown NS equation-of-state
UNKNOWN_NS_ACCRETION_IN_CE, // unknown NS accretion-in-ce
UNKNOWN_PPI_PRESCRIPTION, // unknown pulsational pair instability prescription
UNKNOWN_PROGRAM_OPTION, // unknown program option
UNKNOWN_PROPERTY_TYPE, // unknown property type
Expand Down Expand Up @@ -841,6 +842,7 @@ const COMPASUnorderedMap<ERROR, std::tuple<ERROR_SCOPE, std::string>> ERROR_CATA
{ ERROR::UNKNOWN_MASS_LOSS_PRESCRIPTION, { ERROR_SCOPE::ALWAYS, "Unknown mass loss prescription" }},
{ ERROR::UNKNOWN_NEUTRINO_MASS_LOSS_PRESCRIPTION, { ERROR_SCOPE::ALWAYS, "Unknown neutrino mass loss prescription" }},
{ ERROR::UNKNOWN_NS_EOS, { ERROR_SCOPE::ALWAYS, "Unknown NS equation-of-state" }},
{ ERROR::UNKNOWN_NS_ACCRETION_IN_CE, { ERROR_SCOPE::ALWAYS, "Unknown NS accretion-in-ce" }},
{ ERROR::UNKNOWN_PPI_PRESCRIPTION, { ERROR_SCOPE::ALWAYS, "Unknown pulsational pair instability prescription" }},
{ ERROR::UNKNOWN_PROGRAM_OPTION, { ERROR_SCOPE::ALWAYS, "Unknown program option - property details not found" }},
{ ERROR::UNKNOWN_PROPERTY_TYPE, { ERROR_SCOPE::ALWAYS, "Unknown property type - property details not found" }},
Expand Down Expand Up @@ -1282,6 +1284,14 @@ const COMPASUnorderedMap<NS_EOS, std::string> NS_EOSLabel = {
{ NS_EOS::ARP3, "ARP3" }
};

// Neutron Star accretion in CE
enum class NS_ACCRETION_IN_CE: int { ZERO, DISK, SURFACE };
const COMPASUnorderedMap<NS_ACCRETION_IN_CE, std::string> NS_ACCRETION_IN_CELabel = {
{ NS_ACCRETION_IN_CE::ZERO, "ZERO" },
{ NS_ACCRETION_IN_CE::DISK, "DISK" },
{ NS_ACCRETION_IN_CE::SURFACE, "SURFACE" }
};


// Orbital Period Distributions
enum class ORBITAL_PERIOD_DISTRIBUTION: int { FLATINLOG };
Expand Down Expand Up @@ -2587,6 +2597,7 @@ enum class PROGRAM_OPTION: int {
NOTES,

NS_EOS,
NS_ACCRETION_IN_CE,

ORBITAL_PERIOD,
ORBITAL_PERIOD_DISTRIBUTION,
Expand Down
1 change: 1 addition & 0 deletions src/typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,5 +312,6 @@ typedef struct StellarCEDetails { // Common Envelope detail
typedef std::vector< double > state_type;
typedef boost::numeric::odeint::runge_kutta_cash_karp54< state_type > error_stepper_type;
typedef boost::numeric::odeint::controlled_runge_kutta< error_stepper_type > controlled_stepper_type;
typedef boost::numeric::odeint::runge_kutta4< state_type > stepper;

#endif // __typedefs_h__
1 change: 1 addition & 0 deletions src/yaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ namespace yaml {
" --kick-magnitude-distribution",
" --kick-direction",
" --neutron-star-equation-of-state",
" --neutron-star-accretion-in-ce",
" --neutrino-mass-loss-BH-formation",
" --pulsar-birth-magnetic-field-distribution",
" --pulsar-birth-spin-period-distribution",
Expand Down