Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve internal consistency for reporting (previously: Implement separating major events into separate timesteps) #805

Open
reinhold-willcox opened this issue May 17, 2022 · 7 comments
Assignees
Labels

Comments

@reinhold-willcox
Copy link
Collaborator

As discussed on the compas dev call

@reinhold-willcox reinhold-willcox self-assigned this May 17, 2022
@reinhold-willcox reinhold-willcox linked a pull request May 31, 2022 that will close this issue
@reinhold-willcox
Copy link
Collaborator Author

reinhold-willcox commented Sep 14, 2022

For future use, here is a grid of systems which all undergo MT leading to a successful CEE (non-merger). But then the donor collapses into a SN and the newborn NS collides with the companion resulting in a merger (collision is determined based on the periapsis of the new, possibly hyperbolic, orbit, so about half of these would actually point away from the companion and survive).

All of this happens in one timestep though. The output is fairly confusing, so I've posted what shows up in BSE_RLOF, BSE_Common_Envelopes, and BSE_Supernovae, with some unrelated parameters cut out for brevity.

The gridfile: grid.txt

BSE_RLOF (masked for events which merge)

SEED (units) 44474 80929 94843 16135 17536 26338 32515 39649
CEE>MT Bool 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
Eccentricity<MT - 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
Eccentricity>MT - 1.981982 0.281605 1.530101 1.758171 1.000767 5.144050 3.503769 7.420938
Mass(1)<MT Msol 10.239182 10.644315 10.286461 10.326131 10.987537 10.819973 10.430397 10.414658
Mass(1)>MT Msol 1.277584 1.277584 1.277584 1.277584 1.277584 1.277584 1.277584 1.277584
Mass(2)<MT Msol 5.280300 2.033313 5.289948 1.413487 1.311947 1.477853 2.486255 1.480854
Mass(2)>MT Msol 5.280300 2.033313 5.289948 1.413487 1.311947 1.477853 2.486255 1.480854
Merger Bool 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
RLOF(1)<MT Bool 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
RLOF(1)>MT Bool 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
RLOF(2)<MT Bool 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
RLOF(2)>MT Bool 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
Radius(1)<MT Rsol 669.907981 706.225709 675.910473 680.453567 764.315423 771.739234 692.999918 775.562222
Radius(1)>MT Rsol 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014 0.000014
Radius(1) RL<step - 1.003207 1.015312 1.007227 1.012826 1.012735 1.010711 1.002218
Radius(1) RL>step - 0.000000 0.000013 0.000000 0.000000 0.000000 0.000000 0.000000
Radius(2)<MT Rsol 2.965933 1.563716 2.966997 1.361929 1.278516 1.395491 1.737141 1.397040
Radius(2)>MT Rsol 2.965933 1.563716 2.966997 1.361929 1.278516 1.395491 1.737141 1.397040
Radius(2) RL<step - 0.006007 0.004745 0.005988 0.004951 0.004389 0.004468 0.004808
Radius(2) RL>step - 0.000000 1.177116 0.000000 0.000000 0.000000 0.000000 0.000000
SemiMajorAxis<MT Rsol 1527.187312 1325.682849 1533.851662 1215.425633 1338.239904 1380.913332 1367.731701 1407.761305
SemiMajorAxis>MT Rsol -5.288151 4.405930 -11.811895 -2.468831 -4154.059400 -0.882627 -1.492419 -0.613796
Stellar_Type(1)<MT - 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000 5.000000
Stellar_Type(1)>MT - 13.000000 13.000000 13.000000 13.000000 13.000000 13.000000 13.000000 13.000000
Stellar_Type(2)<MT - 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
Stellar_Type(2)>MT - 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
Time<MT Myr 23.809058 22.203436 23.607148 23.451052 20.925556 21.487003 23.030500 22.973963

BSE_Common_Envelopes

