Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -67,5 +67,21 @@ Note that the BSE SwitchLog file has the following columns automatically appende
* - Header String:
- "SWITCHING_TO"

**IS_MERGER**

.. list-table::
:widths: 20 80
:header-rows: 0
:class: aligned-text

* - Data type:
- BOOL
* - COMPAS variable:
- Not applicable
* - Description:
- Flag to indicate if the switchlog record records a merger (rather than a simple switch)
* - Header String:
- "IS_MERGER"

These columns will always be automatically appended to each BSE Switch Log record: they cannot be removed via the log file record
specifications file.
13 changes: 8 additions & 5 deletions online-docs/pages/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +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.09.00 Nov 25, 2024**
**03.10.00 Nov 29, 2024**

Added functionality to log stellar mergers in the BSE switchlog file.
Switchlog merger records come in pairs (one for each star) so that the stellar type of each star is recorded.

**03.09.00 Nov 28, 2024**

Improved nuclear timescale mass transfer: the nuclear timescale mass transfer rate is now set by the requirement that the star
ends the time step just filling its Roche lobe.
Expand All @@ -23,13 +28,11 @@ Improved the treatment of stellar rotation (with further corrections in 03.08.01

* Assume rigid body rotation
* Keep the angular moment of a star constant when there is no mass loss
* When a star with radius r and angular frequency omega loses mass dm through winds or mass transfer, it loses angular momentum dL =
(2/3) dm r^2 omega
* When a star with radius r and angular frequency omega loses mass dm through winds or mass transfer, it loses angular momentum dL = (2/3) dm r^2 omega
* (However, angular momentum never drops below zero)
* When a star loses its envelope, the remaining core is assumed to rotate with the same rotation rate as the preceding star
* When a star of mass m and radius r gains mass dm through accretion, it gain angular momentum dL = dm \sqrt{G m r}
* If initial binary rotation is fast enough for a star to be CHE, it is set to that rotation frequency without regard for the tidal
prescription; CHE stars remain tidally locked if the tidal prescription is NONE
* If initial binary rotation is fast enough for a star to be CHE, it is set to that rotation frequency without regard for the tidal prescription; CHE stars remain tidally locked if the tidal prescription is NONE

**03.07.01 Oct 23, 2024**

Expand Down
11 changes: 6 additions & 5 deletions src/BaseBinaryStar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3084,11 +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 {
// 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 { // no - for now, log the merger and stop evolution
// log the merger to the switchlog file
// eventually, will want to implement a more careful prescription for the merger product,
// perhaps allowing further evolution of the merger product
(void)LogMergerToSwitchLog(); // log merger
evolutionStatus = EVOLUTION_STATUS::STELLAR_MERGER; // stop evolution
}
}
else if (HasStarsTouching()) { // binary components touching? (should usually be avoided as MT or CE or merger should happen prior to this)
Expand Down
18 changes: 15 additions & 3 deletions src/BaseBinaryStar.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ class BaseBinaryStar {

EVOLUTION_STATUS Evolve();

bool PrintSwitchLog(const bool p_PrimarySwitching) { // print to the switch log file
bool PrintSwitchLog(const bool p_PrimarySwitching, const bool p_IsMerger = false) { // print to the switch log file
return OPTIONS->SwitchLog() // switch logging enabled?
? (LOGGING->ObjectSwitchingPersistence() == OBJECT_PERSISTENCE::PERMANENT // yes, switch logging enabled - is this a 'permanent' object (i.e. not an ephemeral clone)?
? LOGGING->LogBSESwitchLog(this, p_PrimarySwitching) // yes, permanent - log it
? LOGGING->LogBSESwitchLog(this, p_PrimarySwitching, p_IsMerger) // yes, permanent - log it
: true // no, ephemeral - ignore the log request
)
: true; // no - switch logging not enabled - ignore the log request
Expand Down Expand Up @@ -504,7 +504,19 @@ class BaseBinaryStar {
void UpdateSystemicVelocity(Vector3d p_newVelocity) { m_SystemicVelocity += p_newVelocity; }

// printing functions


bool LogMergerToSwitchLog() {
// switchlog merger records come in pairs - one for each star
// record merger for primary
LOGGING->SetSwitchParameters(m_ObjectId, ObjectType(), m_ObjectPersistence, m_Star1->StellarType(), m_Star1->StellarType()); // store switch details to LOGGING service
if (PrintSwitchLog(true, true)) { // record merger details to switchlog
// record merger for secondary
LOGGING->SetSwitchParameters(m_ObjectId, ObjectType(), m_ObjectPersistence, m_Star2->StellarType(), m_Star2->StellarType()); // store switch details to LOGGING service
return PrintSwitchLog(false, true); // record merger details to switchlog
}
return false;
}

bool PrintRLOFParameters(const RLOF_RECORD_TYPE p_RecordType = RLOF_RECORD_TYPE::DEFAULT);

bool PrintBinarySystemParameters(const BSE_SYSPARMS_RECORD_TYPE p_RecordType = BSE_SYSPARMS_RECORD_TYPE::DEFAULT) const {
Expand Down
2 changes: 0 additions & 2 deletions src/BaseStar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2494,8 +2494,6 @@ double BaseStar::CalculateMassLossRateWolfRayetTemperatureCorrectionSander2023(c
else {
logMdotCorrected = logMdotUncorrected;
}

std::cout<<logMdotCorrected<<std::endl;

return PPOW(10.0, logMdotCorrected);
}
Expand Down
19 changes: 14 additions & 5 deletions src/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2751,12 +2751,13 @@ LogfileDetailsT Log::StandardLogFileDetails(const LOGFILE p_Logfile, const strin
// ( i) the steller type from which the star is switching
// (ii) the stellar type to which the star is switching
//
// if we are writing to the BSE Switch file we add three pre-defined columns
// if we are writing to the BSE Switch file we add four pre-defined columns
// to the end of the log record. These are:
//
// ( i) the star switching - 1 = primary, 2 = secondary
// ( ii) the steller type from which the star is switching
// (iii) the stellar type to which the star is switching
// ( iv) boolean flag indicating whether a merger occurred
//
// These are hard-coded here rather than in the *_PROPERTY_DETAIL maps in
// constants.h so that they will always be present in the switch file -
Expand All @@ -2768,7 +2769,7 @@ LogfileDetailsT Log::StandardLogFileDetails(const LOGFILE p_Logfile, const strin
fileDetails.hdrStrings.push_back("Star_Switching"); // append header string for field
fileDetails.unitsStrings.push_back("-"); // append units string for field
fileDetails.typeStrings.push_back("INT"); // append type string for field
fileDetails.fmtStrings.push_back("4.1"); // append format string for field (size accommodates header string)
fileDetails.fmtStrings.push_back("4.1"); // append format string for field
}

if (p_Logfile == LOGFILE::BSE_SWITCH_LOG || p_Logfile == LOGFILE::SSE_SWITCH_LOG) { // BSE Switch Log or SSE Switch Log
Expand All @@ -2784,12 +2785,20 @@ LogfileDetailsT Log::StandardLogFileDetails(const LOGFILE p_Logfile, const strin
fileDetails.typeStrings.push_back("INT"); // append type string for field
fileDetails.typeStrings.push_back("INT"); // append type string for field

fileDetails.fmtStrings.push_back("4.1"); // append format string for field (size accommodates header string)
fileDetails.fmtStrings.push_back("4.1"); // append format string for field (size accommodates header string)
fileDetails.fmtStrings.push_back("4.1"); // append format string for field
fileDetails.fmtStrings.push_back("4.1"); // append format string for field
}

if (p_Logfile == LOGFILE::BSE_SWITCH_LOG) { // BSE Switch Log
fileDetails.propertyTypes.push_back(TYPENAME::BOOL); // append property typename
fileDetails.hdrStrings.push_back("Is_Merger"); // append header string for field
fileDetails.unitsStrings.push_back("-"); // append units string for field
fileDetails.typeStrings.push_back("BOOL"); // append type string for field
fileDetails.fmtStrings.push_back("0.0"); // append format string for field
}

// we add the record type column to the end of the log record here for all logfiles
// except the switch files (BSE_SWITCH_LOG and SSE_SWOTCH_LOG).
// except the switch files (BSE_SWITCH_LOG and SSE_SWITCH_LOG).
//
// This is hard-coded here rather than in the *_PROPERTY_DETAIL maps in constants.h
// so that it will always be present in the logfile - this way users can't add or
Expand Down
21 changes: 17 additions & 4 deletions src/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ class Log {
m_TypeSwitchingFrom = STELLAR_TYPE::NONE; // stellar type from which the Star object is switching - default NONE
m_TypeSwitchingTo = STELLAR_TYPE::NONE; // stellar type to which the Star object is switching - default NONE
m_PrimarySwitching = false; // Star switching is primary star of binary - default false
m_SwitchIsMerger = false; // Switchlog record records a merger (rather than a simple switch)

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
Expand Down Expand Up @@ -616,6 +617,7 @@ class Log {
STELLAR_TYPE m_TypeSwitchingFrom; // the stellar type from which the Star object is switching
STELLAR_TYPE m_TypeSwitchingTo; // the stellar type to which the Star object is switching
bool m_PrimarySwitching; // flag to indicate whether the primary star of the binary is switching
bool m_SwitchIsMerger; // flag to indicate whether the switchlog record records a merger (rather than a simple switch)


// the following struct supports delayed writes to logfiles
Expand Down Expand Up @@ -864,12 +866,13 @@ class Log {
// ( i) the stellar type from which the star is switching
// (ii) the stellar type to which the star is switching
//
// if we are writing to the BSE Switch file we add three pre-defined columns
// if we are writing to the BSE Switch file we add four pre-defined columns
// to the end of the log record. These are:
//
// ( i) the star switching - 1 = primary, 2 = secondary
// ( ii) the stellar type from which the star is switching
// (iii) the stellar type to which the star is switching
// ( iv) boolean flag indicating whether a merger occurred
//
// These are hard-coded here rather than in the *_PROPERTY_DETAIL maps in
// constants.h so that they will always be present in the switch file -
Expand All @@ -881,7 +884,7 @@ class Log {
if (p_LogFile == LOGFILE::BSE_SWITCH_LOG) {
int starSwitching = m_PrimarySwitching ? 1 : 2; // primary (1) or secondary (2)
if (hdf5) { // yes - HDF5 file?
logRecordValues.push_back(starSwitching); // add value to vector of values
logRecordValues.push_back(starSwitching); // yes - add value to vector of values
}
else { // no - CSV, TSV, or TXT file
logRecord += utils::vFormat(fmtStr.c_str(), starSwitching) + delimiter; // add value string to log record - with delimiter
Expand All @@ -904,6 +907,15 @@ class Log {
}
}

if (p_LogFile == LOGFILE::BSE_SWITCH_LOG) {
if (hdf5) { // HDF5 file?
logRecordValues.push_back(m_SwitchIsMerger); // yes - add value to vector of values
}
else { // no - CSV, TSV, or TXT file
logRecord += utils::vFormat(fmtStr.c_str(), m_SwitchIsMerger) + delimiter; // add value string to log record - with delimiter
}
}

// we add the record type column to the end of the log record here for all logfiles
// except the switch files (BSE_SWITCH_LOG and SSE_SWITCH_LOG).
//
Expand Down Expand Up @@ -1203,8 +1215,9 @@ class Log {
const BSE_SN_RECORD_TYPE p_RecordType) { return LogStandardRecord(std::get<2>(LOGFILE_DESCRIPTOR.at(LOGFILE::BSE_SUPERNOVAE)), 0, LOGFILE::BSE_SUPERNOVAE, static_cast<LOGRECORDTYPE>(p_RecordType), p_Binary); }

template <class T>
bool LogBSESwitchLog(const T* const p_Binary, const bool p_PrimarySwitching) {
m_PrimarySwitching = p_PrimarySwitching;
bool LogBSESwitchLog(const T* const p_Binary, const bool p_PrimarySwitching, const bool p_IsMerger) {
m_PrimarySwitching = p_PrimarySwitching;
m_SwitchIsMerger = p_IsMerger;
return LogStandardRecord(std::get<2>(LOGFILE_DESCRIPTOR.at(LOGFILE::BSE_SWITCH_LOG)), 0, LOGFILE::BSE_SWITCH_LOG, 1U, p_Binary);
}

Expand Down
4 changes: 3 additions & 1 deletion src/changelog.h
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,8 @@
// - 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
// - Minor fixes, including to #1255, #1258
const std::string VERSION_STRING = "03.09.03";
// 03.10.00 JR - Nov 29, 2024 - Enhancement:
// - added functionality to allow stellar mergers (for BSE) to be logged to switchlog file (see documentation for details)
const std::string VERSION_STRING = "03.10.00";

# endif // __changelog_h__