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

Piecewise grids for spiner EOS #330

Merged
merged 56 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
1b7bfa8
builds with chris changes but not yet hierarchical grids
jonahm-LANL Jun 23, 2023
1b4081e
update to spiner main with piecewise grids
jonahm-LANL Aug 4, 2023
a15502a
Merge branch 'jmm/hierarchical-grids' of github.com:lanl/singularity-…
jonahm-LANL Aug 4, 2023
82404ac
merge with main
jonahm-LANL Aug 4, 2023
e85a8fb
fix so it compiles
jonahm-LANL Aug 4, 2023
792e4f7
NGRIDS
jonahm-LANL Aug 4, 2023
ad8d9ae
slowly modifying bounds object to use piecewise grids
jonahm-LANL Aug 4, 2023
16e9a30
merge in main
jonahm-LANL Dec 8, 2023
9f0e683
update to main
jonahm-LANL Jul 29, 2024
d3b5ad1
move bounds into singularity-eos. rewrite it for piecewise grids and …
jonahm-LANL Jul 29, 2024
f2502d3
add table bounds tests
jonahm-LANL Jul 30, 2024
39391be
modified bounds to support 2 and 3 grid modes.
jonahm-LANL Jul 31, 2024
d22d3e9
typos in sesame2spiner
jonahm-LANL Jul 31, 2024
6cde9e4
formatting
jonahm-LANL Jul 31, 2024
3bd173f
Merge branch 'main' into jmm/hierarchical-grids
Yurlungur Jul 31, 2024
b6c2589
fix type issues in compare_to_eospac
jonahm-LANL Jul 31, 2024
3776a93
Merge branch 'jmm/hierarchical-grids' of github.com:lanl/singularity-…
jonahm-LANL Jul 31, 2024
b720356
play with bounds
jonahm-LANL Jul 31, 2024
f80bf9f
num points from PPD took a second log
jonahm-LANL Jul 31, 2024
1037cef
remove print
jonahm-LANL Jul 31, 2024
2f4a61e
it all seems to work pretty nicely
jonahm-LANL Aug 1, 2024
bc2313c
Merge branch 'jmm/hierarchical-grids' of github.com:lanl/singularity-…
jonahm-LANL Aug 1, 2024
9c9d88f
formatting
jonahm-LANL Aug 1, 2024
bb4037c
add documentation
jonahm-LANL Aug 1, 2024
6cef272
Merge branch 'main' into jmm/hierarchical-grids
Yurlungur Aug 1, 2024
42fab44
CHANGELOG
jonahm-LANL Aug 1, 2024
ad4ae77
Merge branch 'jmm/hierarchical-grids' of github.com:lanl/singularity-…
jonahm-LANL Aug 1, 2024
ba5c899
CC
jonahm-LANL Aug 1, 2024
79ce8c9
add robustness for refined region out of table bounds or normal densi…
jonahm-LANL Aug 6, 2024
2ab9255
add helium, which is another ill-behaved one
jonahm-LANL Aug 6, 2024
06e81a2
Merge branch 'jmm/hierarchical-grids' of github.com:lanl/singularity-…
jonahm-LANL Aug 6, 2024
1aba45f
format
jonahm-LANL Aug 6, 2024
1dbb8fe
chad comments part 1
jonahm-LANL Aug 6, 2024
1374d7f
add ability to set rhoFineMin, rhoFineMax
jonahm-LANL Aug 6, 2024
058033a
fix bugs
jonahm-LANL Aug 6, 2024
eb6bf66
formating
jonahm-LANL Aug 6, 2024
ac0db6e
add diagram for mesh. fix some build issues with the docs.
jonahm-LANL Aug 6, 2024
a9f23d2
final chad comments
jonahm-LANL Aug 6, 2024
8db13ef
crazy
jonahm-LANL Aug 6, 2024
805e168
figured out error in tests
jonahm-LANL Aug 6, 2024
efc894c
Update doc/sphinx/src/models.rst
Yurlungur Aug 11, 2024
dac88bc
Update doc/sphinx/src/models.rst
Yurlungur Aug 11, 2024
c103b51
Update sesame2spiner/generate_files.cpp
Yurlungur Aug 11, 2024
e0425fe
add const to piecewise vars
Yurlungur Aug 11, 2024
fed7481
Merge branch 'main' into jmm/hierarchical-grids
Yurlungur Aug 11, 2024
c1d2040
add a bunch of const calls
jonahm-LANL Aug 11, 2024
f6363d3
jhp comments
jonahm-LANL Aug 11, 2024
7ed764f
oops REAL TOL not properly declared
jonahm-LANL Aug 11, 2024
fb724a6
more typos in the tests
jonahm-LANL Aug 12, 2024
2c74319
typos
jonahm-LANL Aug 12, 2024
0dc46c4
update spiner so backwards compatibility with hierarchical grids reta…
jonahm-LANL Aug 12, 2024
bd485f9
dholladay comments
jonahm-LANL Aug 12, 2024
7b18911
remove unnecessary line
jonahm-LANL Aug 12, 2024
6e36ffc
change bounds file name
jonahm-LANL Aug 12, 2024
0260d0c
cascade of const correctness
jonahm-LANL Aug 13, 2024
b2db905
these have to be const
jonahm-LANL Aug 13, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
## Current develop