SEED (units) 44474 80929 94843 16135 17536 26338 32515 39649
Eccentricity<CE - 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
Eccentricity>CE - 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
Immediate_RLOF>CE Bool 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
Mass(1)<CE Msol 1.023918e+01 1.064431e+01 1.028646e+01 1.032613e+01 1.098754e+01 1.081997e+01 1.043040e+01 1.041466e+01
Mass(1)>CE Msol 1.277584e+00 1.277584e+00 1.277584e+00 1.277584e+00 1.277584e+00 1.277584e+00 1.277584e+00 1.277584e+00
Mass(2)<CE Msol 5.280300e+00 2.033313e+00 5.289948e+00 1.413487e+00 1.311947e+00 1.477853e+00 2.486255e+00 1.480854e+00
Mass(2)>CE Msol 5.280300e+00 2.033313e+00 5.289948e+00 1.413487e+00 1.311947e+00 1.477853e+00 2.486255e+00 1.480854e+00
Mass_Env(1) Msol 6.957756e+00 7.183770e+00 6.983423e+00 7.006420e+00 7.363432e+00 7.269657e+00 7.064993e+00 7.042050e+00
Mass_Env(2) Msol 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
Merger Bool 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
RLOF(1) Bool 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
RLOF(2) Bool 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
Radius(1)<CE Rsol 6.699080e+02 7.062257e+02 6.759105e+02 6.804536e+02 7.643154e+02 7.717392e+02 6.929999e+02 7.755622e+02
Radius(1)>CE Rsol 1.437401e-05 1.437401e-05 1.437401e-05 1.437401e-05 1.437401e-05 1.437401e-05 1.437401e-05 1.437401e-05
Radius(2)<CE Rsol 2.965933e+00 1.563716e+00 2.966997e+00 1.361929e+00 1.278516e+00 1.395491e+00 1.737141e+00 1.397040e+00
Radius(2)>CE Rsol 2.965933e+00 1.563716e+00 2.966997e+00 1.361929e+00 1.278516e+00 1.395491e+00 1.737141e+00 1.397040e+00
RocheLobe(1)<CE Rsol 6.677667e+02 6.955750e+02 6.710604e+02 6.718367e+02 7.547042e+02 7.635608e+02 6.914660e+02 7.737174e+02
RocheLobe(1)>CE Rsol 1.769406e+00 1.589537e+00 2.129777e+00 8.547538e-01 1.498572e+00 1.738579e+00 1.635813e+00 1.807852e+00
RocheLobe(2)<CE Rsol 4.937196e+02 3.295203e+02 4.955286e+02 2.750910e+02 2.912745e+02 3.123519e+02 3.613013e+02 3.220866e+02
RocheLobe(2)>CE Rsol 2.198493e+00 1.247065e+00 2.640550e+00 5.794074e-01 9.440739e-01 1.166524e+00 1.424553e+00 1.242651e+00
SemiMajorAxis<CE Rsol 1.527187e+03 1.325683e+03 1.533852e+03 1.215426e+03 1.338240e+03 1.380913e+03 1.367732e+03 1.407761e+03
SemiMajorAxis>CE Rsol 5.226110e+00 3.734377e+00 6.283215e+00 1.881421e+00 3.196985e+00 3.809939e+00 4.035224e+00 4.003442e+00
Simultaneous_RLOF Bool 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
Stellar_Type(1) - 1.300000e+01 1.300000e+01 1.300000e+01 1.300000e+01 1.300000e+01 1.300000e+01 1.300000e+01 1.300000e+01
Stellar_Type(1)<CE - 5.000000e+00 5.000000e+00 5.000000e+00 5.000000e+00 5.000000e+00 5.000000e+00 5.000000e+00 5.000000e+00
Stellar_Type(2) - 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
Stellar_Type(2)<CE - 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
Time Myr 2.380906e+01 2.220344e+01 2.360715e+01 2.345105e+01 2.092556e+01 2.148700e+01 2.303050e+01 2.297396e+01
Zeta_Lobe - 1.423058e+00 7.793581e+00 1.433112e+00 1.188081e+01 1.400061e+01 1.191245e+01 5.755379e+00 1.134133e+01
Zeta_Star - 1.725106e-01 1.806810e-01 1.736146e-01 1.742852e-01 1.891047e-01 1.860477e-01 1.763418e-01 1.784246e-01

BSE_Supernovae

