2
2
Equations of State
3
3
******************
4
4
5
- In this chapter on equations of state, we list the EOS routines
6
- available for your use, and then we describe the correct structure of
7
- an EOS module in case you want to build your own.
5
+ The general interface to the equation of state is:
8
6
9
- Available Equations of State
10
- ============================
11
-
12
- .. index :: eos_t
13
-
14
- The following equations of state are available in Microphysics.
15
- Except where noted, each of these EOSs will provide the full
16
- thermodynamic data (including all derivatives) in the ``eos_t ``
17
- type.
18
-
19
- gamma_law
20
- ---------
21
-
22
- ``gamma_law `` represents a gamma law gas, with
23
- equation of state:
24
-
25
- .. math :: p = (\gamma - 1) \rho e.
26
-
27
- :math: `\gamma ` is specified by the runtime parameter ``eos.eos_gamma ``. For
28
- an ideal gas, this represents the ratio of specific heats. The gas is
29
- assumed to be ideal, with the pressure given by
30
-
31
- .. math :: p = \frac{\rho k T}{\mu m_u}
32
-
33
- where :math: `k` is Boltzmann’s constant and :math: `\mu ` is the mean molecular
34
- weight, calculated from the composition, :math: `X_k`. This EOS assumes
35
- the gas is either completely neutral (``eos.assume_neutral = 1 ``),
36
- giving:
37
-
38
- .. math :: \mu^{-1} = \sum_k \frac{X_k}{A_k}
39
-
40
- or completely ionized (``eos.assume_neutral = 0 ``), giving:
41
-
42
- .. math :: \mu^{-1} = \sum_k \left ( 1 + Z_k \right ) \frac{X_k}{A_k}
43
-
44
- The entropy comes from the Sackur-Tetrode equation. Because of the
45
- complex way that composition enters into the entropy, the entropy
46
- formulation here is only correct for a :math: `\gamma = 5 /3 ` gas.
47
-
48
-
49
- polytrope
50
- ---------
51
-
52
- ``polytrope `` represents a polytropic fluid, with equation of
53
- state:
54
-
55
- .. math :: p = K \rho^\gamma.
56
-
57
- The gas is also assumed to obey the above gamma law relation
58
- connecting the pressure and internal energy. Therefore :math: `\rho ` is the
59
- only independent variable; there is no temperature dependence. The
60
- user either selects from a set of predefined options reflecting
61
- physical polytropes (e.g. a non-relativistic, fully degenerate
62
- electron gas) or inputs their own values for :math: `K` and :math: `\gamma `
63
- via ``eos.polytrope_K `` and ``eos.polytrope_gamma ``.
64
-
65
- The runtime parameter ``eos.polytrope_type `` selects the pre-defined
66
- polytropic relations. The options are:
67
-
68
- - ``eos.polytrope_type = 1 ``: sets :math: `\gamma = 5 /3 ` and
69
-
70
- .. math :: K = \left ( \frac{3}{\pi} \right)^{2/3} \frac{h^2}{20 m_e m_p^{5/3}} \frac{1}{\mu_e^{5/3}}
71
-
72
- where :math: `mu_e` is the mean molecular weight per electron, specified via ``eos.polytrope_mu_e ``
73
-
74
- This is the form appropriate for a non-relativistic
75
- fully-degenerate electron gas.
76
-
77
- - ``eos.polytrope_type = 2 ``: sets :math: `\gamma = 4 /3 ` and
78
-
79
- .. math :: K = \left ( \frac{3}{\pi} \right)^{1/3} \frac{hc}{8 m_p^{4/3}} \frac{1}{\mu_e^{4/3}}
80
-
81
- This is the form appropriate for a relativistic fully-degenerate
82
- electron gas.
83
-
84
- ztwd
85
- ----
86
-
87
- ``ztwd `` is the zero-temperature degenerate electron equation
88
- of state of Chandrasekhar (1935), which is designed to describe
89
- white dward material. The pressure satisfies the equation:
90
-
91
- .. math :: p(x) = A \left( x(2x^2-3)(x^2 + 1)^{1/2} + 3\, \text{sinh}^{-1}(x) \right),
92
-
93
- with :math: `A = \pi m_e^4 c^5 / (3 h^3 )`. Here :math: `x` is a dimensionless
94
- measure of the Fermi momentum, with :math: `\rho = B x^3 ` and :math: `B = 8 \pi \mu _e
95
- m_p m_e^3 c^3 / (3 h^3 )`, where :math: `\mu _e` is the mean molecular weight
96
- per electron and :math: `h` is the Planck constant.
97
-
98
- The enthalpy was worked out by Hachisu (1986):
99
-
100
- .. math :: h(x) = \frac{8A}{B}\left(x^2 + 1\right)^{1/2}.
101
-
102
- (note the unfortunate notation here, but this :math: `h` is specific
103
- enthalpy). The specific internal energy satisfies the standard
104
- relationship to the specific enthalpy:
105
-
106
- .. math :: e = h - p / \rho.
107
-
108
- Since the pressure-density relationship does not admit a closed-form
109
- solution for the density in terms of the pressure, if we call the EOS
110
- with pressure as a primary input then we do Newton-Raphson iteration
111
- to find the density that matches this pressure.
112
-
113
- multigamma
114
- ----------
115
-
116
- ``multigamma `` is an ideal gas equation of state where each
117
- species can have a different value of :math: `\gamma `. This mainly affects
118
- how the internal energy is constructed as each species, represented
119
- with a mass fraction :math: `X_k` will have its contribution to the total
120
- specific internal energy take the form of :math: `e = p/\rho /(\gamma _k - 1 )`.
121
- The main thermodynamic quantities take the form:
122
-
123
- .. math ::
124
-
125
- \begin {aligned}
126
- p &= \frac {\rho k T}{m_u} \sum _k \frac {X_k}{A_k} \\
127
- e &= \frac {k T}{m_u} \sum _k \frac {1 }{\gamma _k - 1 } \frac {X_k}{A_k} \\
128
- h &= \frac {k T}{m_u} \sum _k \frac {\gamma _k}{\gamma _k - 1 } \frac {X_k}{A_k}\end {aligned}
129
-
130
- We recognize that the usual astrophysical :math: `\bar {A}^{-1 } = \sum _k
131
- X_k/A_k`, but now we have two other sums that involve different
132
- :math: `\gamma _k` weightings.
133
-
134
- The specific heats are constructed as usual,
135
-
136
- .. math ::
137
-
138
- \begin {aligned}
139
- c_v &= \left . \frac {\partial e}{\partial T} \right |_\rho =
140
- \frac {k}{m_u} \sum _k \frac {1 }{\gamma _k - 1 } \frac {X_k}{A_k} \\
141
- c_p &= \left . \frac {\partial h}{\partial T} \right |_p =
142
- \frac {k}{m_u} \sum _k \frac {\gamma _k}{\gamma _k - 1 } \frac {X_k}{A_k}\end {aligned}
7
+ .. code :: c++
143
8
144
- and it can be seen that the specific gas constant, :math: `R \equiv c_p -
145
- c_v` is independent of the :math: `\gamma _i`, and is simply :math: `R =
146
- k/m_u\bar {A}` giving the usual relation that :math: `p = R\rho T`.
147
- Furthermore, we can show
9
+ template <typename I, typename T>
10
+ AMREX_GPU_HOST_DEVICE AMREX_INLINE
11
+ void eos (const I input, T& state, bool use_raw_inputs = false)
148
12
149
- .. math ::
13
+ where ``input `` specifies which thermodynamic quantities are taken as
14
+ the input and ``state `` is a C++ struct that holds all of the
15
+ thermodynamic information.
150
16
151
- \Gamma _1 \equiv \left . \frac {\partial \log p}{\partial \log \rho } \right |_s =
152
- \left ( \sum _k \frac {\gamma _k}{\gamma _k - 1 } \frac {X_k}{A_k} \right ) \bigg /
153
- \left ( \sum _k \frac {1 }{\gamma _k - 1 } \frac {X_k}{A_k} \right ) =
154
- \frac {c_p}{c_v} \equiv \gamma _\mathrm {effective}
155
-
156
- and :math: `p = \rho e (\gamma _\mathrm {effective} - 1 )`.
157
-
158
- This equation of state takes several runtime parameters that can set
159
- the :math: `\gamma _i` for a specific species. The parameters are:
160
-
161
- - ``eos.eos_gamma_default ``: the default :math: `\gamma ` to apply for all
162
- species
163
-
164
- - ``eos.species_X_name `` and ``eos.species_X_gamma ``: set the
165
- :math: `\gamma _i` for the species whose name is given as
166
- ``eos.species_X_name `` to the value provided by ``eos.species_X_gamma ``.
167
- Here, ``X `` can be one of the letters: ``a ``, ``b ``, or
168
- ``c ``, allowing us to specify custom :math: `\gamma _i` for up to three
169
- different species.
170
-
171
- helmholtz
172
- ---------
173
-
174
- ``helmholtz `` contains a general, publicly available stellar
175
- equation of state based on the Helmholtz free energy, with
176
- contributions from ions, radiation, and electron degeneracy, as
177
- described in :cite: `timmes:1999 `, :cite: `timmes:2000 `, :cite: `flash `.
178
-
179
- We have modified this EOS a bit to fit within the context of our
180
- codes. The vectorization is explicitly thread-safe for use with OpenMP
181
- and OpenACC. In addition, we have added the ability to perform a
182
- Newton-Raphson iteration so that if we call the EOS with density and
183
- energy (say), then we will iterate over temperature until we find the
184
- temperature that matches this density–energy combination. If we
185
- cannot find an appropriate temperature, we will reset it to
186
- ``small_temp ``, which needs to be set in the equation of state wrapper
187
- module in the code calling this. However, there is a choice of whether
188
- to update the energy to match this temperature, respecting
189
- thermodynamic consistency, or to leave the energy alone, respecting
190
- energy conservation. This is controlled through the
191
- ``eos.eos_input_is_constant `` parameter in your inputs file.
192
-
193
- We thank Frank Timmes for permitting us to modify his code and
194
- publicly release it in this repository.
195
-
196
- stellarcollapse
197
- ---------------
198
-
199
- ``stellarcollapse `` is the equation of state module provided
200
- on http://stellarcollapse.org. It is designed
201
- to be used for core-collapse supernovae and is compatible with a
202
- large number of equations of state that are designed to describe
203
- matter near nuclear density. You will need to download an
204
- appropriate interpolation table from that site to use this.
205
17
206
18
Interface and Modes
207
19
===================
@@ -248,16 +60,28 @@ The *eos_type* passed in is one of
248
60
* ``chem_eos_t `` : adds some quantities needed for the primordial chemistry EOS
249
61
and explicitly does not include the mass fractions.
250
62
251
- In general, you should use the type that has the smallest set of
252
- information needed, since we optimize out needless quantities at
253
- compile type (via C++ templating) for ``eos_re_t `` and ``eos_rep_t ``.
63
+ .. tip ::
254
64
255
- .. note ::
65
+ The EOS implementations make heavy use of templating to
66
+ "compile-out" the thermodynamic quantities that are not needed
67
+ (depending on the input type). This can greatly increase
68
+ performance. As such, you should pick the smallest EOS structure
69
+ (``eos_re_t ``, ``eos_rep_t ``, ...) that contains the thermodynamic
70
+ information you need.
71
+
72
+ .. tip ::
73
+
74
+ You can also pass a ``burn_t `` struct into the EOS, although this
75
+ will give you access to a much smaller range of data.
76
+
77
+
78
+ Composition
79
+ ===========
256
80
257
- All of these modes require composition as an input . Usually this is
258
- via the set of mass fractions, ``eos_t. xn[] ``, but if ``USE_AUX_THERMO ``
259
- is set to ``TRUE ``, then we instead use the auxiliary quantities
260
- stored in ``eos_t.aux[] ``.
81
+ All input modes for `` eos() `` require a composition . Usually this is
82
+ via the set of mass fractions, ``eos_t xn[] ``, but if ``USE_AUX_THERMO ``
83
+ is set to ``TRUE ``, then we instead use the auxiliary quantities
84
+ stored in ``eos_t.aux[] ``.
261
85
262
86
.. _aux_eos_comp :
263
87
@@ -266,24 +90,30 @@ Auxiliary Composition
266
90
267
91
.. index :: USE_AUX_THERMO
268
92
93
+ .. note ::
94
+
95
+ The main use-case for the auxiliary composition is when using a reaction
96
+ network together with the tabulated NSE state.
97
+
269
98
With ``USE_AUX_THERMO=TRUE ``, we interpret the composition from the auxiliary variables.
270
- The auxiliary variables are
99
+ For ``eos_t eos_state ``, the auxiliary variables are
100
+
271
101
272
- * ``eos_state.aux[iye] `` : electron fraction, defined as
102
+ * ``eos_state.aux[AuxZero:: iye] `` : electron fraction, defined as
273
103
274
104
.. math ::
275
105
276
106
Y_e = \sum _k \frac {X_k Z_k}{A_k}
277
107
278
- * ``eos_state.aux[iabar] `` : the average mass of the nuclei, :math: `\bar {A}`, defined as:
108
+ * ``eos_state.aux[AuxZero:: iabar] `` : the average mass of the nuclei, :math: `\bar {A}`, defined as:
279
109
280
110
.. math ::
281
111
282
112
\frac {1 }{\bar {A}} = \sum _k \frac {X_k}{A_k}
283
113
284
114
In many stellar evolutions texts, this would be written as :math: `\mu _I`.
285
115
286
- * ``eos_state.aux[ibea] `` : the binding energy per nucleon (units of
116
+ * ``eos_state.aux[AuxZero:: ibea] `` : the binding energy per nucleon (units of
287
117
MeV), defined as
288
118
289
119
.. math ::
@@ -292,11 +122,17 @@ The auxiliary variables are
292
122
293
123
where :math: `B_k` is the binding energy of nucleus :math: `k`
294
124
295
- Given a composition of mass fractions, the function
296
- ``set_aux_comp_from_X(state_t& state) `` will initialize these
297
- auxiliary quantities.
125
+ Given a composition of mass fractions, the function:
126
+
127
+ .. code :: c++
128
+
129
+ template <class state_t>
130
+ AMREX_GPU_HOST_DEVICE AMREX_INLINE
131
+ void set_aux_comp_from_X(state_t& state)
132
+
133
+ will initialize the auxiliary data.
298
134
299
- The equation of state also needs :math: `\bar {Z}` which is easily computed as
135
+ Many equations of state also need :math: `\bar {Z}` which is easily computed as
300
136
301
137
.. math ::
302
138
@@ -315,14 +151,19 @@ extends the non-"extra" variants with these additional fields.
315
151
316
152
The composition derivatives can be used via the ``composition_derivatives() `` function
317
153
in ``eos_composition.H ``
318
- to compute :math: `\partial p/\partial X_k |_{\rho , T, X_j}`, :math: `\partial e/\partial X_k |_{\rho , T, X_j}`, and :math: `\partial h/\partial X_k |_{\rho , T, X_j}`.
154
+ to compute :math: `\partial p/\partial X_k |_{\rho , T, X_j}`, :math: `\partial e/\partial X_k |_{\rho , T, X_j}`, and :math: `\partial h/\partial X_k |_{\rho , T, X_j}`. This has the interface:
155
+
156
+ .. code :: c++
157
+
158
+ template <typename T>
159
+ AMREX_GPU_HOST_DEVICE AMREX_INLINE
160
+ eos_xderivs_t composition_derivatives (const T& state)
161
+
319
162
320
163
321
164
Initialization and Cutoff Values
322
165
================================
323
166
324
- Input Validation
325
- ================
326
167
327
168
The EOS will make sure that the inputs are within an acceptable range,
328
169
(e.g., ``small_temp `` :math: `< T <` ``maxT ``). If they are not, then it
@@ -332,19 +173,26 @@ If you are calling the EOS with ``eos_input_re``, and if :math:`e <
332
173
10 ^{-200 }`, then it calls the EOS with ``eos_input_rt `` with T =
333
174
max ( ``small_temp ``, T ).
334
175
335
- User’s are encourage to do their own validation of inputs before calling
336
- the EOS.
176
+ .. note ::
177
+
178
+ User’s are encourage to do their own validation of inputs before calling
179
+ the EOS.
337
180
338
181
EOS Structure
339
182
=============
340
183
341
- Each EOS should have two main routines by which it interfaces to the
342
- rest of CASTRO. At the beginning of the simulation,
343
- ``actual_eos_init `` will perform any initialization steps and save
344
- EOS variables (mainly ``smallt ``, the temperature floor, and
345
- ``smalld ``, the density floor). These variables are stored in the
346
- main EOS module of the code calling these routines. This would be the
347
- appropriate time for, say, loading an interpolation table into memory.
184
+ Each EOS should have two main routines through which it interfaces to the
185
+ rest of Microphysics.
186
+
187
+ * ``actual_eos_init() `` : At the beginning of the simulation,
188
+ ``actual_eos_init `` will perform any initialization steps and save
189
+ EOS variables (mainly ``smallt ``, the temperature floor, and
190
+ ``smalld ``, the density floor). These variables are stored in the
191
+ main EOS module of the code calling these routines.
192
+
193
+ This is also where an EOS with tables would read in the tables
194
+ and initialize the memory they are stored in.
348
195
349
- The main evaluation routine is called ``actual_eos ``. It should
350
- accept an eos_input and an eos_t state; see Section :ref: `data_structures `.
196
+ * ``actual_eos() `` : this is the main evaluation routine. It should
197
+ accept an ``eos_input_t `` specifying the thermodynamic inputs and a
198
+ struct (like ``eos_t ``) that stores the thermodynamic quantities.
0 commit comments