### Added (new features/APIs/variables/...)
- [[PR330]](https://github.com/lanl/singularity-eos/pull/330) Piecewise grids for Spiner EOS.

### Fixed (Repair bugs, etc)
- [[PR330]](https://github.com/lanl/singularity-eos/pull/330) Includes a fix for extrapolation of specific internal energy in SpinerEOS.
- [[PR401]](https://github.com/lanl/singularity-eos/pull/401) Fix for internal energy scaling in PTE closure

### Changed (changing behavior/API/variables/...)
Expand Down
8 changes: 4 additions & 4 deletions doc/sphinx/src/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,11 @@ packages. This can save lots of time! Note, however, that external
packages are loosely constrained and may not be correctly configured for
the requested package.

*NB*: By default, Spack will try to download the package source from the
repository associated with the package. This behavior can be overrided
with Spack *mirrors* , but that is beyond the scope of this doc.
.. note::

.. code:: bash
By default, Spack will try to download the package source from the
repository associated with the package. This behavior can be overrided
with Spack *mirrors* , but that is beyond the scope of this doc.

Now, we can use Spack similarly to ``module load``,

Expand Down
14 changes: 7 additions & 7 deletions doc/sphinx/src/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,19 @@ instantiated when ``singularity-eos`` is compiled. Therefore to
exercise all code paths, it is best to create an ``EOS`` type
instantiated as

.. code-block:: c++
.. code-block:: cpp

#include <singularity-eos/eos/eos.hpp>
using EOS = singularity::Variant<MyNewEOS>;``.
Yurlungur marked this conversation as resolved.
Show resolved Hide resolved
EOS my_eos = MyNewEOS(parameter1, parameter2, ...)
#include <singularity-eos/eos/eos.hpp>
using EOS = singularity::Variant<MyNewEOS, ...>;
EOS my_eos = MyNewEOS(parameter1, parameter2, ...)

in order to properly test the functionality of a new EOS. Simply using the
new class as the type such as

.. code-block:: c++
.. code-block:: cpp

#include <singularity-eos/eos/eos.hpp>
auto my_eos = my_new_eos(parameter1, parameter2, ...)
#include <singularity-eos/eos/eos.hpp>
auto my_eos = my_new_eos(parameter1, parameter2, ...)

won't ensure that the new EOS is working correctly in singularity with the
static polymorphism of the ``EOS`` type.
Expand Down
4 changes: 2 additions & 2 deletions doc/sphinx/src/integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ or setting ``CMAKE_PREFIX_PATH`` manually, a CMake project can integrate
Singularity-EOS via ``find_package(singularity-eos)`` and using the provided
targets to link to it.

.. code:: cmake
.. code::

find_package(singularity-eos)
...
Expand Down Expand Up @@ -40,7 +40,7 @@ dependencies, but only the compiled Fortran bindings provided by
Singularity-EOS. To avoid unnecessary dependency checks by CMake, a Fortran
project would integrate Singularity-EOS as follows:

.. code:: cmake
.. code::

find_package(singularity-eos COMPONENTS Library)
...
Expand Down
123 changes: 111 additions & 12 deletions doc/sphinx/src/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1364,10 +1364,12 @@ the energy offset of the products EOS is given by
Practically, this means :math:`e_0` should be positive for any energetic material.

To provide the energy offset to the Davis Products EOS, `the energy shift
modifier<modifiers shifted EOS>`_ should be used. Note that the convention there
Yurlungur marked this conversation as resolved.
Show resolved Hide resolved
modifier`_ should be used. Note that the convention there
is that the shift is positive, so :math:`-e_0` should be provided to the shift
modifier.

.. _the energy shift modifier: modifiers shifted EOS

The constructor for the Davis Products EOS is

.. code-block:: cpp
Expand Down Expand Up @@ -1471,8 +1473,7 @@ key-value pairs. For exampe the following input deck is for air:

matid = 5030
# These set the number of grid points per decade
# for each variable. The default is 50 points
# per decade.
# for each variable.
numrho/decade = 40
numT/decade = 40
numSie/decade = 40
Expand All @@ -1491,16 +1492,114 @@ key-value pairs. For exampe the following input deck is for air:
shrinklTBounds = 0.15
shrinkleBounds = 0.5

The only required value in an input file is the matid, in this
case 5030. All other values will be inferred from the original sesame
database if possible and if no value in the input file is
provided. Comments are prefixed with ``#``.
Comments are prefixed with ``#``. `eospac`_ uses environment variables
and files to locate files in the `sesame`_ database, and
``sesame2spiner`` uses `eospac`_. So the location of the ``sesame``
database need not be provided by the command line. For how to specify
`sesame`_ file locations, see the `eospac`_ manual.
Yurlungur marked this conversation as resolved.
Show resolved Hide resolved

Piecewise Spiner Grids
````````````````````````

``sesame2spiner`` also supports grids with different resolutions in
different parts of the table. We call these **piecewise** grids. By
default grids are now piecewise. Piecewise grids can be disabled with

.. code-block::

# defaults are true
piecewiseRho = false
piecewiseT = false
piecewiseSie = false

These options may be true or false. The default is true. When
piecewise grids are active, the density-temperature (or
density-energy) grid is built as a Cartesian product grid of grids of
non-uniform resolutions. The density grid gets split into three
pieces, a region ``[rhoMin, rhoFineMin]``, a region ``[rhoFineMin,
rhoFineMax]``, and a region ``[rhoFineMin, rhoMax]``. The
``numrho/decade`` parameter sets the number of points per decade in
the central refined region. The regions at lower and higher density
have ``rhoCoarseFactorLo`` and ``rhoCoarseFactorHi`` fewer points per
decade respectively compared to the finer region.

Typically the fine region should be roughly centered around the normal
density for a material, which is usually a challenging region to
capture. If you neglect to set ``rhoFineMin`` and ``rhoFineMax``,
``sesame2spiner`` will set the central refined region to be a region
of diameter ``rhoFineDiameterDecades`` (in log space) around the
material's normal density.

The temperature grid has two regions, a more finely spaced region at
low temperatures and a less finely spaced region at high
temperatures. The regions are spearated by a temperature
``TSplitPoint``. The default is :math:`10^4` Kelvin. The energy grid
follows the temperature grid, with the energy split point
corresponding to the temperature split point. The coarser
high-temperature temperature and energy grids are coarsened by a
factor of ``TCoarseFactor`` and ``sieCoarseFactor`` respectively.

A diagram of a density-temperature grid is shown below. The region
with temperatures below ``TSplitPoint`` is refined in temperature. The
region between ``rhoFineMin`` and ``rhoFineMax`` is refined in
density.

.. image:: phase_diagram.png
:width: 400
:alt: An example piecewise density-temperature grid.


Thus the input block for piecewise grid might look like this:

.. code-block::

# Below, all right-hand-sides are set to their default values.
piecewiseRho = true
piecewiseT = true
piecewiseSie = true

# the fine resolution for rho.
numrho/decade = 350
# width of the fine region for rho
rhoFineDiameterDecades = 1.5
# the lower density region is 3x less refined
rhoCoarseFactorLo = 3
# the higher density region is 5x less refined
rhoCoarseFactorHi = 5

# the fine resolution for T
numT/decade = 100
# the point demarking the coarse and fine regions in temperature
TSplitPoint = 1e4
# it's usually wise to to not let
# temperature get too small in log space if you do this
Tmin = 1
# The coarser region (above the split point) is 50 percent less refined
TCoarseFactor = 1.5

# energy has the split point sie(rhonormal, TSplitPoint)
# but we may still specify the resolution
numSie/decade = 100
sieCoarseFactor = 1.5
jhp-lanl marked this conversation as resolved.
Show resolved Hide resolved

.. note::

For all grid types, the only required value in an input file is the
matid. Table bounds and normal density will be inferred from the
sesame metadata if possible and if no value in the original input
file is provided. Table densities and positions and sizes of refined
regions are not inferred from the table, but are chosen with
the default values listed in the above code block.

.. note::

`eospac`_ uses environment variables and files to locate files in the
`sesame`_ database, and ``sesame2spiner`` uses `eospac`_. So the
location of the ``sesame`` database need not be provided by the
command line. For how to specify `sesame`_ file locations, see the
`eospac`_ manual.
Both the flat and hierarchical grids attempt to align their grids so
that there is a grid point in density and temperature exactly at
room temperature and normal density. This is because normal density
and room temperature is a particularly important point in phase
space, as it is the point in phase space a piece of material sitting
on your desk would be at. This is called an *anchor* point for the
mesh.

SAP Polynomial EOS
``````````````````
Expand Down
Binary file added doc/sphinx/src/phase_diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions doc/sphinx/src/phase_diagram.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw[dashed] (4.5, 0) -- ++(0,8);
\draw (4.5, 0) node[below] {$\rho$ normal};
\draw[red, dashed] (2.5, 0) node[below] {rhoFineMin} -- ++(0,8);
\draw[red, dashed] (6.5, 0) node[below] {rhoFineMax} -- ++(0,8);
\draw[red, |-|] (2.5,8.5) -- (6.5,8.5);
\draw[red] (4.5, 8.5) node[above] {rhoFineDiameter};

\draw[blue, dashed] (0, 5) -- ++(8, 0) node[right] {TSplit};
\draw[dashed] (0, 2.5) -- ++(8, 0) node[right] {TAnchor $=298$ K};

% Draw axes
\draw[ultra thick,->] (0,0) -- (9,0) node[below] {\huge $\log_{10}\rho$};
\draw[ultra thick,->] (0,0) -- (0,9) node[left] {\huge $\log_{10}T$};

\draw (4.5, 2.5) node {\huge fine region};
\draw (4.5, 7) node {\huge coarse in T};

\draw (1.25, 1) node {\large coarse in $\rho$};
\draw (7.75, 1) node {\large coarse in $\rho$};

\draw (1.25, 7) node {\large coarse in all};
\draw (7.75, 7) node {\large coarse in all};
\end{tikzpicture}

\end{document}
2 changes: 1 addition & 1 deletion doc/sphinx/src/sphinx-doc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Building documentation locally

While you can rely on the CI to build the documentation associated with your
branch, you can also very easily build sphinx documentation locally through
python. These instructions also _do not_ require admin access and are usable
python. These instructions also **do not** require admin access and are usable
with shared machines or python distributions.

First, ensure that you are running a modern version of python (i.e. python 3 of
Expand Down
8 changes: 6 additions & 2 deletions doc/sphinx/src/using-eos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,17 @@ A modified equation of state can be built up iteratively. To check if
the equation of state currently stored in the variant can modified,
you may call

.. cpp:function:: bool ModifiedInVariant<Mod>() const;
.. code-block:: cpp

bool ModifiedInVariant<Mod>() const;

where ``Mod`` is the type of the modifier you want to apply, for
example ``ShiftedEOS``. If this function returns true, then you can
apply a modifier with the function

.. cpp:function:: Variant Modify<Mod>(Args &&..args) const;
.. code-block:: cpp

Variant Modify<Mod>(Args &&..args) const;

where again ``Mod`` is the modifier you wish to apply, and ``args``
are the arguments to the constructor for that modifier, e.g., the
Expand Down
21 changes: 21 additions & 0 deletions sesame2spiner/examples/aluminum.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ======================================================================
# Example input deck for sesame2spiner,
# a tool for converting eospac to spiner
# Author: Jonah Miller ([email protected])
# © 2024. 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.
# ======================================================================

matid=3720
name=aluminum
rhomin = 1e-5
Tmin = 1
Comment on lines +18 to +21
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the addition to this MR, was it intended to show/test something related to piecewise grids beyond default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly it's here because I tested aluminum. Also I found that the minimum density/temperatures provided by the database are frequently unnecessarily low.

18 changes: 18 additions & 0 deletions sesame2spiner/examples/helium.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ======================================================================
# Example input deck for sesame2spiner,
# a tool for converting eospac to spiner
# Author: Jonah Miller ([email protected])
# © 2024. 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.
# ======================================================================
matid = 5762
name = helium
16 changes: 12 additions & 4 deletions sesame2spiner/examples/steel.dat
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@

matid = 4272
name = steel
rhomin = 1e-2
rhomin = 1e-5
Tmin = 1

#piecewiseRho = false
#piecewiseT = false
#piecewiseSie = false
#numrho = 1334
#numT = 738
#numsie = 634

# These shrink logarithm of bounds
# by a fraction of the total interval <= 1
shrinklRhoBounds = 0.15,
shrinklTBounds = 0.15,
shrinkleBounds = 0.5
#shrinklRhoBounds = 0.15,
#shrinklTBounds = 0.15,
#shrinkleBounds = 0.5
4 changes: 3 additions & 1 deletion sesame2spiner/examples/unit_tests/copper.dat
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@

matid=3337
name=copper
rhomin=0.

piecewiseRho = false
numrho/decade = 50
Loading
Loading