quokka-astro / quokka

Two-moment AMR radiation hydrodynamics (with self-gravity, particles, and chemistry) on CPUs/GPUs for astrophysics
https://quokka-astro.github.io/quokka/
MIT License
46 stars 12 forks source link

Add support for a general EOS #278

Closed BenWibking closed 1 year ago

BenWibking commented 1 year ago

This requires the ability to compute:

From these, we can derive:

[1] Glaister, P. Journal of Computational Physics, Volume 74, Issue 2, p. 382-408. https://ui.adsabs.harvard.edu/abs/1988JCoPh..74..382G/abstract

[3] Kershaw et al., Computer Methods in Applied Mechanics and Engineering, Volume 158, Issues 1–2, 1998, p. 81-116. https://doi.org/10.1016/S0045-7825(97)00228-4

BenWibking commented 1 year ago

The fundamental derivative $\mathcal{G}$ is also useful for constructing a nonlinear wavespeed estimate [2], since it is proportional to $(\partial^2 P / \partial \rho^2)_s$.

[2] https://doi.org/10.1016/S0045-7930(98)00033-4

psharda commented 1 year ago

Continuing from #271 , we can now include gamma_law EOS from Microphysics. So, now we have to see if gamma_law can compute all the things you list above. I don't know what was the conclusion of your conversation with Mike on this? Are you or Mike going to modify gamma_law EOS to compute everything listed above?

BenWibking commented 1 year ago

Well, I'm not sure what the conclusion was either... 😆

It looks like the gamma_law EOS (https://github.com/AMReX-Astro/Microphysics/blob/main/EOS/gamma_law/actual_eos.H) computes all the derivatives that are needed, yes.

It might be necessary to check that the behavior is consistent for other EOSes. For instance, Mike said that state.cs is not set to $(\partial P / \partial \rho)_s$ for the helmholtz equation of state. So it might require some careful checking to make sure that everything is defined as expected in all cases, in case someone decides to use a stellar matter EOS in Quokka for some reason :)

psharda commented 1 year ago

Well, we have only built support for gamma_law and primordial_chem EOS in our new function setup_target_for_microphysics_compilation. If the user gives any other EOS, CMake will throw an error.

Okay, since gamma_law has everything you need already, we can now modify EOS.hpp to just use Microphysics. Do we need the EOS_Traits struct?

psharda commented 1 year ago

Also, looks like we will need to insert preCalculateInitialConditions() function in all Quokka tests, to initialize microphysics routines (just like we do for primordial chem):

template <> void RadhydroSimulation<ShocktubeProblem>::preCalculateInitialConditions()
{
    // initialize microphysics routines
    init_extern_parameters();
    eos_init();
    network_init();
}

I wonder if there is a better way to do this. Can you initialize them in EOS.hpp directly instead of in test.cpp?

BenWibking commented 1 year ago

Okay, since gamma_law has everything you need already, we can now modify EOS.hpp to just use Microphysics. Do we need the EOS_Traits struct?

No, we can get rid of that.

BenWibking commented 1 year ago

Also, looks like we will need to insert preCalculateInitialConditions() function in all Quokka tests, to initialize microphysics routines (just like we do for primordial chem):

template <> void RadhydroSimulation<ShocktubeProblem>::preCalculateInitialConditions()
{
  // initialize microphysics routines
  init_extern_parameters();
  eos_init();
  network_init();
}

I wonder if there is a better way to do this. Can you initialize them in EOS.hpp directly instead of in test.cpp?

Yeah, we should initialize this in RadhydroSimulation.hpp before the simulation starts.

psharda commented 1 year ago

Okay, since gamma_law has everything you need already, we can now modify EOS.hpp to just use Microphysics. Do we need the EOS_Traits struct?

No, we can get rid of that.

I did that, but ran into a bunch of errors from hydro_system.hpp radiation_system.hpp Cloudy_Cooling.hpp that use EOS_Traits. I had to modify a bunch of stuff to get rid of the errors. I will push my changes soon so you can check.

psharda commented 1 year ago

Resolved by #338