lanl / singularity-eos

Performance portable equations of state and mixed cell closures
https://lanl.github.io/singularity-eos/
BSD 3-Clause "New" or "Revised" License
27 stars 8 forks source link

Accuracy of second derivatives, specifically for tabular lookups #242

Open jhp-lanl opened 1 year ago

jhp-lanl commented 1 year ago

@aematts brought up the fact that certain thermodynamic derivatives may be more accurate than others, especially for tabular lookups.

We currently provide three second derivative quantities--the Gruneisen parameter, $\Gamma$, the constant volume heat capacity, $C_V$, and isentropic bulk modulus, $B_S$--that can then in principal be used with our other return variables to compute any desired thermodynamic quantity of interest. However, these are not always the most accurate quantities for a material, especially depending on the preferred inputs for that EOS.

More specifically, for Mie-Gruneisen EOS of the form $P = P(\rho, e)$, the natural derivatives to be returned are

\left( \frac{\partial P}{\partial e}\right)_\rho = \rho \Gamma

and

\left( \frac{\partial P}{\partial \rho}\right)_e = \frac{B_S - P\Gamma}{\rho},

which is what motivates returning the Gruneisen parameter and isentropic sound speed in the first place (check my math though).

However, for an EOS of the form $P = P(\rho, T)$, the natural derivatives are better expressed in terms of $\alpha := -\frac{1}{\rho}\left(\frac{\partial \rho}{\partial T}\right)_P$ and $B_T := \rho\left(\frac{\partial P}{\partial \rho}\right)_T$ such that the natural derivatives are

\left(\frac{\partial P}{\partial T} \right)_\rho = \alpha B_T

and

\left(\frac{\partial P}{\partial \rho} \right)_T = \frac{B_T}{\rho}

This could be especially relevant for FillEos() or an eventual sound speed function as identified in https://github.com/lanl/singularity-eos/issues/4.

For an analytic EOS, this probably won't matter much since any differences in the calculation will be of order roundoff, but interpolation errors in the derivatives in density-energy space will likely be larger than in density-temperature space. It may then be advantageous to minimize these interpolation errors and formulate returned quantities in terms of $\alpha$ and $B_T$.

Moreover, it may make sense to expose routines to access these quantities directly at some point in the future if the interpolation errors can be proven to be significant enough.

Yurlungur commented 1 year ago

Correct me if I'm wrong, but I believe we are doing this in certain places. For the tabulated EOS's I think we try to compute things in terms of the derivatives with respect to the independent variables then use thermodynamic relations to get the derivatives relevant for a hydro code.

jhp-lanl commented 1 year ago

Correct me if I'm wrong, but I believe we are doing this in certain places. For the tabulated EOS's I think we try to compute things in terms of the derivatives with respect to the independent variables then use thermodynamic relations to get the derivatives relevant for a hydro code.

Yes I believe you're right, but it might be appropriate to standardize some of this across EOS. I think the other question is whether to expose routines for accessing the thermal expansion and isothermal bulk modulus. I don't see a need at the moment, but it may be important in the future as the library is integrated into more physics (like KPT).