PrincetonUniversity / athena

Athena++ radiation GRMHD code and adaptive mesh refinement (AMR) framework
https://www.athena-astro.app
BSD 3-Clause "New" or "Revised" License
226 stars 122 forks source link

Passive scalar dependent EOS #444

Closed msbc closed 2 years ago

msbc commented 2 years ago

Add support for equations of state that depend on passive scalars. Closes #359

Prerequisite checklist

Please review the CONTRIBUTING.md file for detailed guidelines.

Description

To enable support for equations of state that depend on passive scalars, the passive scalars must be passed to (nearly) all EOS calls. The main difficulty here is that EOS calls are made inside the Riemann solver. This requires that the face centered values of the scalar primitive values must also be passed to the Riemann solver. Which, in turn, requires that the scalars be interpolated to the face centers at the same time as the hydro variables. Thus PasiveScalars::CalculateFluxes was essentially merged into Hydro::CalculateFluxes (I have left PasiveScalars::CalculateFluxes in the code even-though it is unused). Otherwise I've done my best to keep the scalars as separated from hydro as I can. Although, I think we should combine the hydro and scalar ConservedToPrimitive and PrimitiveToConserved functions as they are always called together (outside of pgens and if NSCALARS>0). If your EOS needs to do an inversion (e.g. find Temperature) it would be useful to store this in the passive scalars to estimate the solution for the next EOS inversion.

Currently 4th-order is not properly supported for an EOS which depends on passive scalars. In EquationOfState::ConservedToPrimitiveCellAverage there is one call to ConservedToPrimitive that uses the 4th-order cell-centered values, but I am currently only passing it the cell-averaged scalars. The only way I see of fixing that is to merge PasiveScalarPrimitiveCellAverage into ConservedToPrimitiveCellAverage so that the 4th-order cell-centered scalars are accessible at this stage. However, I didn't want to make this change without approval from @felker.

You may want to categorize major vs. minor changes and list them:

  1. Change nearly all EOS function and Riemann solver signatures to include passive scalars, enabling scalar dependent EOS.
  2. Merged PasiveScalars::CalculateFluxes into Hydro::CalculateFluxes
  3. The Riemann solvers are now responsible for computing the scalar fluxes
  4. Removed CalculateScalarFlux from task list as it is now part of hydro fluxes (dependancies updated)

Testing and validation

All current tests past using --cxx=clang++-apple on my MacBook Pro (with Apple Arm64 CPU).

...

To-do

felker commented 2 years ago

Is this still actively developed? Or should we close @msbc?

msbc commented 2 years ago

I recently picked this back up, but let's mark it as closed for now.