danieljprice / phantom

Phantom Smoothed Particle Hydrodynamics and Magnetohydrodynamics code
https://phantomsph.github.io
Other
103 stars 223 forks source link

account for accreted/injected energy in conservation checks / .ev file #457

Open danieljprice opened 1 year ago

danieljprice commented 1 year ago

At present the code-stopping energy conservation checks (I_WILL_NOT_PUBLISH_CRAP) are switched off if particles are accreted or there is heating/cooling [energy injection/removal] in the simulation.

Would be better if this could be properly accounted for, so that the "true" energy error can still be estimated even in these cases. However, would also be helpful to have total energy that reflects any heating/cooling. Suggestion would be to:

  1. account for accreted particles (particles deleted with negative energy) by adding to Eacc (as a global parameter)
  2. account for injected energy, e.g. sink particle heating, with new Einject (e.g. set equal to luminosity*time for constant sink particle luminosity)
  3. account for heating/cooling, possibly also in Einject?
  4. add new total energy variable (etot_all) that indicates the total energy including all injected/removed energy, similar to angtot_all and momtot_all variables that include accreted components

A possible further extension would be to also compute etot_all for isothermal (and maybe also locally isothermal??) simulations to reflect the conserved integral quantity (which is not the total energy in this case but there is still a conserved quantity)