PrincetonUniversity / athena-public-version

(MOVED) Athena++ GRMHD code and adaptive mesh refinement (AMR) framework. Active repository --->
https://github.com/PrincetonUniversity/athena
BSD 3-Clause "New" or "Revised" License
162 stars 118 forks source link

Energy conservation #15

Closed Yotag closed 6 years ago

Yotag commented 6 years ago

Hello, What level of energy conservation can I expect from Athena's simulation? Are there conservation tests available to show Athena's consistency in this matter? I am working on a simulation with a gravitational source term added to the problem generator. Should I expect a change to the accuracy of the conservation? If so, at what levels? Are there any ways to improve it? Regards, Yotam.

felker commented 6 years ago

Since Athena++ is built on a Godunov-type method, the core hydro and MHD solvers should conserve energy to machine precision.

I'll let @changgoo remark on the effect of gravitational source terms.

changgoo commented 6 years ago

To make gravity source terms conservative, one needs special care (e.g., http://adsabs.harvard.edu/abs/2013NewA...19...48J). This is not implemented in the current Athena.

Any source terms that are added as an operator-split fashion will hurt energy conservation. I believe @pdmullen had an experience of testing gravity source terms.

pdmullen commented 6 years ago

Hey @Yotag,

Thanks for the question! My experience with gravity in Athena++ is with the included FFT self-gravity solver. As @changgoo mentioned, updates to energy from self-gravity are handled through source terms, not by constructing fluxes, and therefore total energy (when self-gravity is enabled) is not expected to be conserved to machine precision.

If you are not using the FFT self-gravity solver, but are rather implementing your own source terms, I would recommend looking at self_gravity.cpp for reference.

I have done some test problems for the FFT self-gravity solver. One such test problem involves advecting a 1-D self-gravitating sheet once across a periodic domain.

compare.pdf

This problem involves adiabatic hydro with self-gravity and thus employs the self-gravity energy source terms. The L_1 error for this problem converges at second order for both the vl2 and rk2 integrators.

conv.pdf

If interested, below is the time evolution of the total energy in these 1-D self-gravitating disk simulations at different resolutions. Recall that for self-gravitating systems the total energy (without B-fields) is given as

etot.pdf

Best, Patrick