Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
f93634e
Use EosType() member function for name
jhp-lanl Mar 14, 2025
9f5ad0b
Add multi EOS modifier
jhp-lanl Mar 14, 2025
316674e
Move scratch_size and max_scratch_size into base class
jhp-lanl Apr 4, 2025
e04b7dd
Merge branch 'jhp/move_scratch_to_base' of github.com:lanl/singularit…
jhp-lanl Apr 4, 2025
cd32d8f
Add model name and scratch size member functions
jhp-lanl Apr 4, 2025
c7a65b1
Add templated mass fraction indexable type
jhp-lanl Apr 4, 2025
cf7f849
Add tuple utils file
jhp-lanl Apr 4, 2025
53b029b
Build multi-eos and tuple_utils
jhp-lanl Apr 4, 2025
2a0b737
Merge branch 'main' of github.com:lanl/singularity-eos into jhp/two_eos
jhp-lanl Apr 8, 2025
be52b2e
Merge branch 'jhp/closure_info' of github.com:lanl/singularity-eos in…
jhp-lanl Apr 8, 2025
5b4803f
Does not compile, but more progress on the multi-eos modifier
jhp-lanl Apr 8, 2025
c2bc3ed
Move nlambda default behavior into base class
jhp-lanl Apr 9, 2025
f700df3
Remove extraneous remnants of nlamda
jhp-lanl Apr 9, 2025
34d62fc
Merge branch 'jhp/nlambda' of github.com:lanl/singularity-eos into jh…
jhp-lanl Apr 9, 2025
7f9452a
Merge branch 'jhp/nlambda' of github.com:lanl/singularity-eos into jh…
jhp-lanl Apr 9, 2025
ba98a17
Merge branch 'main' of github.com:lanl/singularity-eos into jhp/two_eos
jhp-lanl Apr 10, 2025
dae1bda
Merge branch 'main' of github.com:lanl/singularity-eos into jhp/two_eos
jhp-lanl Jul 22, 2025
1e210a8
Merge branch 'main' of github.com:lanl/singularity-eos into jhp/two_eos
jhp-lanl Jul 23, 2025
272f80a
Add back in reference
jhp-lanl Jul 23, 2025
8c37791
Add _many_ updates and address todos
jhp-lanl Aug 20, 2025
fbd57b4
Add test for multi_eos if closures are enabled
jhp-lanl Aug 20, 2025
ff2fba4
Merge branch 'main' into jhp/two_eos
Yurlungur Aug 21, 2025
6497e28
Merge branch 'jhp/two_eos' of github.com:lanl/singularity-eos into jh…
jhp-lanl Aug 22, 2025
85896b2
Won't compile: add a lot more machinery for averaging quantities
jhp-lanl Aug 22, 2025
a72921b
Add generic indexer class to its own file
jhp-lanl Aug 28, 2025
70333ec
Add macros for easier SFINAE of concepts
jhp-lanl Aug 28, 2025
be5b1b0
Add universal references to functions
jhp-lanl Aug 28, 2025
3360196
DOES NOT COMPILE -- Address github comments and make more progress
jhp-lanl Aug 28, 2025
7fa785d
Move Kahan summation to shared math utils
jhp-lanl Aug 29, 2025
c875f87
Add include guard
jhp-lanl Aug 29, 2025
a83e3e2
Finish filling out the MultiEOS capability
jhp-lanl Aug 29, 2025
f5994a0
Rename to be more in-line with other test names
jhp-lanl Aug 29, 2025
789af12
Move MultiEOS out of modifiers since it really isn't a modifier
jhp-lanl Aug 29, 2025
db0948f
Add include guard
jhp-lanl Aug 29, 2025
079e069
Reflect moved multi_eos.hpp
jhp-lanl Aug 29, 2025
d0bd0d1
Merge branch 'main' of github.com:lanl/singularity-eos into jhp/two_eos
jhp-lanl Aug 29, 2025
f198079
Clang format
jhp-lanl Aug 29, 2025
a4d1a26
Update name for floored energy modifier test
jhp-lanl Aug 29, 2025
469d7d1
A couple more changes with moving the multi_eos.hpp file
jhp-lanl Aug 29, 2025
950efea
Opps... missed conflict and bad find/replace
jhp-lanl Aug 29, 2025
03cbf35
Missed a new feature for Kahan summation
jhp-lanl Aug 29, 2025
88b7dc0
Rename multi_eos test
jhp-lanl Aug 29, 2025
3d7d06d
Update kahan sum location
jhp-lanl Aug 29, 2025
8c60e76
Remove extra > from macro definition
jhp-lanl Aug 29, 2025
b5234f4
Various typos fixed to compile
jhp-lanl Aug 29, 2025
f131397
Clang format
jhp-lanl Aug 29, 2025
ad8203b
Add missing cmath header (how did this compile before?)
jhp-lanl Aug 29, 2025
d208d77
Add basic tests for MultiEOS (adding more)
jhp-lanl Aug 29, 2025
a93b0ce
Clang format
jhp-lanl Aug 29, 2025
e85828c
Fix logic for preferred input checks
jhp-lanl Aug 30, 2025
579b017
Clang format
jhp-lanl Aug 30, 2025
b823d23
Fix clang sanitize issues
jhp-lanl Aug 30, 2025
9096623
Merge branch 'jmm/variant-introspection' of github.com:lanl/singulari…
jhp-lanl Sep 2, 2025
b638600
Make VariadicIndexerBase constexpr and correct logic in SINGULARITY_I…
jhp-lanl Sep 2, 2025
0dfd834
Make CheckParams() throw exceptions so that it's easier to test
jhp-lanl Sep 2, 2025
c95ebf6
Correct error with SINGULARITY_INDEXER_HAS_INDEXABLE_TYPE
jhp-lanl Sep 3, 2025
bf383db
Add test for MassFraction<N> type
jhp-lanl Sep 3, 2025
4adae40
Make SINGULARITY_EOSPAC_USE_MODERN_ERROR_CODES dependent
jhp-lanl Sep 3, 2025
9024dd3
Merge branch 'jhp/eospac_option' of github.com:lanl/singularity-eos i…
jhp-lanl Sep 3, 2025
2147015
Fix dependent option logic and add to shared memory
jhp-lanl Sep 3, 2025
eab2098
Merge branch 'jhp/eospac_option' of github.com:lanl/singularity-eos i…
jhp-lanl Sep 3, 2025
850d425
Const correctness and remove pointer type for variant because it does…
jhp-lanl Sep 3, 2025
5f2e5ff
Add more tests to excerise P-T, mass fraction cutoff, CreateEOSArray,…
jhp-lanl Sep 3, 2025
6e1eeed
Clang format
jhp-lanl Sep 3, 2025
baacd22
Make throws test only run when kokkos is off
jhp-lanl Sep 3, 2025
dd3dbf5
Add more info to failing tests... will debug later
jhp-lanl Sep 3, 2025
63f1dba
Fix pass by value, argument ordering, and make sure lambda is passed …
jhp-lanl Sep 3, 2025
b0ef51e
Fix array filling and test mass fraction filling separately
jhp-lanl Sep 3, 2025
5130751
Clang format
jhp-lanl Sep 3, 2025
1a16407
Add noexcept
jhp-lanl Sep 3, 2025
a93b18f
Remove extraneous this from lambda capture
jhp-lanl Sep 3, 2025
f98e2a3
Add explicit arguments to REQUIRE_THROWS_WITH
jhp-lanl Sep 3, 2025
709b711
Satisfy clang unused issues and try not using REQUIRE_THROWS_WITH
jhp-lanl Sep 3, 2025
049bc59
Clang format
jhp-lanl Sep 3, 2025
c63ada4
Remove REQUIRE_THROWS_WITH since it doesn't appear to be working at p…
jhp-lanl Sep 3, 2025
90aa42b
Don't force references in order to accomodate many container return v…
jhp-lanl Sep 4, 2025
264bfd1
Bug fixes and tune tolerance of RE lookup PTE solve
jhp-lanl Sep 4, 2025
9746606
Add FillEos test and other lookup tests
jhp-lanl Sep 4, 2025
11e5388
Add some TODO comments for the future
jhp-lanl Sep 4, 2025
98d72e3
Clang doesn't like if constexpr for PreferredInput
jhp-lanl Sep 4, 2025
9551270
Add parentheses around bit comparisons for clarity
jhp-lanl Sep 4, 2025
15f1f20
Add SFINAE helpers for tuples
jhp-lanl Sep 5, 2025
1dca750
Correct lambda references, make sure bulk modulus calls bulk modulus,…
jhp-lanl Sep 5, 2025
ac6bd64
Correct CV bug
jhp-lanl Sep 5, 2025
dec5179
Add checks for averaging other thermo quantities (derivatives, etc.)
jhp-lanl Sep 5, 2025
0a4ed3c
Avoid GCC warnings relating to unused variables
jhp-lanl Sep 5, 2025
ad11bbd
Add tests for basic functions
jhp-lanl Sep 5, 2025
de6ed3b
Evaluate 3T properties at multiple densities, and correct MaximumPres…
jhp-lanl Sep 5, 2025
86c45c3
Remove zbar_func for now... use it when we actually test 3T
jhp-lanl Sep 5, 2025
5a492fd
Add ability to check if a type accepts an whole number index
jhp-lanl Sep 12, 2025
02a7396
Add safeSet() and safeGet() helpers
jhp-lanl Sep 12, 2025
8895d80
Add safeGet and safeSet that don't take numerical indices
jhp-lanl Sep 12, 2025
58a920b
Switch to safeGet and safeSet for indexable types
jhp-lanl Sep 12, 2025
fce8f7c
Whoops... forgot comment
jhp-lanl Sep 12, 2025
4959500
Clang format
jhp-lanl Sep 12, 2025
c2b1dbb
Update changelog
jhp-lanl Sep 12, 2025
589e1dc
Update doc
jhp-lanl Sep 12, 2025
fd74c25
Make functions PORTABLE and add required get/set
jhp-lanl Sep 12, 2025
a3d71fc
Make code more DRY and rename things a bit
jhp-lanl Sep 13, 2025
856531f
Add int index check
jhp-lanl Sep 13, 2025
220df73
Rename safeGet/Set to SafeGet/Set and remove direct indexing or regular
jhp-lanl Sep 13, 2025
271e52e
Make indexer const correct
jhp-lanl Sep 13, 2025
63d5a39
Rename safeGet/Set
jhp-lanl Sep 13, 2025
8a893a7
Clang format
jhp-lanl Sep 13, 2025
d6a9f68
Switch to template-based decision to use integer index or not
jhp-lanl Sep 13, 2025
cf8bf93
Whoops... forgot to return
jhp-lanl Sep 13, 2025
2d4153a
Clang format
jhp-lanl Sep 13, 2025
0a4baa1
Add docs for SafeMustGet() and SafeMustSet()
jhp-lanl Sep 13, 2025
4c89631
Get rid of Get and have wrappers use GetSet. Also update comments and…
jhp-lanl Sep 17, 2025
9d52960
Switch Get for Safe versions and expand tests
jhp-lanl Sep 17, 2025
69b56ab
Merge branch 'main' of github.com:lanl/singularity-eos into jhp/spine…
jhp-lanl Sep 17, 2025
0feb8e4
Remove last Get in favor of SafeSet
jhp-lanl Sep 17, 2025
c245728
Remove a few more instances of Get in favor of the Safe variety for I…
jhp-lanl Sep 17, 2025
734d55b
Clang format
jhp-lanl Sep 17, 2025
efd9a9f
Whoops... void was a bad choice for a type index
jhp-lanl Sep 17, 2025
d8dbccc
Let's try an unreachable return to make decltype(auto) happy
jhp-lanl Sep 17, 2025
bfacaac
Add dependent_false_v for if constexpr static asserts
jhp-lanl Sep 17, 2025
36d4286
Move throw into SafeGet/SafeSet wrappers and provide helpful compile …
jhp-lanl Sep 17, 2025
c783623
Can't test for a runtime throw when compile-time error will be used
jhp-lanl Sep 17, 2025
dc2a3a8
Make internal variant type robust to multiple EOS of the same type an…
jhp-lanl Sep 17, 2025
f88c017
Add static assert to variant to make sure there are no duplicate types
jhp-lanl Sep 17, 2025
11da97c
Split tabular and analytic tests of MultiEOS
jhp-lanl Sep 17, 2025
dbcb72a
Add tests for unique typelists
jhp-lanl Sep 17, 2025
fe6ad15
Merge branch 'jhp/spiner_indexable_types' of github.com:lanl/singular…
jhp-lanl Sep 17, 2025
d16bb0c
Whoops... forgot to commit the variadic utilities that enable the uni…
jhp-lanl Sep 17, 2025
07f4a72
Clang format
jhp-lanl Sep 17, 2025
4a60616
Merge branch 'main' of github.com:lanl/singularity-eos into jhp/two_eos
jhp-lanl Sep 17, 2025
e70e071
Add ifdef guards to make sure we don't compile without spiner
jhp-lanl Sep 17, 2025
b09d64d
Add some debugging to try to figure out why the reference state and F…
jhp-lanl Sep 17, 2025
323f0d0
Add constant checks for correct input/output in FillEos
jhp-lanl Sep 17, 2025
2d75238
Add LogDensity and LogTemperature since they stabilize spiner r(P,T) …
jhp-lanl Sep 17, 2025
1b79a06
Merge branch 'main' of github.com:lanl/singularity-eos into jhp/two_eos
jhp-lanl Sep 18, 2025
1654471
Switch to finite differences for mixture derivatives
jhp-lanl Sep 18, 2025
6acd078
Switch testing to account for finite difference derivatives now
jhp-lanl Sep 18, 2025
301bdd7
Merge branch 'main' into jhp/two_eos
Yurlungur Sep 18, 2025
3899052
Merge branch 'main' of github.com:lanl/singularity-eos into jhp/two_eos
jhp-lanl Sep 19, 2025
2d5abb7
Redo derivatives to use finite differences for mixtures
jhp-lanl Sep 20, 2025
9d11b8b
Small cosmetic changes
jhp-lanl Sep 23, 2025
a2063b5
Updates to test to try to track down PTE convergence issue and stagin…
jhp-lanl Sep 23, 2025
0881391
Merge branch 'main' of github.com:lanl/singularity-eos into jhp/two_eos
jhp-lanl Sep 23, 2025
f0f5c70
Merge branch 'main' of github.com:lanl/singularity-eos into jhp/two_eos
jhp-lanl Sep 23, 2025
3e920c2
PTE settings for finite differences or normal lookups
jhp-lanl Sep 23, 2025
a9703fb
Settle in on tolerances and convergence
jhp-lanl Sep 23, 2025
8af5ac5
Merge branch 'jhp/two_eos' of github.com:lanl/singularity-eos into jh…
jhp-lanl Sep 23, 2025
b9e056c
Clang format
jhp-lanl Sep 23, 2025
a941c33
Refactor SetDynamicMemory logic and get rid of extra template arguments
jhp-lanl Sep 23, 2025
4e4769f
Clean up using statements
jhp-lanl Sep 23, 2025
6247f90
Test 3T functions and debug
jhp-lanl Sep 23, 2025
11893ff
Initial stab at serialization and device tests (probably won't compile)
jhp-lanl Sep 24, 2025
7c70789
Now it compiles...
jhp-lanl Sep 24, 2025
24fa0be
Clang format
jhp-lanl Sep 24, 2025
f1fd3fd
Correct SFINAE
jhp-lanl Sep 25, 2025
06c40fd
Fix some segfaults
jhp-lanl Sep 25, 2025
0d91dac
Create CMake option to enable address and undefined behavior sanitizing
jhp-lanl Sep 25, 2025
053da60
Add static-libasan
jhp-lanl Sep 25, 2025
64de92c
Remove extraneous comma and move compile options down with other options
jhp-lanl Sep 25, 2025
f6a4ee4
Update CMakeLists.txt
jhp-lanl Sep 25, 2025
d3364e3
Update CHANGELOG.md
jhp-lanl Sep 25, 2025
13464b2
Merge branch 'jhp/cmake_sanitize' into jhp/two_eos
jhp-lanl Sep 25, 2025
70b0b1c
Merge branch 'jhp/cmake_sanitize' into jhp/two_eos
jhp-lanl Sep 25, 2025
de5b5c0
Merge branch 'main' of github.com:lanl/singularity-eos into jhp/two_eos
jhp-lanl Sep 25, 2025
3216a73
Change shared to dynamic names
jhp-lanl Sep 25, 2025
8a32e53
Merge branch 'main' of github.com:lanl/singularity-eos into jhp/two_eos
jhp-lanl Oct 9, 2025
a50eb4e
Explain zero shared memory size
jhp-lanl Oct 10, 2025
03bf38e
Comment that serialization doesn't work
jhp-lanl Oct 10, 2025
c027b4c
Comment out serialization test since it isn't working yet
jhp-lanl Oct 10, 2025
6de1f9e
Update changelog
jhp-lanl Oct 10, 2025
7988572
add period
jhp-lanl Oct 10, 2025
5e7d452
Rename variables to be more logical
jhp-lanl Oct 10, 2025
918fe7b
Add documentation for MultiEOS
jhp-lanl Oct 10, 2025
89f50d1
Clang format
jhp-lanl Oct 10, 2025
9aed19f
Whoops... too many dots
jhp-lanl Oct 10, 2025
7190289
Merge branch 'main' into jhp/two_eos
Yurlungur Oct 10, 2025
f9de181
Address most comments
jhp-lanl Oct 11, 2025
bdf8811
Merge branch 'jhp/two_eos' of github.com:lanl/singularity-eos into jh…
jhp-lanl Oct 11, 2025
5b72590
Missing semicolon
jhp-lanl Oct 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added (new features/APIs/variables/...)
- [[PR556]](https://github.com/lanl/singularity-eos/pull/556) Add introspection into types available in the variant
- [[PR564]](https://github.com/lanl/singularity-eos/pull/564) Removed Get() function from IndexableTypes since it could have unexpected consequences when a type wasn't present
- [[PR526]](https://github.com/lanl/singularity-eos/pull/526) Added the MultiEOS class to wrap multiple EOS models that are linked via PTE (e.g. a multiphase material or reacting material).

### Fixed (Repair bugs, etc)
- [[PR567]](https://github.com/lanl/singularity-eos/pull/567) Fixed an OOB array access bug in the Fixed T PTE solver
Expand Down
243 changes: 240 additions & 3 deletions doc/sphinx/src/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

.. _PowerMG: https://www.osti.gov/biblio/1762624

.. _Sesame: https://www.lanl.gov/org/ddste/aldsc/theoretical/physics-chemistry-materials/sesame-database.php

.. _EOSPAC: https://laws.lanl.gov/projects/data/eos/eospacReleases.php


EOS Models
===========
Expand Down Expand Up @@ -2189,12 +2193,13 @@ EOSPAC EOS
````````````

.. warning::

Entropy is not yet available for this EOS

This is a striaghtforward wrapper of the `EOSPAC`_ library for the
`Sesame`_ database. The constructor for the ``EOSPAC`` model has several overloads

.. code-block::
.. code-block:: cpp

EOSPAC(int matid, TableSplit split, bool invert_at_setup = false,
Real insert_data = 0.0,
Expand Down Expand Up @@ -2237,8 +2242,240 @@ curve plus Cowan-nuclear model for ions and the final option
Note for performance reasons this EOS uses a slightly different vector API.
See :ref:`EOSPAC Vector Functions <eospac_vector>` for more details.

.. _Sesame: https://www.lanl.gov/org/ddste/aldsc/theoretical/physics-chemistry-materials/sesame-database.php
MultiEOS
`````````

.. warning::

The Serialization/Deserialization capability for this EOS appears bugged
at the moment, especially with EOSPAC. Use with caution.

This class allows multiple EOS models to be combined *at compile time* with a
PTE closure model into a single material. This is useful for simulating e.g.
reacting systems where reactants and products describe the same material. It
can also be used for multi-phase EOS, but again the number of phases and
crucially the *type* of EOS model must be known at compile time. The advantage
of combining these models at compile-time is that logically the EOS will
behave identically to any other EOS model in ``singularity-eos``. It's possible
that there are performance benefits, especially when all EOS are the same model.

The primary way of constructing the ``MultiEOS`` model involves simply
providing an arbitrary series of model objects

.. code-block:: cpp

MultiEOS(EOSModelsT_ &&...eos_models)

Note that the type of the ``MultiEOS`` model is deduced from the inputs to the
constructor. In the follwoing example, it would be
``MultiEOS<IdealGas, IdealGas>``:

.. code-block:: cpp

auto model1 = IdealGas(Gamma_1, Cv_1);
auto model2 = IdealGas(Gamma_2, Cv_2);
auto multi = MultiEOS(model1, model2);

The ``MultiEOS`` model can also optionally accept a mass fraction cutoff where
materials below the cutoff value are ignored for the PTE caluclation

.. code-block:: cpp

MultiEOS(Real mass_frac_cutoff_in, EOSModelsT_ &&...eos_models);

For all of the standard ``singularity-eos`` member functions provided through
the ``Variant`` class (see
:ref:`The Equation of State API <eos methods reference section>`), bulk
properties are returned for the material and no component densities or energies
are available.

Mass fractions of the individual components are provided via the ``lambda``
variable via type-based indexing.

.. note::

Mass fraction information **must** be provided via the ``lambda`` parameter
or a compile-time error will be generated.

For example, the ``IndexerUtils`` in ``singularity-eos`` provide a way to
generate a type-based lambda indexer. For example, a two component spiner EOS
mixture could use a lambda of the type

.. code-block:: cpp

using LambdaT =
VariadicIndexer<IndexableTypes::LogDensity, IndexableTypes::LogTemperature,
IndexableTypes::MassFraction<0>, IndexableTypes::MassFraction<1>>;

A helper macro is provided that uses SFINAE to generate a compile time error
when the appropriate number of mass fractions are not provided via type-based
indexing in the ``LambdaIndexer`` type:

.. code-block:: cpp

SINGULARITY_INDEXER_HAS_MASS_FRAC(LambdaIndexer, nmat)

where ``nmat`` is the number of materials in the ``MultiEOS`` class (known at
compile time).

All derivative quantities (i.e. the Gruneisen parameter, bulk modulus, and heat
capacity) are found via finite differences. The reason for this is that really
there is no accurate way to average the individual material derivatives. For
example, we can attempt to derive an averaging rule for the heat capacity. The
heat capacity is given by

.. math::

C_V = \left( \frac{\partial e}{\partial T} \right)_V,

i.e. the derivative of the specific internal energy with respect to temperature
at constant *total* volume. The total internal energy is given by

.. math::

e_\mathrm{tot} = \sum\limits_{m=0} \mu_m e_m,

where the subscript :math:`m` is the material index in the PTE system (in this
case the material models in the ``MultiEOS`` class) and :math:`\mu_m` is the
mass fraction of that material. Taking the derivative of this equation with
respect to temperature at constant volume gives

.. math::

\left( \frac{\partial e_\mathrm{tot}}{\partial T} \right)_{V_\mathrm{tot}}
= \sum\limits_{m=0} \mu_m
\left( \frac{\partial e_m}{\partial T} \right)_{V_\mathrm{tot}}

But note that the right-hand-side derivatives are at constant *total* volume,
not constant *material* volume. As the temperature increases, a single
material may expand and do work on adjacent materials, causing their energies to
increase more than would be expected for the given temperature increase while
the materials remain in pressure equilibrium.

The best way to express this behavior analytically would be to mass-average the
derivatives with respect to pressure and temperature, i.e.

.. math::

\left( \frac{\partial e_\mathrm{tot}}{\partial T} \right)_P
= \sum\limits_{m=0} \mu_m
\left( \frac{\partial e_m}{\partial T} \right)_P,


and then use thermodynamic identities to combine them to describe the bulk
behavior of the mixture. However, not all models in ``singularity-eos`` provide
pressure and temperature derivatives at present, so these quantities are not
readily accessible.

Instead, the ``MultiEOS`` class relies on perturbing the mixture in density and
temperature or density and energy space and then combining these finite
difference results via thermodynamic identities. The downside of this approach
is that any finite difference errors can be significantly magnified in the
thermodynamic identities.

When access to the bare class is available, additional public member functions
are provided that populate indexers (i.e. anything with a square bracket
operator) for the material densities and specific internal energies. These are

.. code-block:: cpp

template <typename RealIndexer, typename LambdaIndexer>
PORTABLE_INLINE_FUNCTION SolverStatus GetStatesFromDensityEnergy(
const Real density_tot, const Real sie_tot, Real &pressure, Real &temperature,
RealIndexer &density_mat, RealIndexer &sie_mat, LambdaIndexer &lambdas,
bool const doing_derivs = false, bool small_mass_mat_consistency = false);

.. code-block:: cpp

template <typename RealIndexer, typename LambdaIndexer>
PORTABLE_INLINE_FUNCTION SolverStatus GetStatesFromDensityTemperature(
const Real density_tot, Real &sie_tot, Real &pressure, const Real temperature,
RealIndexer &&density_mat, RealIndexer &&sie_mat, LambdaIndexer &lambdas,
bool const doing_derivs = false);

.. code-block:: cpp

template <typename RealIndexer, typename LambdaIndexer>
PORTABLE_INLINE_FUNCTION SolverStatus GetStatesFromDensityPressure(
const Real density_tot, Real &sie_tot, const Real pressure, Real &temperature,
RealIndexer &&density_mat, RealIndexer &&sie_mat, LambdaIndexer &lambdas,
bool const doing_derivs = false);

.. code-block:: cpp

template <typename RealIndexer, typename LambdaIndexer>
PORTABLE_INLINE_FUNCTION void
GetStatesFromPressureTemperature(Real &density_tot, Real &sie_tot, const Real pressure,
const Real temperature, RealIndexer &density_mat,
RealIndexer &sie_mat, LambdaIndexer &lambdas);

Note that the ``doing_derivs`` option essentially tightens the tolerance on the
PTE solver in order to ensure that a perturbation to the PTE state via a finite
difference leads to a new PTE solution. The ``small_mass_mat_consistency``
option for the density-energy lookup populates materials below the mass
fraction cutoff with P-T lookups from the PTE state for the other materials.

Similarly, there are also public member functions for calculating the mixture
derivatives given a PTE state. For the heat capacity function,

.. code-block:: cpp

template <typename RealIndexer, typename LambdaIndexer>
PORTABLE_INLINE_FUNCTION Real CalculateCvFromState(Real const rho, Real const sie,
[[maybe_unused]] Real const pressure,
Real const temperature,
RealIndexer &density_mat,
RealIndexer &sie_mat,
LambdaIndexer &lambdas);

the state is perturbed in temperature space at constant density. For the bulk
modulus function,

.. code-block:: cpp

template <typename RealIndexer, typename LambdaIndexer>
PORTABLE_INLINE_FUNCTION Real CalculateBmodFromState(
Real const rho, Real const sie, Real const pressure, Real const temperature,
RealIndexer &density_mat, RealIndexer &sie_mat, LambdaIndexer &lambdas);

the state is perturbed in both temperature and density (with all materials in
PTE) where the bulk modulus is found from the formula,

.. math::

B_S = B_T + \frac{T}{\rho} \left( \frac{\partial P}{\partial T} \right)_\rho^2
\left( \frac{\partial T}{\partial e} \right)_\rho.

The Gruneisen parameter function is

.. code-block:: cpp

template <typename RealIndexer, typename LambdaIndexer>
PORTABLE_INLINE_FUNCTION Real CalculateGruneisenFromState(
Real const rho, Real const sie, Real const pressure,
[[maybe_unused]] Real const temperature, RealIndexer &density_mat,
RealIndexer &sie_mat, LambdaIndexer &lambdas);

and perturbs the PTE energy at constant density.

Note that in the ``FillEOS()`` and ``ValuesAtReferenceState()`` functions, the
values are all caluclated from density-temperature perturbations and the
appropriate thermodynamic identities. This can lead to slight inconsistencies,
but fewer PTE perturbations are needed as a result.

There is also a public member function to directly perturb the PTE state in
density and temperature, which is what the bulk modulus, ``FillEOS()``, and
``ValuesAtReferenceState()`` functions use:

.. code-block:: cpp

template <typename RealIndexer, typename LambdaIndexer>
PORTABLE_INLINE_FUNCTION void
PerturbPTEStateRT(Real const rho, Real const sie, Real const pressure,
Real const temperature, RealIndexer const &density_mat,
RealIndexer const &sie_mat, LambdaIndexer &lambdas, Real &dedT_R,
Real &dedR_T, Real &dPdT_R, Real &dPdR_T)


.. _EOSPAC: https://laws.lanl.gov/projects/data/eos/eospacReleases.php


4 changes: 2 additions & 2 deletions doc/sphinx/src/using-eos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,6 @@ might look something like this:
eos = EOSBuilder::Modify<ScaledEOS>(eos, scale);
}

.. _eos methods reference section:

CheckParams
------------

Expand All @@ -1030,6 +1028,8 @@ which raise an error and/or print an equation of state specific error
message if something has gone wrong. Most EOS constructors and ways of
building an EOS call ``CheckParams`` by default.

.. _eos methods reference section:

Equation of State Methods Reference
------------------------------------

Expand Down
3 changes: 3 additions & 0 deletions singularity-eos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ register_headers(

# Normal files
base/fast-math/logs.hpp
base/generic_indexer.hpp
base/indexable_types.hpp
base/robust_utils.hpp
base/root-finding-1d/root_finding.hpp
Expand All @@ -38,6 +39,7 @@ register_headers(
base/sp5/singularity_eos_sp5.hpp
eos/default_variant.hpp
base/hermite.hpp
base/tuple_utils.hpp
eos/eos_variant.hpp
eos/eos_stellar_collapse.hpp
eos/eos_ideal.hpp
Expand Down Expand Up @@ -72,6 +74,7 @@ register_headers(
eos/variant_utils.hpp
eos/eos_carnahan_starling.hpp
eos/eos_electrons.hpp
eos/eos_multi_eos.hpp
)

if (SINGULARITY_BUILD_CLOSURE)
Expand Down
62 changes: 62 additions & 0 deletions singularity-eos/base/generic_indexer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//------------------------------------------------------------------------------
// © 2021-2025. Triad National Security, LLC. All rights reserved. This
// program was produced under U.S. Government contract 89233218CNA000001
// for Los Alamos National Laboratory (LANL), which is operated by Triad
// National Security, LLC for the U.S. Department of Energy/National
// Nuclear Security Administration. All rights in the program are
// reserved by Triad National Security, LLC, and the U.S. Department of
// Energy/National Nuclear Security Administration. The Government is
// granted for itself and others acting on its behalf a nonexclusive,
// paid-up, irrevocable worldwide license in this material to reproduce,
// prepare derivative works, distribute copies to the public, perform
// publicly and display publicly, and to permit others to do so.
//------------------------------------------------------------------------------

#ifndef SINGULARITY_EOS_BASE_GENERIC_INDEXER_HPP_
#define SINGULARITY_EOS_BASE_GENERIC_INDEXER_HPP_

#include <utility>

namespace singularity {

template <typename Arr, typename Map>
struct GenericIndexer {
Arr arr_;
Map map_;

template <typename ArrT_, typename MapT_>
constexpr GenericIndexer(ArrT_ &&arr_in, MapT_ &&map_in)
: arr_(std::forward<ArrT_>(arr_in)), map_(std::forward<MapT_>(map_in)) {}

// & : non-const lvalue
template <class I>
constexpr decltype(auto) operator[](I i) & {
return arr_[map_[i]];
}

// const& : const lvalue
template <class I>
constexpr decltype(auto) operator[](I i) const & {
return arr_[map_[i]];
}

// && : rvalue (indexer is a temporary) — forward arr_’s value category
template <class I>
constexpr decltype(auto) operator[](I i) && {
return std::forward<Arr>(arr_)[map_[i]]; // move only if Arr is a value type
}

// const rvalue indexer
template <class I>
constexpr decltype(auto) operator[](I i) const && {
return std::forward<const Arr>(arr_)[map_[i]]; // preserves const
}
};

// CTAD: preserve references for lvalues, decay for rvalues
template <class ArrT_, class MapT_>
GenericIndexer(ArrT_ &&, MapT_ &&) -> GenericIndexer<ArrT_, MapT_>;

} // namespace singularity

#endif // #ifndef SINGULARITY_EOS_BASE_GENERIC_INDEXER_HPP_
Loading