Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pt space pte solver #453

Merged
merged 51 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
c84dbe3
starting to add in stuff Daniel wrote, piecewise so I can check it al…
jonahm-LANL Jan 2, 2025
45e8458
add jacobian
jonahm-LANL Jan 3, 2025
6f5887b
PTE space PTE solver compiles at least
jonahm-LANL Jan 8, 2025
0fdb5db
add to simplest test but it fails lol
jonahm-LANL Jan 8, 2025
0d1e9b8
Merge branch 'jmm/pt-of-re-everywhere' into jmm/pt-space-pte-solver
jonahm-LANL Jan 8, 2025
693d837
tweak initial guess
jonahm-LANL Jan 8, 2025
65c8a44
Merge branch 'jmm/pt-of-re-everywhere' into jmm/pt-space-pte-solver
jonahm-LANL Jan 8, 2025
f0093d9
It seems to work, at least tentatively
jonahm-LANL Jan 8, 2025
eb632f4
docs
jonahm-LANL Jan 8, 2025
b612c66
changelog
jonahm-LANL Jan 8, 2025
a01642d
CC
jonahm-LANL Jan 8, 2025
52891f4
not the boolean I meant to express
jonahm-LANL Jan 8, 2025
83dbba5
unused var
jonahm-LANL Jan 8, 2025
9002ac4
oops... big typo
jonahm-LANL Jan 8, 2025
47445a4
Merge branch 'main' into jmm/pt-space-pte-solver
jonahm-LANL Jan 9, 2025
369dae4
max press AT temp
jonahm-LANL Jan 9, 2025
2d98b03
add OMP_PROC_BIND for unit testing
jonahm-LANL Jan 13, 2025
4d0ef18
split scratch
jonahm-LANL Jan 13, 2025
76c97d2
update test pte to split profiling
jonahm-LANL Jan 13, 2025
383486b
move OMP_PROC_BIND option to BUILD AND TEST
jonahm-LANL Jan 23, 2025
3ce2fda
move OMP_PROC_BIND option to BUILD AND TEST
jonahm-LANL Jan 23, 2025
b8c7a67
Add multi ideal gas PTE test that checks for agreement between PT spa…
jonahm-LANL Jan 23, 2025
107d971
Fix residual to correctly check for mass fraction weighted energy
jonahm-LANL Jan 23, 2025
e2318be
Merge branch 'main' into jmm/pt-space-pte-solver
jonahm-LANL Jan 23, 2025
4c7933a
remove databox dependency
jonahm-LANL Jan 23, 2025
03700d8
fix loops that cause warnings
jonahm-LANL Jan 23, 2025
03d122d
int to size_t
jonahm-LANL Jan 23, 2025
967889d
more size_t conversions
jonahm-LANL Jan 23, 2025
9fde279
no ports-of-call-array
jonahm-LANL Jan 23, 2025
8541df8
fix formatting and typos
jonahm-LANL Jan 23, 2025
977a441
put test pte ideal in generator expression
jonahm-LANL Jan 23, 2025
37c40f8
make sure solver sets pressure and temperature and then gets new micr…
jonahm-LANL Jan 24, 2025
7e50d95
control tolerances so densities match after fixing init issue
jonahm-LANL Jan 24, 2025
20977c3
test PTE infrastructure now supports arbitrary solver... though this …
jonahm-LANL Jan 24, 2025
09780ea
oops forgot to set nsuccess
jonahm-LANL Jan 24, 2025
23d0b4e
Works with multiple kind of EOS
jonahm-LANL Jan 26, 2025
9399573
update closure documentation with correct formulae
jonahm-LANL Jan 26, 2025
dedd291
Jacobian inversion analytic
jonahm-LANL Jan 26, 2025
a20c616
CC
jonahm-LANL Jan 26, 2025
d02454c
ok good enough
jonahm-LANL Jan 26, 2025
e491cfa
Update doc/sphinx/src/using-closures.rst
Yurlungur Feb 1, 2025
38d62d3
Update doc/sphinx/src/using-closures.rst
Yurlungur Feb 1, 2025
efa952d
Merge branch 'main' into jmm/pt-space-pte-solver
jonahm-LANL Feb 1, 2025
dc8ba34
heading levels
jonahm-LANL Feb 1, 2025
232141d
update docs based on Jeff's comments
jonahm-LANL Feb 1, 2025
a8e8231
more detailed performance discussion
jonahm-LANL Feb 1, 2025
4e6c685
JHP comments on mixed_cell_models.hpp
jonahm-LANL Feb 1, 2025
8c1a445
prepare for adding PT-space solver
jonahm-LANL Feb 1, 2025
c62efe1
Add 3 state PTE test
jonahm-LANL Feb 1, 2025
ab76595
comment
jonahm-LANL Feb 1, 2025
33dcce5
CC
jonahm-LANL Feb 1, 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 .gitlab/build_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ cmake_test() {
(
source ${BUILD_ENV}
export CTEST_OUTPUT_ON_FAILURE=1
export OMP_PROC_BIND=false
if ${BUILD_WITH_CTEST}; then
ctest -V -S .gitlab/build_and_test.cmake,Test,$REPORT_ERRORS
else
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Current develop

### Added (new features/APIs/variables/...)
- [[PR453]](https://github.com/lanl/singularity-eos/pull/453) A PT space PTE solver
- [[PR444]](https://github.com/lanl/singularity-eos/pull/444) Add Z split modifier and electron ideal gas EOS

### Fixed (Repair bugs, etc)
Expand Down
85 changes: 68 additions & 17 deletions doc/sphinx/src/using-closures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ These are two non-linear residual equations that will need to be solved. In
``singularity-eos`` a Newton-Raphson method is used that first relies on
Taylor-expanding the equations about the equilibrium state in order to cast the
equations in terms of an update to the unknowns. The expansion about an
equilibrium state described by :math:`f_i^*(\rho_i, y_i)` and
:math:`u_i^*(\rho_i, y_i)` is
equilibrium state described by :math:`f_i^*(x_i, y_i)` and
:math:`u_i^*(x_i, y_i)` is

.. math::

Expand All @@ -217,17 +217,16 @@ new update is found until some tolerance is reached. When a good initial guess
is used (such as a previous PTE state), some algorithms may converge in
relatively few iterations.

The choice of :math:`x` and :math:`y` is discussed below, but crucially it
determines the number of equations and unknowns needed to specify the system.
For example, if pressure, :math:`P`, and temperature, :math:`T`, are chosen,
then the subscripts are eliminated since we seek a solution where all materials
have the same temperature and pressure. In this formulation, there are two
equations and two unkowns, but due to the difficulty of inverting an
equation of state to be a function of pressure and temperature,
``singularity-eos`` does not have any PTE solvers that are designed to use
pressure and temperature as independent variables.

Instead, all of the current PTE solvers in ``singularity-eos`` are cast in terms
The choice of :math:`x` and :math:`y` is discussed below, but
crucially it determines the number of equations and unknowns needed to
specify the system. For example, if pressure, :math:`P`, and
temperature, :math:`T`, are chosen, then the subscripts are eliminated
since we seek a solution where all materials have the same temperature
and pressure. (See :ref:`pressure-temperature-formulation`.) In this
formulation, there are two equations and two unkowns, and one such
solver is described below.

Most of the current PTE solvers in ``singularity-eos`` are cast in terms
of volume fraction and some other independent variable. Using material volume
fractions introduces :math:`N - 1` additional unknowns since all but one of the
volume fractions are independent from each other. The assumption of pressure
Expand Down Expand Up @@ -278,9 +277,61 @@ choice of the second independent variable is discussed below and has
implications for both the number of additional unknowns and the stability of the
method.

.. _pressure-temperature-formulation:
The Pressure-Temperature Formulation
`````````````````````````````````````

An obvious choice is to treat the independent variables as pressure
and temperature. Then one has only two equations and two unknowns. The
residual contains only the volume fraction and energy summmation rules
described above. Taylor expanding these residuals about fixed
temeprature and pressure points leads to two residual equations of the
form

.. math::

1 - \sum_{i=0}^{N-1} f_i = (T^* - T) \sum_{i = 0}^{N-1} \left(\frac{\partial f_i}{\partial T}\right)_P + (P^* - P) \sum_{i = 0}^{N-1} \left(\frac{\partial f_i}{\partial P}\right)_T\\
u_{tot} - \sum_{i=0}^{N-1} u_i = (T^* - T) \sum_{i = 0}^{N-1} \left(\frac{\partial u_i}{\partial T}\right)_P + (P^* - P) \sum_{i = 0}^{N-1} \left(\frac{\partial u_i}{\partial P}\right)_T

However, derivatives in the volume fraction are not easily
accessible. To access them, we leverage the fact that

.. math::

\bar{\rho}_i = \rho_i f_i,

and thus

.. math::

d f_i = - \frac{\overline{\rho}}{\rho_i^2} d \rho_i.

Thus the residual can be recast as

.. math::

f_\mathrm{tot} - \sum_{i=0}^{N-1} = -(T^* - T) \sum_{i = 0}^{N-1} \frac{\bar{\rho}_i}{\rho_i^2} \left(\frac{\partial \rho_i}{\partial T}\right)_P - (P^* - P) \sum_{i = 0}^{N-1} \frac{\bar{\rho}_i}{\rho_i^2} \left(\frac{\partial \rho_i}{\partial P}\right)_T\\
u_\mathrm{tot} - u_i = (T^* - T) \sum_{i = 0}^{N-1} \left(\frac{\partial u_i}{\partial T}\right)_P + (P^* - P) \sum_{i = 0}^{N-1} \left(\frac{\partial u_i}{\partial P}\right)_T

where :math:`\rho_{\mathrm{tot}}` is the sum of densities over all
materials. These residual equations can then be cast as a matrix
equation to solve for pressure and temperature.

The primary advantage of the pressure-temperature space solver is that
it has only two independent variables and two unknowns, meaning the
cost scales only linearly with the number of materials, not
quadratically (or worse). The primary disadvantage, is that most
equations of state are not formulated in terms of pressure and
temperature, meaning additional inversions are required. In the case
where a root-find is required for this inversion, performance may
suffer for a small number of materials compared to a different
formulation.

In the code, this method is referred to as ``PTESolverPT``.

.. _density-energy-formalism:
The Density-Energy Formulation
''''''''''''''''''''''''''''''
```````````````````````````````

One choice is to treat volume fractions and material energies as independent
quantities, but the material energies provide :math:`N - 1` additional
Expand Down Expand Up @@ -319,7 +370,7 @@ more stable and performant and is usually preferrred to this formulation.
In the code this is referred to as the ``PTESolverRhoU``.

The Density-Temperature Formulation
'''''''''''''''''''''''''''''''''''
````````````````````````````````````

Another choice is to treat the temperature as an independent variable, requiring
no additional equations. The energy residual equation then takes the form
Expand Down Expand Up @@ -387,7 +438,7 @@ material pressures.
In the code this is referred to as the ``PTESolverFixedP``.

Using the Pressure-Temperature Equilibrium Solver
'''''''''''''''''''''''''''''''''''''''''''''''''
```````````````````````````````````````````````````

The PTE machinery is implemented in the
``singularity-es/closure/mixed_cell_models.hpp`` header. It is
Expand Down Expand Up @@ -573,7 +624,7 @@ example of the PTE solver machinery in use, see the ``test_pte.cpp``
file in the tests directory.

Initial Guesses for PTE Solvers
'''''''''''''''''''''''''''''''
`````````````````````````````````

As is always the case when solving systems of nonlinear equations, good initial
guesses are important to ensure rapid convergence to the solution. For the PTE
Expand Down
Loading