SEED (units) 44474 80929 94843 16135 17536 26338 32515 39649
Applied_Kick_Magnitude(SN) kms^-1 819.415207 148.233199 532.873829 488.730236 333.401327 494.612537 673.26652 594.943335
Eccentricity - 1.981982 0.281605 1.530101 1.758171 1.000767 5.14405 3.503769 7.420938
Eccentricity<SN - 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Experienced_RLOF(SN) Bool 1 1 1 1 1 1 1 1
MT_Donor_Hist(SN) - b'5' b'5' b'5' b'5' b'5' b'5' b'5' b'5'
Mass(CP) Msol 5.2803 2.033313 5.289948 1.413487 1.311947 1.477853 2.486255 1.480854
Mass(SN) Msol 1.277584 1.277584 1.277584 1.277584 1.277584 1.277584 1.277584 1.277584
Mass_CO_Core@CO(SN) Msol 2.189297 2.328982 2.207144 2.220937 2.47624 2.432836 2.25884 2.318729
Mass_Core@CO(SN) Msol 2.189297 2.328982 2.207144 2.220937 2.47624 2.432836 2.25884 2.318729
Mass_He_Core@CO(SN) Msol 3.281426 3.460545 3.303038 3.319711 3.624104 3.550316 3.365404 3.372608
Mass_Total@CO(SN) Msol 3.281426 3.460545 3.303038 3.319711 3.624104 3.550316 3.365404 3.372608
Orb_Velocity<SN kms^-1 558.922816 529.651314 510.671374 692.619566 542.600244 501.656423 525.855177 480.805595
SemiMajorAxis Rsol -5.288151 4.40593 -11.811895 -2.468831 -4154.0594 -0.882627 -1.492419 -0.613796
SemiMajorAxis<SN Rsol 5.22611 3.734377 6.283215 1.881421 3.196985 3.809939 4.035224 4.003442
Stellar_Type(CP) - 1 1 1 1 1 1 1 1
Stellar_Type(SN) - 13 13 13 13 13 13 13 13
Stellar_Type_Prev(SN) - 8 8 8 8 8 8 8 8
Supernova_State Bool 1 1 1 1 1 1 1 1
Time Myr 23.809058 22.203436 23.607148 23.451052 20.925556 21.487003 23.0305 22.973963
Unbound Bool 1 0 1 1 1 1 1 1

@reinhold-willcox reinhold-willcox changed the title Implement separating major events into separate timesteps Improve internal consistency for reporting (previously: Implement separating major events into separate timesteps) Oct 4, 2022
@reinhold-willcox
Copy link
Collaborator Author

Update: following discussions of this and related improvements, it is probably not possible to split apart events into different timesteps in all cases. An improved solution would be to ensure that the stellar and binary parameters are consistent any time in a timestep that we want to report before and after values (e.g pre/post MT, CE, SN, etc.). This remains a long term fix that we will aim to address in the coming months.

@ilyamandel
Copy link
Collaborator

ilyamandel commented Feb 2, 2023

@reinhold-willcox -- does this supplant and incorporate #722 , #539 and #413 -- i.e., can we close those as duplicates and just keep this one?

@reinhold-willcox
Copy link
Collaborator Author

@ilyamandel done

@jeffriley
Copy link
Collaborator

@reinhold-willcox is this still an issue? If so, can it be at least ameliorated by using the record-type field and logging records to the RLOF file (and/or other logs files) throughout the timestep? That way the information will be available to users that require it, and other users can just filter those records.

@ilyamandel
Copy link
Collaborator

ilyamandel commented May 24, 2024

I am convinced that we should only be doing one thing per timestep.

Firstly, we now end up with some weird systems that make analysing data a pain in the neck. For example, I find that among ultra-stripped SNe (SN_Type(SN) == 16), all have the pre-SN mass Mass_Total@CO(SN) equal to the pre-SN CO core mass Mass_CO_Core@CO(SN). But, remarkably, all USSNe have a pre-SN stellar type Stellar_Type_Prev(SN) of 8 -- that's a HeHG star, for which the total mass cannot be equal to the CO core mass since it must have a He envelope! That's because they all experience RLOF from the HeHG star and a SN event on the same timestep, and we update the pre-SN mass but not the pre-SN type...

Secondly, and perhaps more importantly, we really should be using values at the start of the timestep to evolve during that timestep, not intermediate values. I.e., we should evolve the star using the stellar properties at the start of the time step; we should apply tides using the binary and stellar properties at the start of the timestep; we should apply GWs using the binary properties and masses at the start of the timestep; etc. This is the only way for us to be consistent and to pick sensible timesteps.

