Skip to content

Commit 1398e89

Browse files
committed
Enhancement:
- Add option --timestep-multipliers to enable more granular, phase-dependent, timestep multipliers (see documentation for use) - Added maximum allowed value for options and
1 parent f90c3ac commit 1398e89

File tree

10 files changed

+57
-25
lines changed

10 files changed

+57
-25
lines changed

online-docs/pages/User guide/Program options/program-options-list-defaults.rst

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ Default = 0.0
343343

344344
**--debug-classes** |br|
345345
Developer-defined debug classes to enable (vector). |br|
346+
See :doc:`Vector program options <./program-options-vector-options>` for option format. |br|
346347
Default = `All debug classes enabled (e.g. no filtering)`
347348

348349
**--debug-level** |br|
@@ -694,6 +695,7 @@ Default = HURLEY_ADD |br|
694695

695696
**--log-classes** |br|
696697
Logging classes to be enabled (vector). |br|
698+
See :doc:`Vector program options <./program-options-vector-options>` for option format. |br|
697699
Default = `All debug classes enabled (e.g. no filtering)`
698700

699701
**--logfile-common-envelopes** |br|
@@ -992,11 +994,13 @@ Default = SSE
992994

993995
**--notes** |br|
994996
Annotation strings (vector). |br|
995-
Default = ""
997+
See :doc:`Vector program options <./program-options-vector-options>` for option format. |br|
998+
Default = "" for each annotation
996999

9971000
**--notes-hdrs** |br|
9981001
Annotations header strings (vector). |br|
999-
Default = `No annotations`
1002+
See :doc:`Vector program options <./program-options-vector-options>` for option format. |br|
1003+
Default = `No annotation headers (no annotations)`
10001004

10011005
**--number-of-systems [ -n ]** |br|
10021006
The number of systems to simulate. |br|
@@ -1334,10 +1338,29 @@ User-defined timesteps filename. (See :doc:`Timestep files <../timestep-files>`)
13341338
Default = ’’ (None)
13351339

13361340
**--timestep-multiplier** |br|
1337-
Multiplicative factor for timestep duration. This multiplier is applied after the timesteps are chosen using other program options
1338-
such as ``--radial-change-fraction`` and ``--mass-change-fraction``, and will therefore override expected behaviour. This option is
1339-
primarily intended for debugging/testing of convergence issues rather than for production runs. |br|
1340-
Default = 1.0
1341+
Multiplicative factor for timestep duration. |br|
1342+
|br|
1343+
This multiplier is applied after the timesteps are chosen using other program options such as ``--radial-change-fraction``
1344+
and ``--mass-change-fraction``, and will therefore override expected behaviour. |br|
1345+
This option can be used in conjunction with ``--timestep-multipliers``, in which case this multiplier, and the appropriate
1346+
phase-dependent multiplier (specified by ``--timestep-multipliers``) are both applied. |br|
1347+
Default = 1.0 |br| |br|
1348+
This option is primarily intended for debugging/testing of convergence issues rather than for production runs. |br|
1349+
1350+
**--timestep-multipliers** |br|
1351+
Phase-dependent multiplicative factors for timestep duration. |br|
1352+
See :doc:`Vector program options <./program-options-vector-options>` for option format. |br|
1353+
A multicative factor can be specified for each phase (stellar type), where the ordinal value (zero-based) of the option value
1354+
indicates the stellar type (from ``MS_LTE_07`` to ``CHEMICALLY_HOMOGENEOUS``, see stellar type list at
1355+
:doc:`../../Developer guide/Headers/typedefs-dot-h`>). |br|
1356+
|br|
1357+
This multiplier is applied after the timesteps are chosen using other program options such as ``--radial-change-fraction`` and
1358+
``--mass-change-fraction``, and will therefore override expected behaviour. |br|
1359+
This option can be used in conjunction with ``--timestep-multiplier``, in which case that multiplier, and the appropriate
1360+
phase-dependent multiplier (specified by ``--timestep-multipliers``) are both applied. |br|
1361+
Default = 1.0 for each phase (stellar type) |br| |br|
1362+
This option is primarily intended for debugging/testing of convergence issues rather than for production runs. |br|
1363+
13411364

13421365
.. _options-props-U:
13431366

online-docs/pages/User guide/Program options/program-options-vector-options.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Currently, the only vector program options are:
1212
- --log-classes
1313
- --notes-hdrs
1414
- --notes
15+
- --timestep-multipliers
1516

