GRMHD in dynamical spacetimes
Major changes
This long-delayed merge request adds a new module for GRMHD in dynamical spacetimes. The number of changes are quite extensive, but they are mostly independent of functionality elsewhere in the code. Here is a brief summary of the most important changes:
- The
dyngrfolder contains code forDynGR, the new GRMHD solver based on the Valencia formulation so that it is suitable for dynamical spacetimes. The solver tries to piggyback off of the existing MHD routines where possible, but it implements its own Riemann solvers and source terms, and the EOS-agnostic implementation introduces some subtle complications that make it incompatible with the MHD flux and FOFC methods. - The
CornerEfunction now contains extra branches to handle the Valencia solver. - The
tmunufolder contains code for the newTmunuobject for storing the stress-energy tensor in its 3+1 decomposed form (E, S_i, S_{ij}) for use in the Z4c RHS. This is slightly different from GR-Athena++, which stores an objectmatinsideZ4c. - The
numerical-relativityfolder is for theNumericalRelativityobject, which acts as a task orchestrator forDynGRandZ4c. Rather than creating their ownTaskListobjects directly,DynGRandZ4cboth submit tasks toTaskQueueobjects inNumericalRelativity, each of which has a set of required dependencies and a set of optional dependencies which are conditionally enabled depending on the other physics modules in the code (e.g.,Z4c_CalcRHShas a required dependency onZ4c_CopyUand an optional dependency onMHD_SetTmunuwhich is only enabled if MHD is also active).NumericalRelativitythen loops over eachTaskQueueand attempts to build aTaskListfrom it which satisfies all the correct dependencies. This infrastructure seems excessive at the moment, but it will greatly simplify things as we add additional physics. - The
eos/primitive-solverfolder includesPrimitiveSolver, a library for handling EOS calls and the conserved-to-primitive inversion forDynGR. This is necessary because the existing EOS infrastructure in AthenaK assumes a gamma-law equation of state, and we need support for generic equations of state. Right now there is robust support for an ideal gas, but a hybrid piecewise-polytropic EOS has been lightly tested, and there is preliminary support for a tabulated finite-temperature EOS. - Several problem generators have been modified to support
DynGR. Most of this work involves assigning pressure as a primitive variable instead of internal energy density (the former tends to be better behaved for reconstruction when using tabulated equations of state) and instantiating the ADM metric, but a few also have new features for testingDynGR. - Several new problem generators have been added, such as
dyngr_tov,lorene_bns,elliptica_tov, etc. - The
Coordinatesclass has been modified to support updating the excision mask dynamically during runtime according to a user-specified excision scheme in the parameter file viacoords/excision_scheme. The default scheme,fixed, maintains the original behavior of the code, so existing tests requiring excision should not be affected by this change. The other currently implemented scheme,lapse, is an ad-hoc scheme that applies excision everywhere the lapse falls below a specified cutoff value. - The
utilsfolder now includes code for a new class,TableReader, which is currently used by the tabulated EOS implementation. However, the structure of the tables (ASCII header + binary data) is generic enough that there's no reason it can't be used elsewhere, too.
Unfinished tasks
There are a number of tasks still left to do. However, the code has introduced enough new features that I figured it would be better to merge back sooner rather than later. Here's what is still left:
- There are no automated CI tests for
DynGR. At the bare minimum we need a test that probes the GRMHD alone and a test that probes the GRMHD+Z4c, but it would also be useful to have tests for the tabulated EOS. -
DynGRuses pressure as a primitive variable, but it is still labeledeintin output files. There needs to be logic to handle this properly. Perhaps it can be done when the output infrastructure is refactored into something more maintainable. - The code currently passes the CI pipeline, but a handful of pgens (
blast,kh,gr_torus, etc.) not included in the built-in tests need to be validated more rigorously to ensure that changes forDynGRdidn't cause any unexpected side effects in other cases. - It may be worth separating out the TOV solver into
utils. There are a variety of TOV pgens floating around, both within and without the repository, and there's a lot of unnecessary code duplication going on.
Validation
Here are a few tests showing that the code works as expected:
- MHD shock tubes (Balsara 1 and 4)
- Power spectrum of TOV in Cowling approximation with linear perturbation (vertical lines show predicted oscillation frequencies from perturbation theory)
- Power spectrum of TOV in full GR (vertical lines show predicted oscillation frequencies from perturbation theory)
- Unmagnetized binary neutron star merger
The BNS test achieves approximate second-order convergence of the waveform phase during the inspiral as expected. The merger time differs from GR-Athena++ by \Delta t \approx 0.05~\mathrm{ms}. The results do diverge somewhat in the post-merger phase, particularly in predicted collapse time, but this a combination of insufficient resolution and the extreme sensitivity of collapse to initial conditions.




