Skip to content

Commit b483579

Browse files
authored
Merge pull request #439 from lanl/jmm/mean-atomic-mass
Add mean atomic mass and number
2 parents 668d71a + 0084c80 commit b483579

27 files changed

+583
-43
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
### Added (new features/APIs/variables/...)
66

77
### Fixed (Repair bugs, etc)
8-
- [[OR437]](https://github.com/lanl/singularity-eos/pull/437) Fix segfault on HIP, clean up warnings, add strict sanitizer test
8+
- [[PR439]](https://github.com/lanl/singularity-eos/pull/439) Add mean atomic mass and number to EOS API
9+
- [[PR437]](https://github.com/lanl/singularity-eos/pull/437) Fix segfault on HIP, clean up warnings, add strict sanitizer test
910

1011
### Changed (changing behavior/API/variables/...)
1112

doc/sphinx/src/models.rst

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,38 @@ Note: sometimes temperatures are measured in eV for which the conversion is
338338

339339
Sesame units are equivalent to the mm-mg-µs unit system.
340340

341+
The ``MeanAtomicProperties`` struct
342+
------------------------------------
343+
344+
Several analytic equations of state optionally accept mean atomic mass
345+
and number as physics properties. These are the average number of
346+
nucleons and protons in a constituent nucleus respectively. They are
347+
not necessarily integers, as a given material may be made up of
348+
multiple kinds of atom. For example, dry air contains both nitrogen
349+
and oxygen.
350+
351+
The mean atomic mass and number are frequently carried in the
352+
container struct
353+
354+
.. code-block:: cpp
355+
356+
struct MeanAtomicProperties {
357+
Real Abar, Zbar;
358+
359+
// default is hydrogen
360+
static constexpr Real DEFAULT_ABAR = 1.0;
361+
static constexpr Real DEFAULT_ZBAR = 1.0;
362+
363+
PORTABLE_INLINE_FUNCTION
364+
MeanAtomicProperties(Real Abar_, Real Zbar_) : Abar(Abar_), Zbar(Zbar_) {}
365+
PORTABLE_INLINE_FUNCTION
366+
MeanAtomicProperties() : Abar(DEFAULT_ABAR), Zbar(DEFAULT_ZBAR) {}
367+
};
368+
369+
which owns the atomic mass ``Abar`` and atomic number ``Zbar``. You
370+
may set these by constructing the struct or by setting the fields in a
371+
pre-constructed struct. The defaults are for hydrogen.
372+
341373
Implemented EOS models
342374
----------------------
343375

@@ -429,6 +461,14 @@ these values are not set, they will be the same as those returned by the
429461
conditions are given, the return values of the :code:`ValuesAtReferenceState()`
430462
function will not be the same.
431463

464+
Both constructors also optionally accept `MeanAtomicProperties` for
465+
the atomic mass and number as a final optional parameter, e.g.,
466+
467+
.. code-block:: cpp
468+
469+
IdealGas(Real gm1, Real Cv, MeanAtomicProperties(Abar, Zbar));
470+
IdealGas(Real gm1, Real Cv, Real EntropyT0, Real EntropyRho0, MeanAtomicProperties(Abar, Zbar));
471+
432472
Stiffened Gas
433473
`````````````
434474

@@ -486,6 +526,15 @@ these values are not set, they will be the same as those returned by the
486526
conditions are given, the return values of the :code:`ValuesAtReferenceState()`
487527
function will not be the same.
488528

529+
Both constructors also optionally accept `MeanAtomicProperties` for
530+
the atomic mass and number as a final optional parameter, e.g.,
531+
532+
.. code-block:: cpp
533+
534+
StiffGas(Real gm1, Real Cv, Real Pinf, Real q, MeanAtomicProperties(Abar, Zbar));
535+
StiffGas(Real gm1, Real Cv, Real Pinf, Real q, Real qp, Real T0, Real P0,
536+
EntropyRho0, MeanAtomicProperties(Abar, Zbar));
537+
489538
Noble-Abel
490539
``````````
491540

@@ -544,6 +593,17 @@ these values are not set, they will be the same as those returned by the
544593
conditions are given, the return values of the :code:`ValuesAtReferenceState()`
545594
function will not be the same.
546595

596+
Both constructors also optionally accept `MeanAtomicProperties` for
597+
the atomic mass and number as a final optional parameter, e.g.,
598+
599+
.. code-block:: cpp
600+
601+
NobleAbel(Real gm1, Real Cv, Real b, Real q,
602+
MeanAtomicProperties(Abar, Zbar));
603+
NobleAbel(Real gm1, Real Cv, Real b, Real q, Real qp, Real T0, Real P0,
604+
MeanAtomicProperties(Abar, Zbar));
605+
606+
547607
Carnahan-Starling
548608
`````````````````
549609

@@ -630,6 +690,16 @@ these values are not set, they will be the same as those returned by the
630690
conditions are given, the return values of the :code:`ValuesAtReferenceState()`
631691
function will not be the same.
632692

693+
Both constructors also optionally accept `MeanAtomicProperties` for
694+
the atomic mass and number as a final optional parameter, e.g.,
695+
696+
.. code-block:: cpp
697+
698+
CarnahanStarling(Real gm1, Real Cv, Real b, Real q,
699+
MeanAtomicProperties(Abar, Zbar))
700+
CarnahanStarling(Real gm1, Real Cv, Real b, Real q, Real qp, Real T0, Real P0,
701+
MeanAtomicProperties(Abar, Zbar))
702+
633703
Gruneisen EOS
634704
`````````````
635705

@@ -767,6 +837,9 @@ There is an overload of the ``Gruneisen`` class which computes
767837
Gruneisen(const Real C0, const Real s1, const Real s2, const Real s3, const Real G0,
768838
const Real b, const Real rho0, const Real T0, const Real P0, const Real Cv)
769839
840+
Both constructors also optionally accept `MeanAtomicProperties` for
841+
the atomic mass and number as a final optional parameter.
842+
770843
Extendended Vinet EOS
771844
`````````````````````
772845

@@ -849,6 +922,9 @@ is :math:`S_0`, and ``expconsts`` is a pointer to the constant array of length
849922
:math:`d_2` to :math:`d_{40}`. Expansion coefficients not used should be set to
850923
0.0.
851924

925+
This constructor also optionally accepts `MeanAtomicProperties` for
926+
the atomic mass and number as a final optional parameter.
927+
852928
Mie-Gruneisen linear :math:`U_s`- :math:`u_p` EOS
853929
`````````````````````````````````````````````````
854930

@@ -995,6 +1071,9 @@ where
9951071
``G0`` is :math:`\Gamma(\rho_0)`, ``Cv0`` is :math:`C_V`,
9961072
``E0`` is :math:`E_0`, and ``S0`` is :math:`S_0`.
9971073

1074+
This constructor also optionally accepts `MeanAtomicProperties` for
1075+
the atomic mass and number as a final optional parameter.
1076+
9981077
Mie-Gruneisen power expansion EOS
9991078
`````````````````````````````````
10001079
As we noted above, the assumption of a linear :math:`U_s`- :math:`u_p` relation is simply not valid at large compressions. At
@@ -1075,6 +1154,8 @@ where
10751154
:math:`K_0` to :math:`K_{40}`. Expansion coefficients not used should be set to
10761155
:math:`0.0`.
10771156

1157+
This constructor also optionally accepts `MeanAtomicProperties` for
1158+
the atomic mass and number as a final optional parameter.
10781159

10791160

10801161
JWL EOS
@@ -1127,6 +1208,9 @@ where ``A`` is :math:`A`, ``B`` is :math:`B`, ``R1`` is :math:`R_1`,
11271208
``R2`` is :math:`R_2`, ``w`` is :math:`w`, ``rho0`` is :math:`\rho_0`,
11281209
and ``Cv`` is :math:`C_V`.
11291210

1211+
This constructor also optionally accepts `MeanAtomicProperties` for
1212+
the atomic mass and number as a final optional parameter.
1213+
11301214
Davis EOS
11311215
```````````
11321216

@@ -1274,6 +1358,9 @@ where ``rho0`` is :math:`\rho_0`, ``e0`` is :math:`e_0`, ``P0`` is
12741358
:math:`Z`, ``alpha`` is :math:`\alpha`, and ``Cv0`` is the specific
12751359
heat capacity at the reference state.
12761360

1361+
This constructor also optionally accepts `MeanAtomicProperties` for
1362+
the atomic mass and number as a final optional parameter.
1363+
12771364
Davis Products EOS
12781365
'''''''''''''''''''
12791366

@@ -1381,6 +1468,9 @@ where ``a`` is :math:`a`, ``b`` is :math:`b`, ``k`` is :math:`k`,
13811468
``n`` is :math:`n`, ``vc`` is :math:`V_\mathrm{C}`, ``pc`` is
13821469
:math:`P_\mathrm{C}`, ``Cv`` is :math:`C_{V,0}`.
13831470

1471+
This constructor also optionally accepts `MeanAtomicProperties` for
1472+
the atomic mass and number as a final optional parameter.
1473+
13841474
Spiner EOS
13851475
````````````
13861476

@@ -1443,6 +1533,12 @@ of the material in the file, and ``reproducability_mode`` is a boolean
14431533
which slightly changes how initial guesses for root finds are
14441534
computed. The constructor for ``SpinerEOSDependsRhoSie`` is identical.
14451535

1536+
.. note::
1537+
1538+
Mean atomic mass and number are loaded from input tables. The
1539+
``SpinerEOS`` model does **not** support the
1540+
``MeanAtomicProperties`` struct.
1541+
14461542
``sp5`` files and ``sesame2spiner``
14471543
`````````````````````````````````````
14481544

@@ -1630,6 +1726,8 @@ values in expansion and compression.
16301726
16311727
and similar expressions for :math:`b_2^*`.
16321728

1729+
The SAP polynomial EOS also optionally accepts a
1730+
``MeanAtomicProperties`` struct.
16331731

16341732

16351733
Stellar Collapse EOS
@@ -1711,6 +1809,17 @@ where ``filename`` is the file containing the tabulated model,
17111809
original `Stellar Collapse`_ format, and ``filter_bmod`` specifies
17121810
whether or not to apply the above-described median filter.
17131811

1812+
.. note::
1813+
1814+
The ``StellarCollapse`` EOS assumes nuclear statistical equilibrium
1815+
and as such mean atomic mass and number are state variables. As such
1816+
class does not accept the ``MeanAtomicProperties`` struct. The
1817+
``MeanAtomicMassFromDensityTemperature`` and
1818+
``MeanAtomicNumberFromDensityTemperature`` functions return the
1819+
relevant quantities for some thermodynamic state. The
1820+
``MeanAtomicMass()`` and ``MeanAtomicNumber()`` functions raise an
1821+
error.
1822+
17141823
``StellarCollapse`` also provides
17151824

17161825
.. cpp:function:: void Save(const std::string &filename)
@@ -1796,6 +1905,14 @@ of the Helmholtz free energy (hence the name Helmholtz EOS). The free
17961905
energy is pre-computed via integrals over the Fermi sphere and
17971906
tabulated in a file provided from `Frank Timmes's website`_.
17981907

1908+
.. note::
1909+
1910+
Since mean atomic mass and number are required inputs, the
1911+
``MeanAtomicMassFromDensityTemperature`` and
1912+
``MeanAtomicNumberFromDensityAndTemperature`` functions simply
1913+
return the input values. The ``MeanAtomicMass()`` and
1914+
``MeanAtomicNumber`` functions produce an error.
1915+
17991916
The table is a simple small ascii file. To ensure thermodyanic
18001917
consistency, the table is interpolated using either biquintic or
18011918
bicubic Hermite polynomials, which are sufficiently high order that
@@ -1897,6 +2014,13 @@ and :math:`splitCowan` uses the cold curve plus Cowan-nuclear model
18972014
for ions and the final option ``linear_interp`` uses linear instead of
18982015
bilinear interpolation.
18992016

2017+
.. note::
2018+
2019+
Mean atomic mass and number are loaded from input tables. The
2020+
``EOSPAC`` model does **not** support the ``MeanAtomicProperties``
2021+
struct.
2022+
2023+
19002024
Note for performance reasons this EOS uses a slightly different vector API.
19012025
See :ref:`EOSPAC Vector Functions <eospac_vector>` for more details.
19022026

doc/sphinx/src/using-eos.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,56 @@ specific internal energy in :math:`erg/g`.
10371037

10381038
The function
10391039

1040+
.. code-block:: cpp
1041+
1042+
template<typename Indexer_t Real*>
1043+
void MeanAtomicMassFromDensityTemperature(const Real rho, const Real T,
1044+
Indexer_t &&lambda = nullpter) const;
1045+
1046+
returns the mean atomic mass (i.e., the number of nucleons) of a
1047+
material given density in :math:`g/cm^3` and temperature in
1048+
Kelvin. The reason this is allowed to vary with density and
1049+
temperature is that some equations of state, such as the Stellar
1050+
Collapse and Helmholtz equations of state encapsulate reactive flows
1051+
where the average nucleus may depend on thermodynamic variables. For
1052+
most materials, however, this is not the case and a convenience
1053+
function that drops the dependence is available:
1054+
1055+
.. code-block:: cpp
1056+
1057+
Real MeanAtomicMass() const;
1058+
1059+
The function
1060+
1061+
.. code-block:: cpp
1062+
1063+
template<typename Indexer_t Real*>
1064+
void MeanAtomicNumberFromDensityTemperature(const Real rho, const Real T,
1065+
Indexer_t &&lambda = nullpter) const;
1066+
1067+
returns the mean atomic number (i.e., the number of protons in the
1068+
nucleus) of a material given density in :math:`g/cm^3` and temperature
1069+
in Kelvin. The reason this is allowed to vary with density and
1070+
temperature is that some equations of state, such as the Stellar
1071+
Collapse and Helmholtz equations of state encapsulate reactive flows
1072+
where the average nucleus may depend on thermodynamic variables. For
1073+
most materials, however, this is not the case and a convenience
1074+
function that drops the dependence is available:
1075+
1076+
.. code-block:: cpp
1077+
1078+
Real MeanAtomicNumber() const;
1079+
1080+
1081+
1082+
.. warning::
1083+
1084+
For materials where the mean atomic mass and number **do** vary with
1085+
density and temperature, the convenience call without this
1086+
dependence will produce an error.
1087+
1088+
The function
1089+
10401090
.. code-block:: cpp
10411091
10421092
template <typename Indexer_t = Real*>

0 commit comments

Comments
 (0)