As for extreme events (SNe, fast case A / case B / case C / CE RLOF), we should check for these at the start of the timestep. If a star is ready to go SN or is in fast case A / case B / case C / CE RLOF, we should undertake that behaviour on a zero-length timestep (*), then return to handling more gradual processes (stellar evolution, tides, GWs, etc.) from the following time step.

We'll have to think a bit further about the corner cases, such as the ordering of SNe and RLOF if both are relevant (hopefully, these will be rare if time steps are sufficiently short, and making SNe happen first in this case would not be an issue).

(*) Zero length timesteps would lead to identical timestamps, which could be problematic for determining the ordering, so perhaps a minimal timestep on which nothing else happens but the timestamp is slightly incremented would be more appropriate.

@ilyamandel
Copy link
Collaborator

Here's a concrete proposal for doing one thing per timestep. During each timestep, do the following in this order for BSE (for SSE, the order is the same, but skip steps 3, 4, and 5, and only compute/update quantities relevant for single stars in the list below).

  1. Is either star due for a supernova? If so, take a minimum size timestep, resolve supernova, do nothing else. Here and below, "minimum timestep" just means a non-zero but arbitrarily small timestep -- say, of duration ABSOLUTE_MINIMUM_TIMESTEP -- to avoid outputs with identical time stamps.

  2. Is either star due for a change in stellar type? If so, take a minimum timestep, resolve stellar type change, do nothing else.

  3. Is either star marked as Roche lobe overflowing (or is the binary marked as merging)? If so, establish the timescale of the mass transfer: dynamical (common envelope), thermal, or nuclear.
    a. If dynamical timescale (CE/merger), resolve in minimum timestep, do nothing else.
    b. If thermal timescale, resolve but record timestep duration as thermal timescale of mass loss, do nothing else.
    c. If nuclear but eccentricity is non-zero and circularising on MT is set, set eccentricity to zero over minimum timestep, do nothing else.
    d. Otherwise, compute da/dt, dm_1/dt, dm_2/dt, dr_1/dt, dr_2/dt of nuclear timescale mass transfer and the minimum associated timescales. By associated timescales with a process with rate dx/dt, here and below we mean factor * x / (dx/dt), where factor is a suitable prefactor such as 0.01 or 0.001 to be specificed by the user (we already have these either hard-coded or user defined, e.g., via --mass-change-fraction). Store the derivatives (da/dt, etc.) and this minimum associated timescale.

  4. Compute da/dt, de/dt, and minimum associated timescale due to gravitational-wave emission. Update the stored minimum associated timescale to the smaller of the currently stored value and the one computed in this step. Update the derivatives to the sum of the currently stored values and the ones computed in this step.

  5. Compute da/dt, de/dt, dL1_dt, dL_2/dt and the minimum associated timescale due to tidal interaction. Update the stored minimum associated timescale to the smaller of the currently stored value and the one computed in this step. Update the derivatives to the sum of the currently stored values and the ones computed in this step.

  6. Compute da/dt, dm_1/dt, dm_2/dt, dr_1/dt, dr_2/dt and the minimum associated timescale due to wind mass loss. Update the stored minimum associated timescale to the smaller of the currently stored value and the one computed in this step. Update the derivatives to the sum of the currently stored values and the ones computed in this step.

  7. Compute da/dt, dm_1/dt, dm_2/dt, dr_1/dt, dr_2/dt and the minimum associated timescale due to stellar evolution (including dm_1/dt and dm_2/dt because of the possibility of non-wind TPAGB mass loss, etc.). Update the stored minimum associated timescale to the smaller of the currently stored value and the one computed in this step. Update the derivatives to the sum of the currently stored values and the ones computed in this step.

  8. Take the timestep dt which is the currently stored value. Update all variables (a, e, m_1, m_2, r_1, r_2, Omega_1, Omega_2) according to x_new = x_old + dt * (dx/dt), using currently stored values of dx/dt.

  9. Do any further updates required for the stars and binary to remain in a self-consistent state at the end of the timestep.

Notes:

  • At initialisation, if binary is in contact and over-contact binaries are allowed, set both masses equal to half the total mass, set eccentricity to zero, and update separation to conserve total angular momentum.
  • If both stars are due for a supernova simultaneously, or for a stellar type change simultaneously, do just one per timestep.
  • Current timestep and the derivatives dx/dt mentioned above should be (re)set to zero at the start of each timestep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants