Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into rberger_unit_system_m…
Browse files Browse the repository at this point in the history
…odifier
  • Loading branch information
rbberger committed Aug 23, 2023
2 parents 456b074 + dd5d8d4 commit 4a000be
Show file tree
Hide file tree
Showing 40 changed files with 2,493 additions and 982 deletions.
11 changes: 9 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ variables:
SINGULARITY_EOS_GCC_VERSION: "9.3.0"
SINGULARITY_EOS_OPENMPI_VERSION: "4.1.3"
SINGULARITY_EOS_CUDA_VERSION: "11.6.0"
SINGULARITY_EOS_BUILD_TYPE: "RelWithDebInfo"
SINGULARITY_EOS_SPACK_SPEC: "singularity-eos@main+mpi+hdf5+python+tests%gcc@${SINGULARITY_EOS_GCC_VERSION} ^openmpi@${SINGULARITY_EOS_OPENMPI_VERSION}"
COLOR_CYAN: '\033[1;36m'
COLOR_PLAIN: '\033[0m'
Expand Down Expand Up @@ -45,10 +46,13 @@ before_script:
##########################

.buildtype_debug: &buildtype_debug
BUILD_TYPE: "Debug"
SINGULARITY_EOS_BUILD_TYPE: "Debug"

.buildtype_release: &buildtype_release
BUILD_TYPE: "Release"
SINGULARITY_EOS_BUILD_TYPE: "Release"

.buildtype_relDebugInfo: &buildtype_relDebugInfo
SINGULARITY_EOS_BUILD_TYPE: "RelWithDebInfo"

.gpu: &gpu
SINGULARITY_USE_CUDA: "true"
Expand Down Expand Up @@ -133,6 +137,7 @@ before_script:
- cd build
- |
cmake -DCMAKE_INSTALL_PREFIX=${CI_PROJECT_DIR}/install ${SINGULARITY_CMAKE_CXX_COMPILER_FLAG} \
-DCMAKE_BUILD_TYPE=${SINGULARITY_EOS_BUILD_TYPE} \
-DSINGULARITY_USE_EOSPAC=ON \
-DSINGULARITY_USE_SPINER=ON \
-DSINGULARITY_USE_SPINER_WITH_HDF5=ON \
Expand Down Expand Up @@ -190,13 +195,15 @@ test_gnu_power9_gpu:
extends: .test
variables:
<<: *power9
<<: *buildtype_release
<<: *gpu

test_x86_volta_gpu:
<<: *job_def
extends: .test
variables:
<<: *x86volta
<<: *buildtype_release
<<: *gpu

