Skip to content

Commit

Permalink
Merge pull request #1092 from TeamCOMPAS/issue-1074
Browse files Browse the repository at this point in the history
Defect repair - Fix for issue #1074 - SSE Supernova records duplicated
  • Loading branch information
jeffriley authored Apr 15, 2024
2 parents 1c1c42c + 2ca8289 commit e2c12cd
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/BaseStar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2802,6 +2802,7 @@ void BaseStar::ResolveMassLoss(const bool p_UpdateMDt) {
STELLAR_TYPE st = UpdateAttributesAndAgeOneTimestep(mass - m_Mass, 0.0, 0.0, false, false); // recalculate stellar attributes
if (st != m_StellarType) { // should switch?
SHOW_WARN(ERROR::SWITCH_NOT_TAKEN); // show warning if we think we should switch again...
if (IsSupernova()) ClearSupernovaStash(); // we may have stashed SN details - need to clear them if we're not going to switch
}

UpdateInitialMass(); // update effective initial mass (MS, HG & HeMS)
Expand Down
14 changes: 8 additions & 6 deletions src/BaseStar.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class BaseStar {
bool IsHeSD() const { return (m_SupernovaDetails.events.current & SN_EVENT::HeSD) == SN_EVENT::HeSD; }
virtual bool IsDegenerate() const { return false; } // default is not degenerate - White Dwarfs, NS and BH are degenerate
bool IsECSN() const { return (m_SupernovaDetails.events.current & SN_EVENT::ECSN) == SN_EVENT::ECSN; }
bool IsSN_NONE() const { return m_SupernovaDetails.events.current == SN_EVENT::NONE; }
bool IsOneOf(const STELLAR_TYPE_LIST p_List) const;
bool IsPISN() const { return (m_SupernovaDetails.events.current & SN_EVENT::PISN) == SN_EVENT::PISN; }
bool IsPPISN() const { return (m_SupernovaDetails.events.current & SN_EVENT::PPISN) == SN_EVENT::PPISN; }
Expand Down Expand Up @@ -219,20 +220,19 @@ class BaseStar {
virtual double CalculateZetaConstantsByEnvelope(ZETA_PRESCRIPTION p_ZetaPrescription) { return 0.0; } // Use inheritance hierarchy

void ClearCurrentSNEvent() { m_SupernovaDetails.events.current = SN_EVENT::NONE; } // Clear supernova event/state for current timestep
void ClearSupernovaStash() { LOGGING->ClearSSESupernovaStash(); } // Clear contents of SSE supernova stash

virtual ACCRETION_REGIME DetermineAccretionRegime(const bool p_HeRich,
const double p_DonorThermalMassLossRate) { return ACCRETION_REGIME::NONE; } // Placeholder, use inheritance for WDs

virtual ENVELOPE DetermineEnvelopeType() const { return ENVELOPE::REMNANT; } // Default is REMNANT - but should never be called

void HaltWinds() { m_Mdot = 0.0; } // Disable wind mass loss in current time step (e.g., if star is a donor or accretor in a RLOF episode)

virtual ACCRETION_REGIME DetermineAccretionRegime(const bool p_HeRich,
const double p_DonorThermalMassLossRate) { return ACCRETION_REGIME::NONE; } // Placeholder, use inheritance for WDs
double InterpolateGe20QCrit(const QCRIT_PRESCRIPTION p_qCritPrescription);

void ResetEnvelopeExpulsationByPulsations() { m_EnvelopeJustExpelledByPulsations = false; }

virtual void ResolveShellChange(const double p_AccretedMass) { } // Default does nothing, use inheritance for WDs.

double InterpolateGe20QCrit(const QCRIT_PRESCRIPTION p_qCritPrescription);

void ResolveAccretion(const double p_AccretionMass) { m_Mass = std::max(0.0, m_Mass + p_AccretionMass); } // Handles donation and accretion - won't let mass go negative

virtual void ResolveAccretionRegime(const ACCRETION_REGIME p_Regime,
Expand All @@ -241,6 +241,8 @@ class BaseStar {
virtual STELLAR_TYPE ResolveEnvelopeLoss(bool p_NoCheck = false) { return m_StellarType; }

virtual void ResolveMassLoss(const bool p_UpdateMDt = true);

virtual void ResolveShellChange(const double p_AccretedMass) { } // Default does nothing, use inheritance for WDs.

void SetStellarTypePrev(const STELLAR_TYPE p_StellarTypePrev) { m_StellarTypePrev = p_StellarTypePrev; }

Expand Down
1 change: 1 addition & 0 deletions src/GiantBranch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,7 @@ STELLAR_TYPE GiantBranch::ResolveSupernova() {
STELLAR_TYPE stellarType = m_StellarType;

if (IsSupernova()) { // has gone supernova
// no - resolve new supernova event
// squirrel away some attributes before they get changed...
m_SupernovaDetails.totalMassAtCOFormation = m_Mass;
m_SupernovaDetails.HeCoreMassAtCOFormation = m_HeCoreMass;
Expand Down
5 changes: 5 additions & 0 deletions src/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,11 @@ class Log {
bool LogSSESystemParameters(const T* const p_Star,
const SSE_SYSPARMS_RECORD_TYPE p_RecordType) { return LogStandardRecord(std::get<2>(LOGFILE_DESCRIPTOR.at(LOGFILE::SSE_SYSTEM_PARAMETERS)), 0, LOGFILE::SSE_SYSTEM_PARAMETERS, static_cast<LOGRECORDTYPE>(p_RecordType), p_Star); }

void ClearSSESupernovaStash() {
m_SSESupernovae_DelayedWrite.logRecordType = 0; // delayed log record type for SSE_Supernovae file - initially 0 (set later)
m_SSESupernovae_DelayedWrite.logRecordString = ""; // delayed log record (string) for SSE_Supernovae file - initially empty
m_SSESupernovae_DelayedWrite.logRecordValues = {}; // delayed log record (property values) for SSE_Supernovae file - initially empty
}

template <class T>
void StashSSESupernovaDetails(const T* const p_Star, const STELLAR_TYPE p_StellarType, const SSE_SN_RECORD_TYPE p_RecordType) {
Expand Down
2 changes: 2 additions & 0 deletions src/Star.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ EVOLUTION_STATUS Star::Evolve(const long int p_Id) {
SHOW_WARN(ERROR::TIMESTEPS_NOT_CONSUMED); // show warning
}

(void)m_Star->PrintStashedSupernovaDetails(); // print final stashed SSE Supernova log record if necessary

(void)m_Star->PrintDetailedOutput(m_Id, SSE_DETAILED_RECORD_TYPE::FINAL_STATE); // log record

m_Star->SetEvolutionStatus(evolutionStatus); // set evolution final outcome for star
Expand Down
2 changes: 1 addition & 1 deletion src/WhiteDwarfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ double WhiteDwarfs::CalculateEtaH(const double p_MassTransferRate) {
* table A1. The thresholds here are named by the boundaries RG/SS, SS/MF, and SF/Dt,
* respectively (see text for details). Note that the different flashes regimes from
* Piersanti+ 2014 have been merged into one, i.e we omit the MF/SF boundary, and
* the accumulation regime has been change so we can get double detonations. Finally,
* the accumulation regime has been changed so we can get double detonations. Finally,
* eta_KH04 has also been updated with the accretion efficiency values from Piersanti+ 2014.
*
* double CalculateEtaHe(const double p_MassTransferRate)
Expand Down
5 changes: 3 additions & 2 deletions src/changelog.h
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,9 @@
// - Added Hirai pulsar rocket kick, and related options
// 02.43.01 SS - Apr 8, 2024 - Defect repair
// - Fix CalculateMassLossRateBjorklundEddingtonFactor to use LSOLW (in SI) rather than LSOL (in cgs)
//
// 02.43.02 JR - Apr 15, 2024 - Defect repair
// - Fix for issue #1074 - SSE Supernova records duplicated

const std::string VERSION_STRING = "02.43.01";
const std::string VERSION_STRING = "02.43.02";

# endif // __changelog_h__

0 comments on commit e2c12cd

Please sign in to comment.