MESAHub / mesa

Modules for Experiments in Stellar Astrophysics
http://mesastar.org
GNU Lesser General Public License v2.1
138 stars 38 forks source link

Offset energies in Skye + HELM to match FreeEOS. #258

Closed adamjermyn closed 3 years ago

adamjermyn commented 3 years ago

It looks like there is an offset in the fully-ionized regime in e between Skye/HELM and FreeEOS. This offset is a constant and equals the total ionization energy across all species (weighted by abundance).

I've written to Alan Irwin asking how we can get this quantity out of FreeEOS for arbitrary composition. Assuming we can, the goal will be to add a composition-dependent offset to both Skye and HELM to make them match FreeEOS here.

@jschwab points out that we need to do it in this direction (rather than offsetting FreeEOS) because FreeEOS's current convention (that the neutral ground state energy is zero) guarantees that the energy will be positive, whereas if we make the neutral ground state energy negative then FreeEOS could return negative energies.

Fixing this should remove lots of blend artefacts between these EOS's. It seems unlikely that this affects the evolution beyond helping MESA run, though, because the total energy that gets lost to the blend is "only" ~2e13erg/g, which is large in an absolute sense in that location but small compared with the integrated luminosity in the time it takes to cross the blend.

Once we do this we should be able to push the blend between Skye and FreeEOS back down to ~1d5K * Zbar^2, because that's safely in fully-ionized territory. The main motivation for pushing Skye down to lower temperatures is that it lets us use the real composition vector (rather than pre-tabulated ones) over a wider range of parameter space.

adamjermyn commented 3 years ago

Alan replied and pointed me to the git version of FreeEOS, which is vastly easier to read: https://sourceforge.net/p/freeeos/freeeos/ci/master/tree/src/

If you check out this file: https://sourceforge.net/p/freeeos/freeeos/ci/master/tree/src/mod_ionization_data.f90 you'll see it's basically a commented version of the ionization data file that ships in version 2.2.1, and the comments really clarify things!

My read here is that the energy offset we need to use is given by his table (monatomic_ip) multiplied by h*clight. Note that these are cumulative, so to get the He offset you sum the two He entries, to get the C offset you sum the six C entries, and so on.

In a mixture the energy per ion is given by

Sum_j e_j y_n

where y_j is the number fraction of species j. To turn this into a specific energy we need to divide by the mean mass per ion, or

e = Sum_j e_j y_n / (abar * mp)

I can make a function which does this. In Skye and HELM we then need to add this offset to the energy right after we calculate it (before we calculate any derived quantities). In practice though I think we'll end up wanting to compute the offset at the start of each just to keep things simple.

Does that all sound right?

fxt44 commented 3 years ago

if e is changed, will s then be recalculated from the first law to retain thermodynamic consistency?

adamjermyn commented 3 years ago

I don't think we need to. e is changed by a constant amount for a given composition, so none of the consistency measures should be affected...

fxt44 commented 3 years ago

for derivative based checks like dpe and friends i agree, but changing e without changing s seems not quite right.

adamjermyn commented 3 years ago

e has an arbitrary zero point. You can change it to anything you like as long as it's independent of rho and T and maintain consistency (amounts to offsetting F by a constant).

There's similarly an offset choice to make with S (amounts to adding a function of the form r*T to the free energy) but I'm hoping that FreeEOS and Skye/HELM made the same choice there because that seems much harder to track down than an energy offset...

adamjermyn commented 3 years ago

My attempt to fix this is in 0457120 (introduced one commit earlier but this is the one that compiles).

I'm still waiting back to hear from Alan on some special case handling I noticed in FreeEOS for specific elements, but preliminary testing with the EOS plotter suggests that this resolves the discrepancy.

evbauer commented 3 years ago

Doesn't this actually change the physics coming out of Skye? It looks like there's a non-zero contribution to ∂e/∂{X_i} here, so the chemical potentials reported by Skye will change, and that term could enter into the energy equation.

It may actually be correct input physics, but we should probably be careful about what this means for the physics of Skye since it isn't truly one constant offset.

adamjermyn commented 3 years ago

What chemical potentials do you mean?

-Adam

On Mon, May 24, 2021 at 12:48 PM, Evan Bauer @.***> wrote:

Doesn't this actually change the physics coming out of Skye? It looks like there's a non-zero contribution to ∂e/∂{X_i} here, so the chemical potentials reported by Skye will change, and that term could enter into the energy equation.

It may actually be correct input physics, but we should probably be careful about what this means for the physics of Skye since it isn't truly one constant offset.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/MESAHub/mesa/issues/258#issuecomment-847188026, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPR5H2E7AGOL7L7JM2A57TTPJ7OBANCNFSM45JORPEQ .

evbauer commented 3 years ago

I mean that

Sum_j e_j y_j

has non-zero composition partials, which would modify what goes into the energy equation when composition is changing, right?

adamjermyn commented 3 years ago

Ah yes that's right. This does change those terms.

I think this only comes up in two places: mixing and burning.

I don't understand how we currently handle mixing & energy conservation so someone else probably knows better there.

For burning (and someone should correct me if I'm wrong) I think it comes down to how you define the energy change when burning happens: is the energy release defined relative to the ground state of the neutral atoms, or relative to the fully ionized state? Whichever it is you want to use a consistent zero point for the EOS (though my guess is that the changes in burning are so large that the uncertainties on those exceed the offsets we're talking about here).

Regardless this brings the convention in Skye into agreement with FreeEOS, so if we want to ask "What should the convention be in MESA?" that's maybe a topic for a separate issue (please open that issue if you think this is important!).

fxt44 commented 3 years ago

ground state of neutral hydrogen at rest. nuclear has specific energies ~1e6 times more than chemical; MeV scales vs eV scales - the electronic binding energy terms are thus sometimes dropped in a mass models for nuclei. for complete burns of fuel to ash, handy numbers are h-burn ~5e18 erg/g, he-burn ~1e18erg/g, c-burn ~4e17 erg/g, ne-burn ~1e17 erg/g, o-burn ~5e17 erg/g, and si burn ~2e17 erg/g.

adamjermyn commented 3 years ago

Ok, then I think this fix brings our EOS energy definition in line with the burning definition. I'll deploy to HELM soon too...

adamjermyn commented 3 years ago

Hmmm scratch that. At the moment there are no blends into HELM where this matters, and introducing this term would require that HELM know about the full composition vector. I'm happy to do it if/when it becomes relevant, but for now I'm closing this issue.

Feel free to reopen if you think this isn't addressed sufficiently in the Skye_on_PC_off branch. If that branch is never merged in I'll cherrypick the relevant commits into main.