install_gnu_skylake_fort:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [[PR269]](https://github.com/lanl/singularity-eos/pull/269) Add SAP Polynomial EoS

### Fixed (Repair bugs, etc)
- [[PR291]](https://github.com/lanl/singularity-eos/pull/291) package.py updates to reflect new CMake options
- [[PR290]](https://github.com/lanl/singularity-eos/pull/290) Added target guards on export config
- [[PR288]](https://github.com/lanl/singularity-eos/pull/288) Don't build tests that depend on spiner when spiner is disabled
- [[PR287]](https://github.com/lanl/singularity-eos/pull/287) Fix testing logic with new HDF5 options
Expand All @@ -21,6 +22,7 @@

### Added (new features/APIs/variables/...)
- [[PR265]](https://github.com/lanl/singularity-eos/pull/265) Add missing UnitSystem modifier combinations to variant and EOSPAC
- [[PR279]](https://github.com/lanl/singularity-eos/pull/279) added noble-abel EoS
- [[PR274]](https://github.com/lanl/singularity-eos/pull/274) added a stiffened gas EoS
- [[PR254]](https://github.com/lanl/singularity-eos/pull/254) added ability to peel off modifiers as needed
- [[PR250]](https://github.com/lanl/singularity-eos/pull/250) added mass fraction output to stellar collapse eos
Expand All @@ -42,6 +44,7 @@

### Infrastructure (changes irrelevant to downstream codes)
- [[PR190]](https://github.com/lanl/singularity-eos/pull/190) update CI on re-git
- [[PR245]](https://github.com/lanl/singularity-eos/pull/245) Separating get_sg_eos to other files. Build/compilation improvements, warning fixes/suppression.

### Removed (removing behavior/API/varaibles/...)

Expand Down
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
# publicly and display publicly, and to permit others to do so.
# ------------------------------------------------------------------------------#

# We want to stay near to latest, as more compilers and third-party libraries
# are supported. However, uptake of new CMake releases can be slow. 20230403:
# version 3.19 is available on all testing platforms
cmake_minimum_required(VERSION 3.19)

# Disable "in-source" builds
Expand Down Expand Up @@ -51,9 +48,10 @@ option(SINGULARITY_USE_FORTRAN "Enable fortran bindings" ON)
option(SINGULARITY_USE_KOKKOS "Use Kokkos for portability" OFF)
option(SINGULARITY_USE_EOSPAC "Enable eospac backend" OFF)

#TODO This should be dependent option (or fortran option)
option(SINGULARITY_BUILD_CLOSURE "Mixed Cell Closure" ON)

cmake_dependent_option(SINGULARITY_USE_CUDA "Use CUDA backend of Kokkos" ON
cmake_dependent_option(SINGULARITY_USE_CUDA "Use CUDA backend of Kokkos" OFF
"SINGULARITY_USE_KOKKOS" OFF)
cmake_dependent_option(
SINGULARITY_USE_KOKKOSKERNELS "Use KokkosKernels for LA routines" ON
Expand Down
1 change: 0 additions & 1 deletion cmake/submodule_configs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ macro(singularity_cmake_config pkg)
if(SINGULARITY_USE_CUDA)
set(Kokkos_ENABLE_CUDA ON CACHE BOOL "" FORCE)
set(Kokkos_ENABLE_CUDA_LAMBDA ON CACHE BOOL "" FORCE)
set(Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE ON CACHE BOOL "" FORCE)
endif()
elseif(${pkg} STREQUAL "KokkosKernels")
# Disable TPLs
Expand Down
12 changes: 6 additions & 6 deletions doc/sphinx/src/building.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Overview
========
Building `singularity-eos`
==========================

The ``singularity-eos`` build system is designed with two goals in mind

Expand Down Expand Up @@ -53,15 +53,15 @@ Dependencies
====================================== =============================== ===========================================
Package Name Distribution Comment
====================================== =============================== ===========================================
`spiner`_ submodule [*]_ / external [*]_ Required
`ports-of-call`_ submodule / external Required
`mpark_variant`_ submodule / external Required
`spiner`_ submodule [*]_ / external [*]_ Optional; enhanced backend for EOS tables
`hdf5`_ external only Optional; used for table I/O
`eospac`_ external only Optional; used for sesame tables.
`kokkos`_ submodule / external Optional; enables GPU offloading.
`Eigen`_ submodule / external Optional; used for linear algebra on the CPU when doing mixed-cell closures.
`kokkos-kernels`_ submodule / external Optional; used for linear algebra on the GPU when doing mixed-cell closures.
`pybind11`_ external / fetchable [*]_ Optional;
`pybind11`_ external / fetchable [*]_ Optional
====================================== =============================== ===========================================

.. [*] availible as a git submodule for in-tree builds
Expand Down Expand Up @@ -105,6 +105,7 @@ The main CMake options to configure building are in the following table:
``SINGULARITY_USE_FORTRAN`` ON Enable Fortran API for equation of state.
``SINGULARITY_USE_KOKKOS`` OFF Uses Kokkos as the portability backend. Currently only Kokkos is supported for GPUs.
``SINGULARITY_USE_EOSPAC`` OFF Link against EOSPAC. Needed for sesame2spiner and some tests.
``SINGULARITY_BUILD_CLOSURE`` OFF Build the mixed cell closure models
``SINGULARITY_BUILD_TESTS`` OFF Build test infrastructure.
``SINGULARITY_BUILD_PYTHON`` OFF Build Python bindings.
``SINGULARITY_INVERT_AT_SETUP`` OFF For tests, pre-invert eospac tables.
Expand Down Expand Up @@ -146,8 +147,7 @@ preconditions:
============================================== ================================================================================= ===========================================
``SINGULARITY_USE_SPINER_WITH_HDF5`` ``SINGULARITY_USE_SPINER=ON`` Requests that ``spiner`` be configured for ``HDF5`` support.
``SINGULARITY_USE_CUDA`` ``SINGULARITY_USE_KOKKOS=ON`` Target nvidia GPUs for ``Kokkos`` offloading.
``SINGULARITY_USE_KOKKOSKERNELS`` ``SINGULARITY_USE_KOKKOS=ON`` Use Kokkos Kernels for linear algebra. Needed for mixed cell closure models on GPU.
``SINGULARITY_BUILD_CLOSURE`` ``SINGULARITY_USE_KOKKOS=ON`` ``SINGULARITY_USE_KOKKOSKERNELS=ON`` Mixed cell closure.
``SINGULARITY_USE_KOKKOSKERNELS`` ``SINGULARITY_USE_KOKKOS=ON`` ``SINGULARITY_BUILD_CLOSURE=ON`` Use Kokkos Kernels for linear algebra. Needed for mixed cell closure models on GPU.
``SINGULARITY_BUILD_SESAME2SPINER`` ``SINGULARITY_USE_SPINER=ON`` ``SINGULARITY_USE_SPINER_WITH_HDF5=ON`` Builds the conversion tool sesame2spiner which makes files readable by SpinerEOS.
``SINGULARITY_BUILD_STELLARCOLLAPSE2SPINER`` ``SINGULARITY_USE_SPINER=ON`` ``SINGULARITY_USE_SPINER_WITH_HDF5=ON`` Builds the conversion tool stellarcollapse2spiner which optionally makes stellar collapse files faster to read.
``SINGULARITY_TEST_SESAME`` ``SINGULARITY_BUILD_TESTS=ON`` ``SINGULARITY_BUILD_SESAME2SPINER=ON`` Test the Sesame table readers.
Expand Down
60 changes: 60 additions & 0 deletions doc/sphinx/src/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

.. _WillsThermo: https://www.osti.gov/biblio/1561015

.. _NobleAbel: https://doi.org/10.1063/5.0079187

.. _StiffGas: https://doi.org/10.1016/j.ijthermalsci.2003.09.002


Expand Down Expand Up @@ -482,6 +484,64 @@ these values are not set, they will be the same as those returned by the
conditions are given, the return values of the :code:`ValuesAtReferenceState()`
function will not be the same.

Noble-Abel
``````````

The implementation here was influenced by the reference `NobleAbel`_. The Noble-Abel (aka Clausius I or Hirn) model in ``singularity-eos`` takes
the form

.. math::
P = \frac{ \rho (e-q) (\gamma-1) }{ 1 - b \rho }
.. math::
e = C_V T + q,
where quantities are similar to the ideal gas law with the exception of covolume (:math:`b`) and offset internal energy (:math:`q`).
It should be noted that covolume is physically significant as it represents the maximum compressibility of the gas, and as a result it should be non-negative.

The entropy for the Noble-Abel EoS is given by

.. math::
S = C_V \ln\left(\frac{T}{T_0}\right) + C_V (\gamma-1) \ln\left(\frac{v - b}
{v_0 - b}\right) + q',
where :math:`S(\rho_0,T_0)=q'`. By default, :math:`T_0 = 298` K and the
reference density is given by

.. math::
\rho_0 = \frac{P_0}{C_V T_0(\gamma-1) + bP_0},
where :math:`P_0` is by default 1 bar.

The settable parameters for this EOS are :math:`\gamma-1`, specific
heat capacity (:math:`C_V`), covolume (:math:`b`) and offset internal energy (:math:`q`). Optionally, the reference state for the entropy calculation can
be provided by setting the reference temperature, pressure, and entropy offset.

The ``NobleAbel`` EOS constructor has four arguments: ``gm1``, which is :math:`\gamma-1`; ``Cv``, the
specific heat :math:`C_V`; :math:`b`, the covolume; and :math:`q`, the internal energy offset.

.. code-block:: cpp
NobleAbel(Real gm1, Real Cv, Real b, Real q)
Optionally, the reference state for the entropy calculation,
can be provided in the constructor via ``qp``, ``T0`` and ``P0``:

.. code-block:: cpp
NobleAbel(Real gm1, Real Cv, Real b, Real q, Real qp, Real T0, Real P0)
Note that these parameters are provided solely for the entropy calculation. When
these values are not set, they will be the same as those returned by the
:code:`ValuesAtReferenceState()` function. However, if the entropy reference
conditions are given, the return values of the :code:`ValuesAtReferenceState()`
function will not be the same.

Gruneisen EOS
`````````````

Expand Down
23 changes: 20 additions & 3 deletions singularity-eos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#------------------------------------------------------------------------------#

set(EOS_HEADERS
closure/mixed_cell_models.hpp
base/fast-math/logs.hpp
base/robust_utils.hpp
base/root-finding-1d/root_finding.hpp
Expand All @@ -40,19 +39,37 @@ set(EOS_HEADERS
eos/modifiers/eos_unitsystem.hpp
eos/eos_base.hpp
eos/eos_eospac.hpp
eos/eos_noble_abel.hpp
eos/eos_stiff.hpp
)

set(EOS_SRCS
eos/eos_builder.cpp
)

if (SINGULARITY_BUILD_CLOSURE)
list(APPEND EOS_SRCS eos/singularity_eos.cpp)
list(APPEND EOS_HEADERS eos/singularity_eos.hpp closure/mixed_cell_models.hpp)
list(APPEND EOS_HEADERS
closure/mixed_cell_models.hpp)
if (SINGULARITY_USE_FORTRAN)
list(APPEND EOS_SRCS
eos/get_sg_eos.cpp)
if (SINGULARITY_USE_KOKKOS)
list(APPEND EOS_SRCS
eos/get_sg_eos_p_t.cpp
eos/get_sg_eos_rho_t.cpp
eos/get_sg_eos_rho_p.cpp
eos/get_sg_eos_rho_e.cpp)
endif()
list(APPEND EOS_HEADERS
eos/get_sg_eos.hpp
eos/get_sg_eos_functors.hpp)
endif()
endif()

if (SINGULARITY_USE_FORTRAN)
list(APPEND EOS_SRCS eos/singularity_eos.f90)
list(APPEND EOS_SRCS eos/singularity_eos.cpp)
list(APPEND EOS_HEADERS eos/singularity_eos.hpp)
# would rather handle this more robustly, being sloppy for now
list(APPEND EOS_MODS singularity_eos.mod singularity_eos_types.mod)
endif()
Expand Down
23 changes: 7 additions & 16 deletions singularity-eos/base/variadic_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ struct flatten<type_list<Ts...>> {
};

// filter nested variadic templates
template <template <typename> class FIRST, template <typename> class... REST>
constexpr auto remove_first(adapt_list<FIRST, REST...>) {
return adapt_list<REST...>{};
}

// nested specialization filter type
template <template <typename> class Template, typename T>
Expand Down Expand Up @@ -109,18 +105,13 @@ struct filter<ADAPTER, Pred, Variadic, T, Ts...> {
typename filter<ADAPTER, Pred, Variadic, Ts...>::type>::type;
};

template <template <typename> class U, typename... Ts>
constexpr auto filter_nested(type_list<Ts...>) {
using f_list = typename filter<U, is_not_duplicate_nested, type_list, Ts...>::type;
return f_list{};
}

template <template <typename> class FIRST, template <typename> class... Us,
typename... Ts>
constexpr auto filter_nested_variadic(adapt_list<FIRST, Us...> m, type_list<Ts...> l) {
using t1 = type_list<decltype(filter_nested<FIRST>(l))>;
using t1 =
type_list<typename filter<FIRST, is_not_duplicate_nested, type_list, Ts...>::type>;
constexpr typename flatten<t1>::type l1{};
return filter_nested_variadic(remove_first(m), l1);
return filter_nested_variadic(adapt_list<Us...>{}, l1);
}

template <typename... Ts>
Expand All @@ -130,14 +121,14 @@ constexpr auto filter_nested_variadic(adapt_list<>, type_list<Ts...> l) {

// apply class template to typelist
template <template <typename> class T, typename... Us>
constexpr auto transform_list(type_list<Us...>) {
return type_list<T<Us>...>{};
}
struct transform_list_struct {
using type = type_list<T<Us>...>;
};

template <template <typename> class... Ts, typename... Us>
constexpr auto transform_variadic_list(type_list<Us...> list,
adapt_list<Ts...> mod_list) {
using t1 = type_list<decltype(transform_list<Ts>(list))...>;
using t1 = type_list<typename transform_list_struct<Ts, Us...>::type...>;
constexpr typename flatten<t1>::type l1{};
constexpr auto l2 = filter_nested_variadic(mod_list, l1);
return l2;
Expand Down
5 changes: 3 additions & 2 deletions singularity-eos/eos/eos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <singularity-eos/eos/eos_gruneisen.hpp>
#include <singularity-eos/eos/eos_ideal.hpp>
#include <singularity-eos/eos/eos_jwl.hpp>
#include <singularity-eos/eos/eos_noble_abel.hpp>
#include <singularity-eos/eos/eos_sap_polynomial.hpp>
#include <singularity-eos/eos/eos_spiner.hpp>
#include <singularity-eos/eos/eos_stellar_collapse.hpp>
Expand Down Expand Up @@ -66,7 +67,7 @@ using singularity::detail::transform_variadic_list;
// all eos's
static constexpr const auto full_eos_list =
tl<IdealGas, Gruneisen, Vinet, JWL, DavisReactants, DavisProducts, StiffGas,
SAP_Polynomial
SAP_Polynomial, NobleAbel
#ifdef SINGULARITY_USE_SPINER_WITH_HDF5
,
SpinerEOSDependsRhoT, SpinerEOSDependsRhoSie, StellarCollapse
Expand Down Expand Up @@ -135,7 +136,7 @@ static constexpr const auto ramped_all =
transform_variadic_list(combined_list_1, al<BilinearRampEOS>{});
// final combined list
static constexpr const auto combined_list =
singularity::detail::concat(full_eos_list, shifted, scaled, unit_or_rel, ramped_all);
singularity::detail::concat(combined_list_1, ramped_all);
// a function that returns a Variant from a typelist
template <typename... Ts>
struct tl_to_Variant_struct {
Expand Down
18 changes: 11 additions & 7 deletions singularity-eos/eos/eos_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ char *StrCat(char *destination, const char *source) {
using EosBase<EOSDERIVED>::FillEos; \
using EosBase<EOSDERIVED>::EntropyFromDensityTemperature; \
using EosBase<EOSDERIVED>::EntropyFromDensityInternalEnergy; \
using EosBase<EOSDERIVED>::EntropyIsNotEnabled;
using EosBase<EOSDERIVED>::EntropyIsNotEnabled; \
using EosBase<EOSDERIVED>::IsModified; \
using EosBase<EOSDERIVED>::UnmodifyOnce; \
using EosBase<EOSDERIVED>::GetUnmodifiedObject;

class Factor {
Real value_ = 1.0;
Expand Down Expand Up @@ -606,12 +609,13 @@ class EosBase {
}

// Tooling for modifiers
PORTABLE_FORCEINLINE_FUNCTION
bool IsModified() const { return false; }
PORTABLE_FORCEINLINE_FUNCTION
auto UnmodifyOnce() { return *static_cast<CRTP *>(this); }
PORTABLE_FORCEINLINE_FUNCTION
auto GetUnmodifiedObject() { return *static_cast<CRTP *>(this); }
inline constexpr bool IsModified() const { return false; }

inline constexpr decltype(auto) UnmodifyOnce() { return *static_cast<CRTP *>(this); }

inline constexpr decltype(auto) GetUnmodifiedObject() {
return *static_cast<CRTP *>(this);
}
};
} // namespace eos_base
} // namespace singularity
Expand Down
Loading

0 comments on commit 4a000be

Please sign in to comment.