1617

1718
The notation for vector program options provides for the specification of one or more values. e.g.::
@@ -26,8 +27,8 @@ for program options (to the command-line value, then to the COMPAS default) - le
2627
`log-class` had been left blank), and specifying an empty string ("") for a value would be ambiguous (as to whether the user wanted the
2728
option value to default, or just be an empty string).
2829

29-
Non-numeric option values (in general, but also specifically for vector options) may not begin with the dash character ('-'), because the
30-
shell parser will parse them as option names before passing them through to COMPAS.
30+
Option values beyond the first value may not begin with the dash character ('-'), because the shell parser will parse them as option names
31+
before passing them through to COMPAS (this is a Boost limitation).
3132

3233
COMPAS imposes no limit to the length (number of characters) of an individual option values that are specified as strings, but there may
3334
be practical limits imposed by the underlying system.

online-docs/pages/User guide/Running COMPAS/running-grid.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Both option ``--grid-start-line`` and ``--grid-lines-to-process`` are ignored if
5151
Example
5252
~~~~~~~
5353

54-
We will submit a set of COMPAS runs using a grid-file ``grid_demo.txt''
54+
We will submit a set of COMPAS runs using a grid-file ``grid_demo.txt``
5555
.. code-block::
5656
5757
COMPAS --grid grid_demo.txt

online-docs/pages/User guide/docker.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Bonus Info
140140
----------
141141

142142
Dockerfile
143-
^^^^^^^^^^
143+
~~~~~~~~~~
144144

145145
The `Dockerfile <https://docs.docker.com/engine/reference/builder/>`__ defines how the docker image is constructed.
146146

@@ -159,7 +159,7 @@ The Dockerfile for COMPAS consists of 8 layers:
159159
Dockerfiles usually end with a `CMD` directive specifying the command to run when the container starts. COMPAS does not have a `CMD` directive because some users will run the executable directly, while others will use `runSubmit.py`.
160160

161161
Makefile.docker
162-
^^^^^^^^^^^^^^^
162+
~~~~~~~~~~~~~~~
163163

164164
A separate makefile is required for Docker to:
165165
1. Separate compiled files from source files.

online-docs/pages/whats-new.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ What's new
33

44
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``.
55

6+
**03.18.00 Apr 13, 2025**
7+
8+
New command line option:
9+
10+
* ``--timestep-multipliers`` to enable more granular, phase-dependent, timestep multipliers
11+
612
**03.17.00 Mar 22, 2025**
713

8-
* Added ENVELOPE_STATE_PRESCRIPTION::CONVECTIVE_MASS_FRACTION (default threshold of convective envelope by mass to label envelope
9-
convective is 0.1, can be set with --convective-envelope-mass-threshold)
14+
* Added ENVELOPE_STATE_PRESCRIPTION::CONVECTIVE_MASS_FRACTION (default threshold of convective envelope by mass to label envelope convective is 0.1, can be set with --convective-envelope-mass-threshold)
1015
* Stable mass transfer now conserves angular momentum after accounting for the rotational angular momentum lost or gained by the stars
1116
* Imposed Keplerian rotation limit on mass-gaining stars:
1217
* Response depends on the new --response-to-spin-up option

src/BaseBinaryStar.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,12 +2953,14 @@ void BaseBinaryStar::EmitGravitationalWave(const double p_Dt) {
29532953
*
29542954
* double ChooseTimestep(const double p_Multiplier)
29552955
*
2956-
* @param [IN] p_Multiplier timestep multiplier
2956+
* @param [IN] p_Factor factor applied to timestep (in addition to multipliers)
29572957
* @return new timestep in Myr
29582958
*/
2959-
double BaseBinaryStar::ChooseTimestep(const double p_Multiplier) {
2959+
double BaseBinaryStar::ChooseTimestep(const double p_Factor) {
29602960

2961-
double dt = std::min(m_Star1->CalculateTimestep(), m_Star2->CalculateTimestep()); // dt = smaller of timesteps required by individual stars
2961+
double dt1 = m_Star1->CalculateTimestep();
2962+
double dt2 = m_Star2->CalculateTimestep();
2963+
double dt = std::min(dt1, dt2); // dt = smaller of timesteps required by individual stars
29622964

29632965
if (!IsUnbound()) { // check that binary is bound
29642966

@@ -3007,7 +3009,8 @@ double BaseBinaryStar::ChooseTimestep(const double p_Multiplier) {
30073009
}
30083010
}
30093011

3010-
dt *= p_Multiplier;
3012+
// apply timestep multipliers
3013+
dt *= OPTIONS->TimestepMultiplier() * (dt1 < dt2 ? OPTIONS->TimestepMultipliers(static_cast<int>(m_Star1->StellarType())) : OPTIONS->TimestepMultipliers(static_cast<int>(m_Star2->StellarType()))) * p_Factor;
30113014

30123015
return std::max(std::round(dt / TIMESTEP_QUANTUM) * TIMESTEP_QUANTUM, TIDES_MINIMUM_FRACTIONAL_NUCLEAR_TIME * NUCLEAR_MINIMUM_TIMESTEP); // quantised and not less than minimum
30133016
}
@@ -3240,7 +3243,7 @@ EVOLUTION_STATUS BaseBinaryStar::Evolve() {
32403243
}
32413244

32423245
// we want the first timestep to be small - calculate timestep and divide by 1000.0
3243-
dt = ChooseTimestep(OPTIONS->TimestepMultiplier() / 1000.0); // calculate timestep - make first step small
3246+
dt = ChooseTimestep(0.001); // calculate timestep - make first step small
32443247
}
32453248

32463249
unsigned long int stepNum = 1;
@@ -3370,7 +3373,7 @@ EVOLUTION_STATUS BaseBinaryStar::Evolve() {
33703373
dt = timesteps[stepNum];
33713374
}
33723375
else { // no - not using user-provided timesteps
3373-
dt = ChooseTimestep(OPTIONS->TimestepMultiplier());
3376+
dt = ChooseTimestep();
33743377
}
33753378

33763379
stepNum++; // increment stepNum

src/BaseBinaryStar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ class BaseBinaryStar {
418418
void CalculateGravitationalRadiation();
419419
void EmitGravitationalWave(const double p_Dt);
420420

421-
double ChooseTimestep(const double p_Multiplier);
421+
double ChooseTimestep(const double p_Factor = 1.0);
422422

423423
void CalculateEnergyAndAngularMomentum();
424424

src/Options.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ class Options {
274274
~ShorthandDefault_t() {}
275275
};
276276

277-
278277
typedef std::tuple<std::string, bool, TYPENAME, ShorthandDefault_t> SHORTHAND_ENTRY; // option name, default allowed (i.e. can be omitted), default string
279278

280279
std::vector<SHORTHAND_ENTRY> m_ShorthandAllowed = {

src/Star.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ EVOLUTION_STATUS Star::Evolve(const long int p_Id) {
449449
dt = timesteps[stepNum];
450450
}
451451
else { // not using user-provided timesteps
452-
dt = m_Star->CalculateTimestep() * OPTIONS->TimestepMultiplier(); // calculate new timestep
452+
dt = m_Star->CalculateTimestep() * OPTIONS->TimestepMultiplier() * OPTIONS->TimestepMultipliers(static_cast<int>(m_Star->StellarType())); // calculate new timestep
453453
dt = std::round(dt / TIMESTEP_QUANTUM) * TIMESTEP_QUANTUM; // quantised
454454
}
455455
stepNum++; // increment step number

src/changelog.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,9 +1526,10 @@
15261526
// 03.17.02 JR - Apr 11, 2025 - Defect Repair:
15271527
// - Remove extraneous debug print statement in MainSequence.h (inavertently added by me in v03.17.00)
15281528
// - fix description of return value for BaseStar::CalculateOmegaCHE()
1529-
// 03.17.03 JR - Apr 12, 2025 - Enhancement:
1530-
// - Add option "--timestep-multipliers" to enable more granular, phase-dependent, timestep multipliers
1529+
// 03.18.00 JR - Apr 13, 2025 - Enhancement:
1530+
// - Add option "--timestep-multipliers" to enable more granular, phase-dependent, timestep multipliers (see documentation for use)
1531+
// - Added maximum allowed value for options `--timestep-multiplier` and `--timestep-multipliers`
15311532

1532-
const std::string VERSION_STRING = "03.17.03";
1533+
const std::string VERSION_STRING = "03.18.00";
15331534

15341535
# endif // __changelog_h__

0 commit comments

Comments
 (0)