From 72912770640ee9840b38dc6ea8fcdb5224930038 Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Mon, 13 Feb 2023 10:44:14 -0700 Subject: [PATCH 01/55] Readd SAP api --- singularity-eos/eos/singularity_eos.cpp | 24 +++++++++++++ singularity-eos/eos/singularity_eos.f90 | 47 +++++++++++++++++++++++++ singularity-eos/eos/singularity_eos.hpp | 14 ++++++++ 3 files changed, 85 insertions(+) diff --git a/singularity-eos/eos/singularity_eos.cpp b/singularity-eos/eos/singularity_eos.cpp index e4aab54e83..332de660a0 100644 --- a/singularity-eos/eos/singularity_eos.cpp +++ b/singularity-eos/eos/singularity_eos.cpp @@ -215,6 +215,30 @@ int init_sg_eospac(const int matindex, EOS *eos, const int id) { #undef SGAPPLYMOD +int get_sg_PressureFromDensityInternalEnergy(int matindex, + EOS *eos, + const double* rhos, + const double* sies, + double* pressures, + const int len + ) +{ + eos[matindex].PressureFromDensityInternalEnergy(rhos, sies, pressures, len); + return 0; + +} + +int get_sg_BulkModulusFromDensityInternalEnergy(int matindex, + EOS *eos, + const double* rhos, + const double* sies, + double* bmods, + const int len + ){ + eos[matindex].BulkModulusFromDensityInternalEnergy(rhos, sies, bmods, len); + return 0; +} + #ifdef PORTABILITY_STRATEGY_KOKKOS using Lrgt = Kokkos::LayoutRight; using Llft = Kokkos::LayoutLeft; diff --git a/singularity-eos/eos/singularity_eos.f90 b/singularity-eos/eos/singularity_eos.f90 index 5f539099c6..b8d6f6977e 100644 --- a/singularity-eos/eos/singularity_eos.f90 +++ b/singularity-eos/eos/singularity_eos.f90 @@ -40,6 +40,8 @@ module singularity_eos init_sg_SpinerDependsRhoT_f,& init_sg_SpinerDependsRhoSie_f,& init_sg_eospac_f,& + get_sg_PressureFromDensityInternalEnergy_f,& + get_sg_BulkModulusFromDensityInternalEnergy_f,& get_sg_eos_f,& finalize_sg_eos_f @@ -158,6 +160,30 @@ end function init_sg_SpinerDependsRhoSie end function init_sg_eospac end interface + interface + integer(kind=c_int) function & + get_sg_PressureFromDensityInternalEnergy(matindex, eos, rhos, sies,& + pressures, len) & + bind(C, name='get_sg_PressureFromDensityInternalEnergy') + import + integer(c_int), value, intent(in) :: matindex, len + type(c_ptr), value, intent(in) :: eos, rhos, sies + type(c_ptr), value, intent(in) :: pressures + end function + end interface + + interface + integer(kind=c_int) function & + get_sg_BulkModulusFromDensityInternalEnergy(matindex, eos, rhos, sies,& + bmods, len) & + bind(C, name='get_sg_BulkModulusFromDensityInternalEnergy') + import + integer(c_int),value, intent(in) :: matindex, len + type(c_ptr), value, intent(in) :: eos, rhos, sies + type(c_ptr), value, intent(in) :: bmods + end function + end interface + interface integer(kind=c_int) function & get_sg_eos(nmat, ncell, cell_dim,& @@ -385,6 +411,27 @@ integer function init_sg_eospac_f(matindex, eos, id, sg_mods_enabled, & err = init_sg_eospac(matindex-1, eos%ptr, id, c_loc(sg_mods_enabled), & c_loc(sg_mods_values)) end function init_sg_eospac_f +integer function get_sg_PressureFromDensityInternalEnergy_f(matindex, & + eos, rhos, sies, pressures, len) & + result(err) + integer(c_int), intent(in) :: matindex, len + real(kind=8), dimension(:,:,:), intent(in), target:: rhos, sies + real(kind=8), dimension(:,:,:), intent(inout), target:: pressures + type(sg_eos_ary_t), intent(in) :: eos + err = get_sg_PressureFromDensityInternalEnergy(matindex-1, & + eos%ptr, c_loc(rhos(1,1,1)), c_loc(sies(1,1,1)), c_loc(pressures(1,1,1)), len) + end function get_sg_PressureFromDensityInternalEnergy_f + + integer function get_sg_BulkModulusFromDensityInternalEnergy_f(matindex, & + eos, rhos, sies, bmods, len) & + result(err) + integer(c_int), intent(in) :: matindex, len + real(kind=8), dimension(:,:,:), intent(in), target:: rhos, sies + real(kind=8), dimension(:,:,:), intent(inout), target:: bmods + type(sg_eos_ary_t), intent(in) :: eos + err = get_sg_BulkModulusFromDensityInternalEnergy(matindex-1, & + eos%ptr, c_loc(rhos(1,1,1)), c_loc(sies(1,1,1)), c_loc(bmods(1,1,1)), len) + end function get_sg_BulkModulusFromDensityInternalEnergy_f integer function finalize_sg_eos_f(nmat, eos) & result(err) diff --git a/singularity-eos/eos/singularity_eos.hpp b/singularity-eos/eos/singularity_eos.hpp index 5ea962c1c7..6700a6e946 100644 --- a/singularity-eos/eos/singularity_eos.hpp +++ b/singularity-eos/eos/singularity_eos.hpp @@ -65,6 +65,20 @@ int init_sg_eospac(const int matindex, EOS *eos, const int id, int const *const double *const vals); #endif // SINGULARITY_USE_EOSPAC +int get_sg_PressureFromDensityInternalEnergy(int matindex, + EOS *eos, + const double* rhos, + const double* sies, + double* pressures, + const int len); + +int get_sg_BulkModulusFromDensityInternalEnergy(int matindex, + EOS *eos, + const double* rhos, + const double* sies, + double* bmods, + const int len); + int get_sg_eos( // sizing information int nmat, int ncell, int cell_dim, // Input parameters From 2e979183a9bc7d065df99668415cdc9e86ef7502 Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Thu, 23 Mar 2023 16:16:37 -0600 Subject: [PATCH 02/55] remove spiner dep from f90 hack --- singularity-eos/eos/singularity_eos.cpp | 38 ------------ singularity-eos/eos/singularity_eos.f90 | 59 ------------------- .../packages/singularity-eos/package.py | 7 ++- 3 files changed, 4 insertions(+), 100 deletions(-) diff --git a/singularity-eos/eos/singularity_eos.cpp b/singularity-eos/eos/singularity_eos.cpp index 332de660a0..cba3162809 100644 --- a/singularity-eos/eos/singularity_eos.cpp +++ b/singularity-eos/eos/singularity_eos.cpp @@ -156,44 +156,6 @@ int init_sg_DavisReactants(const int matindex, EOS *eos, const double rho0, Cv0, def_en, def_v); } -#ifdef SPINER_USE_HDF -int init_sg_SpinerDependsRhoT(const int matindex, EOS *eos, const char *filename, - const int matid, int const *const enabled, - double *const vals) { - assert(matindex >= 0); - EOS eosi = SGAPPLYMODSIMPLE(SpinerEOSDependsRhoT(std::string(filename), matid)); - if (enabled[3] == 1) { - singularity::pAlpha2BilinearRampParams(eosi, vals[2], vals[3], vals[4], vals[2], - vals[3], vals[4], vals[5]); - } - EOS eos_ = SGAPPLYMOD(SpinerEOSDependsRhoT(std::string(filename), matid)); - eos[matindex] = eos_.GetOnDevice(); - return 0; -} - -int init_sg_SpinerDependsRhoT(const int matindex, EOS *eos, const char *filename, - const int matid) { - return init_sg_SpinerDependsRhoT(matindex, eos, filename, matid, def_en, def_v); -} - -int init_sg_SpinerDependsRhoSie(const int matindex, EOS *eos, const char *filename, - const int matid, int const *const enabled, - double *const vals) { - assert(matindex >= 0); - EOS eosi = SGAPPLYMODSIMPLE(SpinerEOSDependsRhoSie(std::string(filename), matid)); - if (enabled[3] == 1) { - singularity::pAlpha2BilinearRampParams(eosi, vals[2], vals[3], vals[4], vals[2], - vals[3], vals[4], vals[5]); - } - EOS eos_ = SGAPPLYMOD(SpinerEOSDependsRhoSie(std::string(filename), matid)); - eos[matindex] = eos_.GetOnDevice(); - return 0; -} -int init_sg_SpinerDependsRhoSie(const int matindex, EOS *eos, const char *filename, - const int matid) { - return init_sg_SpinerDependsRhoSie(matindex, eos, filename, matid, def_en, def_v); -} -#endif #ifdef SINGULARITY_USE_EOSPAC int init_sg_eospac(const int matindex, EOS *eos, const int id, int const *const enabled, diff --git a/singularity-eos/eos/singularity_eos.f90 b/singularity-eos/eos/singularity_eos.f90 index b8d6f6977e..506b5cd229 100644 --- a/singularity-eos/eos/singularity_eos.f90 +++ b/singularity-eos/eos/singularity_eos.f90 @@ -37,8 +37,6 @@ module singularity_eos init_sg_JWL_f,& init_sg_DavisProducts_f,& init_sg_DavisReactants_f,& - init_sg_SpinerDependsRhoT_f,& - init_sg_SpinerDependsRhoSie_f,& init_sg_eospac_f,& get_sg_PressureFromDensityInternalEnergy_f,& get_sg_BulkModulusFromDensityInternalEnergy_f,& @@ -123,32 +121,6 @@ end function init_sg_DavisProducts end function init_sg_DavisReactants end interface - interface - integer(kind=c_int) function & - init_sg_SpinerDependsRhoT(matindex, eos, filename, id, sg_mods_enabled, & - sg_mods_values) & - bind(C, name='init_sg_SpinerDependsRhoT') - import - integer(c_int), value, intent(in) :: matindex, id - type(c_ptr), value, intent(in) :: eos - character(kind=c_char), intent(in) :: filename(*) - type(c_ptr), value, intent(in) :: sg_mods_enabled, sg_mods_values - end function init_sg_SpinerDependsRhoT - end interface - - interface - integer(kind=c_int) function & - init_sg_SpinerDependsRhoSie(matindex, eos, filename, id, & - sg_mods_enabled, sg_mods_values) & - bind(C, name='init_sg_SpinerDependsRhoSie') - import - integer(c_int), value, intent(in) :: matindex, id - type(c_ptr), value, intent(in) :: eos - character(kind=c_char), intent(in) :: filename(*) - type(c_ptr), value, intent(in) :: sg_mods_enabled, sg_mods_values - end function init_sg_SpinerDependsRhoSie - end interface - interface integer(kind=c_int) function & init_sg_eospac(matindex, eos, id, sg_mods_enabled, sg_mods_values) & @@ -370,37 +342,6 @@ integer function init_sg_DavisReactants_f(matindex, eos, rho0, e0, P0, T0, & c_loc(sg_mods_values)) end function init_sg_DavisReactants_f - integer function init_sg_SpinerDependsRhoT_f(matindex, eos, filename, id, & - sg_mods_enabled, & - sg_mods_values) & - result(err) - integer(c_int), value, intent(in) :: matindex - type(sg_eos_ary_t), intent(in) :: eos - character(len=*, kind=c_char), intent(in) :: filename - integer(c_int), intent(inout) :: id - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values - err = init_sg_SpinerDependsRhoT(matindex-1, eos%ptr,& - trim(filename)//C_NULL_CHAR, id, & - c_loc(sg_mods_enabled), & - c_loc(sg_mods_values)) - end function init_sg_SpinerDependsRhoT_f - - integer function init_sg_SpinerDependsRhoSie_f(matindex, eos, filename, id, & - sg_mods_enabled, & - sg_mods_values) & - result(err) - integer(c_int), value, intent(in) :: matindex, id - type(sg_eos_ary_t), intent(in) :: eos - character(len=*, kind=c_char), intent(in) :: filename - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values - err = init_sg_SpinerDependsRhoSie(matindex-1, eos%ptr,& - trim(filename)//C_NULL_CHAR, id, & - c_loc(sg_mods_enabled), & - c_loc(sg_mods_values)) - end function init_sg_SpinerDependsRhoSie_f - integer function init_sg_eospac_f(matindex, eos, id, sg_mods_enabled, & sg_mods_values) & result(err) diff --git a/spack-repo/packages/singularity-eos/package.py b/spack-repo/packages/singularity-eos/package.py index 20f0df5323..f79353bea3 100644 --- a/spack-repo/packages/singularity-eos/package.py +++ b/spack-repo/packages/singularity-eos/package.py @@ -12,12 +12,13 @@ class SingularityEos(CMakePackage, CudaPackage): """Singularity-EOS: A collection of closure models and tools useful for multiphysics codes.""" - homepage = "https://lanl.github.io/singularity-eos/main/index.html" - git = "https://github.com/lanl/singularity-eos.git" - url = "https://github.com/lanl/singularity-eos/archive/refs/tags/release-1.6.1.tar.gz" + homepage = "https://re-git.lanl.gov/xcap/oss/singularity-eos" + url = "https://re-git.lanl.gov/xcap/oss/singularity-eos.git" + git = "ssh://git@re-git.lanl.gov:10022/xcap/oss/singularity-eos.git" maintainers = ["rbberger"] + version("sap", branch="apg/sap_integration") version("main", branch="main") version("1.7.0", sha256="ce0825db2e9d079503e98cecf1c565352be696109042b3a0941762b35f36dc49") version("1.6.2", sha256="9c85fca679139a40cc9c72fcaeeca78a407cc1ca184734785236042de364b942") From 7525c24e942f340666410dbd24574e5a01eb0b9b Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Fri, 5 May 2023 13:58:16 -0600 Subject: [PATCH 03/55] SAP integration: most results agree, some outliers (phase boundaries?) --- eospac-wrapper/eospac_wrapper.cpp | 2 +- singularity-eos/eos/eos_eospac.hpp | 49 ++++++++++++++---------------- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/eospac-wrapper/eospac_wrapper.cpp b/eospac-wrapper/eospac_wrapper.cpp index 67bb0552b9..d3e85c6875 100644 --- a/eospac-wrapper/eospac_wrapper.cpp +++ b/eospac-wrapper/eospac_wrapper.cpp @@ -19,7 +19,6 @@ #include #include #include - #include "eospac_wrapper.hpp" #include @@ -181,6 +180,7 @@ bool eosSafeInterpolate(EOS_INTEGER *table, EOS_INTEGER nxypairs, EOS_REAL xVals } eos_Interpolate(table, &nxypairs, xVals, yVals, var, dx, dy, &errorCode); + #ifndef SINGULARITY_EOSPAC_SKIP_EXTRAP if (errorCode != EOS_OK && eospacWarn == Verbosity::Debug) { eos_GetErrorMessage(&errorCode, errorMessage); diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 721e3c93a1..82e04bd134 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -280,29 +280,17 @@ class EOSPAC : public EosBase { EOS_REAL *R = const_cast(&rhos[0]); EOS_REAL *E = const_cast(&sies[0]); EOS_REAL *P = &pressures[0]; - EOS_REAL *T = scratch + 0 * num; - EOS_REAL *dTdr = scratch + 1 * num; - EOS_REAL *dTde = scratch + 2 * num; - EOS_REAL *dPdr = dTdr; - EOS_REAL *dPdT = dTde; - - EOS_INTEGER table = TofRE_table_; - { - EOS_INTEGER options[]{EOS_Y_CONVERT}; - EOS_REAL values[]{sieFromSesame(1.0)}; - EOS_INTEGER nopts = 1; + EOS_REAL *dPdr = scratch + 1 * num; + EOS_REAL *dPde = scratch + 2 * num; - eosSafeInterpolate(&table, num, R, E, T, dTdr, dTde, "TofRE", Verbosity::Quiet, - options, values, nopts); - } - - table = PofRT_table_; + EOS_INTEGER table = PofRE_table_; { - EOS_INTEGER options[]{EOS_F_CONVERT, EOS_XY_PASSTHRU}; - EOS_REAL values[]{pressureFromSesame(1.0), 1.0}; + EOS_INTEGER options[]{EOS_Y_CONVERT, EOS_F_CONVERT}; + EOS_REAL values[]{1,1};//{sieToSesame(1.0), pressureFromSesame(1.0)}; EOS_INTEGER nopts = 2; - eosSafeInterpolate(&table, num, R, T, P, dPdr, dPdT, "PofRT", Verbosity::Quiet, - options, values, nopts); + + eosSafeInterpolate(&table, num, R, E, P, dPdr, dPdE, "PofRE", Verbosity::Quiet, + options, values, nopts); } } @@ -710,13 +698,13 @@ class EOSPAC : public EosBase { static constexpr const unsigned long _preferred_input = thermalqs::density | thermalqs::temperature; int matid_; - static constexpr int NT = 5; + static constexpr int NT = 6; EOS_INTEGER PofRT_table_; EOS_INTEGER TofRE_table_; EOS_INTEGER EofRT_table_; EOS_INTEGER RofPT_table_; EOS_INTEGER TofRP_table_; - // EOS_INTEGER PofRE_table_; + EOS_INTEGER PofRE_table_; EOS_INTEGER tablehandle[NT]; EOS_INTEGER EOS_Info_table_; static constexpr Real temp_ref_ = 293; @@ -754,16 +742,17 @@ class EOSPAC : public EosBase { inline EOSPAC::EOSPAC(const int matid, bool invert_at_setup) : matid_(matid) { using namespace EospacWrapper; - EOS_INTEGER tableType[NT] = {EOS_Pt_DT, EOS_T_DUt, EOS_Ut_DT, EOS_D_PtT, EOS_T_DPt}; + EOS_INTEGER tableType[NT] = {EOS_Pt_DT, EOS_T_DUt, EOS_Ut_DT, EOS_D_PtT, EOS_T_DPt, EOS_Pt_DUt}; eosSafeLoad(NT, matid, tableType, tablehandle, std::vector( - {"EOS_Pt_DT", "EOS_T_DUt", "EOS_Ut_DT", "EOS_D_PtT", "EOS_T_DPt"}), + {"EOS_Pt_DT", "EOS_T_DUt", "EOS_Ut_DT", "EOS_D_PtT", "EOS_T_DPt", "EOS_Pt_DUt"}), Verbosity::Quiet, invert_at_setup); PofRT_table_ = tablehandle[0]; TofRE_table_ = tablehandle[1]; EofRT_table_ = tablehandle[2]; RofPT_table_ = tablehandle[3]; TofRP_table_ = tablehandle[4]; + PofRE_table_ = tablehandle[5]; // Set reference states and table bounds SesameMetadata m; @@ -933,8 +922,16 @@ PORTABLE_INLINE_FUNCTION Real EOSPAC::SpecificHeatFromDensityTemperature( PORTABLE_INLINE_FUNCTION Real EOSPAC::PressureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda) const { using namespace EospacWrapper; - Real temp = TemperatureFromDensityInternalEnergy(rho, sie, lambda); - return PressureFromDensityTemperature(rho, temp, lambda); + EOS_INTEGER options[]{EOS_Y_CONVERT, EOS_F_CONVERT}; + EOS_REAL values[]{sieToSesame(1.0), pressureFromSesame(1.0)}; + EOS_INTEGER nopts = 2; + EOS_REAL R[1] = {rho}, E[1] = {sieToSesame(sie)}, P[1], dPdr[1], dPde[1]; + EOS_INTEGER nxypairs = 1; + EOS_INTEGER table = PofRE_table_; + eosSafeInterpolate(&table, nxypairs, R, E, P, dPdr, dPde, "PofRE", Verbosity::Quiet, + options, values, nopts); + + return Real(P[0]); } PORTABLE_INLINE_FUNCTION Real EOSPAC::EntropyFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda) const { From 818f7c1f43c8ed9d0ee572d652ca2937f68d9278 Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Tue, 23 May 2023 14:48:43 -0600 Subject: [PATCH 04/55] unit fixes --- eospac-wrapper/eospac_wrapper.cpp | 4 ++++ singularity-eos/eos/eos_eospac.hpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/eospac-wrapper/eospac_wrapper.cpp b/eospac-wrapper/eospac_wrapper.cpp index d3e85c6875..313983fecd 100644 --- a/eospac-wrapper/eospac_wrapper.cpp +++ b/eospac-wrapper/eospac_wrapper.cpp @@ -170,6 +170,7 @@ bool eosSafeInterpolate(EOS_INTEGER *table, EOS_INTEGER nxypairs, EOS_REAL xVals EOS_CHAR errorMessage[EOS_MaxErrMsgLen]; for (int i = 0; i < nopts; i++) { + // std::cout << "OPT" << tablename << " " << options[i] << " " << option_values[i] << std::endl; eos_SetOption(table, &options[i], &(option_values[i]), &errorCode); if (errorCode != EOS_OK) { eos_GetErrorMessage(&errorCode, errorMessage); @@ -178,9 +179,12 @@ bool eosSafeInterpolate(EOS_INTEGER *table, EOS_INTEGER nxypairs, EOS_REAL xVals << std::endl; } } + // std::cout << tablename << " x " << xVals[0] << " y " << yVals[0] << std::endl; eos_Interpolate(table, &nxypairs, xVals, yVals, var, dx, dy, &errorCode); + // std::cout << tablename << "x " << xVals[0] << " y " << yVals[0] << " f" << var[0] < { EOS_INTEGER table = PofRT_table_; EOS_INTEGER options[]{EOS_F_CONVERT, EOS_XY_PASSTHRU}; EOS_REAL values[]{pressureFromSesame(1.0), 1.0}; - EOS_INTEGER nopts = 2; + EOS_INTEGER nopts = 1; eosSafeInterpolate(&table, num, R, T, P, dPdr, dPdT, "PofRT", Verbosity::Quiet, options, values, nopts); @@ -286,7 +286,7 @@ class EOSPAC : public EosBase { EOS_INTEGER table = PofRE_table_; { EOS_INTEGER options[]{EOS_Y_CONVERT, EOS_F_CONVERT}; - EOS_REAL values[]{1,1};//{sieToSesame(1.0), pressureFromSesame(1.0)}; + EOS_REAL values[]{sieFromSesame(1.0), pressureFromSesame(1.0)}; EOS_INTEGER nopts = 2; eosSafeInterpolate(&table, num, R, E, P, dPdr, dPdE, "PofRE", Verbosity::Quiet, From f5896df6dcc2baaeba4fb3b715962ab57053410f Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Fri, 30 Jun 2023 13:01:55 -0600 Subject: [PATCH 05/55] continue ramp treatment into neg pressures, consistent w/ pagosa --- singularity-eos/eos/modifiers/ramps_eos.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/singularity-eos/eos/modifiers/ramps_eos.hpp b/singularity-eos/eos/modifiers/ramps_eos.hpp index 5565330ca8..fb22982b4f 100644 --- a/singularity-eos/eos/modifiers/ramps_eos.hpp +++ b/singularity-eos/eos/modifiers/ramps_eos.hpp @@ -117,7 +117,7 @@ class BilinearRampEOS : public EosBase> { PORTABLE_INLINE_FUNCTION Real get_ramp_dpdrho(Real rho) const { - const Real dpdr{rho < r0_ ? 0.0 : rho < rmid_ ? ratio(a_, r0_) : ratio(b_, r0_)}; + const Real dpdr{rho < rmid_ ? ratio(a_, r0_) : ratio(b_, r0_)}; return dpdr; } @@ -158,7 +158,7 @@ class BilinearRampEOS : public EosBase> { const Real p_eos{t_.PressureFromDensityInternalEnergy(rho, sie, lambda)}; return p_eos < p_ramp ? rho * get_ramp_dpdrho(rho) - : t_.BulkModulusFromDensityInternalEnergy(rho, sie, lambda); + : t_.BulkModulusFromDensityInternalEnergy(rho, sie, lambda); } PORTABLE_FUNCTION Real GruneisenParamFromDensityInternalEnergy(const Real rho, const Real sie, From ad44cb2c543e3579b042c0735f7a67923ddc9ddf Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Wed, 19 Jul 2023 15:51:39 -0600 Subject: [PATCH 06/55] added Pagosa setOptions to Eospac table intitialization --- eospac-wrapper/eospac_wrapper.cpp | 80 ++++++++++++++++++++++--- eospac-wrapper/eospac_wrapper.hpp | 10 +++- singularity-eos/eos/eos_eospac.hpp | 21 ++----- singularity-eos/eos/singularity_eos.cpp | 20 +++++-- singularity-eos/eos/singularity_eos.f90 | 10 ++-- singularity-eos/eos/singularity_eos.hpp | 4 +- 6 files changed, 105 insertions(+), 40 deletions(-) diff --git a/eospac-wrapper/eospac_wrapper.cpp b/eospac-wrapper/eospac_wrapper.cpp index d3e85c6875..b704028f28 100644 --- a/eospac-wrapper/eospac_wrapper.cpp +++ b/eospac-wrapper/eospac_wrapper.cpp @@ -106,16 +106,19 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, Verbosity eospacWarn) { EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], Verbosity eospacWarn, - bool invert_at_setup) { + bool invert_at_setup, double insert_data, double monotonicity, + bool apply_smoothing, double apply_splitting, bool linear_interp) { std::vector empty; return eosSafeLoad(ntables, matid, tableType, tableHandle, empty, eospacWarn, - invert_at_setup); + invert_at_setup, insert_data, monotonicity, apply_smoothing, + apply_splitting, linear_interp); } EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], const std::vector &table_names, Verbosity eospacWarn, - bool invert_at_setup) { + bool invert_at_setup, double insert_data, double monotonicity, + bool apply_smoothing, double apply_splitting, bool linear_interp) { EOS_INTEGER NTABLES[] = {ntables}; std::vector MATID(ntables, matid); @@ -126,19 +129,78 @@ EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], eos_CreateTables(NTABLES, tableType, MATID.data(), tableHandle, &errorCode); if (invert_at_setup) { - EOS_INTEGER options[] = {EOS_INVERT_AT_SETUP, EOS_INSERT_DATA}; - EOS_REAL values[] = {1., 4.}; + EOS_REAL values[] = {1.}; for (int i = 0; i < ntables; i++) { - if (tableType[i] == EOS_T_DUt) { - eos_SetOption(&(tableHandle[i]), &(options[0]), &(values[0]), &errorCode); - eos_SetOption(&(tableHandle[i]), &(options[1]), &(values[1]), &errorCode); + if (tableType[i] !=EOS_Uc_D and tableType[i] !=EOS_Pc_D and tableType[i] !=EOS_Pt_DT and tableType[i] !=EOS_Ut_DT) { + eos_SetOption(&(tableHandle[i]), &EOS_INVERT_AT_SETUP, &(values[0]), &errorCode); + eosCheckError(errorCode, "eospac options: eos_invert_at_setup", eospacWarn); } } } + if (insert_data>0) { + EOS_REAL values[] = {insert_data}; + for (int i = 0; i < ntables; i++) { + eos_SetOption(&(tableHandle[i]), &EOS_INSERT_DATA, &(values[0]), &errorCode); + eosCheckError(errorCode, "eospac options: eos_insert_data", eospacWarn); + } + } + + + //choice of which table types setOption is called on mimics SAP. Some table types are incmopatible whiel others lead to numerical issues. + if (monotonicity==1 || monotonicity==2) { + for (int i = 0; i < ntables; i++) { + if (tableType[i]!=EOS_Uc_D and tableType[i]!=EOS_Ut_DT and tableType[i]!=EOS_Ut_DPt){ + eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_X, &(EOS_NullVal), &errorCode); + eosCheckError(errorCode, "eospac options: eos_monotonic_in_x", eospacWarn); + } + } + } + + if (monotonicity==2 || monotonicity==3) { + for (int i = 0; i < ntables; i++) { + eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_Y, &(EOS_NullVal), &errorCode); + eosCheckError(errorCode, "eospac options: eos_monotonic_in_y", eospacWarn); + } + } + + if (apply_smoothing) { + for (int i = 0; i < ntables; i++) { + if (tableType[i]==EOS_Pt_DUt || tableType[i]==EOS_T_DUt || tableType[i]==EOS_Ut_DPt){ + eos_SetOption(&(tableHandle[i]), &EOS_SMOOTH, &(EOS_NullVal), &errorCode); + eosCheckError(errorCode, "eospac options: eos_smooth", eospacWarn); + } + } + } + + if (abs(apply_splitting) == 1) { + for (int i = 0; i < ntables; i++) { + eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_NUM_PROP, &(EOS_NullVal), &errorCode); + eosCheckError(errorCode, "eospac options: eos_split_num_prop", eospacWarn); } + } else if (abs(apply_splitting) == 2) { + for (int i = 0; i < ntables; i++) { + eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_IDEAL_GAS, &(EOS_NullVal), &errorCode); + eosCheckError(errorCode, "eospac options: eos_split_ideal_gas", eospacWarn); + } + } else if (abs(apply_splitting) == 3) { + for (int i = 0; i < ntables; i++) { + eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_COWAN, &(EOS_NullVal), &errorCode); + eosCheckError(errorCode, "eospac options: eos_split_cowan", eospacWarn); + } + } + + if (linear_interp) { + for (int i = 0; i < ntables; i++) { + eos_SetOption(&(tableHandle[i]), &EOS_LINEAR, &(EOS_NullVal), &errorCode); + eosCheckError(errorCode, "eospac options: linear_interp", eospacWarn); + } + } + + #ifdef SINGULARITY_EOSPAC_SKIP_EXTRAP for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_SKIP_EXTRAP_CHECK, NULL, &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_SKIP_EXTRAP_CHECK, &(EOS_NullVal), &errorCode); + eosCheckError(errorCode, "eos_skip_extrap_check", eospacWarn); } #endif // SINGULARITY_EOSPAC_SKIP_EXTRAP diff --git a/eospac-wrapper/eospac_wrapper.hpp b/eospac-wrapper/eospac_wrapper.hpp index 999c68556b..7a36270397 100644 --- a/eospac-wrapper/eospac_wrapper.hpp +++ b/eospac-wrapper/eospac_wrapper.hpp @@ -56,6 +56,7 @@ class SesameMetadata { double TConversionFactor; double sieConversionFactor; int numRho, numT; + bool apply_cc_fix; std::string comments; std::string name; friend std::ostream &operator<<(std::ostream &os, const SesameMetadata &m) { @@ -87,11 +88,15 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], Verbosity eospacWarn, - bool invert_at_setup = false); + bool invert_at_setup = false, EOS_REAL insert_data=0.0, + EOS_REAL monotonicity=0.0, bool apply_smoothing=false, + EOS_REAL apply_splitting=0.0, bool linear_interp=false); EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], const std::vector &table_names, Verbosity eospacWarn, - bool invert_at_setup = false); + bool invert_at_setup = false, EOS_REAL insert_data=0.0, + EOS_REAL monotonicity=0.0, bool apply_smoothing=false, + EOS_REAL apply_splitting=0.0, bool linear_interp=false); // output is boolean mask. 1 for no errors. 0 for errors. bool eosSafeInterpolate(EOS_INTEGER *table, EOS_INTEGER nxypairs, EOS_REAL xVals[], @@ -105,6 +110,7 @@ void eosSafeTableInfo(EOS_INTEGER *table, EOS_INTEGER numInfoItems, void eosSafeTableCmnts(EOS_INTEGER *table, EOS_CHAR *comments, Verbosity eospacWarn); + void eosCheckError(EOS_INTEGER errorCode, const std::string &name, Verbosity eospacWarn); std::string eosErrorString(EOS_INTEGER errorCode); void eosSafeDestroy(int ntables, EOS_INTEGER tableHandles[], Verbosity eospacWarn); diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 87ecc6e20d..009daacd6b 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -44,7 +44,9 @@ using namespace eos_base; class EOSPAC : public EosBase { public: inline EOSPAC() = default; - inline EOSPAC(int matid, bool invert_at_setup = false, bool apply_cc_fix = true); + + ////add options here... and elsewhere + inline EOSPAC(int matid, bool invert_at_setup = false, Real insert_data = 0.0, Real monotonicity = 0.0, bool apply_smoothing = false, Real apply_splitting = 0.0, bool linear_interp = false, bool apply_cc_fix = false); inline EOSPAC GetOnDevice() { return *this; } PORTABLE_INLINE_FUNCTION Real TemperatureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; @@ -1163,13 +1165,13 @@ class EOSPAC : public EosBase { // Implementation details below // ====================================================================== - inline EOSPAC::EOSPAC(const int matid, bool invert_at_setup, bool apply_cc_fix) : matid_(matid) { + inline EOSPAC::EOSPAC(const int matid, bool invert_at_setup, Real insert_data, Real monotonicity, bool apply_smoothing, Real apply_splitting, bool linear_interp, bool apply_cc_fix) : matid_(matid) { using namespace EospacWrapper; EOS_INTEGER tableType[NT] = {EOS_Pt_DT, EOS_T_DUt, EOS_Ut_DT, EOS_D_PtT, EOS_T_DPt, EOS_Pt_DUt, EOS_Uc_D}; eosSafeLoad(NT, matid, tableType, tablehandle, std::vector( {"EOS_Pt_DT", "EOS_T_DUt", "EOS_Ut_DT", "EOS_D_PtT", "EOS_T_DPt", "EOS_Pt_DUt","EOS_Uc_D"}), - Verbosity::Quiet, invert_at_setup); + Verbosity::Quiet, invert_at_setup=invert_at_setup, insert_data=insert_data, monotonicity=monotonicity, apply_smoothing=apply_smoothing, linear_interp=linear_interp); PofRT_table_ = tablehandle[0]; TofRE_table_ = tablehandle[1]; EofRT_table_ = tablehandle[2]; @@ -1351,18 +1353,7 @@ PORTABLE_INLINE_FUNCTION Real EOSPAC::PressureFromDensityInternalEnergy( EOS_INTEGER nopts = 2; EOS_REAL R[1] = {rho}, E[1] = {sieToSesame(sie)}, P[1], dPdr[1], dPde[1], Ec[1]; EOS_INTEGER nxypairs = 1; - EOS_INTEGER table; - - /* if (apply_cc_fix){ - EOS_INTEGER options_c[]{EOS_Y_CONVERT, EOS_F_CONVERT}; - EOS_REAL values_c[]{sieToSesame(1.0), 1./sieToSesame(1.0)}; - EOS_INTEGER nopts_c = 2; - table = UcofD_table_; - eosSafeInterpolate(&table, nxypairs, R, R, Ec, dPdr, dPde, "UcofD", Verbosity::Quiet, - options, values, nopts); - E=E= 0); - bool invert_at_setup=eospac_enabled[0]; - EOS eosi = SGAPPLYMODSIMPLE(EOSPAC(id, invert_at_setup = invert_at_setup)); + bool invert_at_setup=eospac_vals[0]; + double insert_data=eospac_vals[1]; + double monotonicity=eospac_vals[2]; + bool apply_smoothing=eospac_vals[3]; + double apply_splitting=eospac_vals[4]; + bool linear_interp=eospac_vals[5]; + bool apply_cc_fix=eospac_vals[6]; + + + EOS eosi = SGAPPLYMODSIMPLE(EOSPAC(id, invert_at_setup = invert_at_setup, insert_data=insert_data, monotonicity=monotonicity, apply_smoothing=apply_smoothing, apply_splitting=apply_splitting, linear_interp=linear_interp, apply_cc_fix=apply_cc_fix)); if (enabled[3] == 1) { singularity::pAlpha2BilinearRampParams(eosi, vals[2], vals[3], vals[4], vals[2], vals[3], vals[4], vals[5]); } - EOS eos_ = SGAPPLYMOD(EOSPAC(id, invert_at_setup = invert_at_setup)); + EOS eos_ = SGAPPLYMOD(EOSPAC(id, invert_at_setup = invert_at_setup, insert_data=insert_data, monotonicity=monotonicity, apply_smoothing=apply_smoothing, apply_splitting=apply_splitting, linear_interp=linear_interp, apply_cc_fix=apply_cc_fix)); eos[matindex] = eos_.GetOnDevice(); return 0; } -int init_sg_eospac(const int matindex, EOS *eos, const int id, int const *const eospac_enabled, +int init_sg_eospac(const int matindex, EOS *eos, const int id, double *const eospac_vals ) { - return init_sg_eospac(matindex, eos, id, eospac_enabled, eospac_vals, def_en, def_v); + return init_sg_eospac(matindex, eos, id, eospac_vals, def_en, def_v); } #endif // SINGULARITY_USE_EOSPAC diff --git a/singularity-eos/eos/singularity_eos.f90 b/singularity-eos/eos/singularity_eos.f90 index 4f37c86f8e..4487d09873 100644 --- a/singularity-eos/eos/singularity_eos.f90 +++ b/singularity-eos/eos/singularity_eos.f90 @@ -123,14 +123,14 @@ end function init_sg_DavisReactants interface integer(kind=c_int) function & - init_sg_eospac(matindex, eos, id, eospac_opts_enabled, eospac_opts_values, & + init_sg_eospac(matindex, eos, id, eospac_opts_values, & sg_mods_enabled, sg_mods_values) & bind(C, name='init_sg_eospac') import integer(c_int), value, intent(in) :: matindex, id type(c_ptr), value, intent(in) :: eos type(c_ptr), value, intent(in) :: sg_mods_enabled, sg_mods_values - type(c_ptr), value, intent(in) :: eospac_opts_enabled, eospac_opts_values + type(c_ptr), value, intent(in) :: eospac_opts_values end function init_sg_eospac end interface @@ -344,17 +344,15 @@ integer function init_sg_DavisReactants_f(matindex, eos, rho0, e0, P0, T0, & c_loc(sg_mods_values)) end function init_sg_DavisReactants_f - integer function init_sg_eospac_f(matindex, eos, id, eospac_opts_enabled, eospac_opts_values, & + integer function init_sg_eospac_f(matindex, eos, id, eospac_opts_values, & sg_mods_enabled, sg_mods_values) & result(err) integer(c_int), value, intent(in) :: matindex, id type(sg_eos_ary_t), intent(in) :: eos integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values - integer(kind=c_int), dimension(:), target, intent(inout) :: eospac_opts_enabled real(kind=8), dimension(:), target, intent(inout) :: eospac_opts_values - err = init_sg_eospac(matindex-1, eos%ptr, id, & - c_loc(eospac_opts_enabled) ,c_loc(eospac_opts_values), & + err = init_sg_eospac(matindex-1, eos%ptr, id, c_loc(eospac_opts_values), & c_loc(sg_mods_enabled), c_loc(sg_mods_values)) end function init_sg_eospac_f diff --git a/singularity-eos/eos/singularity_eos.hpp b/singularity-eos/eos/singularity_eos.hpp index 9070dd5689..13e09c878b 100644 --- a/singularity-eos/eos/singularity_eos.hpp +++ b/singularity-eos/eos/singularity_eos.hpp @@ -61,7 +61,7 @@ int init_sg_SpinerDependsRhoSie(const int matindex, EOS *eos, const char *filena #ifdef SINGULARITY_USE_EOSPAC // capitalize? eospaceos Eospac Eospaceos EOSPAC EOSPACeos? - int init_sg_eospac(const int matindex, EOS *eos, const int id, int const *const eospac_enabled, + int init_sg_eospac(const int matindex, EOS *eos, const int id, double *const eospac_vals, int const *const enabled, double *const vals); #endif // SINGULARITY_USE_EOSPAC @@ -136,7 +136,7 @@ int init_sg_SpinerDependsRhoSie(const int matindex, EOS *eos, const char *filena #ifdef SINGULARITY_USE_EOSPAC // capitalize? eospaceos Eospac Eospaceos EOSPAC EOSPACeos? -int init_sg_eospac(const int matindex, EOS *eos, const int id, const int *eospac_enabled, const double *eospac_vals); +int init_sg_eospac(const int matindex, EOS *eos, const int id, const double *eospac_vals); #endif // SINGULARITY_USE_EOSPAC #endif // EOS_SINGULARITY_EOS_HPP_ From 30d8a82d197d47ec19ca4f20a96d460a7e2a61e7 Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Mon, 24 Jul 2023 11:01:51 -0600 Subject: [PATCH 07/55] Remove cold curve as eospac_opt, will be implemented as an API call --- eospac-wrapper/eospac_wrapper.hpp | 1 - singularity-eos/eos/eos_eospac.hpp | 4 ++-- singularity-eos/eos/singularity_eos.cpp | 6 ++---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/eospac-wrapper/eospac_wrapper.hpp b/eospac-wrapper/eospac_wrapper.hpp index 7a36270397..27132e5b8a 100644 --- a/eospac-wrapper/eospac_wrapper.hpp +++ b/eospac-wrapper/eospac_wrapper.hpp @@ -56,7 +56,6 @@ class SesameMetadata { double TConversionFactor; double sieConversionFactor; int numRho, numT; - bool apply_cc_fix; std::string comments; std::string name; friend std::ostream &operator<<(std::ostream &os, const SesameMetadata &m) { diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 009daacd6b..e0445b23f5 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -46,7 +46,7 @@ class EOSPAC : public EosBase { inline EOSPAC() = default; ////add options here... and elsewhere - inline EOSPAC(int matid, bool invert_at_setup = false, Real insert_data = 0.0, Real monotonicity = 0.0, bool apply_smoothing = false, Real apply_splitting = 0.0, bool linear_interp = false, bool apply_cc_fix = false); + inline EOSPAC(int matid, bool invert_at_setup = false, Real insert_data = 0.0, Real monotonicity = 0.0, bool apply_smoothing = false, Real apply_splitting = 0.0, bool linear_interp = false); inline EOSPAC GetOnDevice() { return *this; } PORTABLE_INLINE_FUNCTION Real TemperatureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; @@ -1165,7 +1165,7 @@ class EOSPAC : public EosBase { // Implementation details below // ====================================================================== - inline EOSPAC::EOSPAC(const int matid, bool invert_at_setup, Real insert_data, Real monotonicity, bool apply_smoothing, Real apply_splitting, bool linear_interp, bool apply_cc_fix) : matid_(matid) { + inline EOSPAC::EOSPAC(const int matid, bool invert_at_setup, Real insert_data, Real monotonicity, bool apply_smoothing, Real apply_splitting, bool linear_interp) : matid_(matid) { using namespace EospacWrapper; EOS_INTEGER tableType[NT] = {EOS_Pt_DT, EOS_T_DUt, EOS_Ut_DT, EOS_D_PtT, EOS_T_DPt, EOS_Pt_DUt, EOS_Uc_D}; eosSafeLoad(NT, matid, tableType, tablehandle, diff --git a/singularity-eos/eos/singularity_eos.cpp b/singularity-eos/eos/singularity_eos.cpp index c6dd3c6c90..cbcc669079 100644 --- a/singularity-eos/eos/singularity_eos.cpp +++ b/singularity-eos/eos/singularity_eos.cpp @@ -168,15 +168,13 @@ int init_sg_eospac(const int matindex, EOS *eos, const int id, bool apply_smoothing=eospac_vals[3]; double apply_splitting=eospac_vals[4]; bool linear_interp=eospac_vals[5]; - bool apply_cc_fix=eospac_vals[6]; - - EOS eosi = SGAPPLYMODSIMPLE(EOSPAC(id, invert_at_setup = invert_at_setup, insert_data=insert_data, monotonicity=monotonicity, apply_smoothing=apply_smoothing, apply_splitting=apply_splitting, linear_interp=linear_interp, apply_cc_fix=apply_cc_fix)); + EOS eosi = SGAPPLYMODSIMPLE(EOSPAC(id, invert_at_setup = invert_at_setup, insert_data=insert_data, monotonicity=monotonicity, apply_smoothing=apply_smoothing, apply_splitting=apply_splitting, linear_interp=linear_interp)); if (enabled[3] == 1) { singularity::pAlpha2BilinearRampParams(eosi, vals[2], vals[3], vals[4], vals[2], vals[3], vals[4], vals[5]); } - EOS eos_ = SGAPPLYMOD(EOSPAC(id, invert_at_setup = invert_at_setup, insert_data=insert_data, monotonicity=monotonicity, apply_smoothing=apply_smoothing, apply_splitting=apply_splitting, linear_interp=linear_interp, apply_cc_fix=apply_cc_fix)); + EOS eos_ = SGAPPLYMOD(EOSPAC(id, invert_at_setup = invert_at_setup, insert_data=insert_data, monotonicity=monotonicity, apply_smoothing=apply_smoothing, apply_splitting=apply_splitting, linear_interp=linear_interp)); eos[matindex] = eos_.GetOnDevice(); return 0; } From 8084259c2a6766f0fcf98f8ec8d4f93080df746e Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Tue, 25 Jul 2023 17:25:53 -0600 Subject: [PATCH 08/55] Add MinInternalEnergyFromDensity, needed for pagosa integration --- singularity-eos/eos/eos_base.hpp | 34 +++++++++ singularity-eos/eos/eos_davis.hpp | 8 +++ singularity-eos/eos/eos_eospac.hpp | 69 +++++++++++++++++++ singularity-eos/eos/eos_gruneisen.hpp | 6 ++ singularity-eos/eos/eos_ideal.hpp | 4 ++ singularity-eos/eos/eos_jwl.hpp | 5 ++ singularity-eos/eos/eos_spiner.hpp | 16 +++++ singularity-eos/eos/eos_stellar_collapse.hpp | 9 +++ singularity-eos/eos/eos_variant.hpp | 58 ++++++++++++++++ singularity-eos/eos/eos_vinet.hpp | 6 ++ .../eos/modifiers/eos_unitsystem.hpp | 6 ++ singularity-eos/eos/modifiers/ramps_eos.hpp | 14 ++++ .../eos/modifiers/relativistic_eos.hpp | 5 ++ singularity-eos/eos/modifiers/scaled_eos.hpp | 16 +++++ singularity-eos/eos/modifiers/shifted_eos.hpp | 15 ++++ singularity-eos/eos/singularity_eos.cpp | 13 ++++ singularity-eos/eos/singularity_eos.f90 | 25 +++++++ singularity-eos/eos/singularity_eos.hpp | 6 ++ 18 files changed, 315 insertions(+) diff --git a/singularity-eos/eos/eos_base.hpp b/singularity-eos/eos/eos_base.hpp index 0eada63c7e..51e372ab77 100644 --- a/singularity-eos/eos/eos_base.hpp +++ b/singularity-eos/eos/eos_base.hpp @@ -68,6 +68,7 @@ char *StrCat(char *destination, const char *source) { using EosBase::InternalEnergyFromDensityTemperature; \ using EosBase::PressureFromDensityTemperature; \ using EosBase::PressureFromDensityInternalEnergy; \ + using EosBase::MinInternalEnergyFromDensity; \ using EosBase::SpecificHeatFromDensityTemperature; \ using EosBase::SpecificHeatFromDensityInternalEnergy; \ using EosBase::BulkModulusFromDensityTemperature; \ @@ -262,6 +263,39 @@ class EosBase { PressureFromDensityInternalEnergy(rhos, sies, pressures, num, std::forward(lambdas)); } + /// + template + inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, + RealIndexer &&sies, const int num, + LambdaIndexer &&lambdas) const { + static auto const name = SG_MEMBER_FUNC_NAME(); + static auto const cname = name.c_str(); + CRTP copy = *(static_cast(this)); + portableFor( + cname, 0, num, PORTABLE_LAMBDA(const int i) { + sies[i] = + copy.MinInternalEnergyFromDensity(rhos[i], lambdas[i]); + }); + } + template ::value>> + inline void + MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, + Real * /*scratch*/, + const int num, LambdaIndexer &&lambdas) const { + MinInternalEnergyFromDensity( + std::forward(rhos), std::forward(sies), + num, std::forward(lambdas)); + } + template + inline void MinInternalEnergyFromDensity(const Real *rhos, Real *sies, + Real * /*scratch*/, + const int num, LambdaIndexer &&lambdas, + Transform && = Transform()) const { + MinInternalEnergyFromDensity(rhos, entropies, num, + std::forward(lambdas)); + } + /// template inline void EntropyFromDensityTemperature(ConstRealIndexer &&rhos, ConstRealIndexer &&temperatures, diff --git a/singularity-eos/eos/eos_davis.hpp b/singularity-eos/eos/eos_davis.hpp index d728ca2591..1e02d62428 100644 --- a/singularity-eos/eos/eos_davis.hpp +++ b/singularity-eos/eos/eos_davis.hpp @@ -60,6 +60,10 @@ class DavisReactants : public EosBase { const Real rho, const Real sie, Real *lambda = nullptr) const { return Ps(rho) + Gamma(rho) * rho * (sie - Es(rho)); } + + PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { + return 0.0; + } PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( const Real rho, const Real temperature, Real *lambda = nullptr) const { EntropyIsNotEnabled("DavisReactants"); @@ -161,6 +165,10 @@ class DavisProducts : public EosBase { PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const { return Ps(rho) + rho * Gamma(rho) * (sie - Es(rho)); + } + PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity( + const Real rho, Real *lambda = nullptr) const { + return 0.0; } PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( const Real rho, const Real temperature, Real *lambda = nullptr) const { diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 8be9538ae7..b7dc301602 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -56,6 +56,8 @@ class EOSPAC : public EosBase { const Real rho, const Real temperature, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity( + const Real rho, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( const Real rho, const Real temperature, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityInternalEnergy( @@ -148,6 +150,13 @@ class EOSPAC : public EosBase { EosBase::PressureFromDensityInternalEnergy(rhos, sies, pressures, num, lambdas); } + template + inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, + RealIndexer &&sies, const int num, + LambdaIndexer &&lambdas) const { + EosBase::MinInternalEnergyFromDensity(rhos, sies, num, + lambdas); + } template ::value>> inline void @@ -158,6 +167,15 @@ class EOSPAC : public EosBase { EosBase::PressureFromDensityInternalEnergy(rhos, sies, pressures, num, lambdas); } + template ::value>> + inline void + MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, Real * /*scratch*/, + const int num, LambdaIndexer &&lambdas) const { + PORTABLE_WARN("EOSPAC type mismatch will cause significant performance degradation"); + EosBase::MinInternalEnergyFromDensity(rhos, sies, num, + lambdas); + } template inline void EntropyFromDensityTemperature(ConstRealIndexer &&rhos, ConstRealIndexer &&temperatures, @@ -601,6 +619,43 @@ class EOSPAC : public EosBase { options, values, nopts); } + template + inline void MinInternalEnergyFromDensity( + const Real *rhos, Real *sies, Real *scratch, const int num, + LambdaIndexer /*lambdas*/, Transform &&transform = Transform()) const { + using namespace EospacWrapper; + EOS_REAL *R = const_cast(&rhos[0]); + EOS_REAL *S = &pressures[0]; + EOS_REAL *dSdr = scratch + 1 * num; + + EOS_INTEGER table = EcofD_table_; + EOS_INTEGER options[3]; + EOS_REAL values[3]; + EOS_INTEGER nopts = 0; + if (!transform.x.is_set()) { + options[nopts] = EOS_XY_PASSTHRU; + values[nopts] = 1.0; + ++nopts; + } else { + if (transform.x.is_set()) { + options[nopts] = EOS_X_CONVERT; + values[nopts] = 1.0 / transform.x.get(); + ++nopts; + } + } + + options[nopts] = EOS_F_CONVERT; + values[nopts] = pressureFromSesame(1.0); + + if (transform.f.is_set()) { + values[nopts] *= transform.f.get(); + } + ++nopts; + + eosSafeInterpolate(&table, num, R, E, R, dSdr, dSdR, "EcofD", Verbosity::Quiet, + options, values, nopts); + } + template inline void SpecificHeatFromDensityTemperature( const Real *rhos, const Real *temperatures, Real *cvs, Real *scratch, const int num, @@ -1362,6 +1417,20 @@ PORTABLE_INLINE_FUNCTION Real EOSPAC::PressureFromDensityInternalEnergy( return Real(P[0]); } +PORTABLE_INLINE_FUNCTION Real EOSPAC::MinInternalEnergyFromDensity( + const Real rho, Real *lambda) const { + using namespace EospacWrapper; + EOS_INTEGER options[]{EOS_F_CONVERT}; + EOS_REAL values[]{sieFromSesame(1.0)}; + EOS_INTEGER nopts = 1; + EOS_REAL R[1] = {rho}, S[1], dSdr[1]; + EOS_INTEGER nxypairs = 1; + EOS_INTEGER table = EcofD_table_; + eosSafeInterpolate(&table, nxypairs, R, S, S, dSdr, dSdr, "EcofD", Verbosity::Quiet, + options, values, nopts); + + return Real(S[0]); +} PORTABLE_INLINE_FUNCTION Real EOSPAC::EntropyFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda) const { using namespace EospacWrapper; diff --git a/singularity-eos/eos/eos_gruneisen.hpp b/singularity-eos/eos/eos_gruneisen.hpp index f102082253..e5b4d1bfc1 100644 --- a/singularity-eos/eos/eos_gruneisen.hpp +++ b/singularity-eos/eos/eos_gruneisen.hpp @@ -76,6 +76,7 @@ class Gruneisen : public EosBase { const Real rho, const Real temperature, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( const Real rho, const Real temperature, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityInternalEnergy( @@ -313,6 +314,11 @@ PORTABLE_INLINE_FUNCTION Real Gruneisen::PressureFromDensityInternalEnergy( } return P_H + Gamma(rho) * rho * (sie - E_H); } +PORTABLE_INLINE_FUNCTION Real Gruneisen::MinInternalEnergyFromDensity( + const Real rho_in, Real *lambda) const { + const Real rho = std::min(rho_in, _rho_max); + return 0.0; +} PORTABLE_INLINE_FUNCTION Real Gruneisen::EntropyFromDensityInternalEnergy( const Real rho_in, const Real sie, Real *lambda) const { const Real rho = std::min(rho_in, _rho_max); diff --git a/singularity-eos/eos/eos_ideal.hpp b/singularity-eos/eos/eos_ideal.hpp index 27af667d31..01f306838a 100644 --- a/singularity-eos/eos/eos_ideal.hpp +++ b/singularity-eos/eos/eos_ideal.hpp @@ -78,6 +78,10 @@ class IdealGas : public EosBase { const Real rho, const Real sie, Real *lambda = nullptr) const { return MYMAX(0.0, _gm1 * rho * sie); } + PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { + return 0.0; + }; + PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( const Real rho, const Real temperature, Real *lambda = nullptr) const { return _Cv * log(robust::ratio(temperature, _EntropyT0)) + diff --git a/singularity-eos/eos/eos_jwl.hpp b/singularity-eos/eos/eos_jwl.hpp index c46d2f074b..6a16899caa 100644 --- a/singularity-eos/eos/eos_jwl.hpp +++ b/singularity-eos/eos/eos_jwl.hpp @@ -50,6 +50,7 @@ class JWL : public EosBase { const Real rho, const Real temperature, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( const Real rho, const Real temperature, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityInternalEnergy( @@ -122,6 +123,10 @@ PORTABLE_INLINE_FUNCTION Real JWL::PressureFromDensityInternalEnergy(const Real Real *lambda) const { return ReferencePressure(rho) + _w * rho * (sie - ReferenceEnergy(rho)); } +PORTABLE_INLINE_FUNCTION Real JWL::MinInternalEnergyFromDensity(const Real rho, + Real *lambda) const { + return 0.0; +} PORTABLE_INLINE_FUNCTION Real JWL::EntropyFromDensityInternalEnergy(const Real rho, const Real sie, Real *lambda) const { diff --git a/singularity-eos/eos/eos_spiner.hpp b/singularity-eos/eos/eos_spiner.hpp index 1af778e455..eba880b979 100644 --- a/singularity-eos/eos/eos_spiner.hpp +++ b/singularity-eos/eos/eos_spiner.hpp @@ -77,6 +77,7 @@ class SpinerEOSDependsRhoT : public EosBase { using EosBase::InternalEnergyFromDensityTemperature; using EosBase::PressureFromDensityTemperature; using EosBase::PressureFromDensityInternalEnergy; + using EosBase::MinInternalEnergyFromDensity; using EosBase::EntropyFromDensityTemperature; using EosBase::EntropyFromDensityInternalEnergy; using EosBase::SpecificHeatFromDensityTemperature; @@ -102,6 +103,8 @@ class SpinerEOSDependsRhoT : public EosBase { PORTABLE_INLINE_FUNCTION Real TemperatureFromDensityInternalEnergy(const Real rho, const Real sie, Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity( const Real rho, Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION Real InternalEnergyFromDensityTemperature(const Real rho, const Real temperature, Real *lambda = nullptr) const; @@ -309,6 +312,7 @@ class SpinerEOSDependsRhoSie : public EosBase { using EosBase::InternalEnergyFromDensityTemperature; using EosBase::PressureFromDensityTemperature; using EosBase::PressureFromDensityInternalEnergy; + using EosBase::MinInternalEnergyFromDensity; using EosBase::EntropyFromDensityTemperature; using EosBase::EntropyFromDensityInternalEnergy; using EosBase::SpecificHeatFromDensityTemperature; @@ -344,6 +348,8 @@ class SpinerEOSDependsRhoSie : public EosBase { PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy(const Real rho, const Real sie, Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature(const Real rho, const Real temperature, Real *lambda = nullptr) const; @@ -950,6 +956,11 @@ Real SpinerEOSDependsRhoT::PressureFromDensityInternalEnergy(const Real rho, return P; } +PORTABLE_INLINE_FUNCTION +Real SpinerEOSDependsRhoT::MinInternalEnergyFromDensity(const Real rho, + Real *lambda) const { + return 0.0; +} PORTABLE_INLINE_FUNCTION Real SpinerEOSDependsRhoT::EntropyFromDensityTemperature(const Real rho, const Real temperature, @@ -1698,6 +1709,11 @@ Real SpinerEOSDependsRhoSie::PressureFromDensityInternalEnergy(const Real rho, Real *lambda) const { return interpRhoSie_(rho, sie, dependsRhoSie_.P, lambda); } +PORTABLE_INLINE_FUNCTION +Real SpinerEOSDependsRhoSie::MinInternalEnergyFromDensity(const Real rho, + Real *lambda) const { + return 0.0; +} PORTABLE_INLINE_FUNCTION Real SpinerEOSDependsRhoSie::EntropyFromDensityTemperature(const Real rho, diff --git a/singularity-eos/eos/eos_stellar_collapse.hpp b/singularity-eos/eos/eos_stellar_collapse.hpp index cb5d0340be..9cd241269f 100644 --- a/singularity-eos/eos/eos_stellar_collapse.hpp +++ b/singularity-eos/eos/eos_stellar_collapse.hpp @@ -71,6 +71,7 @@ class StellarCollapse : public EosBase { using EosBase::InternalEnergyFromDensityTemperature; using EosBase::PressureFromDensityTemperature; using EosBase::PressureFromDensityInternalEnergy; + using EosBase::MinInternalEnergyFromDensity; using EosBase::EntropyFromDensityTemperature; using EosBase::EntropyFromDensityInternalEnergy; using EosBase::SpecificHeatFromDensityTemperature; @@ -105,6 +106,9 @@ class StellarCollapse : public EosBase { PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy(const Real rho, const Real sie, Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION + Real MinInternalEnergyFromDensity(const Real rho, + Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature(const Real rho, const Real temperature, Real *lambda = nullptr) const; @@ -507,6 +511,11 @@ Real StellarCollapse::PressureFromDensityInternalEnergy(const Real rho, const Re const Real lP = lP_.interpToReal(Ye, lT, lRho); return lP2P_(lP); } +PORTABLE_INLINE_FUNCTION +Real StellarCollapse::MinInternalEnergyFromDensity(const Real rho, + Real *lambda) const { + return 0.0; +} PORTABLE_INLINE_FUNCTION Real StellarCollapse::EntropyFromDensityTemperature(const Real rho, diff --git a/singularity-eos/eos/eos_variant.hpp b/singularity-eos/eos/eos_variant.hpp index bb6b035039..1ef63a8cea 100644 --- a/singularity-eos/eos/eos_variant.hpp +++ b/singularity-eos/eos/eos_variant.hpp @@ -112,6 +112,15 @@ class Variant { eos_); } PORTABLE_INLINE_FUNCTION + Real MinInternalEnergyFromDensity(const Real rho, + Real *lambda = nullptr) const { + return mpark::visit( + [&rho, &lambda](const auto &eos) { + return eos.MinInternalEnergyFromDensity(rho, lambda); + }, + eos_); + } + PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature(const Real rho, const Real temperature, Real *lambda = nullptr) const { return mpark::visit( @@ -475,7 +484,56 @@ class Variant { }, eos_); } + /// + template + inline void + MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, + const int num) const { + NullIndexer lambdas{}; // Returns null pointer for every index + return MinInternalEnergyFromDensity( + std::forward(rhos), std::forward(sies), + num, lambdas); + } + template + inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, + RealIndexer &&sies, + const int num, + LambdaIndexer &&lambdas) const { + return mpark::visit( + [&rhos, &sies, &num, &lambdas](const auto &eos) { + return eos.MinInternalEnergyFromDensity( + std::forward(rhos), std::forward(sies), + num, std::forward(lambdas)); + }, + eos_); + } + + template + inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, + RealIndexer &&sies, Real *scratch, + const int num) const { + NullIndexer lambdas{}; // Returns null pointer for every index + return MinInternalEnergyFromDensity( + std::forward(rhos), std::forward(sies), + scratch, num, lambdas); + } + + template + inline void + MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, + Real *scratch, const int num, + LambdaIndexer &&lambdas) const { + return mpark::visit( + [&rhos, &sies, &scratch, &num, &lambdas](const auto &eos) { + return eos.MinInternalEnergyFromDensity( + std::forward(rhos), std::forward(sies), + scratch, num, + std::forward(lambdas)); + }, + eos_); + } + /// template inline void EntropyFromDensityTemperature(ConstRealIndexer &&rhos, ConstRealIndexer &&temperatures, diff --git a/singularity-eos/eos/eos_vinet.hpp b/singularity-eos/eos/eos_vinet.hpp index 7f6c65cf22..abcb5e7220 100644 --- a/singularity-eos/eos/eos_vinet.hpp +++ b/singularity-eos/eos/eos_vinet.hpp @@ -55,6 +55,8 @@ class Vinet : public EosBase { const Real rho, const Real temp, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, + Real *lambda = nullptr) const; // Entropy added AEM Dec. 2022 PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( const Real rho, const Real temp, Real *lambda = nullptr) const; @@ -304,6 +306,10 @@ PORTABLE_INLINE_FUNCTION Real Vinet::PressureFromDensityInternalEnergy( Vinet_F_DT_func(rho, temp, output); return output[1]; } +PORTABLE_INLINE_FUNCTION Real Vinet::MinInternalEnergyFromDensity( + const Real rho, Real *lambda) const { + return 0.0; +} PORTABLE_INLINE_FUNCTION Real Vinet::EntropyFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda) const { Real temp; diff --git a/singularity-eos/eos/modifiers/eos_unitsystem.hpp b/singularity-eos/eos/modifiers/eos_unitsystem.hpp index 5e7f6b033a..c91d40da7e 100644 --- a/singularity-eos/eos/modifiers/eos_unitsystem.hpp +++ b/singularity-eos/eos/modifiers/eos_unitsystem.hpp @@ -55,6 +55,7 @@ class UnitSystem : public EosBase> { using EosBase>::InternalEnergyFromDensityTemperature; using EosBase>::PressureFromDensityTemperature; using EosBase>::PressureFromDensityInternalEnergy; + using EosBase>::MinInternalEnergyFromDensity; using EosBase>::EntropyFromDensityTemperature; using EosBase>::EntropyFromDensityInternalEnergy; using EosBase>::SpecificHeatFromDensityTemperature; @@ -131,6 +132,11 @@ class UnitSystem : public EosBase> { t_.PressureFromDensityInternalEnergy(rho * rho_unit_, sie * sie_unit_, lambda); return inv_press_unit_ * P; } + Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { + const Real S = + t_.MinInternalEnergyFromDensity(rho * rho_unit_, lambda); + return inv_sie_unit_ * S; + } PORTABLE_FUNCTION Real EntropyFromDensityInternalEnergy(const Real rho, const Real sie, Real *lambda = nullptr) const { diff --git a/singularity-eos/eos/modifiers/ramps_eos.hpp b/singularity-eos/eos/modifiers/ramps_eos.hpp index 5e92a00ed4..948b37e6c7 100644 --- a/singularity-eos/eos/modifiers/ramps_eos.hpp +++ b/singularity-eos/eos/modifiers/ramps_eos.hpp @@ -142,6 +142,10 @@ class BilinearRampEOS : public EosBase> { return p_eos < p_ramp ? p_ramp : p_eos; } PORTABLE_FUNCTION + Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { + return t_.MinInternalEnergyFromDensity(rho, lambda); + } + PORTABLE_FUNCTION Real EntropyFromDensityInternalEnergy(const Real rho, const Real sie, Real *lambda = nullptr) const { return t_.EntropyFromDensityInternalEnergy(rho, sie, lambda); @@ -273,6 +277,16 @@ class BilinearRampEOS : public EosBase> { }); } + template + inline void + MinInternalEnergyFromDensity(const Real *rhos, Real *sies, + Real *scratch, const int num, LambdaIndexer &&lambdas, + Transform &&transform = Transform()) const { + t_.MinInternalEnergyFromDensity(rhos, sies, scratch, num, + std::forward(lambdas), + std::forward(transform)); + } + template inline void SpecificHeatFromDensityTemperature( const Real *rhos, const Real *temperatures, Real *cvs, Real *scratch, const int num, diff --git a/singularity-eos/eos/modifiers/relativistic_eos.hpp b/singularity-eos/eos/modifiers/relativistic_eos.hpp index e1fe0b5fa7..0591c03353 100644 --- a/singularity-eos/eos/modifiers/relativistic_eos.hpp +++ b/singularity-eos/eos/modifiers/relativistic_eos.hpp @@ -47,6 +47,7 @@ class RelativisticEOS : public EosBase> { using EosBase>::InternalEnergyFromDensityTemperature; using EosBase>::PressureFromDensityTemperature; using EosBase>::PressureFromDensityInternalEnergy; + using EosBase>::MinInternalEnergyFromDensity; using EosBase>::EntropyFromDensityTemperature; using EosBase>::EntropyFromDensityInternalEnergy; using EosBase>::SpecificHeatFromDensityTemperature; @@ -94,6 +95,10 @@ class RelativisticEOS : public EosBase> { return t_.PressureFromDensityInternalEnergy(rho, sie, lambda); } PORTABLE_FUNCTION + Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { + return t_.MinInternalEnergyFromDensity(rho, lambda); + } + PORTABLE_FUNCTION Real EntropyFromDensityInternalEnergy(const Real rho, const Real sie, Real *lambda = nullptr) const { return t_.EntropyFromDensityInternalEnergy(rho, sie, lambda); diff --git a/singularity-eos/eos/modifiers/scaled_eos.hpp b/singularity-eos/eos/modifiers/scaled_eos.hpp index 730aa1e7d0..77e73bf2c2 100644 --- a/singularity-eos/eos/modifiers/scaled_eos.hpp +++ b/singularity-eos/eos/modifiers/scaled_eos.hpp @@ -47,6 +47,7 @@ class ScaledEOS : public EosBase> { using EosBase>::InternalEnergyFromDensityTemperature; using EosBase>::PressureFromDensityTemperature; using EosBase>::PressureFromDensityInternalEnergy; + using EosBase>::MinInternalEnergyFromDensity; using EosBase>::EntropyFromDensityTemperature; using EosBase>::EntropyFromDensityInternalEnergy; using EosBase>::SpecificHeatFromDensityTemperature; @@ -92,6 +93,10 @@ class ScaledEOS : public EosBase> { Real *lambda = nullptr) const { return t_.PressureFromDensityInternalEnergy(scale_ * rho, inv_scale_ * sie, lambda); } + PORTABLE_FUNCTION + Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { + return t_.MinInternalEnergyFromDensity(scale_ * rho, lambda); + } Real EntropyFromDensityInternalEnergy(const Real rho, const Real sie, Real *lambda = nullptr) const { return scale_ * @@ -204,6 +209,17 @@ class ScaledEOS : public EosBase> { std::forward(transform)); } + template + inline void + MinInternalEnergyFromDensity(const Real *rhos, Real *sies, + Real *scratch, const int num, LambdaIndexer &&lambdas, + Transform &&transform = Transform()) const { + transform.x.apply(scale_); + t_.MinInternalEnergyFromDensity(rhos, sies, scratch, num, + std::forward(lambdas), + std::forward(transform)); + } + template inline void SpecificHeatFromDensityTemperature( const Real *rhos, const Real *temperatures, Real *cvs, Real *scratch, const int num, diff --git a/singularity-eos/eos/modifiers/shifted_eos.hpp b/singularity-eos/eos/modifiers/shifted_eos.hpp index be2d0b4773..e452ba03e6 100644 --- a/singularity-eos/eos/modifiers/shifted_eos.hpp +++ b/singularity-eos/eos/modifiers/shifted_eos.hpp @@ -47,6 +47,7 @@ class ShiftedEOS : public EosBase> { using EosBase>::InternalEnergyFromDensityTemperature; using EosBase>::PressureFromDensityTemperature; using EosBase>::PressureFromDensityInternalEnergy; + using EosBase>::MinInternalEnergyFromDensity; using EosBase>::EntropyFromDensityTemperature; using EosBase>::EntropyFromDensityInternalEnergy; using EosBase>::SpecificHeatFromDensityTemperature; @@ -91,6 +92,10 @@ class ShiftedEOS : public EosBase> { return t_.PressureFromDensityInternalEnergy(rho, sie - shift_, lambda); } PORTABLE_FUNCTION + Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { + return t_.MinInternalEnergyFromDensity(rho, lambda); + } + PORTABLE_FUNCTION Real EntropyFromDensityInternalEnergy(const Real rho, const Real sie, Real *lambda = nullptr) const { return t_.EntropyFromDensityInternalEnergy(rho, sie - shift_, lambda); @@ -203,6 +208,16 @@ class ShiftedEOS : public EosBase> { std::forward(transform)); } + template + inline void + MinInternalEnergyFromDensity(const Real *rhos, Real *sies, + Real *scratch, const int num, LambdaIndexer &&lambdas, + Transform &&transform = Transform()) const { + t_.MinInternalEnergyFromDensity(rhos, sies, &scratch[num], + num, std::forward(lambdas), + std::forward(transform)); + } + template inline void SpecificHeatFromDensityTemperature( const Real *rhos, const Real *temperatures, Real *cvs, Real *scratch, const int num, diff --git a/singularity-eos/eos/singularity_eos.cpp b/singularity-eos/eos/singularity_eos.cpp index cbcc669079..6d0fb50018 100644 --- a/singularity-eos/eos/singularity_eos.cpp +++ b/singularity-eos/eos/singularity_eos.cpp @@ -199,6 +199,19 @@ int get_sg_PressureFromDensityInternalEnergy(int matindex, } +int get_sg_MinInternalEnergyFromDensity(int matindex, + EOS *eos, + const double* rhos, + double* sies, + const int len + ) +{ + eos[matindex].MinInternalEnergyFromDensity(rhos, sies, len); + return 0; + +} + + int get_sg_BulkModulusFromDensityInternalEnergy(int matindex, EOS *eos, const double* rhos, diff --git a/singularity-eos/eos/singularity_eos.f90 b/singularity-eos/eos/singularity_eos.f90 index 4487d09873..0f0d5c8938 100644 --- a/singularity-eos/eos/singularity_eos.f90 +++ b/singularity-eos/eos/singularity_eos.f90 @@ -39,6 +39,7 @@ module singularity_eos init_sg_DavisReactants_f,& init_sg_eospac_f,& get_sg_PressureFromDensityInternalEnergy_f,& + get_sg_MinInternalEnergyFromDensity_f,& get_sg_BulkModulusFromDensityInternalEnergy_f,& get_sg_eos_f,& finalize_sg_eos_f @@ -146,6 +147,18 @@ end function init_sg_eospac end function end interface + interface + integer(kind=c_int) function & + get_sg_MinInternalEnergyFromDensity(matindex, eos, rhos, sies,& + len) & + bind(C, name='get_sg_MinInternalEnergyFromDensity') + import + integer(c_int), value, intent(in) :: matindex, len + type(c_ptr), value, intent(in) :: eos, rhos, sies + end function + end interface + + interface integer(kind=c_int) function & get_sg_BulkModulusFromDensityInternalEnergy(matindex, eos, rhos, sies,& @@ -367,6 +380,18 @@ integer function get_sg_PressureFromDensityInternalEnergy_f(matindex, & eos%ptr, c_loc(rhos(1,1,1)), c_loc(sies(1,1,1)), c_loc(pressures(1,1,1)), len) end function get_sg_PressureFromDensityInternalEnergy_f + +integer function get_sg_MinInternalEnergyFromDensity_f(matindex, & + eos, rhos, sies, len) & + result(err) + integer(c_int), intent(in) :: matindex, len + real(kind=8), dimension(:,:,:), intent(in), target:: rhos + real(kind=8), dimension(:,:,:), intent(inout), target:: sies + type(sg_eos_ary_t), intent(in) :: eos + err = get_sg_MinInternalEnergyFromDensity(matindex-1, & + eos%ptr, c_loc(rhos(1,1,1)), c_loc(sies(1,1,1)), len) + end function get_sg_MinInternalEnergyFromDensity_f + integer function get_sg_BulkModulusFromDensityInternalEnergy_f(matindex, & eos, rhos, sies, bmods, len) & result(err) diff --git a/singularity-eos/eos/singularity_eos.hpp b/singularity-eos/eos/singularity_eos.hpp index 13e09c878b..eedf8cb675 100644 --- a/singularity-eos/eos/singularity_eos.hpp +++ b/singularity-eos/eos/singularity_eos.hpp @@ -73,6 +73,12 @@ int get_sg_PressureFromDensityInternalEnergy(int matindex, double* pressures, const int len); +int get_sg_MinInternalEnergyFromDensity(int matindex, + EOS *eos, + const double* rhos, + double* sies, + const int len); + int get_sg_BulkModulusFromDensityInternalEnergy(int matindex, EOS *eos, const double* rhos, From 953eaf4afe250afe208ce98d6d676007de7585c2 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Tue, 25 Jul 2023 20:20:44 -0600 Subject: [PATCH 09/55] Fix capitalization typo --- singularity-eos/eos/eos_eospac.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 8be9538ae7..b54c9efba4 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -597,7 +597,7 @@ class EOSPAC : public EosBase { } ++nopts; - eosSafeInterpolate(&table, num, R, E, P, dPdr, dPdE, "PofRE", Verbosity::Quiet, + eosSafeInterpolate(&table, num, R, E, P, dPdr, dPde, "PofRE", Verbosity::Quiet, options, values, nopts); } From fe9363bb822fc48df7b778a33bc9c1b92f904ac7 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Tue, 25 Jul 2023 20:33:28 -0600 Subject: [PATCH 10/55] Remove copy/paste bug --- singularity-eos/eos/eos_base.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/singularity-eos/eos/eos_base.hpp b/singularity-eos/eos/eos_base.hpp index 51e372ab77..9768171e5f 100644 --- a/singularity-eos/eos/eos_base.hpp +++ b/singularity-eos/eos/eos_base.hpp @@ -292,8 +292,7 @@ class EosBase { Real * /*scratch*/, const int num, LambdaIndexer &&lambdas, Transform && = Transform()) const { - MinInternalEnergyFromDensity(rhos, entropies, num, - std::forward(lambdas)); + MinInternalEnergyFromDensity(rhos, num, std::forward(lambdas)); } /// template From 99d35b1962533c3ce172784ecb4946a3d22d26b7 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Tue, 25 Jul 2023 20:37:51 -0600 Subject: [PATCH 11/55] Fix variable name errors and add scratch --- singularity-eos/eos/eos_eospac.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index ec9c2af25e..063ede9cc4 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -625,8 +625,8 @@ class EOSPAC : public EosBase { LambdaIndexer /*lambdas*/, Transform &&transform = Transform()) const { using namespace EospacWrapper; EOS_REAL *R = const_cast(&rhos[0]); - EOS_REAL *S = &pressures[0]; - EOS_REAL *dSdr = scratch + 1 * num; + EOS_REAL *E = &sies[0]; + EOS_REAL *dedr = scratch + 1 * num; EOS_INTEGER table = EcofD_table_; EOS_INTEGER options[3]; @@ -652,7 +652,7 @@ class EOSPAC : public EosBase { } ++nopts; - eosSafeInterpolate(&table, num, R, E, R, dSdr, dSdR, "EcofD", Verbosity::Quiet, + eosSafeInterpolate(&table, num, R, R, E, dedr, dedr, "EcofD", Verbosity::Quiet, options, values, nopts); } @@ -1214,6 +1214,7 @@ class EOSPAC : public EosBase { {"BulkModulusFromDensityInternalEnergy", 6}, {"GruneisenParamFromDensityTemperature", 4}, {"GruneisenParamFromDensityInternalEnergy", 5}, + {"MinInternalEnergyFromDensity", 1}, {"PTofRE", 11}}; return nbuffers; } From 92b3238f3f6ff90e77f3ff092a9cbf135d65372f Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Fri, 28 Jul 2023 12:16:57 -0600 Subject: [PATCH 12/55] mods by format.sh --- eospac-wrapper/eospac_wrapper.cpp | 69 ++++++++++-------- eospac-wrapper/eospac_wrapper.hpp | 13 ++-- singularity-eos/eos/eos_base.hpp | 29 ++++---- singularity-eos/eos/eos_davis.hpp | 7 +- singularity-eos/eos/eos_eospac.hpp | 66 +++++++++-------- singularity-eos/eos/eos_gruneisen.hpp | 7 +- singularity-eos/eos/eos_ideal.hpp | 3 +- singularity-eos/eos/eos_jwl.hpp | 5 +- singularity-eos/eos/eos_spiner.hpp | 10 ++- singularity-eos/eos/eos_stellar_collapse.hpp | 8 +- singularity-eos/eos/eos_variant.hpp | 48 +++++------- singularity-eos/eos/eos_vinet.hpp | 8 +- .../eos/modifiers/eos_unitsystem.hpp | 3 +- singularity-eos/eos/modifiers/ramps_eos.hpp | 13 ++-- singularity-eos/eos/modifiers/scaled_eos.hpp | 11 ++- singularity-eos/eos/modifiers/shifted_eos.hpp | 13 ++-- singularity-eos/eos/singularity_eos.cpp | 73 ++++++++----------- singularity-eos/eos/singularity_eos.hpp | 34 +++------ 18 files changed, 198 insertions(+), 222 deletions(-) diff --git a/eospac-wrapper/eospac_wrapper.cpp b/eospac-wrapper/eospac_wrapper.cpp index b704028f28..382ba43380 100644 --- a/eospac-wrapper/eospac_wrapper.cpp +++ b/eospac-wrapper/eospac_wrapper.cpp @@ -14,13 +14,13 @@ // publicly and display publicly, and to permit others to do so. //====================================================================== +#include "eospac_wrapper.hpp" #include +#include #include #include #include #include -#include "eospac_wrapper.hpp" -#include namespace EospacWrapper { @@ -106,19 +106,21 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, Verbosity eospacWarn) { EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], Verbosity eospacWarn, - bool invert_at_setup, double insert_data, double monotonicity, - bool apply_smoothing, double apply_splitting, bool linear_interp) { + bool invert_at_setup, double insert_data, double monotonicity, + bool apply_smoothing, double apply_splitting, + bool linear_interp) { std::vector empty; return eosSafeLoad(ntables, matid, tableType, tableHandle, empty, eospacWarn, - invert_at_setup, insert_data, monotonicity, apply_smoothing, - apply_splitting, linear_interp); + invert_at_setup, insert_data, monotonicity, apply_smoothing, + apply_splitting, linear_interp); } EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], const std::vector &table_names, Verbosity eospacWarn, - bool invert_at_setup, double insert_data, double monotonicity, - bool apply_smoothing, double apply_splitting, bool linear_interp) { + bool invert_at_setup, double insert_data, double monotonicity, + bool apply_smoothing, double apply_splitting, + bool linear_interp) { EOS_INTEGER NTABLES[] = {ntables}; std::vector MATID(ntables, matid); @@ -131,75 +133,78 @@ EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], if (invert_at_setup) { EOS_REAL values[] = {1.}; for (int i = 0; i < ntables; i++) { - if (tableType[i] !=EOS_Uc_D and tableType[i] !=EOS_Pc_D and tableType[i] !=EOS_Pt_DT and tableType[i] !=EOS_Ut_DT) { + if (tableType[i] != EOS_Uc_D and tableType[i] != EOS_Pc_D and + tableType[i] != EOS_Pt_DT and tableType[i] != EOS_Ut_DT) { eos_SetOption(&(tableHandle[i]), &EOS_INVERT_AT_SETUP, &(values[0]), &errorCode); - eosCheckError(errorCode, "eospac options: eos_invert_at_setup", eospacWarn); + eosCheckError(errorCode, "eospac options: eos_invert_at_setup", eospacWarn); } } } - if (insert_data>0) { + if (insert_data > 0) { EOS_REAL values[] = {insert_data}; for (int i = 0; i < ntables; i++) { eos_SetOption(&(tableHandle[i]), &EOS_INSERT_DATA, &(values[0]), &errorCode); eosCheckError(errorCode, "eospac options: eos_insert_data", eospacWarn); - } + } } - - //choice of which table types setOption is called on mimics SAP. Some table types are incmopatible whiel others lead to numerical issues. - if (monotonicity==1 || monotonicity==2) { + // choice of which table types setOption is called on mimics SAP. Some table types are + // incmopatible whiel others lead to numerical issues. + if (monotonicity == 1 || monotonicity == 2) { for (int i = 0; i < ntables; i++) { - if (tableType[i]!=EOS_Uc_D and tableType[i]!=EOS_Ut_DT and tableType[i]!=EOS_Ut_DPt){ - eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_X, &(EOS_NullVal), &errorCode); - eosCheckError(errorCode, "eospac options: eos_monotonic_in_x", eospacWarn); - } + if (tableType[i] != EOS_Uc_D and tableType[i] != EOS_Ut_DT and + tableType[i] != EOS_Ut_DPt) { + eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_X, &(EOS_NullVal), &errorCode); + eosCheckError(errorCode, "eospac options: eos_monotonic_in_x", eospacWarn); + } } } - if (monotonicity==2 || monotonicity==3) { + if (monotonicity == 2 || monotonicity == 3) { for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_Y, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_Y, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_monotonic_in_y", eospacWarn); - } + } } if (apply_smoothing) { for (int i = 0; i < ntables; i++) { - if (tableType[i]==EOS_Pt_DUt || tableType[i]==EOS_T_DUt || tableType[i]==EOS_Ut_DPt){ - eos_SetOption(&(tableHandle[i]), &EOS_SMOOTH, &(EOS_NullVal), &errorCode); - eosCheckError(errorCode, "eospac options: eos_smooth", eospacWarn); + if (tableType[i] == EOS_Pt_DUt || tableType[i] == EOS_T_DUt || + tableType[i] == EOS_Ut_DPt) { + eos_SetOption(&(tableHandle[i]), &EOS_SMOOTH, &(EOS_NullVal), &errorCode); + eosCheckError(errorCode, "eospac options: eos_smooth", eospacWarn); } } } - + if (abs(apply_splitting) == 1) { for (int i = 0; i < ntables; i++) { eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_NUM_PROP, &(EOS_NullVal), &errorCode); - eosCheckError(errorCode, "eospac options: eos_split_num_prop", eospacWarn); } + eosCheckError(errorCode, "eospac options: eos_split_num_prop", eospacWarn); + } } else if (abs(apply_splitting) == 2) { for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_IDEAL_GAS, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_IDEAL_GAS, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_split_ideal_gas", eospacWarn); } } else if (abs(apply_splitting) == 3) { for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_COWAN, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_COWAN, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_split_cowan", eospacWarn); } } if (linear_interp) { for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_LINEAR, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_LINEAR, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: linear_interp", eospacWarn); } } - #ifdef SINGULARITY_EOSPAC_SKIP_EXTRAP for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_SKIP_EXTRAP_CHECK, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_SKIP_EXTRAP_CHECK, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eos_skip_extrap_check", eospacWarn); } #endif // SINGULARITY_EOSPAC_SKIP_EXTRAP diff --git a/eospac-wrapper/eospac_wrapper.hpp b/eospac-wrapper/eospac_wrapper.hpp index 27132e5b8a..745f4c1f1f 100644 --- a/eospac-wrapper/eospac_wrapper.hpp +++ b/eospac-wrapper/eospac_wrapper.hpp @@ -87,15 +87,15 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], Verbosity eospacWarn, - bool invert_at_setup = false, EOS_REAL insert_data=0.0, - EOS_REAL monotonicity=0.0, bool apply_smoothing=false, - EOS_REAL apply_splitting=0.0, bool linear_interp=false); + bool invert_at_setup = false, EOS_REAL insert_data = 0.0, + EOS_REAL monotonicity = 0.0, bool apply_smoothing = false, + EOS_REAL apply_splitting = 0.0, bool linear_interp = false); EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], const std::vector &table_names, Verbosity eospacWarn, - bool invert_at_setup = false, EOS_REAL insert_data=0.0, - EOS_REAL monotonicity=0.0, bool apply_smoothing=false, - EOS_REAL apply_splitting=0.0, bool linear_interp=false); + bool invert_at_setup = false, EOS_REAL insert_data = 0.0, + EOS_REAL monotonicity = 0.0, bool apply_smoothing = false, + EOS_REAL apply_splitting = 0.0, bool linear_interp = false); // output is boolean mask. 1 for no errors. 0 for errors. bool eosSafeInterpolate(EOS_INTEGER *table, EOS_INTEGER nxypairs, EOS_REAL xVals[], @@ -109,7 +109,6 @@ void eosSafeTableInfo(EOS_INTEGER *table, EOS_INTEGER numInfoItems, void eosSafeTableCmnts(EOS_INTEGER *table, EOS_CHAR *comments, Verbosity eospacWarn); - void eosCheckError(EOS_INTEGER errorCode, const std::string &name, Verbosity eospacWarn); std::string eosErrorString(EOS_INTEGER errorCode); void eosSafeDestroy(int ntables, EOS_INTEGER tableHandles[], Verbosity eospacWarn); diff --git a/singularity-eos/eos/eos_base.hpp b/singularity-eos/eos/eos_base.hpp index 9768171e5f..416dc3416c 100644 --- a/singularity-eos/eos/eos_base.hpp +++ b/singularity-eos/eos/eos_base.hpp @@ -68,7 +68,7 @@ char *StrCat(char *destination, const char *source) { using EosBase::InternalEnergyFromDensityTemperature; \ using EosBase::PressureFromDensityTemperature; \ using EosBase::PressureFromDensityInternalEnergy; \ - using EosBase::MinInternalEnergyFromDensity; \ + using EosBase::MinInternalEnergyFromDensity; \ using EosBase::SpecificHeatFromDensityTemperature; \ using EosBase::SpecificHeatFromDensityInternalEnergy; \ using EosBase::BulkModulusFromDensityTemperature; \ @@ -265,33 +265,30 @@ class EosBase { } /// template - inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, - RealIndexer &&sies, const int num, - LambdaIndexer &&lambdas) const { + inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, + const int num, LambdaIndexer &&lambdas) const { static auto const name = SG_MEMBER_FUNC_NAME(); static auto const cname = name.c_str(); CRTP copy = *(static_cast(this)); portableFor( cname, 0, num, PORTABLE_LAMBDA(const int i) { - sies[i] = - copy.MinInternalEnergyFromDensity(rhos[i], lambdas[i]); + sies[i] = copy.MinInternalEnergyFromDensity(rhos[i], lambdas[i]); }); } template ::value>> - inline void - MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, - Real * /*scratch*/, - const int num, LambdaIndexer &&lambdas) const { - MinInternalEnergyFromDensity( - std::forward(rhos), std::forward(sies), - num, std::forward(lambdas)); + inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, + Real * /*scratch*/, const int num, + LambdaIndexer &&lambdas) const { + MinInternalEnergyFromDensity(std::forward(rhos), + std::forward(sies), num, + std::forward(lambdas)); } template inline void MinInternalEnergyFromDensity(const Real *rhos, Real *sies, - Real * /*scratch*/, - const int num, LambdaIndexer &&lambdas, - Transform && = Transform()) const { + Real * /*scratch*/, const int num, + LambdaIndexer &&lambdas, + Transform && = Transform()) const { MinInternalEnergyFromDensity(rhos, num, std::forward(lambdas)); } /// diff --git a/singularity-eos/eos/eos_davis.hpp b/singularity-eos/eos/eos_davis.hpp index 1e02d62428..1a9bdb8231 100644 --- a/singularity-eos/eos/eos_davis.hpp +++ b/singularity-eos/eos/eos_davis.hpp @@ -61,7 +61,8 @@ class DavisReactants : public EosBase { return Ps(rho) + Gamma(rho) * rho * (sie - Es(rho)); } - PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { + PORTABLE_INLINE_FUNCTION Real + MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { return 0.0; } PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( @@ -166,8 +167,8 @@ class DavisProducts : public EosBase { const Real rho, const Real sie, Real *lambda = nullptr) const { return Ps(rho) + rho * Gamma(rho) * (sie - Es(rho)); } - PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity( - const Real rho, Real *lambda = nullptr) const { + PORTABLE_INLINE_FUNCTION Real + MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { return 0.0; } PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 063ede9cc4..66f015974b 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -46,7 +46,9 @@ class EOSPAC : public EosBase { inline EOSPAC() = default; ////add options here... and elsewhere - inline EOSPAC(int matid, bool invert_at_setup = false, Real insert_data = 0.0, Real monotonicity = 0.0, bool apply_smoothing = false, Real apply_splitting = 0.0, bool linear_interp = false); + inline EOSPAC(int matid, bool invert_at_setup = false, Real insert_data = 0.0, + Real monotonicity = 0.0, bool apply_smoothing = false, + Real apply_splitting = 0.0, bool linear_interp = false); inline EOSPAC GetOnDevice() { return *this; } PORTABLE_INLINE_FUNCTION Real TemperatureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; @@ -56,8 +58,8 @@ class EOSPAC : public EosBase { const Real rho, const Real temperature, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; - PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity( - const Real rho, Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION Real + MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( const Real rho, const Real temperature, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityInternalEnergy( @@ -151,11 +153,9 @@ class EOSPAC : public EosBase { lambdas); } template - inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, - RealIndexer &&sies, const int num, - LambdaIndexer &&lambdas) const { - EosBase::MinInternalEnergyFromDensity(rhos, sies, num, - lambdas); + inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, + const int num, LambdaIndexer &&lambdas) const { + EosBase::MinInternalEnergyFromDensity(rhos, sies, num, lambdas); } template ::value>> @@ -169,12 +169,11 @@ class EOSPAC : public EosBase { } template ::value>> - inline void - MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, Real * /*scratch*/, - const int num, LambdaIndexer &&lambdas) const { + inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, + Real * /*scratch*/, const int num, + LambdaIndexer &&lambdas) const { PORTABLE_WARN("EOSPAC type mismatch will cause significant performance degradation"); - EosBase::MinInternalEnergyFromDensity(rhos, sies, num, - lambdas); + EosBase::MinInternalEnergyFromDensity(rhos, sies, num, lambdas); } template inline void EntropyFromDensityTemperature(ConstRealIndexer &&rhos, @@ -616,13 +615,13 @@ class EOSPAC : public EosBase { ++nopts; eosSafeInterpolate(&table, num, R, E, P, dPdr, dPde, "PofRE", Verbosity::Quiet, - options, values, nopts); + options, values, nopts); } template - inline void MinInternalEnergyFromDensity( - const Real *rhos, Real *sies, Real *scratch, const int num, - LambdaIndexer /*lambdas*/, Transform &&transform = Transform()) const { + inline void MinInternalEnergyFromDensity(const Real *rhos, Real *sies, Real *scratch, + const int num, LambdaIndexer /*lambdas*/, + Transform &&transform = Transform()) const { using namespace EospacWrapper; EOS_REAL *R = const_cast(&rhos[0]); EOS_REAL *E = &sies[0]; @@ -653,7 +652,7 @@ class EOSPAC : public EosBase { ++nopts; eosSafeInterpolate(&table, num, R, R, E, dedr, dedr, "EcofD", Verbosity::Quiet, - options, values, nopts); + options, values, nopts); } template @@ -1224,13 +1223,20 @@ class EOSPAC : public EosBase { // Implementation details below // ====================================================================== - inline EOSPAC::EOSPAC(const int matid, bool invert_at_setup, Real insert_data, Real monotonicity, bool apply_smoothing, Real apply_splitting, bool linear_interp) : matid_(matid) { +inline EOSPAC::EOSPAC(const int matid, bool invert_at_setup, Real insert_data, + Real monotonicity, bool apply_smoothing, Real apply_splitting, + bool linear_interp) + : matid_(matid) { using namespace EospacWrapper; - EOS_INTEGER tableType[NT] = {EOS_Pt_DT, EOS_T_DUt, EOS_Ut_DT, EOS_D_PtT, EOS_T_DPt, EOS_Pt_DUt, EOS_Uc_D}; - eosSafeLoad(NT, matid, tableType, tablehandle, - std::vector( - {"EOS_Pt_DT", "EOS_T_DUt", "EOS_Ut_DT", "EOS_D_PtT", "EOS_T_DPt", "EOS_Pt_DUt","EOS_Uc_D"}), - Verbosity::Quiet, invert_at_setup=invert_at_setup, insert_data=insert_data, monotonicity=monotonicity, apply_smoothing=apply_smoothing, linear_interp=linear_interp); + EOS_INTEGER tableType[NT] = {EOS_Pt_DT, EOS_T_DUt, EOS_Ut_DT, EOS_D_PtT, + EOS_T_DPt, EOS_Pt_DUt, EOS_Uc_D}; + eosSafeLoad( + NT, matid, tableType, tablehandle, + std::vector({"EOS_Pt_DT", "EOS_T_DUt", "EOS_Ut_DT", "EOS_D_PtT", + "EOS_T_DPt", "EOS_Pt_DUt", "EOS_Uc_D"}), + Verbosity::Quiet, invert_at_setup = invert_at_setup, insert_data = insert_data, + monotonicity = monotonicity, apply_smoothing = apply_smoothing, + linear_interp = linear_interp); PofRT_table_ = tablehandle[0]; TofRE_table_ = tablehandle[1]; EofRT_table_ = tablehandle[2]; @@ -1414,12 +1420,12 @@ PORTABLE_INLINE_FUNCTION Real EOSPAC::PressureFromDensityInternalEnergy( EOS_INTEGER nxypairs = 1; EOS_INTEGER table = PofRE_table_; eosSafeInterpolate(&table, nxypairs, R, E, P, dPdr, dPde, "PofRE", Verbosity::Quiet, - options, values, nopts); - + options, values, nopts); + return Real(P[0]); } -PORTABLE_INLINE_FUNCTION Real EOSPAC::MinInternalEnergyFromDensity( - const Real rho, Real *lambda) const { +PORTABLE_INLINE_FUNCTION Real EOSPAC::MinInternalEnergyFromDensity(const Real rho, + Real *lambda) const { using namespace EospacWrapper; EOS_INTEGER options[]{EOS_F_CONVERT}; EOS_REAL values[]{sieFromSesame(1.0)}; @@ -1428,8 +1434,8 @@ PORTABLE_INLINE_FUNCTION Real EOSPAC::MinInternalEnergyFromDensity( EOS_INTEGER nxypairs = 1; EOS_INTEGER table = EcofD_table_; eosSafeInterpolate(&table, nxypairs, R, S, S, dSdr, dSdr, "EcofD", Verbosity::Quiet, - options, values, nopts); - + options, values, nopts); + return Real(S[0]); } PORTABLE_INLINE_FUNCTION Real EOSPAC::EntropyFromDensityInternalEnergy( diff --git a/singularity-eos/eos/eos_gruneisen.hpp b/singularity-eos/eos/eos_gruneisen.hpp index e5b4d1bfc1..aa215f1196 100644 --- a/singularity-eos/eos/eos_gruneisen.hpp +++ b/singularity-eos/eos/eos_gruneisen.hpp @@ -76,7 +76,8 @@ class Gruneisen : public EosBase { const Real rho, const Real temperature, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; - PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION Real + MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( const Real rho, const Real temperature, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityInternalEnergy( @@ -314,8 +315,8 @@ PORTABLE_INLINE_FUNCTION Real Gruneisen::PressureFromDensityInternalEnergy( } return P_H + Gamma(rho) * rho * (sie - E_H); } -PORTABLE_INLINE_FUNCTION Real Gruneisen::MinInternalEnergyFromDensity( - const Real rho_in, Real *lambda) const { +PORTABLE_INLINE_FUNCTION Real +Gruneisen::MinInternalEnergyFromDensity(const Real rho_in, Real *lambda) const { const Real rho = std::min(rho_in, _rho_max); return 0.0; } diff --git a/singularity-eos/eos/eos_ideal.hpp b/singularity-eos/eos/eos_ideal.hpp index 01f306838a..dc52e84fa7 100644 --- a/singularity-eos/eos/eos_ideal.hpp +++ b/singularity-eos/eos/eos_ideal.hpp @@ -78,7 +78,8 @@ class IdealGas : public EosBase { const Real rho, const Real sie, Real *lambda = nullptr) const { return MYMAX(0.0, _gm1 * rho * sie); } - PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { + PORTABLE_INLINE_FUNCTION Real + MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { return 0.0; }; diff --git a/singularity-eos/eos/eos_jwl.hpp b/singularity-eos/eos/eos_jwl.hpp index 6a16899caa..2251d21122 100644 --- a/singularity-eos/eos/eos_jwl.hpp +++ b/singularity-eos/eos/eos_jwl.hpp @@ -50,7 +50,8 @@ class JWL : public EosBase { const Real rho, const Real temperature, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; - PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION Real + MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( const Real rho, const Real temperature, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityInternalEnergy( @@ -124,7 +125,7 @@ PORTABLE_INLINE_FUNCTION Real JWL::PressureFromDensityInternalEnergy(const Real return ReferencePressure(rho) + _w * rho * (sie - ReferenceEnergy(rho)); } PORTABLE_INLINE_FUNCTION Real JWL::MinInternalEnergyFromDensity(const Real rho, - Real *lambda) const { + Real *lambda) const { return 0.0; } PORTABLE_INLINE_FUNCTION Real JWL::EntropyFromDensityInternalEnergy(const Real rho, diff --git a/singularity-eos/eos/eos_spiner.hpp b/singularity-eos/eos/eos_spiner.hpp index eba880b979..e7196214b9 100644 --- a/singularity-eos/eos/eos_spiner.hpp +++ b/singularity-eos/eos/eos_spiner.hpp @@ -103,7 +103,8 @@ class SpinerEOSDependsRhoT : public EosBase { PORTABLE_INLINE_FUNCTION Real TemperatureFromDensityInternalEnergy(const Real rho, const Real sie, Real *lambda = nullptr) const; - PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity( const Real rho, Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION Real + MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real InternalEnergyFromDensityTemperature(const Real rho, const Real temperature, @@ -348,7 +349,8 @@ class SpinerEOSDependsRhoSie : public EosBase { PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy(const Real rho, const Real sie, Real *lambda = nullptr) const; - PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION Real + MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature(const Real rho, const Real temperature, @@ -958,7 +960,7 @@ Real SpinerEOSDependsRhoT::PressureFromDensityInternalEnergy(const Real rho, PORTABLE_INLINE_FUNCTION Real SpinerEOSDependsRhoT::MinInternalEnergyFromDensity(const Real rho, - Real *lambda) const { + Real *lambda) const { return 0.0; } PORTABLE_INLINE_FUNCTION @@ -1711,7 +1713,7 @@ Real SpinerEOSDependsRhoSie::PressureFromDensityInternalEnergy(const Real rho, } PORTABLE_INLINE_FUNCTION Real SpinerEOSDependsRhoSie::MinInternalEnergyFromDensity(const Real rho, - Real *lambda) const { + Real *lambda) const { return 0.0; } diff --git a/singularity-eos/eos/eos_stellar_collapse.hpp b/singularity-eos/eos/eos_stellar_collapse.hpp index 9cd241269f..6fa869d9ef 100644 --- a/singularity-eos/eos/eos_stellar_collapse.hpp +++ b/singularity-eos/eos/eos_stellar_collapse.hpp @@ -106,9 +106,8 @@ class StellarCollapse : public EosBase { PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy(const Real rho, const Real sie, Real *lambda = nullptr) const; - PORTABLE_INLINE_FUNCTION - Real MinInternalEnergyFromDensity(const Real rho, - Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION + Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature(const Real rho, const Real temperature, Real *lambda = nullptr) const; @@ -512,8 +511,7 @@ Real StellarCollapse::PressureFromDensityInternalEnergy(const Real rho, const Re return lP2P_(lP); } PORTABLE_INLINE_FUNCTION -Real StellarCollapse::MinInternalEnergyFromDensity(const Real rho, - Real *lambda) const { +Real StellarCollapse::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { return 0.0; } diff --git a/singularity-eos/eos/eos_variant.hpp b/singularity-eos/eos/eos_variant.hpp index 1ef63a8cea..c4431e2079 100644 --- a/singularity-eos/eos/eos_variant.hpp +++ b/singularity-eos/eos/eos_variant.hpp @@ -112,8 +112,7 @@ class Variant { eos_); } PORTABLE_INLINE_FUNCTION - Real MinInternalEnergyFromDensity(const Real rho, - Real *lambda = nullptr) const { + Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { return mpark::visit( [&rho, &lambda](const auto &eos) { return eos.MinInternalEnergyFromDensity(rho, lambda); @@ -484,52 +483,45 @@ class Variant { }, eos_); } - /// + /// template - inline void - MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, - const int num) const { + inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, + const int num) const { NullIndexer lambdas{}; // Returns null pointer for every index - return MinInternalEnergyFromDensity( - std::forward(rhos), std::forward(sies), - num, lambdas); + return MinInternalEnergyFromDensity(std::forward(rhos), + std::forward(sies), num, lambdas); } template - inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, - RealIndexer &&sies, - const int num, - LambdaIndexer &&lambdas) const { + inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, + const int num, LambdaIndexer &&lambdas) const { return mpark::visit( [&rhos, &sies, &num, &lambdas](const auto &eos) { - return eos.MinInternalEnergyFromDensity( - std::forward(rhos), std::forward(sies), - num, std::forward(lambdas)); + return eos.MinInternalEnergyFromDensity(std::forward(rhos), + std::forward(sies), num, + std::forward(lambdas)); }, eos_); } template - inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, - RealIndexer &&sies, Real *scratch, - const int num) const { + inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, + Real *scratch, const int num) const { NullIndexer lambdas{}; // Returns null pointer for every index - return MinInternalEnergyFromDensity( - std::forward(rhos), std::forward(sies), - scratch, num, lambdas); + return MinInternalEnergyFromDensity(std::forward(rhos), + std::forward(sies), scratch, num, + lambdas); } template - inline void - MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, - Real *scratch, const int num, - LambdaIndexer &&lambdas) const { + inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies, + Real *scratch, const int num, + LambdaIndexer &&lambdas) const { return mpark::visit( [&rhos, &sies, &scratch, &num, &lambdas](const auto &eos) { return eos.MinInternalEnergyFromDensity( std::forward(rhos), std::forward(sies), - scratch, num, - std::forward(lambdas)); + scratch, num, std::forward(lambdas)); }, eos_); } diff --git a/singularity-eos/eos/eos_vinet.hpp b/singularity-eos/eos/eos_vinet.hpp index abcb5e7220..525874229a 100644 --- a/singularity-eos/eos/eos_vinet.hpp +++ b/singularity-eos/eos/eos_vinet.hpp @@ -55,8 +55,8 @@ class Vinet : public EosBase { const Real rho, const Real temp, Real *lambda = nullptr) const; PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; - PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, - Real *lambda = nullptr) const; + PORTABLE_INLINE_FUNCTION Real + MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const; // Entropy added AEM Dec. 2022 PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( const Real rho, const Real temp, Real *lambda = nullptr) const; @@ -306,8 +306,8 @@ PORTABLE_INLINE_FUNCTION Real Vinet::PressureFromDensityInternalEnergy( Vinet_F_DT_func(rho, temp, output); return output[1]; } -PORTABLE_INLINE_FUNCTION Real Vinet::MinInternalEnergyFromDensity( - const Real rho, Real *lambda) const { +PORTABLE_INLINE_FUNCTION Real Vinet::MinInternalEnergyFromDensity(const Real rho, + Real *lambda) const { return 0.0; } PORTABLE_INLINE_FUNCTION Real Vinet::EntropyFromDensityInternalEnergy( diff --git a/singularity-eos/eos/modifiers/eos_unitsystem.hpp b/singularity-eos/eos/modifiers/eos_unitsystem.hpp index c91d40da7e..a897b5b3c1 100644 --- a/singularity-eos/eos/modifiers/eos_unitsystem.hpp +++ b/singularity-eos/eos/modifiers/eos_unitsystem.hpp @@ -133,8 +133,7 @@ class UnitSystem : public EosBase> { return inv_press_unit_ * P; } Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { - const Real S = - t_.MinInternalEnergyFromDensity(rho * rho_unit_, lambda); + const Real S = t_.MinInternalEnergyFromDensity(rho * rho_unit_, lambda); return inv_sie_unit_ * S; } PORTABLE_FUNCTION diff --git a/singularity-eos/eos/modifiers/ramps_eos.hpp b/singularity-eos/eos/modifiers/ramps_eos.hpp index 948b37e6c7..e748a90253 100644 --- a/singularity-eos/eos/modifiers/ramps_eos.hpp +++ b/singularity-eos/eos/modifiers/ramps_eos.hpp @@ -162,7 +162,7 @@ class BilinearRampEOS : public EosBase> { const Real p_eos{t_.PressureFromDensityInternalEnergy(rho, sie, lambda)}; return p_eos < p_ramp ? rho * get_ramp_dpdrho(rho) - : t_.BulkModulusFromDensityInternalEnergy(rho, sie, lambda); + : t_.BulkModulusFromDensityInternalEnergy(rho, sie, lambda); } PORTABLE_FUNCTION Real GruneisenParamFromDensityInternalEnergy(const Real rho, const Real sie, @@ -278,13 +278,12 @@ class BilinearRampEOS : public EosBase> { } template - inline void - MinInternalEnergyFromDensity(const Real *rhos, Real *sies, - Real *scratch, const int num, LambdaIndexer &&lambdas, - Transform &&transform = Transform()) const { + inline void MinInternalEnergyFromDensity(const Real *rhos, Real *sies, Real *scratch, + const int num, LambdaIndexer &&lambdas, + Transform &&transform = Transform()) const { t_.MinInternalEnergyFromDensity(rhos, sies, scratch, num, - std::forward(lambdas), - std::forward(transform)); + std::forward(lambdas), + std::forward(transform)); } template diff --git a/singularity-eos/eos/modifiers/scaled_eos.hpp b/singularity-eos/eos/modifiers/scaled_eos.hpp index 77e73bf2c2..da6005725e 100644 --- a/singularity-eos/eos/modifiers/scaled_eos.hpp +++ b/singularity-eos/eos/modifiers/scaled_eos.hpp @@ -210,14 +210,13 @@ class ScaledEOS : public EosBase> { } template - inline void - MinInternalEnergyFromDensity(const Real *rhos, Real *sies, - Real *scratch, const int num, LambdaIndexer &&lambdas, - Transform &&transform = Transform()) const { + inline void MinInternalEnergyFromDensity(const Real *rhos, Real *sies, Real *scratch, + const int num, LambdaIndexer &&lambdas, + Transform &&transform = Transform()) const { transform.x.apply(scale_); t_.MinInternalEnergyFromDensity(rhos, sies, scratch, num, - std::forward(lambdas), - std::forward(transform)); + std::forward(lambdas), + std::forward(transform)); } template diff --git a/singularity-eos/eos/modifiers/shifted_eos.hpp b/singularity-eos/eos/modifiers/shifted_eos.hpp index e452ba03e6..3ad17a2b9c 100644 --- a/singularity-eos/eos/modifiers/shifted_eos.hpp +++ b/singularity-eos/eos/modifiers/shifted_eos.hpp @@ -209,13 +209,12 @@ class ShiftedEOS : public EosBase> { } template - inline void - MinInternalEnergyFromDensity(const Real *rhos, Real *sies, - Real *scratch, const int num, LambdaIndexer &&lambdas, - Transform &&transform = Transform()) const { - t_.MinInternalEnergyFromDensity(rhos, sies, &scratch[num], - num, std::forward(lambdas), - std::forward(transform)); + inline void MinInternalEnergyFromDensity(const Real *rhos, Real *sies, Real *scratch, + const int num, LambdaIndexer &&lambdas, + Transform &&transform = Transform()) const { + t_.MinInternalEnergyFromDensity(rhos, sies, &scratch[num], num, + std::forward(lambdas), + std::forward(transform)); } template diff --git a/singularity-eos/eos/singularity_eos.cpp b/singularity-eos/eos/singularity_eos.cpp index 6d0fb50018..f7045ee3ee 100644 --- a/singularity-eos/eos/singularity_eos.cpp +++ b/singularity-eos/eos/singularity_eos.cpp @@ -156,71 +156,58 @@ int init_sg_DavisReactants(const int matindex, EOS *eos, const double rho0, Cv0, def_en, def_v); } - #ifdef SINGULARITY_USE_EOSPAC -int init_sg_eospac(const int matindex, EOS *eos, const int id, - double *const eospac_vals, int const *const enabled, - double *const vals) { +int init_sg_eospac(const int matindex, EOS *eos, const int id, double *const eospac_vals, + int const *const enabled, double *const vals) { assert(matindex >= 0); - bool invert_at_setup=eospac_vals[0]; - double insert_data=eospac_vals[1]; - double monotonicity=eospac_vals[2]; - bool apply_smoothing=eospac_vals[3]; - double apply_splitting=eospac_vals[4]; - bool linear_interp=eospac_vals[5]; - - EOS eosi = SGAPPLYMODSIMPLE(EOSPAC(id, invert_at_setup = invert_at_setup, insert_data=insert_data, monotonicity=monotonicity, apply_smoothing=apply_smoothing, apply_splitting=apply_splitting, linear_interp=linear_interp)); + bool invert_at_setup = eospac_vals[0]; + double insert_data = eospac_vals[1]; + double monotonicity = eospac_vals[2]; + bool apply_smoothing = eospac_vals[3]; + double apply_splitting = eospac_vals[4]; + bool linear_interp = eospac_vals[5]; + + EOS eosi = SGAPPLYMODSIMPLE( + EOSPAC(id, invert_at_setup = invert_at_setup, insert_data = insert_data, + monotonicity = monotonicity, apply_smoothing = apply_smoothing, + apply_splitting = apply_splitting, linear_interp = linear_interp)); if (enabled[3] == 1) { singularity::pAlpha2BilinearRampParams(eosi, vals[2], vals[3], vals[4], vals[2], vals[3], vals[4], vals[5]); } - EOS eos_ = SGAPPLYMOD(EOSPAC(id, invert_at_setup = invert_at_setup, insert_data=insert_data, monotonicity=monotonicity, apply_smoothing=apply_smoothing, apply_splitting=apply_splitting, linear_interp=linear_interp)); + EOS eos_ = SGAPPLYMOD( + EOSPAC(id, invert_at_setup = invert_at_setup, insert_data = insert_data, + monotonicity = monotonicity, apply_smoothing = apply_smoothing, + apply_splitting = apply_splitting, linear_interp = linear_interp)); eos[matindex] = eos_.GetOnDevice(); return 0; -} +} int init_sg_eospac(const int matindex, EOS *eos, const int id, - double *const eospac_vals ) { + double *const eospac_vals) { return init_sg_eospac(matindex, eos, id, eospac_vals, def_en, def_v); } #endif // SINGULARITY_USE_EOSPAC #undef SGAPPLYMOD -int get_sg_PressureFromDensityInternalEnergy(int matindex, - EOS *eos, - const double* rhos, - const double* sies, - double* pressures, - const int len - ) -{ +int get_sg_PressureFromDensityInternalEnergy(int matindex, EOS *eos, const double *rhos, + const double *sies, double *pressures, + const int len) { eos[matindex].PressureFromDensityInternalEnergy(rhos, sies, pressures, len); - return 0; - + return 0; } -int get_sg_MinInternalEnergyFromDensity(int matindex, - EOS *eos, - const double* rhos, - double* sies, - const int len - ) -{ +int get_sg_MinInternalEnergyFromDensity(int matindex, EOS *eos, const double *rhos, + double *sies, const int len) { eos[matindex].MinInternalEnergyFromDensity(rhos, sies, len); - return 0; - + return 0; } - -int get_sg_BulkModulusFromDensityInternalEnergy(int matindex, - EOS *eos, - const double* rhos, - const double* sies, - double* bmods, - const int len - ){ +int get_sg_BulkModulusFromDensityInternalEnergy(int matindex, EOS *eos, + const double *rhos, const double *sies, + double *bmods, const int len) { eos[matindex].BulkModulusFromDensityInternalEnergy(rhos, sies, bmods, len); - return 0; + return 0; } #ifdef PORTABILITY_STRATEGY_KOKKOS diff --git a/singularity-eos/eos/singularity_eos.hpp b/singularity-eos/eos/singularity_eos.hpp index eedf8cb675..0feb7bc87f 100644 --- a/singularity-eos/eos/singularity_eos.hpp +++ b/singularity-eos/eos/singularity_eos.hpp @@ -61,30 +61,20 @@ int init_sg_SpinerDependsRhoSie(const int matindex, EOS *eos, const char *filena #ifdef SINGULARITY_USE_EOSPAC // capitalize? eospaceos Eospac Eospaceos EOSPAC EOSPACeos? - int init_sg_eospac(const int matindex, EOS *eos, const int id, - double *const eospac_vals, int const *const enabled, - double *const vals); +int init_sg_eospac(const int matindex, EOS *eos, const int id, double *const eospac_vals, + int const *const enabled, double *const vals); #endif // SINGULARITY_USE_EOSPAC -int get_sg_PressureFromDensityInternalEnergy(int matindex, - EOS *eos, - const double* rhos, - const double* sies, - double* pressures, - const int len); - -int get_sg_MinInternalEnergyFromDensity(int matindex, - EOS *eos, - const double* rhos, - double* sies, - const int len); - -int get_sg_BulkModulusFromDensityInternalEnergy(int matindex, - EOS *eos, - const double* rhos, - const double* sies, - double* bmods, - const int len); +int get_sg_PressureFromDensityInternalEnergy(int matindex, EOS *eos, const double *rhos, + const double *sies, double *pressures, + const int len); + +int get_sg_MinInternalEnergyFromDensity(int matindex, EOS *eos, const double *rhos, + double *sies, const int len); + +int get_sg_BulkModulusFromDensityInternalEnergy(int matindex, EOS *eos, + const double *rhos, const double *sies, + double *bmods, const int len); int get_sg_eos( // sizing information int nmat, int ncell, int cell_dim, From edb82599500f3e7bbae2e87189d7798153d7dbf8 Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Fri, 28 Jul 2023 13:01:42 -0600 Subject: [PATCH 13/55] fix format --- eospac-wrapper/eospac_wrapper.cpp | 69 ++++++++++++++----------------- eospac-wrapper/eospac_wrapper.hpp | 13 +++--- 2 files changed, 39 insertions(+), 43 deletions(-) diff --git a/eospac-wrapper/eospac_wrapper.cpp b/eospac-wrapper/eospac_wrapper.cpp index 382ba43380..b704028f28 100644 --- a/eospac-wrapper/eospac_wrapper.cpp +++ b/eospac-wrapper/eospac_wrapper.cpp @@ -14,13 +14,13 @@ // publicly and display publicly, and to permit others to do so. //====================================================================== -#include "eospac_wrapper.hpp" #include -#include #include #include #include #include +#include "eospac_wrapper.hpp" +#include namespace EospacWrapper { @@ -106,21 +106,19 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, Verbosity eospacWarn) { EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], Verbosity eospacWarn, - bool invert_at_setup, double insert_data, double monotonicity, - bool apply_smoothing, double apply_splitting, - bool linear_interp) { + bool invert_at_setup, double insert_data, double monotonicity, + bool apply_smoothing, double apply_splitting, bool linear_interp) { std::vector empty; return eosSafeLoad(ntables, matid, tableType, tableHandle, empty, eospacWarn, - invert_at_setup, insert_data, monotonicity, apply_smoothing, - apply_splitting, linear_interp); + invert_at_setup, insert_data, monotonicity, apply_smoothing, + apply_splitting, linear_interp); } EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], const std::vector &table_names, Verbosity eospacWarn, - bool invert_at_setup, double insert_data, double monotonicity, - bool apply_smoothing, double apply_splitting, - bool linear_interp) { + bool invert_at_setup, double insert_data, double monotonicity, + bool apply_smoothing, double apply_splitting, bool linear_interp) { EOS_INTEGER NTABLES[] = {ntables}; std::vector MATID(ntables, matid); @@ -133,78 +131,75 @@ EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], if (invert_at_setup) { EOS_REAL values[] = {1.}; for (int i = 0; i < ntables; i++) { - if (tableType[i] != EOS_Uc_D and tableType[i] != EOS_Pc_D and - tableType[i] != EOS_Pt_DT and tableType[i] != EOS_Ut_DT) { + if (tableType[i] !=EOS_Uc_D and tableType[i] !=EOS_Pc_D and tableType[i] !=EOS_Pt_DT and tableType[i] !=EOS_Ut_DT) { eos_SetOption(&(tableHandle[i]), &EOS_INVERT_AT_SETUP, &(values[0]), &errorCode); - eosCheckError(errorCode, "eospac options: eos_invert_at_setup", eospacWarn); + eosCheckError(errorCode, "eospac options: eos_invert_at_setup", eospacWarn); } } } - if (insert_data > 0) { + if (insert_data>0) { EOS_REAL values[] = {insert_data}; for (int i = 0; i < ntables; i++) { eos_SetOption(&(tableHandle[i]), &EOS_INSERT_DATA, &(values[0]), &errorCode); eosCheckError(errorCode, "eospac options: eos_insert_data", eospacWarn); - } + } } - // choice of which table types setOption is called on mimics SAP. Some table types are - // incmopatible whiel others lead to numerical issues. - if (monotonicity == 1 || monotonicity == 2) { + + //choice of which table types setOption is called on mimics SAP. Some table types are incmopatible whiel others lead to numerical issues. + if (monotonicity==1 || monotonicity==2) { for (int i = 0; i < ntables; i++) { - if (tableType[i] != EOS_Uc_D and tableType[i] != EOS_Ut_DT and - tableType[i] != EOS_Ut_DPt) { - eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_X, &(EOS_NullVal), &errorCode); - eosCheckError(errorCode, "eospac options: eos_monotonic_in_x", eospacWarn); - } + if (tableType[i]!=EOS_Uc_D and tableType[i]!=EOS_Ut_DT and tableType[i]!=EOS_Ut_DPt){ + eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_X, &(EOS_NullVal), &errorCode); + eosCheckError(errorCode, "eospac options: eos_monotonic_in_x", eospacWarn); + } } } - if (monotonicity == 2 || monotonicity == 3) { + if (monotonicity==2 || monotonicity==3) { for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_Y, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_Y, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_monotonic_in_y", eospacWarn); - } + } } if (apply_smoothing) { for (int i = 0; i < ntables; i++) { - if (tableType[i] == EOS_Pt_DUt || tableType[i] == EOS_T_DUt || - tableType[i] == EOS_Ut_DPt) { - eos_SetOption(&(tableHandle[i]), &EOS_SMOOTH, &(EOS_NullVal), &errorCode); - eosCheckError(errorCode, "eospac options: eos_smooth", eospacWarn); + if (tableType[i]==EOS_Pt_DUt || tableType[i]==EOS_T_DUt || tableType[i]==EOS_Ut_DPt){ + eos_SetOption(&(tableHandle[i]), &EOS_SMOOTH, &(EOS_NullVal), &errorCode); + eosCheckError(errorCode, "eospac options: eos_smooth", eospacWarn); } } } - + if (abs(apply_splitting) == 1) { for (int i = 0; i < ntables; i++) { eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_NUM_PROP, &(EOS_NullVal), &errorCode); - eosCheckError(errorCode, "eospac options: eos_split_num_prop", eospacWarn); - } + eosCheckError(errorCode, "eospac options: eos_split_num_prop", eospacWarn); } } else if (abs(apply_splitting) == 2) { for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_IDEAL_GAS, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_IDEAL_GAS, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_split_ideal_gas", eospacWarn); } } else if (abs(apply_splitting) == 3) { for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_COWAN, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_COWAN, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_split_cowan", eospacWarn); } } if (linear_interp) { for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_LINEAR, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_LINEAR, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: linear_interp", eospacWarn); } } + #ifdef SINGULARITY_EOSPAC_SKIP_EXTRAP for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_SKIP_EXTRAP_CHECK, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_SKIP_EXTRAP_CHECK, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eos_skip_extrap_check", eospacWarn); } #endif // SINGULARITY_EOSPAC_SKIP_EXTRAP diff --git a/eospac-wrapper/eospac_wrapper.hpp b/eospac-wrapper/eospac_wrapper.hpp index 745f4c1f1f..27132e5b8a 100644 --- a/eospac-wrapper/eospac_wrapper.hpp +++ b/eospac-wrapper/eospac_wrapper.hpp @@ -87,15 +87,15 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], Verbosity eospacWarn, - bool invert_at_setup = false, EOS_REAL insert_data = 0.0, - EOS_REAL monotonicity = 0.0, bool apply_smoothing = false, - EOS_REAL apply_splitting = 0.0, bool linear_interp = false); + bool invert_at_setup = false, EOS_REAL insert_data=0.0, + EOS_REAL monotonicity=0.0, bool apply_smoothing=false, + EOS_REAL apply_splitting=0.0, bool linear_interp=false); EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], const std::vector &table_names, Verbosity eospacWarn, - bool invert_at_setup = false, EOS_REAL insert_data = 0.0, - EOS_REAL monotonicity = 0.0, bool apply_smoothing = false, - EOS_REAL apply_splitting = 0.0, bool linear_interp = false); + bool invert_at_setup = false, EOS_REAL insert_data=0.0, + EOS_REAL monotonicity=0.0, bool apply_smoothing=false, + EOS_REAL apply_splitting=0.0, bool linear_interp=false); // output is boolean mask. 1 for no errors. 0 for errors. bool eosSafeInterpolate(EOS_INTEGER *table, EOS_INTEGER nxypairs, EOS_REAL xVals[], @@ -109,6 +109,7 @@ void eosSafeTableInfo(EOS_INTEGER *table, EOS_INTEGER numInfoItems, void eosSafeTableCmnts(EOS_INTEGER *table, EOS_CHAR *comments, Verbosity eospacWarn); + void eosCheckError(EOS_INTEGER errorCode, const std::string &name, Verbosity eospacWarn); std::string eosErrorString(EOS_INTEGER errorCode); void eosSafeDestroy(int ntables, EOS_INTEGER tableHandles[], Verbosity eospacWarn); From 7d2568dc08e4770c12299713fcf6c41022281006 Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Fri, 28 Jul 2023 13:05:50 -0600 Subject: [PATCH 14/55] format mods --- eospac-wrapper/eospac_wrapper.cpp | 65 +++++++++++++++++-------------- eospac-wrapper/eospac_wrapper.hpp | 13 +++---- 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/eospac-wrapper/eospac_wrapper.cpp b/eospac-wrapper/eospac_wrapper.cpp index b704028f28..84552c377d 100644 --- a/eospac-wrapper/eospac_wrapper.cpp +++ b/eospac-wrapper/eospac_wrapper.cpp @@ -106,19 +106,21 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, Verbosity eospacWarn) { EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], Verbosity eospacWarn, - bool invert_at_setup, double insert_data, double monotonicity, - bool apply_smoothing, double apply_splitting, bool linear_interp) { + bool invert_at_setup, double insert_data, double monotonicity, + bool apply_smoothing, double apply_splitting, + bool linear_interp) { std::vector empty; return eosSafeLoad(ntables, matid, tableType, tableHandle, empty, eospacWarn, - invert_at_setup, insert_data, monotonicity, apply_smoothing, - apply_splitting, linear_interp); + invert_at_setup, insert_data, monotonicity, apply_smoothing, + apply_splitting, linear_interp); } EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], const std::vector &table_names, Verbosity eospacWarn, - bool invert_at_setup, double insert_data, double monotonicity, - bool apply_smoothing, double apply_splitting, bool linear_interp) { + bool invert_at_setup, double insert_data, double monotonicity, + bool apply_smoothing, double apply_splitting, + bool linear_interp) { EOS_INTEGER NTABLES[] = {ntables}; std::vector MATID(ntables, matid); @@ -131,75 +133,78 @@ EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], if (invert_at_setup) { EOS_REAL values[] = {1.}; for (int i = 0; i < ntables; i++) { - if (tableType[i] !=EOS_Uc_D and tableType[i] !=EOS_Pc_D and tableType[i] !=EOS_Pt_DT and tableType[i] !=EOS_Ut_DT) { + if (tableType[i] != EOS_Uc_D and tableType[i] != EOS_Pc_D and + tableType[i] != EOS_Pt_DT and tableType[i] != EOS_Ut_DT) { eos_SetOption(&(tableHandle[i]), &EOS_INVERT_AT_SETUP, &(values[0]), &errorCode); - eosCheckError(errorCode, "eospac options: eos_invert_at_setup", eospacWarn); + eosCheckError(errorCode, "eospac options: eos_invert_at_setup", eospacWarn); } } } - if (insert_data>0) { + if (insert_data > 0) { EOS_REAL values[] = {insert_data}; for (int i = 0; i < ntables; i++) { eos_SetOption(&(tableHandle[i]), &EOS_INSERT_DATA, &(values[0]), &errorCode); eosCheckError(errorCode, "eospac options: eos_insert_data", eospacWarn); - } + } } - - //choice of which table types setOption is called on mimics SAP. Some table types are incmopatible whiel others lead to numerical issues. - if (monotonicity==1 || monotonicity==2) { + // choice of which table types setOption is called on mimics SAP. Some table types are + // incmopatible whiel others lead to numerical issues. + if (monotonicity == 1 || monotonicity == 2) { for (int i = 0; i < ntables; i++) { - if (tableType[i]!=EOS_Uc_D and tableType[i]!=EOS_Ut_DT and tableType[i]!=EOS_Ut_DPt){ - eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_X, &(EOS_NullVal), &errorCode); - eosCheckError(errorCode, "eospac options: eos_monotonic_in_x", eospacWarn); - } + if (tableType[i] != EOS_Uc_D and tableType[i] != EOS_Ut_DT and + tableType[i] != EOS_Ut_DPt) { + eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_X, &(EOS_NullVal), &errorCode); + eosCheckError(errorCode, "eospac options: eos_monotonic_in_x", eospacWarn); + } } } - if (monotonicity==2 || monotonicity==3) { + if (monotonicity == 2 || monotonicity == 3) { for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_Y, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_Y, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_monotonic_in_y", eospacWarn); - } + } } if (apply_smoothing) { for (int i = 0; i < ntables; i++) { - if (tableType[i]==EOS_Pt_DUt || tableType[i]==EOS_T_DUt || tableType[i]==EOS_Ut_DPt){ - eos_SetOption(&(tableHandle[i]), &EOS_SMOOTH, &(EOS_NullVal), &errorCode); - eosCheckError(errorCode, "eospac options: eos_smooth", eospacWarn); + if (tableType[i] == EOS_Pt_DUt || tableType[i] == EOS_T_DUt || + tableType[i] == EOS_Ut_DPt) { + eos_SetOption(&(tableHandle[i]), &EOS_SMOOTH, &(EOS_NullVal), &errorCode); + eosCheckError(errorCode, "eospac options: eos_smooth", eospacWarn); } } } - + if (abs(apply_splitting) == 1) { for (int i = 0; i < ntables; i++) { eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_NUM_PROP, &(EOS_NullVal), &errorCode); - eosCheckError(errorCode, "eospac options: eos_split_num_prop", eospacWarn); } + eosCheckError(errorCode, "eospac options: eos_split_num_prop", eospacWarn); + } } else if (abs(apply_splitting) == 2) { for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_IDEAL_GAS, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_IDEAL_GAS, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_split_ideal_gas", eospacWarn); } } else if (abs(apply_splitting) == 3) { for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_COWAN, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_COWAN, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_split_cowan", eospacWarn); } } if (linear_interp) { for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_LINEAR, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_LINEAR, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: linear_interp", eospacWarn); } } - #ifdef SINGULARITY_EOSPAC_SKIP_EXTRAP for (int i = 0; i < ntables; i++) { - eos_SetOption(&(tableHandle[i]), &EOS_SKIP_EXTRAP_CHECK, &(EOS_NullVal), &errorCode); + eos_SetOption(&(tableHandle[i]), &EOS_SKIP_EXTRAP_CHECK, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eos_skip_extrap_check", eospacWarn); } #endif // SINGULARITY_EOSPAC_SKIP_EXTRAP diff --git a/eospac-wrapper/eospac_wrapper.hpp b/eospac-wrapper/eospac_wrapper.hpp index 27132e5b8a..745f4c1f1f 100644 --- a/eospac-wrapper/eospac_wrapper.hpp +++ b/eospac-wrapper/eospac_wrapper.hpp @@ -87,15 +87,15 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], Verbosity eospacWarn, - bool invert_at_setup = false, EOS_REAL insert_data=0.0, - EOS_REAL monotonicity=0.0, bool apply_smoothing=false, - EOS_REAL apply_splitting=0.0, bool linear_interp=false); + bool invert_at_setup = false, EOS_REAL insert_data = 0.0, + EOS_REAL monotonicity = 0.0, bool apply_smoothing = false, + EOS_REAL apply_splitting = 0.0, bool linear_interp = false); EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], const std::vector &table_names, Verbosity eospacWarn, - bool invert_at_setup = false, EOS_REAL insert_data=0.0, - EOS_REAL monotonicity=0.0, bool apply_smoothing=false, - EOS_REAL apply_splitting=0.0, bool linear_interp=false); + bool invert_at_setup = false, EOS_REAL insert_data = 0.0, + EOS_REAL monotonicity = 0.0, bool apply_smoothing = false, + EOS_REAL apply_splitting = 0.0, bool linear_interp = false); // output is boolean mask. 1 for no errors. 0 for errors. bool eosSafeInterpolate(EOS_INTEGER *table, EOS_INTEGER nxypairs, EOS_REAL xVals[], @@ -109,7 +109,6 @@ void eosSafeTableInfo(EOS_INTEGER *table, EOS_INTEGER numInfoItems, void eosSafeTableCmnts(EOS_INTEGER *table, EOS_CHAR *comments, Verbosity eospacWarn); - void eosCheckError(EOS_INTEGER errorCode, const std::string &name, Verbosity eospacWarn); std::string eosErrorString(EOS_INTEGER errorCode); void eosSafeDestroy(int ntables, EOS_INTEGER tableHandles[], Verbosity eospacWarn); From e8006f4ce6cce69057e7f5d73b2934331977b223 Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Fri, 28 Jul 2023 14:38:04 -0600 Subject: [PATCH 15/55] Start adding enums --- eospac-wrapper/eospac_wrapper.cpp | 10 +++++----- eospac-wrapper/eospac_wrapper.hpp | 5 +++-- singularity-eos/eos/eos_eospac.hpp | 4 ++-- singularity-eos/eos/singularity_eos.cpp | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/eospac-wrapper/eospac_wrapper.cpp b/eospac-wrapper/eospac_wrapper.cpp index 84552c377d..2ec5e8fead 100644 --- a/eospac-wrapper/eospac_wrapper.cpp +++ b/eospac-wrapper/eospac_wrapper.cpp @@ -107,7 +107,7 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, Verbosity eospacWarn) { EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], Verbosity eospacWarn, bool invert_at_setup, double insert_data, double monotonicity, - bool apply_smoothing, double apply_splitting, + bool apply_smoothing, eosSplit apply_splitting, bool linear_interp) { std::vector empty; return eosSafeLoad(ntables, matid, tableType, tableHandle, empty, eospacWarn, @@ -119,7 +119,7 @@ EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], const std::vector &table_names, Verbosity eospacWarn, bool invert_at_setup, double insert_data, double monotonicity, - bool apply_smoothing, double apply_splitting, + bool apply_smoothing, eosSplit apply_splitting, bool linear_interp) { EOS_INTEGER NTABLES[] = {ntables}; std::vector MATID(ntables, matid); @@ -178,17 +178,17 @@ EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], } } - if (abs(apply_splitting) == 1) { + if (apply_splitting == eosSplit::splitNumProp) { for (int i = 0; i < ntables; i++) { eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_NUM_PROP, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_split_num_prop", eospacWarn); } - } else if (abs(apply_splitting) == 2) { + } else if (apply_splitting == eosSplit::splitIdealGas) { for (int i = 0; i < ntables; i++) { eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_IDEAL_GAS, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_split_ideal_gas", eospacWarn); } - } else if (abs(apply_splitting) == 3) { + } else if (apply_splitting == eosSplit::splitCowan) { for (int i = 0; i < ntables; i++) { eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_COWAN, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_split_cowan", eospacWarn); diff --git a/eospac-wrapper/eospac_wrapper.hpp b/eospac-wrapper/eospac_wrapper.hpp index 745f4c1f1f..7c9fc972cd 100644 --- a/eospac-wrapper/eospac_wrapper.hpp +++ b/eospac-wrapper/eospac_wrapper.hpp @@ -39,6 +39,7 @@ inline double getBulkModulus(const double rho, const double P, const double DPDR return rho * DPDR_T + DPDE_R * ((P / rho) - rho * DEDR_T); } +enum class eosSplit { none=0, splitNumProp=1, splitIdealGas=2, splitCowan=3 }; enum class Verbosity { Quiet, Verbose, Debug }; class SesameMetadata { @@ -89,13 +90,13 @@ EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], Verbosity eospacWarn, bool invert_at_setup = false, EOS_REAL insert_data = 0.0, EOS_REAL monotonicity = 0.0, bool apply_smoothing = false, - EOS_REAL apply_splitting = 0.0, bool linear_interp = false); + eosSplit apply_splitting = eosSplit::none, bool linear_interp = false); EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], const std::vector &table_names, Verbosity eospacWarn, bool invert_at_setup = false, EOS_REAL insert_data = 0.0, EOS_REAL monotonicity = 0.0, bool apply_smoothing = false, - EOS_REAL apply_splitting = 0.0, bool linear_interp = false); + eosSplit apply_splitting = eosSplit::none, bool linear_interp = false); // output is boolean mask. 1 for no errors. 0 for errors. bool eosSafeInterpolate(EOS_INTEGER *table, EOS_INTEGER nxypairs, EOS_REAL xVals[], diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 66f015974b..01c7c5dd64 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -48,7 +48,7 @@ class EOSPAC : public EosBase { ////add options here... and elsewhere inline EOSPAC(int matid, bool invert_at_setup = false, Real insert_data = 0.0, Real monotonicity = 0.0, bool apply_smoothing = false, - Real apply_splitting = 0.0, bool linear_interp = false); + eosSplit apply_splitting = eosSplit::none, bool linear_interp = false); inline EOSPAC GetOnDevice() { return *this; } PORTABLE_INLINE_FUNCTION Real TemperatureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; @@ -1224,7 +1224,7 @@ class EOSPAC : public EosBase { // ====================================================================== inline EOSPAC::EOSPAC(const int matid, bool invert_at_setup, Real insert_data, - Real monotonicity, bool apply_smoothing, Real apply_splitting, + Real monotonicity, bool apply_smoothing, eosSplit apply_splitting, bool linear_interp) : matid_(matid) { using namespace EospacWrapper; diff --git a/singularity-eos/eos/singularity_eos.cpp b/singularity-eos/eos/singularity_eos.cpp index f7045ee3ee..9e6e86fcbc 100644 --- a/singularity-eos/eos/singularity_eos.cpp +++ b/singularity-eos/eos/singularity_eos.cpp @@ -164,7 +164,7 @@ int init_sg_eospac(const int matindex, EOS *eos, const int id, double *const eos double insert_data = eospac_vals[1]; double monotonicity = eospac_vals[2]; bool apply_smoothing = eospac_vals[3]; - double apply_splitting = eospac_vals[4]; + int apply_splitting = eospac_vals[4]; bool linear_interp = eospac_vals[5]; EOS eosi = SGAPPLYMODSIMPLE( From 528b5fd2cc2266fe2d0e62595aef38f865de64cd Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Mon, 31 Jul 2023 16:27:25 -0600 Subject: [PATCH 16/55] Fix bug when commentLen for eospac tables is zero --- eospac-wrapper/eospac_wrapper.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eospac-wrapper/eospac_wrapper.cpp b/eospac-wrapper/eospac_wrapper.cpp index 84552c377d..57bbd0ee4b 100644 --- a/eospac-wrapper/eospac_wrapper.cpp +++ b/eospac-wrapper/eospac_wrapper.cpp @@ -86,7 +86,8 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, Verbosity eospacWarn) { comments.resize(static_cast(commentLen)); metadata.comments.resize(comments.size()); - eosSafeTableCmnts(&eospacComments, comments.data(), eospacWarn); + + if (commentLen>0) eosSafeTableCmnts(&eospacComments, comments.data(), eospacWarn); for (size_t i = 0; i < comments.size(); i++) { metadata.comments[i] = comments[i]; } From d9bfa854b2d01ac9960f575ad95ca95ee9908704 Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Thu, 3 Aug 2023 09:09:35 -0600 Subject: [PATCH 17/55] Add enum for eospac split and monotonicity options --- eospac-wrapper/eospac_wrapper.cpp | 18 +++++++++--------- eospac-wrapper/eospac_wrapper.hpp | 13 +++++++------ singularity-eos/eos/eos_eospac.hpp | 13 +++++++++---- singularity-eos/eos/singularity_eos.cpp | 8 +++++--- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/eospac-wrapper/eospac_wrapper.cpp b/eospac-wrapper/eospac_wrapper.cpp index 7de782bf4b..8765d00f2c 100644 --- a/eospac-wrapper/eospac_wrapper.cpp +++ b/eospac-wrapper/eospac_wrapper.cpp @@ -107,8 +107,8 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, Verbosity eospacWarn) { EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], Verbosity eospacWarn, - bool invert_at_setup, double insert_data, double monotonicity, - bool apply_smoothing, eosSplit apply_splitting, + bool invert_at_setup, double insert_data, eospacMonotonicity monotonicity, + bool apply_smoothing, eospacSplit apply_splitting, bool linear_interp) { std::vector empty; return eosSafeLoad(ntables, matid, tableType, tableHandle, empty, eospacWarn, @@ -119,8 +119,8 @@ EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], const std::vector &table_names, Verbosity eospacWarn, - bool invert_at_setup, double insert_data, double monotonicity, - bool apply_smoothing, eosSplit apply_splitting, + bool invert_at_setup, double insert_data, eospacMonotonicity monotonicity, + bool apply_smoothing, eospacSplit apply_splitting, bool linear_interp) { EOS_INTEGER NTABLES[] = {ntables}; std::vector MATID(ntables, matid); @@ -152,7 +152,7 @@ EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], // choice of which table types setOption is called on mimics SAP. Some table types are // incmopatible whiel others lead to numerical issues. - if (monotonicity == 1 || monotonicity == 2) { + if (monotonicity == eospacMonotonicity::monotonicityX || monotonicity ==eospacMonotonicity::monotonicityXY ) { for (int i = 0; i < ntables; i++) { if (tableType[i] != EOS_Uc_D and tableType[i] != EOS_Ut_DT and tableType[i] != EOS_Ut_DPt) { @@ -162,7 +162,7 @@ EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], } } - if (monotonicity == 2 || monotonicity == 3) { + if (monotonicity ==eospacMonotonicity::monotonicityXY || monotonicity == eospacMonotonicity::monotonicityY) { for (int i = 0; i < ntables; i++) { eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_Y, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_monotonic_in_y", eospacWarn); @@ -179,17 +179,17 @@ EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], } } - if (apply_splitting == eosSplit::splitNumProp) { + if (apply_splitting == eospacSplit::splitNumProp) { for (int i = 0; i < ntables; i++) { eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_NUM_PROP, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_split_num_prop", eospacWarn); } - } else if (apply_splitting == eosSplit::splitIdealGas) { + } else if (apply_splitting == eospacSplit::splitIdealGas) { for (int i = 0; i < ntables; i++) { eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_IDEAL_GAS, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_split_ideal_gas", eospacWarn); } - } else if (apply_splitting == eosSplit::splitCowan) { + } else if (apply_splitting == eospacSplit::splitCowan) { for (int i = 0; i < ntables; i++) { eos_SetOption(&(tableHandle[i]), &EOS_SPLIT_COWAN, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_split_cowan", eospacWarn); diff --git a/eospac-wrapper/eospac_wrapper.hpp b/eospac-wrapper/eospac_wrapper.hpp index 7c9fc972cd..3c6e2c4ad2 100644 --- a/eospac-wrapper/eospac_wrapper.hpp +++ b/eospac-wrapper/eospac_wrapper.hpp @@ -22,8 +22,10 @@ #include // eospac API -namespace EospacWrapper { +namespace EospacWrapper { +enum class eospacSplit { none=0, splitNumProp=1, splitIdealGas=2, splitCowan=3 }; +enum class eospacMonotonicity { none=0, monotonicityX=1, monotonicityXY=2, monotonicityY=3 }; inline double densityToSesame(const double CodeTemp) { return CodeTemp; } inline double densityFromSesame(const double sesTemp) { return sesTemp; } inline double temperatureToSesame(const double CodeTemp) { return CodeTemp; } @@ -39,7 +41,6 @@ inline double getBulkModulus(const double rho, const double P, const double DPDR return rho * DPDR_T + DPDE_R * ((P / rho) - rho * DEDR_T); } -enum class eosSplit { none=0, splitNumProp=1, splitIdealGas=2, splitCowan=3 }; enum class Verbosity { Quiet, Verbose, Debug }; class SesameMetadata { @@ -89,14 +90,14 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], Verbosity eospacWarn, bool invert_at_setup = false, EOS_REAL insert_data = 0.0, - EOS_REAL monotonicity = 0.0, bool apply_smoothing = false, - eosSplit apply_splitting = eosSplit::none, bool linear_interp = false); + eospacMonotonicity monotonicity = eospacMonotonicity::none, bool apply_smoothing = false, + eospacSplit apply_splitting = eospacSplit::none, bool linear_interp = false); EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], const std::vector &table_names, Verbosity eospacWarn, bool invert_at_setup = false, EOS_REAL insert_data = 0.0, - EOS_REAL monotonicity = 0.0, bool apply_smoothing = false, - eosSplit apply_splitting = eosSplit::none, bool linear_interp = false); + eospacMonotonicity monotonicity = eospacMonotonicity::none, bool apply_smoothing = false, + eospacSplit apply_splitting = eospacSplit::none, bool linear_interp = false); // output is boolean mask. 1 for no errors. 0 for errors. bool eosSafeInterpolate(EOS_INTEGER *table, EOS_INTEGER nxypairs, EOS_REAL xVals[], diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 01c7c5dd64..3e501ddeda 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -33,7 +33,11 @@ namespace singularity { + + using namespace eos_base; +using namespace EospacWrapper; + // How do I make a destructor? How do I free the EOS memory if more than one // points to the same table? Does EOSPAC give me multiple (reference-counted) @@ -42,13 +46,14 @@ using namespace eos_base; // Only really works in serial // Not really supported on device class EOSPAC : public EosBase { + public: inline EOSPAC() = default; ////add options here... and elsewhere inline EOSPAC(int matid, bool invert_at_setup = false, Real insert_data = 0.0, - Real monotonicity = 0.0, bool apply_smoothing = false, - eosSplit apply_splitting = eosSplit::none, bool linear_interp = false); + eospacMonotonicity monotonicity = eospacMonotonicity::none, bool apply_smoothing = false, + eospacSplit apply_splitting = eospacSplit::none, bool linear_interp = false); inline EOSPAC GetOnDevice() { return *this; } PORTABLE_INLINE_FUNCTION Real TemperatureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; @@ -1224,7 +1229,7 @@ class EOSPAC : public EosBase { // ====================================================================== inline EOSPAC::EOSPAC(const int matid, bool invert_at_setup, Real insert_data, - Real monotonicity, bool apply_smoothing, eosSplit apply_splitting, + EospacWrapper::eospacMonotonicity monotonicity, bool apply_smoothing, EospacWrapper::eospacSplit apply_splitting, bool linear_interp) : matid_(matid) { using namespace EospacWrapper; @@ -1235,7 +1240,7 @@ inline EOSPAC::EOSPAC(const int matid, bool invert_at_setup, Real insert_data, std::vector({"EOS_Pt_DT", "EOS_T_DUt", "EOS_Ut_DT", "EOS_D_PtT", "EOS_T_DPt", "EOS_Pt_DUt", "EOS_Uc_D"}), Verbosity::Quiet, invert_at_setup = invert_at_setup, insert_data = insert_data, - monotonicity = monotonicity, apply_smoothing = apply_smoothing, + monotonicity = monotonicity, apply_smoothing = apply_smoothing, apply_splitting=apply_splitting, linear_interp = linear_interp); PofRT_table_ = tablehandle[0]; TofRE_table_ = tablehandle[1]; diff --git a/singularity-eos/eos/singularity_eos.cpp b/singularity-eos/eos/singularity_eos.cpp index 9e6e86fcbc..70bbbea62f 100644 --- a/singularity-eos/eos/singularity_eos.cpp +++ b/singularity-eos/eos/singularity_eos.cpp @@ -159,12 +159,14 @@ int init_sg_DavisReactants(const int matindex, EOS *eos, const double rho0, #ifdef SINGULARITY_USE_EOSPAC int init_sg_eospac(const int matindex, EOS *eos, const int id, double *const eospac_vals, int const *const enabled, double *const vals) { + + using namespace EospacWrapper; assert(matindex >= 0); bool invert_at_setup = eospac_vals[0]; double insert_data = eospac_vals[1]; - double monotonicity = eospac_vals[2]; + eospacMonotonicity monotonicity = static_cast(eospac_vals[2]); bool apply_smoothing = eospac_vals[3]; - int apply_splitting = eospac_vals[4]; + eospacSplit apply_splitting = static_cast(eospac_vals[4]); bool linear_interp = eospac_vals[5]; EOS eosi = SGAPPLYMODSIMPLE( @@ -178,7 +180,7 @@ int init_sg_eospac(const int matindex, EOS *eos, const int id, double *const eos EOS eos_ = SGAPPLYMOD( EOSPAC(id, invert_at_setup = invert_at_setup, insert_data = insert_data, monotonicity = monotonicity, apply_smoothing = apply_smoothing, - apply_splitting = apply_splitting, linear_interp = linear_interp)); + apply_splitting = apply_splitting, linear_interp = linear_interp)); eos[matindex] = eos_.GetOnDevice(); return 0; } From b8a2328cd0b9d3d559ec7bf457f0f051a99ef9ff Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Thu, 3 Aug 2023 13:14:14 -0600 Subject: [PATCH 18/55] Add warnings to stub mininternalenergy functions when in debug mode --- singularity-eos/eos/eos_davis.hpp | 4 ++++ singularity-eos/eos/eos_gruneisen.hpp | 6 ++++++ singularity-eos/eos/eos_ideal.hpp | 4 ++++ singularity-eos/eos/eos_jwl.hpp | 4 ++++ singularity-eos/eos/eos_spiner.hpp | 4 ++++ singularity-eos/eos/eos_stellar_collapse.hpp | 5 +++++ singularity-eos/eos/eos_vinet.hpp | 5 +++++ 7 files changed, 32 insertions(+) diff --git a/singularity-eos/eos/eos_davis.hpp b/singularity-eos/eos/eos_davis.hpp index 1a9bdb8231..19657e3d99 100644 --- a/singularity-eos/eos/eos_davis.hpp +++ b/singularity-eos/eos/eos_davis.hpp @@ -63,6 +63,10 @@ class DavisReactants : public EosBase { PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { +#ifndef NDEBUG + printf( + "WARNING: MinInternalEnergtyFromDensity is not defined for Davis EOS."); +#endif return 0.0; } PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( diff --git a/singularity-eos/eos/eos_gruneisen.hpp b/singularity-eos/eos/eos_gruneisen.hpp index aa215f1196..9fc5d86741 100644 --- a/singularity-eos/eos/eos_gruneisen.hpp +++ b/singularity-eos/eos/eos_gruneisen.hpp @@ -318,6 +318,12 @@ PORTABLE_INLINE_FUNCTION Real Gruneisen::PressureFromDensityInternalEnergy( PORTABLE_INLINE_FUNCTION Real Gruneisen::MinInternalEnergyFromDensity(const Real rho_in, Real *lambda) const { const Real rho = std::min(rho_in, _rho_max); + +#ifndef NDEBUG + printf( + "WARNING: MinInternalEnergtyFromDensity is not defined for Gruneisen EOS."); +#endif + return 0.0; } PORTABLE_INLINE_FUNCTION Real Gruneisen::EntropyFromDensityInternalEnergy( diff --git a/singularity-eos/eos/eos_ideal.hpp b/singularity-eos/eos/eos_ideal.hpp index dc52e84fa7..5cf620d6a5 100644 --- a/singularity-eos/eos/eos_ideal.hpp +++ b/singularity-eos/eos/eos_ideal.hpp @@ -80,6 +80,10 @@ class IdealGas : public EosBase { } PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { +#ifndef NDEBUG + printf( + "WARNING: MinInternalEnergtyFromDensity is not defined for ideal gas EOS."); +#endif return 0.0; }; diff --git a/singularity-eos/eos/eos_jwl.hpp b/singularity-eos/eos/eos_jwl.hpp index 2251d21122..549adeb340 100644 --- a/singularity-eos/eos/eos_jwl.hpp +++ b/singularity-eos/eos/eos_jwl.hpp @@ -126,6 +126,10 @@ PORTABLE_INLINE_FUNCTION Real JWL::PressureFromDensityInternalEnergy(const Real } PORTABLE_INLINE_FUNCTION Real JWL::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { +#ifndef NDEBUG + printf( + "WARNING: MinInternalEnergtyFromDensity is not defined for JWL EOS."); +#endif return 0.0; } PORTABLE_INLINE_FUNCTION Real JWL::EntropyFromDensityInternalEnergy(const Real rho, diff --git a/singularity-eos/eos/eos_spiner.hpp b/singularity-eos/eos/eos_spiner.hpp index e7196214b9..bd1e2b1e9b 100644 --- a/singularity-eos/eos/eos_spiner.hpp +++ b/singularity-eos/eos/eos_spiner.hpp @@ -961,6 +961,10 @@ Real SpinerEOSDependsRhoT::PressureFromDensityInternalEnergy(const Real rho, PORTABLE_INLINE_FUNCTION Real SpinerEOSDependsRhoT::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { +#ifndef NDEBUG + printf( + "WARNING: MinInternalEnergtyFromDensity is not defined for Spiner EOS."); +#endif return 0.0; } PORTABLE_INLINE_FUNCTION diff --git a/singularity-eos/eos/eos_stellar_collapse.hpp b/singularity-eos/eos/eos_stellar_collapse.hpp index 6fa869d9ef..37f09090a0 100644 --- a/singularity-eos/eos/eos_stellar_collapse.hpp +++ b/singularity-eos/eos/eos_stellar_collapse.hpp @@ -512,6 +512,11 @@ Real StellarCollapse::PressureFromDensityInternalEnergy(const Real rho, const Re } PORTABLE_INLINE_FUNCTION Real StellarCollapse::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { +#ifndef NDEBUG + printf( + "WARNING: MinInternalEnergtyFromDensity is not defined for stellar collapse EOS."); +#endif + return 0.0; } diff --git a/singularity-eos/eos/eos_vinet.hpp b/singularity-eos/eos/eos_vinet.hpp index 525874229a..8b099f391d 100644 --- a/singularity-eos/eos/eos_vinet.hpp +++ b/singularity-eos/eos/eos_vinet.hpp @@ -308,6 +308,11 @@ PORTABLE_INLINE_FUNCTION Real Vinet::PressureFromDensityInternalEnergy( } PORTABLE_INLINE_FUNCTION Real Vinet::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { +#ifndef NDEBUG + printf( + "WARNING: MinInternalEnergtyFromDensity is not defined for Vinet EOS."); +#endif + return 0.0; } PORTABLE_INLINE_FUNCTION Real Vinet::EntropyFromDensityInternalEnergy( From 1597c466976ab02003dcd51d5616c9b3ccb29049 Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Fri, 4 Aug 2023 08:36:05 -0600 Subject: [PATCH 19/55] clang format --- doc/sphinx/src/models.rst | 18 ++++++++++++--- eospac-wrapper/eospac_wrapper.cpp | 24 +++++++++++--------- eospac-wrapper/eospac_wrapper.hpp | 22 ++++++++++++------ singularity-eos/eos/eos_davis.hpp | 6 ++--- singularity-eos/eos/eos_eospac.hpp | 16 ++++++------- singularity-eos/eos/eos_gruneisen.hpp | 3 +-- singularity-eos/eos/eos_ideal.hpp | 3 +-- singularity-eos/eos/eos_jwl.hpp | 3 +-- singularity-eos/eos/eos_sap_polynomial.hpp | 8 +++---- singularity-eos/eos/eos_spiner.hpp | 3 +-- singularity-eos/eos/eos_stellar_collapse.hpp | 4 ++-- singularity-eos/eos/eos_stiff.hpp | 3 +-- singularity-eos/eos/eos_vinet.hpp | 3 +-- singularity-eos/eos/singularity_eos.cpp | 7 +----- 14 files changed, 66 insertions(+), 57 deletions(-) diff --git a/doc/sphinx/src/models.rst b/doc/sphinx/src/models.rst index 1a0938a23a..e92c8843df 100644 --- a/doc/sphinx/src/models.rst +++ b/doc/sphinx/src/models.rst @@ -1239,11 +1239,23 @@ This is a striaghtforward wrapper of the `EOSPAC`_ library for the .. code-block:: - EOSPAC(int matid, bool invert_at_setup = false) + EOSPAC(int matid, bool invert_at_setup = false, Real insert_data = 0.0, eospacMonotonicity monotonicity = eospacMonotonicity::none, bool apply_smoothing = false, eospacSplit apply_splitting = eospacSplit::none, bool linear_interp = false) -where ``matid`` is the unique material number in the database and +where ``matid`` is the unique material number in the database, ``invert_at_setup`` specifies whether or not pre-compute tables of -temperature as a function of density and energy. +temperature as a function of density and energy, ``insert_data`` +inserts specified number of grid points between original grid points +in the `Sesame`_ table, ``monotonicity` enforces monotonicity in x, +y or both (:math:`monotonicityX/Y/XY`), ``apply_smoothing`` enables +data table smoothing that imposes a linear floor on temperature dependence, +forces linear temperature dependence for low temperature, and forces +linear density dependence for low and high density, ``apply_splitting`` +has the following options for ion data tables not found in the `Sesame`_ +database :. :math:`splitNumProp` uses the cold curve plus number-proportional +model, :math:`splitIdealGas` uses the cold curve plus ideal gas model +and :math:`splitCowan` uses the cold curve plus Cowan-nuclear model +for ions and the final option ``linear_interp`` uses linear instead of +bilinear interpolation. Note for performance reasons this EOS uses a slightly different vector API. See :ref:`EOSPAC Vector Functions ` for more details. diff --git a/eospac-wrapper/eospac_wrapper.cpp b/eospac-wrapper/eospac_wrapper.cpp index 8765d00f2c..451a10ad36 100644 --- a/eospac-wrapper/eospac_wrapper.cpp +++ b/eospac-wrapper/eospac_wrapper.cpp @@ -19,8 +19,8 @@ #include #include #include -#include "eospac_wrapper.hpp" #include +#include "eospac_wrapper.hpp" namespace EospacWrapper { @@ -86,8 +86,8 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, Verbosity eospacWarn) { comments.resize(static_cast(commentLen)); metadata.comments.resize(comments.size()); - - if (commentLen>0) eosSafeTableCmnts(&eospacComments, comments.data(), eospacWarn); + + if (commentLen > 0) eosSafeTableCmnts(&eospacComments, comments.data(), eospacWarn); for (size_t i = 0; i < comments.size(); i++) { metadata.comments[i] = comments[i]; } @@ -107,9 +107,9 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, Verbosity eospacWarn) { EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], Verbosity eospacWarn, - bool invert_at_setup, double insert_data, eospacMonotonicity monotonicity, - bool apply_smoothing, eospacSplit apply_splitting, - bool linear_interp) { + bool invert_at_setup, double insert_data, + eospacMonotonicity monotonicity, bool apply_smoothing, + eospacSplit apply_splitting, bool linear_interp) { std::vector empty; return eosSafeLoad(ntables, matid, tableType, tableHandle, empty, eospacWarn, invert_at_setup, insert_data, monotonicity, apply_smoothing, @@ -119,9 +119,9 @@ EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], const std::vector &table_names, Verbosity eospacWarn, - bool invert_at_setup, double insert_data, eospacMonotonicity monotonicity, - bool apply_smoothing, eospacSplit apply_splitting, - bool linear_interp) { + bool invert_at_setup, double insert_data, + eospacMonotonicity monotonicity, bool apply_smoothing, + eospacSplit apply_splitting, bool linear_interp) { EOS_INTEGER NTABLES[] = {ntables}; std::vector MATID(ntables, matid); @@ -152,7 +152,8 @@ EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], // choice of which table types setOption is called on mimics SAP. Some table types are // incmopatible whiel others lead to numerical issues. - if (monotonicity == eospacMonotonicity::monotonicityX || monotonicity ==eospacMonotonicity::monotonicityXY ) { + if (monotonicity == eospacMonotonicity::monotonicityX || + monotonicity == eospacMonotonicity::monotonicityXY) { for (int i = 0; i < ntables; i++) { if (tableType[i] != EOS_Uc_D and tableType[i] != EOS_Ut_DT and tableType[i] != EOS_Ut_DPt) { @@ -162,7 +163,8 @@ EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], } } - if (monotonicity ==eospacMonotonicity::monotonicityXY || monotonicity == eospacMonotonicity::monotonicityY) { + if (monotonicity == eospacMonotonicity::monotonicityXY || + monotonicity == eospacMonotonicity::monotonicityY) { for (int i = 0; i < ntables; i++) { eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_Y, &(EOS_NullVal), &errorCode); eosCheckError(errorCode, "eospac options: eos_monotonic_in_y", eospacWarn); diff --git a/eospac-wrapper/eospac_wrapper.hpp b/eospac-wrapper/eospac_wrapper.hpp index 3c6e2c4ad2..50b622601f 100644 --- a/eospac-wrapper/eospac_wrapper.hpp +++ b/eospac-wrapper/eospac_wrapper.hpp @@ -22,10 +22,14 @@ #include // eospac API - namespace EospacWrapper { -enum class eospacSplit { none=0, splitNumProp=1, splitIdealGas=2, splitCowan=3 }; -enum class eospacMonotonicity { none=0, monotonicityX=1, monotonicityXY=2, monotonicityY=3 }; +enum class eospacSplit { none = 0, splitNumProp = 1, splitIdealGas = 2, splitCowan = 3 }; +enum class eospacMonotonicity { + none = 0, + monotonicityX = 1, + monotonicityXY = 2, + monotonicityY = 3 +}; inline double densityToSesame(const double CodeTemp) { return CodeTemp; } inline double densityFromSesame(const double sesTemp) { return sesTemp; } inline double temperatureToSesame(const double CodeTemp) { return CodeTemp; } @@ -90,14 +94,18 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], Verbosity eospacWarn, bool invert_at_setup = false, EOS_REAL insert_data = 0.0, - eospacMonotonicity monotonicity = eospacMonotonicity::none, bool apply_smoothing = false, - eospacSplit apply_splitting = eospacSplit::none, bool linear_interp = false); + eospacMonotonicity monotonicity = eospacMonotonicity::none, + bool apply_smoothing = false, + eospacSplit apply_splitting = eospacSplit::none, + bool linear_interp = false); EOS_INTEGER eosSafeLoad(int ntables, int matid, EOS_INTEGER tableType[], EOS_INTEGER tableHandle[], const std::vector &table_names, Verbosity eospacWarn, bool invert_at_setup = false, EOS_REAL insert_data = 0.0, - eospacMonotonicity monotonicity = eospacMonotonicity::none, bool apply_smoothing = false, - eospacSplit apply_splitting = eospacSplit::none, bool linear_interp = false); + eospacMonotonicity monotonicity = eospacMonotonicity::none, + bool apply_smoothing = false, + eospacSplit apply_splitting = eospacSplit::none, + bool linear_interp = false); // output is boolean mask. 1 for no errors. 0 for errors. bool eosSafeInterpolate(EOS_INTEGER *table, EOS_INTEGER nxypairs, EOS_REAL xVals[], diff --git a/singularity-eos/eos/eos_davis.hpp b/singularity-eos/eos/eos_davis.hpp index ae7e004d2e..1e1ca72a8a 100644 --- a/singularity-eos/eos/eos_davis.hpp +++ b/singularity-eos/eos/eos_davis.hpp @@ -64,8 +64,7 @@ class DavisReactants : public EosBase { PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { #ifndef NDEBUG - printf( - "WARNING: MinInternalEnergtyFromDensity is not defined for Davis EOS."); + printf("WARNING: MinInternalEnergtyFromDensity is not defined for Davis EOS."); #endif return 0.0; } @@ -174,8 +173,7 @@ class DavisProducts : public EosBase { PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { #ifndef NDEBUG - printf( - "WARNING: MinInternalEnergtyFromDensity is not defined for Davis EOS."); + printf("WARNING: MinInternalEnergtyFromDensity is not defined for Davis EOS."); #endif return 0.0; } diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 3e501ddeda..73adfedb7c 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -33,11 +33,8 @@ namespace singularity { - - using namespace eos_base; using namespace EospacWrapper; - // How do I make a destructor? How do I free the EOS memory if more than one // points to the same table? Does EOSPAC give me multiple (reference-counted) @@ -52,8 +49,10 @@ class EOSPAC : public EosBase { ////add options here... and elsewhere inline EOSPAC(int matid, bool invert_at_setup = false, Real insert_data = 0.0, - eospacMonotonicity monotonicity = eospacMonotonicity::none, bool apply_smoothing = false, - eospacSplit apply_splitting = eospacSplit::none, bool linear_interp = false); + eospacMonotonicity monotonicity = eospacMonotonicity::none, + bool apply_smoothing = false, + eospacSplit apply_splitting = eospacSplit::none, + bool linear_interp = false); inline EOSPAC GetOnDevice() { return *this; } PORTABLE_INLINE_FUNCTION Real TemperatureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; @@ -1229,7 +1228,8 @@ class EOSPAC : public EosBase { // ====================================================================== inline EOSPAC::EOSPAC(const int matid, bool invert_at_setup, Real insert_data, - EospacWrapper::eospacMonotonicity monotonicity, bool apply_smoothing, EospacWrapper::eospacSplit apply_splitting, + EospacWrapper::eospacMonotonicity monotonicity, + bool apply_smoothing, EospacWrapper::eospacSplit apply_splitting, bool linear_interp) : matid_(matid) { using namespace EospacWrapper; @@ -1240,8 +1240,8 @@ inline EOSPAC::EOSPAC(const int matid, bool invert_at_setup, Real insert_data, std::vector({"EOS_Pt_DT", "EOS_T_DUt", "EOS_Ut_DT", "EOS_D_PtT", "EOS_T_DPt", "EOS_Pt_DUt", "EOS_Uc_D"}), Verbosity::Quiet, invert_at_setup = invert_at_setup, insert_data = insert_data, - monotonicity = monotonicity, apply_smoothing = apply_smoothing, apply_splitting=apply_splitting, - linear_interp = linear_interp); + monotonicity = monotonicity, apply_smoothing = apply_smoothing, + apply_splitting = apply_splitting, linear_interp = linear_interp); PofRT_table_ = tablehandle[0]; TofRE_table_ = tablehandle[1]; EofRT_table_ = tablehandle[2]; diff --git a/singularity-eos/eos/eos_gruneisen.hpp b/singularity-eos/eos/eos_gruneisen.hpp index 9fc5d86741..9718436001 100644 --- a/singularity-eos/eos/eos_gruneisen.hpp +++ b/singularity-eos/eos/eos_gruneisen.hpp @@ -320,8 +320,7 @@ Gruneisen::MinInternalEnergyFromDensity(const Real rho_in, Real *lambda) const { const Real rho = std::min(rho_in, _rho_max); #ifndef NDEBUG - printf( - "WARNING: MinInternalEnergtyFromDensity is not defined for Gruneisen EOS."); + printf("WARNING: MinInternalEnergtyFromDensity is not defined for Gruneisen EOS."); #endif return 0.0; diff --git a/singularity-eos/eos/eos_ideal.hpp b/singularity-eos/eos/eos_ideal.hpp index 5cf620d6a5..66348f1855 100644 --- a/singularity-eos/eos/eos_ideal.hpp +++ b/singularity-eos/eos/eos_ideal.hpp @@ -81,8 +81,7 @@ class IdealGas : public EosBase { PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { #ifndef NDEBUG - printf( - "WARNING: MinInternalEnergtyFromDensity is not defined for ideal gas EOS."); + printf("WARNING: MinInternalEnergtyFromDensity is not defined for ideal gas EOS."); #endif return 0.0; }; diff --git a/singularity-eos/eos/eos_jwl.hpp b/singularity-eos/eos/eos_jwl.hpp index 549adeb340..d8a2428088 100644 --- a/singularity-eos/eos/eos_jwl.hpp +++ b/singularity-eos/eos/eos_jwl.hpp @@ -127,8 +127,7 @@ PORTABLE_INLINE_FUNCTION Real JWL::PressureFromDensityInternalEnergy(const Real PORTABLE_INLINE_FUNCTION Real JWL::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { #ifndef NDEBUG - printf( - "WARNING: MinInternalEnergtyFromDensity is not defined for JWL EOS."); + printf("WARNING: MinInternalEnergtyFromDensity is not defined for JWL EOS."); #endif return 0.0; } diff --git a/singularity-eos/eos/eos_sap_polynomial.hpp b/singularity-eos/eos/eos_sap_polynomial.hpp index 8605a297c4..2706620e3f 100644 --- a/singularity-eos/eos/eos_sap_polynomial.hpp +++ b/singularity-eos/eos/eos_sap_polynomial.hpp @@ -75,11 +75,11 @@ class SAP_Polynomial : public EosBase { sie * (_b0 + _b1 * mu + _b2e * mu * mu + _b3 * mu * mu * mu); } - PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity( - const Real rho, Real *lambda = nullptr) const { + PORTABLE_INLINE_FUNCTION Real + MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { #ifndef NDEBUG - printf( - "WARNING: MinInternalEnergtyFromDensity is not defined for SAP polynomial EOS."); + printf( + "WARNING: MinInternalEnergtyFromDensity is not defined for SAP polynomial EOS."); #endif return 0.0; }; diff --git a/singularity-eos/eos/eos_spiner.hpp b/singularity-eos/eos/eos_spiner.hpp index 133858d384..a4d7f390ef 100644 --- a/singularity-eos/eos/eos_spiner.hpp +++ b/singularity-eos/eos/eos_spiner.hpp @@ -965,8 +965,7 @@ PORTABLE_INLINE_FUNCTION Real SpinerEOSDependsRhoT::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { #ifndef NDEBUG - printf( - "WARNING: MinInternalEnergtyFromDensity is not defined for Spiner EOS."); + printf("WARNING: MinInternalEnergtyFromDensity is not defined for Spiner EOS."); #endif return 0.0; } diff --git a/singularity-eos/eos/eos_stellar_collapse.hpp b/singularity-eos/eos/eos_stellar_collapse.hpp index 5b4a31c9e5..7eb30f845d 100644 --- a/singularity-eos/eos/eos_stellar_collapse.hpp +++ b/singularity-eos/eos/eos_stellar_collapse.hpp @@ -515,8 +515,8 @@ Real StellarCollapse::PressureFromDensityInternalEnergy(const Real rho, const Re PORTABLE_INLINE_FUNCTION Real StellarCollapse::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { #ifndef NDEBUG - printf( - "WARNING: MinInternalEnergtyFromDensity is not defined for stellar collapse EOS."); + printf( + "WARNING: MinInternalEnergtyFromDensity is not defined for stellar collapse EOS."); #endif return 0.0; diff --git a/singularity-eos/eos/eos_stiff.hpp b/singularity-eos/eos/eos_stiff.hpp index 0a08598d93..2a7a679b42 100644 --- a/singularity-eos/eos/eos_stiff.hpp +++ b/singularity-eos/eos/eos_stiff.hpp @@ -81,8 +81,7 @@ class StiffGas : public EosBase { PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { #ifndef NDEBUG - printf( - "WARNING: MinInternalEnergtyFromDensity is not defined for stiff EOS."); + printf("WARNING: MinInternalEnergtyFromDensity is not defined for stiff EOS."); #endif return 0.0; }; diff --git a/singularity-eos/eos/eos_vinet.hpp b/singularity-eos/eos/eos_vinet.hpp index 8b099f391d..559db4d0db 100644 --- a/singularity-eos/eos/eos_vinet.hpp +++ b/singularity-eos/eos/eos_vinet.hpp @@ -309,8 +309,7 @@ PORTABLE_INLINE_FUNCTION Real Vinet::PressureFromDensityInternalEnergy( PORTABLE_INLINE_FUNCTION Real Vinet::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { #ifndef NDEBUG - printf( - "WARNING: MinInternalEnergtyFromDensity is not defined for Vinet EOS."); + printf("WARNING: MinInternalEnergtyFromDensity is not defined for Vinet EOS."); #endif return 0.0; diff --git a/singularity-eos/eos/singularity_eos.cpp b/singularity-eos/eos/singularity_eos.cpp index cfe985c200..062e2a61f7 100644 --- a/singularity-eos/eos/singularity_eos.cpp +++ b/singularity-eos/eos/singularity_eos.cpp @@ -219,7 +219,7 @@ int init_sg_eospac(const int matindex, EOS *eos, const int id, double *const eos EOS eos_ = SGAPPLYMOD( EOSPAC(id, invert_at_setup = invert_at_setup, insert_data = insert_data, monotonicity = monotonicity, apply_smoothing = apply_smoothing, - apply_splitting = apply_splitting, linear_interp = linear_interp)); + apply_splitting = apply_splitting, linear_interp = linear_interp)); eos[matindex] = eos_.GetOnDevice(); return 0; } @@ -229,8 +229,6 @@ int init_sg_eospac(const int matindex, EOS *eos, const int id, } #endif // SINGULARITY_USE_EOSPAC - - int init_sg_SAP_Polynomial(const int matindex, EOS *eos, const double rho0, const double a0, const double a1, const double a2c, const double a2e, const double a3, const double b0, @@ -268,7 +266,6 @@ int init_sg_StiffGas(const int matindex, EOS *eos, const double gm1, const doubl return init_sg_StiffGas(matindex, eos, gm1, Cv, Pinf, qq, def_en, def_v); } - #ifdef PORTABILITY_STRATEGY_KOKKOS using Lrgt = Kokkos::LayoutRight; using Llft = Kokkos::LayoutLeft; @@ -847,7 +844,6 @@ int get_sg_eos( // sizing information return ret; } - #undef SGAPPLYMOD int get_sg_PressureFromDensityInternalEnergy(int matindex, EOS *eos, const double *rhos, @@ -870,7 +866,6 @@ int get_sg_BulkModulusFromDensityInternalEnergy(int matindex, EOS *eos, return 0; } - int finalize_sg_eos(const int nmat, EOS *&eos, const int own_kokkos) { { for (int i = 0; i < nmat; ++i) From 743d081e3bad4802d2b2259e227c9d10c5674cd9 Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Fri, 11 Aug 2023 14:20:40 -0600 Subject: [PATCH 20/55] Update submodule hashes --- utils/kokkos | 2 +- utils/spiner | 2 +- utils/variant | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/kokkos b/utils/kokkos index 1fb0c284d4..5ad609661e 160000 --- a/utils/kokkos +++ b/utils/kokkos @@ -1 +1 @@ -Subproject commit 1fb0c284d458c75370094921d9f202c287502325 +Subproject commit 5ad609661e570ba6aa7716a26a91cb67d559f8a2 diff --git a/utils/spiner b/utils/spiner index cba97e8cd9..c76462824c 160000 --- a/utils/spiner +++ b/utils/spiner @@ -1 +1 @@ -Subproject commit cba97e8cd90af34d77499cc72830a31f33a20d1b +Subproject commit c76462824ca56e83ce6257f05da3454af042ac0c diff --git a/utils/variant b/utils/variant index 3c7fc8266b..23cb94f027 160000 --- a/utils/variant +++ b/utils/variant @@ -1 +1 @@ -Subproject commit 3c7fc8266bb46046b42c2dc2663f9f505f0cec28 +Subproject commit 23cb94f027d4ef33bf48133acc2695c7e5c6f1e7 From ba7277200f21716c43b7e6a3a959670be7caf89e Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Thu, 17 Aug 2023 13:41:53 -0600 Subject: [PATCH 21/55] Fix eospac empty comment check --- eospac-wrapper/eospac_wrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eospac-wrapper/eospac_wrapper.cpp b/eospac-wrapper/eospac_wrapper.cpp index 451a10ad36..5d45ca23d3 100644 --- a/eospac-wrapper/eospac_wrapper.cpp +++ b/eospac-wrapper/eospac_wrapper.cpp @@ -87,7 +87,7 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, Verbosity eospacWarn) { comments.resize(static_cast(commentLen)); metadata.comments.resize(comments.size()); - if (commentLen > 0) eosSafeTableCmnts(&eospacComments, comments.data(), eospacWarn); + if (comments.size() > 0) eosSafeTableCmnts(&eospacComments, comments.data(), eospacWarn); for (size_t i = 0; i < comments.size(); i++) { metadata.comments[i] = comments[i]; } From 723fd9fd6140090ad583539fa4d23c9edcd4a414 Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Thu, 17 Aug 2023 16:07:57 -0600 Subject: [PATCH 22/55] fix merge issues --- singularity-eos/eos/singularity_eos.cpp | 36 ------------------------- 1 file changed, 36 deletions(-) diff --git a/singularity-eos/eos/singularity_eos.cpp b/singularity-eos/eos/singularity_eos.cpp index 2cab0cb207..5fcea20501 100644 --- a/singularity-eos/eos/singularity_eos.cpp +++ b/singularity-eos/eos/singularity_eos.cpp @@ -281,42 +281,6 @@ int init_sg_eospac(const int matindex, EOS *eos, const int id, } #endif // SINGULARITY_USE_EOSPAC -int init_sg_SAP_Polynomial(const int matindex, EOS *eos, const double rho0, - const double a0, const double a1, const double a2c, - const double a2e, const double a3, const double b0, - const double b1, const double b2c, const double b2e, - const double b3, int const *const enabled, - double *const vals) { - assert(matindex >= 0); - EOS eosi = - SGAPPLYMODSIMPLE(SAP_Polynomial(rho0, a0, a1, a2c, a2e, a3, b0, b1, b2c, b2e, b3)); - if (enabled[3] == 1) { - singularity::pAlpha2BilinearRampParams(eosi, vals[2], vals[3], vals[4], vals[2], - vals[3], vals[4], vals[5]); - } - EOS eos_ = SGAPPLYMOD(SAP_Polynomial(rho0, a0, a1, a2c, a2e, a3, b0, b1, b2c, b2e, b3)); - eos[matindex] = eos_.GetOnDevice(); - return 0; -} - -int init_sg_StiffGas(const int matindex, EOS *eos, const double gm1, const double Cv, - const double Pinf, const double qq, int const *const enabled, - double *const vals) { - assert(matindex >= 0); - EOS eosi = SGAPPLYMODSIMPLE(StiffGas(gm1, Cv, Pinf, qq)); - if (enabled[3] == 1) { - singularity::pAlpha2BilinearRampParams(eosi, vals[2], vals[3], vals[4], vals[2], - vals[3], vals[4], vals[5]); - } - EOS eos_ = SGAPPLYMOD(StiffGas(gm1, Cv, Pinf, qq)); - eos[matindex] = eos_.GetOnDevice(); - return 0; -} - -int init_sg_StiffGas(const int matindex, EOS *eos, const double gm1, const double Cv, - const double Pinf, const double qq) { - return init_sg_StiffGas(matindex, eos, gm1, Cv, Pinf, qq, def_en, def_v); -} int finalize_sg_eos(const int nmat, EOS *&eos, const int own_kokkos) { { From 306937647320b6806632d9a20d0e57ac52828b28 Mon Sep 17 00:00:00 2001 From: Anna Pietarila Graham Date: Thu, 17 Aug 2023 16:26:40 -0600 Subject: [PATCH 23/55] More merge fixes --- singularity-eos/eos/eos_noble_abel.hpp | 9 +++++++++ singularity-eos/eos/singularity_eos.cpp | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/singularity-eos/eos/eos_noble_abel.hpp b/singularity-eos/eos/eos_noble_abel.hpp index 18e5843072..a3d5001a99 100644 --- a/singularity-eos/eos/eos_noble_abel.hpp +++ b/singularity-eos/eos/eos_noble_abel.hpp @@ -80,6 +80,14 @@ class NobleAbel : public EosBase { return std::max(robust::SMALL(), robust::ratio(_gm1 * rho * (sie - _qq), 1.0 - _bb * rho)); } + PORTABLE_INLINE_FUNCTION Real + MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { +#ifndef NDEBUG + printf("WARNING: MinInternalEnergtyFromDensity is not defined for Noble Abel EOS."); +#endif + return 0.0; + } + PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( const Real rho, const Real temperature, Real *lambda = nullptr) const { const Real vol = robust::ratio(1.0, rho); @@ -95,6 +103,7 @@ class NobleAbel : public EosBase { _gm1 * _Cv * std::log(robust::ratio(vol - _bb, _vol0 - _bb) + robust::SMALL()) + _qp; + } PORTABLE_INLINE_FUNCTION Real SpecificHeatFromDensityTemperature( const Real rho, const Real temperature, Real *lambda = nullptr) const { diff --git a/singularity-eos/eos/singularity_eos.cpp b/singularity-eos/eos/singularity_eos.cpp index 5fcea20501..ed6415b1b4 100644 --- a/singularity-eos/eos/singularity_eos.cpp +++ b/singularity-eos/eos/singularity_eos.cpp @@ -282,6 +282,24 @@ int init_sg_eospac(const int matindex, EOS *eos, const int id, #endif // SINGULARITY_USE_EOSPAC + + +int get_sg_PressureFromDensityInternalEnergy(int matindex, EOS *eos, const double *rhos, const double *sies, double *pressures, + const int len) { + eos[matindex].PressureFromDensityInternalEnergy(rhos, sies, pressures, len); + return 0; +} +int get_sg_MinInternalEnergyFromDensity(int matindex, EOS *eos, const double *rhos, double *sies, const int len) { + eos[matindex].MinInternalEnergyFromDensity(rhos, sies, len); + return 0; + } +int get_sg_BulkModulusFromDensityInternalEnergy(int matindex, EOS *eos, const double *rhos, const double *sies, double *bmods, const int len) { + eos[matindex].BulkModulusFromDensityInternalEnergy(rhos, sies, bmods, len); + return 0; +} + + + int finalize_sg_eos(const int nmat, EOS *&eos, const int own_kokkos) { { for (int i = 0; i < nmat; ++i) From e4cc9b7f179bce9e6fadf62928c45dbad42a1e26 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Mon, 18 Sep 2023 15:05:38 -0600 Subject: [PATCH 24/55] clang format --- eospac-wrapper/eospac_wrapper.cpp | 7 ++++--- eospac-wrapper/eospac_wrapper.hpp | 1 + singularity-eos/eos/eos_noble_abel.hpp | 1 - singularity-eos/eos/singularity_eos.cpp | 24 +++++++++++------------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/eospac-wrapper/eospac_wrapper.cpp b/eospac-wrapper/eospac_wrapper.cpp index 5d45ca23d3..67643ac107 100644 --- a/eospac-wrapper/eospac_wrapper.cpp +++ b/eospac-wrapper/eospac_wrapper.cpp @@ -14,13 +14,13 @@ // publicly and display publicly, and to permit others to do so. //====================================================================== +#include "eospac_wrapper.hpp" #include +#include #include #include #include #include -#include -#include "eospac_wrapper.hpp" namespace EospacWrapper { @@ -87,7 +87,8 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, Verbosity eospacWarn) { comments.resize(static_cast(commentLen)); metadata.comments.resize(comments.size()); - if (comments.size() > 0) eosSafeTableCmnts(&eospacComments, comments.data(), eospacWarn); + if (comments.size() > 0) + eosSafeTableCmnts(&eospacComments, comments.data(), eospacWarn); for (size_t i = 0; i < comments.size(); i++) { metadata.comments[i] = comments[i]; } diff --git a/eospac-wrapper/eospac_wrapper.hpp b/eospac-wrapper/eospac_wrapper.hpp index 50b622601f..a9c285d656 100644 --- a/eospac-wrapper/eospac_wrapper.hpp +++ b/eospac-wrapper/eospac_wrapper.hpp @@ -19,6 +19,7 @@ #include #include +#include #include // eospac API diff --git a/singularity-eos/eos/eos_noble_abel.hpp b/singularity-eos/eos/eos_noble_abel.hpp index a3d5001a99..86eaaab29b 100644 --- a/singularity-eos/eos/eos_noble_abel.hpp +++ b/singularity-eos/eos/eos_noble_abel.hpp @@ -103,7 +103,6 @@ class NobleAbel : public EosBase { _gm1 * _Cv * std::log(robust::ratio(vol - _bb, _vol0 - _bb) + robust::SMALL()) + _qp; - } PORTABLE_INLINE_FUNCTION Real SpecificHeatFromDensityTemperature( const Real rho, const Real temperature, Real *lambda = nullptr) const { diff --git a/singularity-eos/eos/singularity_eos.cpp b/singularity-eos/eos/singularity_eos.cpp index ed6415b1b4..8fe146180b 100644 --- a/singularity-eos/eos/singularity_eos.cpp +++ b/singularity-eos/eos/singularity_eos.cpp @@ -150,7 +150,6 @@ int init_sg_DavisReactants(const int matindex, EOS *eos, const double rho0, Cv0, def_en, def_v); } - int init_sg_SAP_Polynomial(const int matindex, EOS *eos, const double rho0, const double a0, const double a1, const double a2c, const double a2e, const double a3, const double b0, @@ -281,25 +280,24 @@ int init_sg_eospac(const int matindex, EOS *eos, const int id, } #endif // SINGULARITY_USE_EOSPAC - - - -int get_sg_PressureFromDensityInternalEnergy(int matindex, EOS *eos, const double *rhos, const double *sies, double *pressures, - const int len) { +int get_sg_PressureFromDensityInternalEnergy(int matindex, EOS *eos, const double *rhos, + const double *sies, double *pressures, + const int len) { eos[matindex].PressureFromDensityInternalEnergy(rhos, sies, pressures, len); return 0; } -int get_sg_MinInternalEnergyFromDensity(int matindex, EOS *eos, const double *rhos, double *sies, const int len) { - eos[matindex].MinInternalEnergyFromDensity(rhos, sies, len); - return 0; - } -int get_sg_BulkModulusFromDensityInternalEnergy(int matindex, EOS *eos, const double *rhos, const double *sies, double *bmods, const int len) { +int get_sg_MinInternalEnergyFromDensity(int matindex, EOS *eos, const double *rhos, + double *sies, const int len) { + eos[matindex].MinInternalEnergyFromDensity(rhos, sies, len); + return 0; +} +int get_sg_BulkModulusFromDensityInternalEnergy(int matindex, EOS *eos, + const double *rhos, const double *sies, + double *bmods, const int len) { eos[matindex].BulkModulusFromDensityInternalEnergy(rhos, sies, bmods, len); return 0; } - - int finalize_sg_eos(const int nmat, EOS *&eos, const int own_kokkos) { { for (int i = 0; i < nmat; ++i) From edbf05ef854fa9cc8e0bfba5511c91a81a76e84d Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Tue, 19 Sep 2023 14:01:18 -0600 Subject: [PATCH 25/55] Use C preprocessor on fortran files --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59ad2c2c3d..795c7a5ef0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -383,8 +383,10 @@ endforeach() target_sources(singularity-eos PRIVATE ${_srcs} ${_headers}) -# make sure .mods are placed in build path, and installed along with includes if(SINGULARITY_USE_FORTRAN) + # Turn on preprocessor for fortran files + set_target_properties(singularity-eos PROPERTIES Fortran_PREPROCESS ON) + # make sure .mods are placed in build path, and installed along with includes set_target_properties(singularity-eos PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories( From 9b83dd402802ca5067f6ac92968c232c3439076f Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Tue, 19 Sep 2023 14:02:30 -0600 Subject: [PATCH 26/55] Add preprocessor #ifdefs around initialization functions --- singularity-eos/eos/singularity_eos.f90 | 82 +++++++++++++++---------- 1 file changed, 50 insertions(+), 32 deletions(-) diff --git a/singularity-eos/eos/singularity_eos.f90 b/singularity-eos/eos/singularity_eos.f90 index 369f15b8c5..a98f50a5a8 100644 --- a/singularity-eos/eos/singularity_eos.f90 +++ b/singularity-eos/eos/singularity_eos.f90 @@ -40,10 +40,16 @@ module singularity_eos init_sg_NobleAbel_f,& init_sg_SAP_Polynomial_f,& init_sg_StiffGas_f,& +#ifdef SINGULARITY_USE_HELMHOLTZ init_sg_Helmholtz_f,& +#endif +#ifdef SINGULARITY_USE_SPINER_WITH_HDF5 init_sg_SpinerDependsRhoT_f,& init_sg_SpinerDependsRhoSie_f,& +#endif +#ifdef SINGULARITY_USE_EOSPAC init_sg_eospac_f,& +#endif get_sg_PressureFromDensityInternalEnergy_f,& get_sg_MinInternalEnergyFromDensity_f,& get_sg_BulkModulusFromDensityInternalEnergy_f,& @@ -168,6 +174,7 @@ end function init_sg_StiffGas end function init_sg_SAP_Polynomial end interface +#ifdef SINGULARITY_USE_HELMHOLTZ interface integer(kind=c_int) function & init_sg_Helmholtz(matindex, eos, filename, rad, gas, coul, ion, ele, & @@ -182,7 +189,9 @@ end function init_sg_SAP_Polynomial type(c_ptr), value, intent(in) :: sg_mods_enabled, sg_mods_values end function init_sg_Helmholtz end interface +#endif +#ifdef SINGULARITY_USE_SPINER_WITH_HDF5 interface integer(kind=c_int) function & init_sg_SpinerDependsRhoT(matindex, eos, filename, id, sg_mods_enabled, & @@ -208,7 +217,9 @@ end function init_sg_SpinerDependsRhoT type(c_ptr), value, intent(in) :: sg_mods_enabled, sg_mods_values end function init_sg_SpinerDependsRhoSie end interface +#endif +#ifdef SINGULARITY_USE_EOSPAC interface integer(kind=c_int) function & init_sg_eospac(matindex, eos, id, eospac_opts_values, sg_mods_enabled, & @@ -221,6 +232,7 @@ end function init_sg_SpinerDependsRhoSie type(c_ptr), value, intent(in) :: eospac_opts_values end function init_sg_eospac end interface +#endif interface integer(kind=c_int) function & @@ -485,6 +497,7 @@ integer function init_sg_NobleAbel_f(matindex, eos, gm1, Cv, & c_loc(sg_mods_enabled), c_loc(sg_mods_values)) end function init_sg_NobleAbel_f +#ifdef SINGULARITY_USE_HELMHOLTZ integer function init_sg_Helmholtz_f(matindex, eos, filename, rad, gas, coul, ion, ele, & verbose, sg_mods_enabled, sg_mods_values) & result(err) @@ -499,38 +512,42 @@ integer function init_sg_Helmholtz_f(matindex, eos, filename, rad, gas, coul, io rad, gas, coul, ion, ele, verbose, & c_loc(sg_mods_enabled), c_loc(sg_mods_values)) end function init_sg_Helmholtz_f - -! integer function init_sg_SpinerDependsRhoT_f(matindex, eos, filename, id, & -! sg_mods_enabled, & -! sg_mods_values) & -! result(err) -! integer(c_int), value, intent(in) :: matindex -! type(sg_eos_ary_t), intent(in) :: eos -! character(len=*, kind=c_char), intent(in) :: filename -! integer(c_int), intent(inout) :: id -! integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled -! real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values -! err = init_sg_SpinerDependsRhoT(matindex-1, eos%ptr,& -! trim(filename)//C_NULL_CHAR, id, & -! c_loc(sg_mods_enabled), & -! c_loc(sg_mods_values)) -! end function init_sg_SpinerDependsRhoT_f - -! integer function init_sg_SpinerDependsRhoSie_f(matindex, eos, filename, id, & -! sg_mods_enabled, & -! sg_mods_values) & -! result(err) -! integer(c_int), value, intent(in) :: matindex, id -! type(sg_eos_ary_t), intent(in) :: eos -! character(len=*, kind=c_char), intent(in) :: filename -! integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled -! real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values -! err = init_sg_SpinerDependsRhoSie(matindex-1, eos%ptr,& -! trim(filename)//C_NULL_CHAR, id, & -! c_loc(sg_mods_enabled), & -! c_loc(sg_mods_values)) -! end function init_sg_SpinerDependsRhoSie_f - +#endif + +#ifdef SINGULARITY_USE_SPINER_WITH_HDF5 + integer function init_sg_SpinerDependsRhoT_f(matindex, eos, filename, id, & + sg_mods_enabled, & + sg_mods_values) & + result(err) + integer(c_int), value, intent(in) :: matindex + type(sg_eos_ary_t), intent(in) :: eos + character(len=*, kind=c_char), intent(in) :: filename + integer(c_int), intent(inout) :: id + integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + err = init_sg_SpinerDependsRhoT(matindex-1, eos%ptr,& + trim(filename)//C_NULL_CHAR, id, & + c_loc(sg_mods_enabled), & + c_loc(sg_mods_values)) + end function init_sg_SpinerDependsRhoT_f + + integer function init_sg_SpinerDependsRhoSie_f(matindex, eos, filename, id, & + sg_mods_enabled, & + sg_mods_values) & + result(err) + integer(c_int), value, intent(in) :: matindex, id + type(sg_eos_ary_t), intent(in) :: eos + character(len=*, kind=c_char), intent(in) :: filename + integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + err = init_sg_SpinerDependsRhoSie(matindex-1, eos%ptr,& + trim(filename)//C_NULL_CHAR, id, & + c_loc(sg_mods_enabled), & + c_loc(sg_mods_values)) + end function init_sg_SpinerDependsRhoSie_f +#endif + +#ifdef SINGULARITY_USE_EOSPAC integer function init_sg_eospac_f(matindex, eos, id, eospac_opts_values, & sg_mods_enabled, sg_mods_values) & result(err) @@ -542,6 +559,7 @@ integer function init_sg_eospac_f(matindex, eos, id, eospac_opts_values, & err = init_sg_eospac(matindex-1, eos%ptr, id, c_loc(eospac_opts_values), & c_loc(sg_mods_enabled), c_loc(sg_mods_values)) end function init_sg_eospac_f +#endif integer function get_sg_PressureFromDensityInternalEnergy_f(matindex, & eos, rhos, sies, pressures, len) & From b150ac47632664107b4ba940023891cc862e1773 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Thu, 28 Sep 2023 18:34:11 -0600 Subject: [PATCH 27/55] Add minimum energy not enabled function --- singularity-eos/eos/eos_base.hpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/singularity-eos/eos/eos_base.hpp b/singularity-eos/eos/eos_base.hpp index 85683193a3..462c70cf5f 100644 --- a/singularity-eos/eos/eos_base.hpp +++ b/singularity-eos/eos/eos_base.hpp @@ -35,7 +35,7 @@ namespace singularity { namespace eos_base { namespace impl { -constexpr std::size_t MAX_NUM_CHARS = 81; +constexpr std::size_t MAX_NUM_CHARS = 121; // Cuda doesn't have strcat, so we implement it ourselves PORTABLE_FORCEINLINE_FUNCTION char *StrCat(char *destination, const char *source) { @@ -81,6 +81,7 @@ char *StrCat(char *destination, const char *source) { using EosBase::EntropyFromDensityTemperature; \ using EosBase::EntropyFromDensityInternalEnergy; \ using EosBase::EntropyIsNotEnabled; \ + using EosBase::MinInternalEnergyIsNotEnabled; \ using EosBase::IsModified; \ using EosBase::UnmodifyOnce; \ using EosBase::GetUnmodifiedObject; @@ -586,7 +587,7 @@ class EosBase { PORTABLE_INLINE_FUNCTION Real RhoPmin(const Real temp) const { return 0.0; } - // Default entropy behavior is to return an error + // Default entropy behavior is to cause an error PORTABLE_FORCEINLINE_FUNCTION void EntropyIsNotEnabled(const char *eosname) const { // Construct the error message using char* so it works on device @@ -600,6 +601,20 @@ class EosBase { PORTABLE_ALWAYS_THROW_OR_ABORT(msg); } + // Default MinInternalEnergyFromDensity behavior is to cause an error + PORTABLE_FORCEINLINE_FUNCTION + void MinInternalEnergyIsNotEnabled(const char *eosname) const { + // Construct the error message using char* so it works on device + // WARNING: This needs to be updated if EOS names get longer + // base msg length 32 + 5 chars = 37 chars + // + 1 char for null terminator + // maximum allowed EOS length = 44 chars + char msg[impl::MAX_NUM_CHARS] = "MinInternalEnergyFromDensity() is not enabled for the '"; + impl::StrCat(msg, eosname); + impl::StrCat(msg, "' EOS"); + PORTABLE_ALWAYS_THROW_OR_ABORT(msg); + } + // Tooling for modifiers inline constexpr bool IsModified() const { return false; } From 6000aa75b712066e987ebb64b353473c6cc31aa7 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Thu, 28 Sep 2023 18:38:58 -0600 Subject: [PATCH 28/55] Switch to using default error message funciton for non-enabled minimum energy functions --- singularity-eos/eos/eos_davis.hpp | 8 ++------ singularity-eos/eos/eos_gruneisen.hpp | 6 +----- singularity-eos/eos/eos_helmholtz.hpp | 5 +++++ singularity-eos/eos/eos_ideal.hpp | 3 --- singularity-eos/eos/eos_jwl.hpp | 4 +--- singularity-eos/eos/eos_noble_abel.hpp | 4 +--- singularity-eos/eos/eos_sap_polynomial.hpp | 5 +---- singularity-eos/eos/eos_spiner.hpp | 5 ++--- singularity-eos/eos/eos_stellar_collapse.hpp | 6 +----- singularity-eos/eos/eos_stiff.hpp | 4 +--- 10 files changed, 15 insertions(+), 35 deletions(-) diff --git a/singularity-eos/eos/eos_davis.hpp b/singularity-eos/eos/eos_davis.hpp index 5e71a84b89..c24b826821 100644 --- a/singularity-eos/eos/eos_davis.hpp +++ b/singularity-eos/eos/eos_davis.hpp @@ -63,9 +63,7 @@ class DavisReactants : public EosBase { PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { -#ifndef NDEBUG - printf("WARNING: MinInternalEnergtyFromDensity is not defined for Davis EOS."); -#endif + MinInternalEnergyIsNotEnabled("DavisReactants"); return 0.0; } PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( @@ -172,9 +170,7 @@ class DavisProducts : public EosBase { } PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { -#ifndef NDEBUG - printf("WARNING: MinInternalEnergtyFromDensity is not defined for Davis EOS."); -#endif + MinInternalEnergyIsNotEnabled("DavisProducts"); return 0.0; } PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( diff --git a/singularity-eos/eos/eos_gruneisen.hpp b/singularity-eos/eos/eos_gruneisen.hpp index 9718436001..1cbdc90061 100644 --- a/singularity-eos/eos/eos_gruneisen.hpp +++ b/singularity-eos/eos/eos_gruneisen.hpp @@ -318,11 +318,7 @@ PORTABLE_INLINE_FUNCTION Real Gruneisen::PressureFromDensityInternalEnergy( PORTABLE_INLINE_FUNCTION Real Gruneisen::MinInternalEnergyFromDensity(const Real rho_in, Real *lambda) const { const Real rho = std::min(rho_in, _rho_max); - -#ifndef NDEBUG - printf("WARNING: MinInternalEnergtyFromDensity is not defined for Gruneisen EOS."); -#endif - + MinInternalEnergyIsNotEnabled("Gruneisen"); return 0.0; } PORTABLE_INLINE_FUNCTION Real Gruneisen::EntropyFromDensityInternalEnergy( diff --git a/singularity-eos/eos/eos_helmholtz.hpp b/singularity-eos/eos/eos_helmholtz.hpp index 8464bf1bf0..b24f149aef 100644 --- a/singularity-eos/eos/eos_helmholtz.hpp +++ b/singularity-eos/eos/eos_helmholtz.hpp @@ -484,6 +484,11 @@ class Helmholtz : public EosBase { thermalqs::pressure | thermalqs::temperature, lambda); return p; } + PORTABLE_INLINE_FUNCTION Real + MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { + MinInternalEnergyIsNotEnabled("Helmholtz"); + return 0.0; + } PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( const Real rho, const Real temperature, Real *lambda = nullptr) const { diff --git a/singularity-eos/eos/eos_ideal.hpp b/singularity-eos/eos/eos_ideal.hpp index 66348f1855..dc52e84fa7 100644 --- a/singularity-eos/eos/eos_ideal.hpp +++ b/singularity-eos/eos/eos_ideal.hpp @@ -80,9 +80,6 @@ class IdealGas : public EosBase { } PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { -#ifndef NDEBUG - printf("WARNING: MinInternalEnergtyFromDensity is not defined for ideal gas EOS."); -#endif return 0.0; }; diff --git a/singularity-eos/eos/eos_jwl.hpp b/singularity-eos/eos/eos_jwl.hpp index d8a2428088..304bd64b0d 100644 --- a/singularity-eos/eos/eos_jwl.hpp +++ b/singularity-eos/eos/eos_jwl.hpp @@ -126,9 +126,7 @@ PORTABLE_INLINE_FUNCTION Real JWL::PressureFromDensityInternalEnergy(const Real } PORTABLE_INLINE_FUNCTION Real JWL::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { -#ifndef NDEBUG - printf("WARNING: MinInternalEnergtyFromDensity is not defined for JWL EOS."); -#endif + MinInternalEnergyIsNotEnabled("JWL"); return 0.0; } PORTABLE_INLINE_FUNCTION Real JWL::EntropyFromDensityInternalEnergy(const Real rho, diff --git a/singularity-eos/eos/eos_noble_abel.hpp b/singularity-eos/eos/eos_noble_abel.hpp index 86eaaab29b..fc2edd49c4 100644 --- a/singularity-eos/eos/eos_noble_abel.hpp +++ b/singularity-eos/eos/eos_noble_abel.hpp @@ -82,9 +82,7 @@ class NobleAbel : public EosBase { } PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { -#ifndef NDEBUG - printf("WARNING: MinInternalEnergtyFromDensity is not defined for Noble Abel EOS."); -#endif + MinInternalEnergyIsNotEnabled("Noble Abel"); return 0.0; } diff --git a/singularity-eos/eos/eos_sap_polynomial.hpp b/singularity-eos/eos/eos_sap_polynomial.hpp index 2706620e3f..c5d0369c7c 100644 --- a/singularity-eos/eos/eos_sap_polynomial.hpp +++ b/singularity-eos/eos/eos_sap_polynomial.hpp @@ -77,10 +77,7 @@ class SAP_Polynomial : public EosBase { PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { -#ifndef NDEBUG - printf( - "WARNING: MinInternalEnergtyFromDensity is not defined for SAP polynomial EOS."); -#endif + MinInternalEnergyIsNotEnabled("SAP Polynomial"); return 0.0; }; diff --git a/singularity-eos/eos/eos_spiner.hpp b/singularity-eos/eos/eos_spiner.hpp index a8e3ef4411..45938111cf 100644 --- a/singularity-eos/eos/eos_spiner.hpp +++ b/singularity-eos/eos/eos_spiner.hpp @@ -958,9 +958,7 @@ Real SpinerEOSDependsRhoT::PressureFromDensityInternalEnergy(const Real rho, PORTABLE_INLINE_FUNCTION Real SpinerEOSDependsRhoT::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { -#ifndef NDEBUG - printf("WARNING: MinInternalEnergtyFromDensity is not defined for Spiner EOS."); -#endif + MinInternalEnergyIsNotEnabled("SpinerEOSDependsRhoT"); return 0.0; } PORTABLE_INLINE_FUNCTION @@ -1721,6 +1719,7 @@ Real SpinerEOSDependsRhoSie::PressureFromDensityInternalEnergy(const Real rho, PORTABLE_INLINE_FUNCTION Real SpinerEOSDependsRhoSie::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { + MinInternalEnergyIsNotEnabled("SpinerEOSDependsRhoSie"); return 0.0; } diff --git a/singularity-eos/eos/eos_stellar_collapse.hpp b/singularity-eos/eos/eos_stellar_collapse.hpp index 974a20d4fa..9aeabf79b8 100644 --- a/singularity-eos/eos/eos_stellar_collapse.hpp +++ b/singularity-eos/eos/eos_stellar_collapse.hpp @@ -512,11 +512,7 @@ Real StellarCollapse::PressureFromDensityInternalEnergy(const Real rho, const Re } PORTABLE_INLINE_FUNCTION Real StellarCollapse::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { -#ifndef NDEBUG - printf( - "WARNING: MinInternalEnergtyFromDensity is not defined for stellar collapse EOS."); -#endif - + MinInternalEnergyIsNotEnabled("Stellar Collapse"); return 0.0; } diff --git a/singularity-eos/eos/eos_stiff.hpp b/singularity-eos/eos/eos_stiff.hpp index 2a7a679b42..60ad252db3 100644 --- a/singularity-eos/eos/eos_stiff.hpp +++ b/singularity-eos/eos/eos_stiff.hpp @@ -80,9 +80,7 @@ class StiffGas : public EosBase { PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { -#ifndef NDEBUG - printf("WARNING: MinInternalEnergtyFromDensity is not defined for stiff EOS."); -#endif + // TODO: Calculate zero temperature minimum equation return 0.0; }; From dd1dfc586419ac58caa5b4915658b775226bfd0c Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Thu, 28 Sep 2023 18:39:50 -0600 Subject: [PATCH 29/55] Add performance warning for vector lookups without scratch. Correct unit converison issue --- singularity-eos/eos/eos_eospac.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 34f9f3e74b..bdcb8aa044 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -177,6 +177,7 @@ class EOSPAC : public EosBase { ConstRealIndexer &&sies, RealIndexer &&pressures, const int num, LambdaIndexer &&lambdas) const { + PORTABLE_WARN("Not providing scratch memory will trigger scalar EOSPAC lookups"); EosBase::PressureFromDensityInternalEnergy(rhos, sies, pressures, num, lambdas); } @@ -1380,7 +1381,7 @@ PORTABLE_INLINE_FUNCTION Real EOSPAC::PressureFromDensityInternalEnergy( EOS_INTEGER options[]{EOS_Y_CONVERT, EOS_F_CONVERT}; EOS_REAL values[]{sieToSesame(1.0), pressureFromSesame(1.0)}; EOS_INTEGER nopts = 2; - EOS_REAL R[1] = {rho}, E[1] = {sieToSesame(sie)}, P[1], dPdr[1], dPde[1], Ec[1]; + EOS_REAL R[1] = {rho}, E[1] = {sie}, P[1], dPdr[1], dPde[1], Ec[1]; EOS_INTEGER nxypairs = 1; EOS_INTEGER table = PofRE_table_; eosSafeInterpolate(&table, nxypairs, R, E, P, dPdr, dPde, "PofRE", Verbosity::Quiet, From f1f8a93651f1d366f0f072b9de6026a6019b4185 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Tue, 10 Oct 2023 12:42:41 -0600 Subject: [PATCH 30/55] Fix unit conversions in EOSPAC --- singularity-eos/eos/eos_eospac.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index bdcb8aa044..a1e299dce7 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -1270,7 +1270,7 @@ PORTABLE_INLINE_FUNCTION void EOSPAC::FillEos(Real &rho, Real &temp, Real &sie, Real *lambda) const { using namespace EospacWrapper; EOS_REAL R[1] = {rho}, T[1] = {temperatureToSesame(temp)}; - EOS_REAL E[1] = {sie}, P[1] = {pressureToSesame(press)}; + EOS_REAL E[1] = {sieToSesame(sie)}, P[1] = {pressureToSesame(press)}; EOS_REAL dx[1], dy[1]; EOS_INTEGER nxypairs = 1; Real /*CV,*/ BMOD_T, BMOD, SIE, PRESS, DPDE, DPDT, DPDR, DEDT, DEDR; @@ -1379,7 +1379,7 @@ PORTABLE_INLINE_FUNCTION Real EOSPAC::PressureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda) const { using namespace EospacWrapper; EOS_INTEGER options[]{EOS_Y_CONVERT, EOS_F_CONVERT}; - EOS_REAL values[]{sieToSesame(1.0), pressureFromSesame(1.0)}; + EOS_REAL values[]{sieFromSesame(1.0), pressureFromSesame(1.0)}; EOS_INTEGER nopts = 2; EOS_REAL R[1] = {rho}, E[1] = {sie}, P[1], dPdr[1], dPde[1], Ec[1]; EOS_INTEGER nxypairs = 1; From a29e1ad8fc47e753056fbaea95adf9edea9d949c Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Thu, 26 Oct 2023 15:01:38 -0600 Subject: [PATCH 31/55] Improve error message --- singularity-eos/eos/eos_base.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/singularity-eos/eos/eos_base.hpp b/singularity-eos/eos/eos_base.hpp index 462c70cf5f..c230d0dc27 100644 --- a/singularity-eos/eos/eos_base.hpp +++ b/singularity-eos/eos/eos_base.hpp @@ -595,7 +595,7 @@ class EosBase { // base msg length 32 + 5 chars = 37 chars // + 1 char for null terminator // maximum allowed EOS length = 44 chars - char msg[impl::MAX_NUM_CHARS] = "Entropy is not enabled for the '"; + char msg[impl::MAX_NUM_CHARS] = "Singularity-EOS: Entropy is not enabled for the '"; impl::StrCat(msg, eosname); impl::StrCat(msg, "' EOS"); PORTABLE_ALWAYS_THROW_OR_ABORT(msg); @@ -609,7 +609,8 @@ class EosBase { // base msg length 32 + 5 chars = 37 chars // + 1 char for null terminator // maximum allowed EOS length = 44 chars - char msg[impl::MAX_NUM_CHARS] = "MinInternalEnergyFromDensity() is not enabled for the '"; + char msg[impl::MAX_NUM_CHARS] = + "Singularity-EOS: MinInternalEnergyFromDensity() is not enabled for the '"; impl::StrCat(msg, eosname); impl::StrCat(msg, "' EOS"); PORTABLE_ALWAYS_THROW_OR_ABORT(msg); From 06ed14812756cbb42fa530790dfd0e65decf2eec Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Fri, 27 Oct 2023 14:47:13 -0600 Subject: [PATCH 32/55] clang format --- singularity-eos/eos/eos_base.hpp | 2 +- singularity-eos/eos/eos_eospac.hpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/singularity-eos/eos/eos_base.hpp b/singularity-eos/eos/eos_base.hpp index c230d0dc27..ccd09808ef 100644 --- a/singularity-eos/eos/eos_base.hpp +++ b/singularity-eos/eos/eos_base.hpp @@ -609,7 +609,7 @@ class EosBase { // base msg length 32 + 5 chars = 37 chars // + 1 char for null terminator // maximum allowed EOS length = 44 chars - char msg[impl::MAX_NUM_CHARS] = + char msg[impl::MAX_NUM_CHARS] = "Singularity-EOS: MinInternalEnergyFromDensity() is not enabled for the '"; impl::StrCat(msg, eosname); impl::StrCat(msg, "' EOS"); diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 32cce8327e..ae592d97f6 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -1174,7 +1174,8 @@ class EOSPAC : public EosBase { {"BulkModulusFromDensityInternalEnergy", 6}, {"GruneisenParamFromDensityTemperature", 4}, {"GruneisenParamFromDensityInternalEnergy", 5}, - {"MinInternalEnergyFromDensity", 1},}; + {"MinInternalEnergyFromDensity", 1}, + }; return nbuffers; } }; From 6c6f209b0b42a95979a2f57176900d3ef0d04904 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Fri, 27 Oct 2023 14:54:19 -0600 Subject: [PATCH 33/55] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d555491177..8e8475bc42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [[PR269]](https://github.com/lanl/singularity-eos/pull/269) Add SAP Polynomial EoS ### Fixed (Repair bugs, etc) +- [[PR278]](https://github.com/lanl/singularity-eos/pull/278) Fixed EOSPAC unit conversion errors for scalar lookups - [[PR296]](https://github.com/lanl/singularity-eos/pull/296) changed `CMAKE_SOURCE_DIR` to `PROJECT_SOURCE_DIR` to fix downstream submodule build - [[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 @@ -22,6 +23,9 @@ - [[PR232]](https://github.com/lanl/singularity-eos/pull/228) Fixed uninitialized cmake path variables ### Added (new features/APIs/variables/...) +- [[PR278]](https://github.com/lanl/singularity-eos/pull/278) Added EOSPAC option functionality in class constructor +- [[PR278]](https://github.com/lanl/singularity-eos/pull/278) Added a new function for returning the minimum energy as a function of density for an EOS (only EOSPAC at the moment) +- [[PR278]](https://github.com/lanl/singularity-eos/pull/278) Added a new Fortran API for simple pressure and bulk moduli lookups - [[PR304]](https://github.com/lanl/singularity-eos/pull/304) added a Newton-Raphson root find for use with the Helmholtz EoS - [[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 From 3f46bac4f33b5c79208429eefc9c9cb15abd3b88 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Wed, 8 Nov 2023 12:44:53 -0700 Subject: [PATCH 34/55] Make indentation consistent --- singularity-eos/eos/singularity_eos.f90 | 64 ++++++++++++------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/singularity-eos/eos/singularity_eos.f90 b/singularity-eos/eos/singularity_eos.f90 index a98f50a5a8..6cecdf31e6 100644 --- a/singularity-eos/eos/singularity_eos.f90 +++ b/singularity-eos/eos/singularity_eos.f90 @@ -515,36 +515,36 @@ end function init_sg_Helmholtz_f #endif #ifdef SINGULARITY_USE_SPINER_WITH_HDF5 - integer function init_sg_SpinerDependsRhoT_f(matindex, eos, filename, id, & - sg_mods_enabled, & - sg_mods_values) & - result(err) - integer(c_int), value, intent(in) :: matindex - type(sg_eos_ary_t), intent(in) :: eos - character(len=*, kind=c_char), intent(in) :: filename - integer(c_int), intent(inout) :: id - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values - err = init_sg_SpinerDependsRhoT(matindex-1, eos%ptr,& - trim(filename)//C_NULL_CHAR, id, & - c_loc(sg_mods_enabled), & - c_loc(sg_mods_values)) - end function init_sg_SpinerDependsRhoT_f - - integer function init_sg_SpinerDependsRhoSie_f(matindex, eos, filename, id, & - sg_mods_enabled, & - sg_mods_values) & - result(err) - integer(c_int), value, intent(in) :: matindex, id - type(sg_eos_ary_t), intent(in) :: eos - character(len=*, kind=c_char), intent(in) :: filename - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values - err = init_sg_SpinerDependsRhoSie(matindex-1, eos%ptr,& - trim(filename)//C_NULL_CHAR, id, & - c_loc(sg_mods_enabled), & - c_loc(sg_mods_values)) - end function init_sg_SpinerDependsRhoSie_f + integer function init_sg_SpinerDependsRhoT_f(matindex, eos, filename, id, & + sg_mods_enabled, & + sg_mods_values) & + result(err) + integer(c_int), value, intent(in) :: matindex + type(sg_eos_ary_t), intent(in) :: eos + character(len=*, kind=c_char), intent(in) :: filename + integer(c_int), intent(inout) :: id + integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + err = init_sg_SpinerDependsRhoT(matindex-1, eos%ptr,& + trim(filename)//C_NULL_CHAR, id, & + c_loc(sg_mods_enabled), & + c_loc(sg_mods_values)) + end function init_sg_SpinerDependsRhoT_f + + integer function init_sg_SpinerDependsRhoSie_f(matindex, eos, filename, id, & + sg_mods_enabled, & + sg_mods_values) & + result(err) + integer(c_int), value, intent(in) :: matindex, id + type(sg_eos_ary_t), intent(in) :: eos + character(len=*, kind=c_char), intent(in) :: filename + integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + err = init_sg_SpinerDependsRhoSie(matindex-1, eos%ptr,& + trim(filename)//C_NULL_CHAR, id, & + c_loc(sg_mods_enabled), & + c_loc(sg_mods_values)) + end function init_sg_SpinerDependsRhoSie_f #endif #ifdef SINGULARITY_USE_EOSPAC @@ -561,7 +561,7 @@ integer function init_sg_eospac_f(matindex, eos, id, eospac_opts_values, & end function init_sg_eospac_f #endif -integer function get_sg_PressureFromDensityInternalEnergy_f(matindex, & + integer function get_sg_PressureFromDensityInternalEnergy_f(matindex, & eos, rhos, sies, pressures, len) & result(err) integer(c_int), intent(in) :: matindex, len @@ -573,7 +573,7 @@ integer function get_sg_PressureFromDensityInternalEnergy_f(matindex, & end function get_sg_PressureFromDensityInternalEnergy_f -integer function get_sg_MinInternalEnergyFromDensity_f(matindex, & + integer function get_sg_MinInternalEnergyFromDensity_f(matindex, & eos, rhos, sies, len) & result(err) integer(c_int), intent(in) :: matindex, len From 6d86a435ffb95cb7525172c03f05c72a38659378 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Tue, 14 Nov 2023 16:30:45 -0700 Subject: [PATCH 35/55] Eliminate unnneded scratch memory for PressureFromDensityInternalEnergy --- singularity-eos/eos/eos_eospac.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index ae592d97f6..194a5d3e45 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -613,8 +613,8 @@ class EOSPAC : public EosBase { EOS_REAL *R = const_cast(&rhos[0]); EOS_REAL *E = const_cast(&sies[0]); EOS_REAL *P = &pressures[0]; - EOS_REAL *dPdr = scratch + 1 * num; - EOS_REAL *dPde = scratch + 2 * num; + EOS_REAL *dPdr = scratch + 0 * num; + EOS_REAL *dPde = scratch + 1 * num; EOS_INTEGER table = PofRE_table_; EOS_INTEGER options[3]; @@ -1167,7 +1167,7 @@ class EOSPAC : public EosBase { {"PressureFromDensityTemperature", 2}, {"FillEos", 4}, {"InternalEnergyFromDensityTemperature", 2}, - {"PressureFromDensityInternalEnergy", 3}, + {"PressureFromDensityInternalEnergy", 2}, {"SpecificHeatFromDensityTemperature", 2}, {"SpecificHeatFromDensityInternalEnergy", 4}, {"BulkModulusFromDensityTemperature", 6}, From fde9ceb99535947e977ba432b5d581e2eff7a2ae Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Wed, 15 Nov 2023 18:35:14 -0700 Subject: [PATCH 36/55] Add scratch version of 'InternalEnergyFromDensity()' to unit system --- singularity-eos/eos/modifiers/eos_unitsystem.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/singularity-eos/eos/modifiers/eos_unitsystem.hpp b/singularity-eos/eos/modifiers/eos_unitsystem.hpp index 58e2cd1392..d8b4fe5366 100644 --- a/singularity-eos/eos/modifiers/eos_unitsystem.hpp +++ b/singularity-eos/eos/modifiers/eos_unitsystem.hpp @@ -295,6 +295,18 @@ class UnitSystem : public EosBase> { std::forward(transform)); } + template + inline void + MinInternalEnergyFromDensity(const Real *rhos, Real *sies, Real *scratch, + const int num, LambdaIndexer &&lambdas, + Transform &&transform = Transform()) const { + transform.x.apply(rho_unit_); + transform.f.apply(sie_unit_); + t_.MinInternalEnergyFromDensity(rhos, sies, scratch, num, + std::forward(lambdas), + std::forward(transform)); + } + template inline void SpecificHeatFromDensityTemperature( const Real *rhos, const Real *temperatures, Real *cvs, Real *scratch, const int num, From 684eefa770be23542e8f0e88938d9828d6a9c185 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Wed, 15 Nov 2023 18:37:53 -0700 Subject: [PATCH 37/55] Rework unit scaling to ensure EOSPAC is given correct units always. Consolidate logic in functions to avoid bugs --- singularity-eos/eos/eos_eospac.hpp | 327 ++++++++++++----------------- 1 file changed, 131 insertions(+), 196 deletions(-) diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 194a5d3e45..2f3bf9169c 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -54,6 +54,80 @@ using namespace EospacWrapper; #define SG_PIF_NOWARN #endif // !defind SG_PIF_NOWARN +namespace impl_eospac { + +inline void SetUpDensityTemperatureScalingOptions( + EOS_INTEGER options[], EOS_REAL values[], EOS_INTEGER &nopts, + Transform &transform) { + if (!transform.x.is_set() && !transform.y.is_set()) { + // Default singularity units are sesame density-temperature units so use + // pass-through + options[nopts] = EOS_XY_PASSTHRU; + values[nopts] = 1.0; + ++nopts; + } else { + // Density scaling + if (transform.x.is_set()) { + options[nopts] = EOS_X_CONVERT; + values[nopts] = 1.0 / transform.x.get(); + ++nopts; + } + // Temperature scaling + if (transform.y.is_set()) { + options[nopts] = EOS_Y_CONVERT; + values[nopts] = 1.0 / transform.y.get(); + ++nopts; + } + } +} + +inline void SetUpDensityEnergyScalingOptions( + EOS_INTEGER options[], EOS_REAL values[], EOS_INTEGER &nopts, Transform &transform) { + // Density scaling + if (transform.x.is_set()) { + options[nopts] = EOS_X_CONVERT; + values[nopts] = 1.0 / transform.x.get(); + ++nopts; + } + // Sesame energy units differ from singularity so always convert + EOS_REAL sie_scale = sieFromSesame(1.0); + if (transform.y.is_set()) { + sie_scale /= transform.y.get(); + } + // Optimize using pass-through if energy and density are already in sesame units + if (!transform.x.is_set() && sie_scale == 1.0) { + options[nopts] = EOS_XY_PASSTHRU; + values[nopts] = 1.0; + } else { + options[nopts] = EOS_Y_CONVERT; + values[nopts] = sie_scale; + } + ++nopts; +} + +inline void SetUpOutputScalingOption( + EOS_INTEGER options[], EOS_REAL values[], EOS_INTEGER &nopts, Transform &transform) { + if (transform.f.is_set()) { + options[nopts] = EOS_F_CONVERT; + values[nopts] = transform.f.get(); + ++nopts; + } +} + +// Overload for when the output needs a singularity conversion as well +inline void SetUpOutputScalingOption( + EOS_INTEGER options[], EOS_REAL values[], EOS_INTEGER &nopts, Transform &transform, + EOS_REAL const singularity_unit_conv) { + options[nopts] = EOS_F_CONVERT; + values[nopts] = pressureFromSesame(1.0); + if (transform.f.is_set()) { + values[nopts] *= transform.f.get(); + } + ++nopts; +} + +} + class EOSPAC : public EosBase { public: @@ -377,24 +451,11 @@ class EOSPAC : public EosBase { EOS_REAL values[3]; EOS_INTEGER nopts = 0; - if (transform.x.is_set()) { - options[nopts] = EOS_X_CONVERT; - values[nopts] = 1.0 / transform.x.get(); - ++nopts; - } - - options[nopts] = EOS_Y_CONVERT; - values[nopts] = sieFromSesame(1.0); - if (transform.y.is_set()) { - values[nopts] /= transform.y.get(); - } - ++nopts; + // Set up density/energy unit scaling + impl_eospac::SetUpDensityEnergyScalingOptions(options, values, nopts, transform); - if (transform.f.is_set()) { - options[nopts] = EOS_F_CONVERT; - values[nopts] = transform.f.get(); - ++nopts; - } + // Temperature scaling + impl_eospac::SetUpOutputScalingOption(options, values, nopts, transform); eosSafeInterpolate(&table, num, R, E, T, dTdr, dTde, "TofRE", Verbosity::Quiet, options, values, nopts); @@ -416,31 +477,14 @@ class EOSPAC : public EosBase { EOS_INTEGER options[3]; EOS_REAL values[3]; EOS_INTEGER nopts = 0; - if (!transform.x.is_set() && !transform.y.is_set()) { - options[nopts] = EOS_XY_PASSTHRU; - values[nopts] = 1.0; - ++nopts; - } else { - if (transform.x.is_set()) { - options[nopts] = EOS_X_CONVERT; - values[nopts] = 1.0 / transform.x.get(); - ++nopts; - } - if (transform.y.is_set()) { - options[nopts] = EOS_Y_CONVERT; - values[nopts] = 1.0 / transform.y.get(); - ++nopts; - } - } + // Set up density/temperature unit scaling + impl_eospac::SetUpDensityTemperatureScalingOptions(options, values, nopts, transform); - options[nopts] = EOS_F_CONVERT; - values[nopts] = pressureFromSesame(1.0); + // Pressure units differ from singularity so always convert + impl_eospac::SetUpOutputScalingOption(options, values, nopts, transform, + pressureFromSesame(1.0)); - if (transform.f.is_set()) { - values[nopts] *= transform.f.get(); - } - ++nopts; eosSafeInterpolate(&table, num, R, T, P, dPdr, dPdT, "PofRT", Verbosity::Quiet, options, values, nopts); } @@ -575,31 +619,12 @@ class EOSPAC : public EosBase { EOS_REAL values[3]; EOS_INTEGER nopts = 0; - if (!transform.x.is_set() && !transform.y.is_set()) { - options[nopts] = EOS_XY_PASSTHRU; - values[nopts] = 1.0; - ++nopts; - } else { - if (transform.x.is_set()) { - options[nopts] = EOS_X_CONVERT; - values[nopts] = 1.0 / transform.x.get(); - ++nopts; - } - - if (transform.y.is_set()) { - options[nopts] = EOS_Y_CONVERT; - values[nopts] = 1.0 / transform.y.get(); - ++nopts; - } - } - - options[nopts] = EOS_F_CONVERT; - values[nopts] = sieFromSesame(1.0); + // Set up density/temperature unit scaling + impl_eospac::SetUpDensityTemperatureScalingOptions(options, values, nopts, transform); - if (transform.f.is_set()) { - values[nopts] *= transform.f.get(); - } - ++nopts; + // Energy units differ from singularity so always convert + impl_eospac::SetUpOutputScalingOption(options, values, nopts, transform, + sieFromSesame(1.0)); eosSafeInterpolate(&table, num, R, T, E, DEDR, DEDT, "EofRT", Verbosity::Quiet, options, values, nopts); @@ -620,31 +645,13 @@ class EOSPAC : public EosBase { EOS_INTEGER options[3]; EOS_REAL values[3]; EOS_INTEGER nopts = 0; - if (!transform.x.is_set() && !transform.y.is_set()) { - options[nopts] = EOS_XY_PASSTHRU; - values[nopts] = 1.0; - ++nopts; - } else { - if (transform.x.is_set()) { - options[nopts] = EOS_X_CONVERT; - values[nopts] = 1.0 / transform.x.get(); - ++nopts; - } + + // Set up density/energy unit scaling + impl_eospac::SetUpDensityEnergyScalingOptions(options, values, nopts, transform); - if (transform.y.is_set()) { - options[nopts] = EOS_Y_CONVERT; - values[nopts] = 1.0 / transform.y.get(); - ++nopts; - } - } - - options[nopts] = EOS_F_CONVERT; - values[nopts] = pressureFromSesame(1.0); - - if (transform.f.is_set()) { - values[nopts] *= transform.f.get(); - } - ++nopts; + // Pressure units differ from singularity so always convert + impl_eospac::SetUpOutputScalingOption(options, values, nopts, transform, + pressureFromSesame(1.0)); eosSafeInterpolate(&table, num, R, E, P, dPdr, dPde, "PofRE", Verbosity::Quiet, options, values, nopts); @@ -663,25 +670,13 @@ class EOSPAC : public EosBase { EOS_INTEGER options[3]; EOS_REAL values[3]; EOS_INTEGER nopts = 0; - if (!transform.x.is_set()) { - options[nopts] = EOS_XY_PASSTHRU; - values[nopts] = 1.0; - ++nopts; - } else { - if (transform.x.is_set()) { - options[nopts] = EOS_X_CONVERT; - values[nopts] = 1.0 / transform.x.get(); - ++nopts; - } - } - options[nopts] = EOS_F_CONVERT; - values[nopts] = pressureFromSesame(1.0); + // Set up density/temperature unit scaling + impl_eospac::SetUpDensityTemperatureScalingOptions(options, values, nopts, transform); - if (transform.f.is_set()) { - values[nopts] *= transform.f.get(); - } - ++nopts; + // Energy units differ from singularity so always convert + impl_eospac::SetUpOutputScalingOption(options, values, nopts, transform, + sieFromSesame(1.0)); eosSafeInterpolate(&table, num, R, R, E, dedr, dedr, "EcofD", Verbosity::Quiet, options, values, nopts); @@ -691,10 +686,10 @@ class EOSPAC : public EosBase { inline void SpecificHeatFromDensityTemperature( const Real *rhos, const Real *temperatures, Real *cvs, Real *scratch, const int num, LambdaIndexer /*lambdas*/, Transform &&transform = Transform()) const { + using namespace EospacWrapper; static auto const name = singularity::mfuncname::member_func_name(typeid(EOSPAC).name(), __func__); static auto const cname = name.c_str(); - using namespace EospacWrapper; EOS_REAL *R = const_cast(&rhos[0]); EOS_REAL *T = const_cast(&temperatures[0]); EOS_REAL *E = scratch + 0 * num; @@ -707,22 +702,8 @@ class EOSPAC : public EosBase { EOS_REAL values[3]; EOS_INTEGER nopts = 0; - if (!transform.x.is_set() && !transform.y.is_set()) { - options[nopts] = EOS_XY_PASSTHRU; - values[nopts] = 1.0; - ++nopts; - } else { - if (transform.x.is_set()) { - options[nopts] = EOS_X_CONVERT; - values[nopts] = 1.0 / transform.x.get(); - ++nopts; - } - if (transform.y.is_set()) { - options[nopts] = EOS_Y_CONVERT; - values[nopts] = 1.0 / transform.y.get(); - ++nopts; - } - } + // Set up density/temperature unit scaling + impl_eospac::SetUpDensityTemperatureScalingOptions(options, values, nopts, transform); eosSafeInterpolate(&table, num, R, T, E, DEDR, DEDT, "EofRT", Verbosity::Quiet, options, values, nopts); @@ -756,24 +737,18 @@ class EOSPAC : public EosBase { EOS_REAL *DEDT = dTdr; EOS_REAL *DEDR = dTde; + // TODO: Use direct lookup to reduce scratch usage and allow consistent temperature + // scaling + EOS_INTEGER table = TofRE_table_; { EOS_INTEGER options[2]; EOS_REAL values[2]; EOS_INTEGER nopts = 0; - if (transform.x.is_set()) { - options[nopts] = EOS_X_CONVERT; - values[nopts] = 1.0 / transform.x.get(); - ++nopts; - } - - options[nopts] = EOS_Y_CONVERT; - values[nopts] = sieFromSesame(1.0); - if (transform.y.is_set()) { - values[nopts] /= transform.y.get(); - } - ++nopts; + // Set up density/energy unit scaling + impl_eospac::SetUpDensityEnergyScalingOptions(options, values, nopts, + transform); eosSafeInterpolate(&table, num, R, E, T, dTdr, dTde, "TofRE", Verbosity::Quiet, options, values, nopts); @@ -785,14 +760,8 @@ class EOSPAC : public EosBase { EOS_REAL values[2]; EOS_INTEGER nopts = 0; - if (transform.x.is_set()) { - options[nopts] = EOS_X_CONVERT; - values[nopts] = 1.0 / transform.x.get(); - } else { - options[nopts] = EOS_XY_PASSTHRU; - values[nopts] = 1.0; - } - ++nopts; + // Set up density/energy unit scaling + impl_eospac::SetUpDensityEnergyScalingOptions(options, values, nopts, transform); eosSafeInterpolate(&table, num, R, T, NE, DEDR, DEDT, "EofRT", Verbosity::Quiet, options, values, nopts); @@ -830,22 +799,11 @@ class EOSPAC : public EosBase { EOS_REAL values[2]; EOS_INTEGER nopts = 0; - if (!transform.x.is_set() && !transform.y.is_set()) { - options[nopts] = EOS_XY_PASSTHRU; - values[nopts] = 1.0; - ++nopts; - } else { - if (transform.x.is_set()) { - options[nopts] = EOS_X_CONVERT; - values[nopts] = 1.0 / transform.x.get(); - ++nopts; - } - if (transform.y.is_set()) { - options[nopts] = EOS_Y_CONVERT; - values[nopts] = 1.0 / transform.y.get(); - ++nopts; - } - } + // Set up density/temperature unit scaling + impl_eospac::SetUpDensityTemperatureScalingOptions(options, values, nopts, transform); + + // TODO: Just use the native bulk modulus lookup instead to reduce scratch usage and + // avoid consistency issues with energy and pressure units EOS_INTEGER table = EofRT_table_; eosSafeInterpolate(&table, num, R, T, E, DEDR, DEDT, "EofRT", Verbosity::Quiet, @@ -908,22 +866,15 @@ class EOSPAC : public EosBase { EOS_REAL *DPDT = dTdr; EOS_REAL *DPDR = dTde; + // TODO: Use direct lookup to reduce scratch usage + EOS_INTEGER table = TofRE_table_; { EOS_INTEGER options[2]; EOS_REAL values[2]; EOS_INTEGER nopts = 0; - if (transform.x.is_set()) { - options[nopts] = EOS_X_CONVERT; - values[nopts] = 1.0 / transform.x.get(); - ++nopts; - } - options[nopts] = EOS_Y_CONVERT; - values[nopts] = sieFromSesame(1.0); - if (transform.y.is_set()) { - values[nopts] /= transform.y.get(); - } - ++nopts; + // Set up density/energy unit scaling + impl_eospac::SetUpDensityEnergyScalingOptions(options, values, nopts, transform); eosSafeInterpolate(&table, num, R, E, T, dTdr, dTde, "TofRE", Verbosity::Quiet, options, values, nopts); } @@ -1003,22 +954,12 @@ class EOSPAC : public EosBase { EOS_REAL values[2]; EOS_INTEGER nopts = 0; - if (!transform.x.is_set() && !transform.y.is_set()) { - options[nopts] = EOS_XY_PASSTHRU; - values[nopts] = 1.0; - ++nopts; - } else { - if (transform.x.is_set()) { - options[nopts] = EOS_X_CONVERT; - values[nopts] = 1.0 / transform.x.get(); - ++nopts; - } - if (transform.y.is_set()) { - options[nopts] = EOS_Y_CONVERT; - values[nopts] = 1.0 / transform.y.get(); - ++nopts; - } - } + // Set up density/temperature unit scaling + impl_eospac::SetUpDensityTemperatureScalingOptions(options, values, nopts, transform); + + // TODO: Use direct lookup to reduce scratch memory usage and avoid energy unit + // inconsistencies + EOS_INTEGER table = EofRT_table_; eosSafeInterpolate(&table, num, R, T, E, dx, DEDT, "EofRT", Verbosity::Quiet, options, values, nopts); @@ -1055,24 +996,18 @@ class EOSPAC : public EosBase { EOS_REAL *Etmp = P; EOS_REAL *dy = DEDT; + // TODO: Use direct lookup to reduce scratch memory usage and avoid temperature unit + // inconsistencies + EOS_INTEGER table = TofRE_table_; { EOS_INTEGER options[3]; EOS_REAL values[3]; EOS_INTEGER nopts = 0; - if (transform.x.is_set()) { - options[nopts] = EOS_X_CONVERT; - values[nopts] = 1.0 / transform.x.get(); - ++nopts; - } - - options[nopts] = EOS_Y_CONVERT; - values[nopts] = sieFromSesame(1.0); - if (transform.y.is_set()) { - values[nopts] /= transform.y.get(); - } - ++nopts; + // Set up density/energy unit scaling + impl_eospac::SetUpDensityEnergyScalingOptions(options, values, nopts, transform); + eosSafeInterpolate(&table, num, R, E, T, dx, dy, "TofRE", Verbosity::Quiet, options, values, nopts); } From d5eb54988fe321c867d0b23b8215e96f76420813 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Wed, 15 Nov 2023 18:40:02 -0700 Subject: [PATCH 38/55] Clang format --- singularity-eos/eos/eos_eospac.hpp | 29 +++++++++---------- .../eos/modifiers/eos_unitsystem.hpp | 7 ++--- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 2f3bf9169c..3f299b303d 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -56,9 +56,9 @@ using namespace EospacWrapper; namespace impl_eospac { -inline void SetUpDensityTemperatureScalingOptions( - EOS_INTEGER options[], EOS_REAL values[], EOS_INTEGER &nopts, - Transform &transform) { +inline void SetUpDensityTemperatureScalingOptions(EOS_INTEGER options[], + EOS_REAL values[], EOS_INTEGER &nopts, + Transform &transform) { if (!transform.x.is_set() && !transform.y.is_set()) { // Default singularity units are sesame density-temperature units so use // pass-through @@ -81,8 +81,8 @@ inline void SetUpDensityTemperatureScalingOptions( } } -inline void SetUpDensityEnergyScalingOptions( - EOS_INTEGER options[], EOS_REAL values[], EOS_INTEGER &nopts, Transform &transform) { +inline void SetUpDensityEnergyScalingOptions(EOS_INTEGER options[], EOS_REAL values[], + EOS_INTEGER &nopts, Transform &transform) { // Density scaling if (transform.x.is_set()) { options[nopts] = EOS_X_CONVERT; @@ -105,8 +105,8 @@ inline void SetUpDensityEnergyScalingOptions( ++nopts; } -inline void SetUpOutputScalingOption( - EOS_INTEGER options[], EOS_REAL values[], EOS_INTEGER &nopts, Transform &transform) { +inline void SetUpOutputScalingOption(EOS_INTEGER options[], EOS_REAL values[], + EOS_INTEGER &nopts, Transform &transform) { if (transform.f.is_set()) { options[nopts] = EOS_F_CONVERT; values[nopts] = transform.f.get(); @@ -115,9 +115,9 @@ inline void SetUpOutputScalingOption( } // Overload for when the output needs a singularity conversion as well -inline void SetUpOutputScalingOption( - EOS_INTEGER options[], EOS_REAL values[], EOS_INTEGER &nopts, Transform &transform, - EOS_REAL const singularity_unit_conv) { +inline void SetUpOutputScalingOption(EOS_INTEGER options[], EOS_REAL values[], + EOS_INTEGER &nopts, Transform &transform, + EOS_REAL const singularity_unit_conv) { options[nopts] = EOS_F_CONVERT; values[nopts] = pressureFromSesame(1.0); if (transform.f.is_set()) { @@ -126,7 +126,7 @@ inline void SetUpOutputScalingOption( ++nopts; } -} +} // namespace impl_eospac class EOSPAC : public EosBase { @@ -645,7 +645,7 @@ class EOSPAC : public EosBase { EOS_INTEGER options[3]; EOS_REAL values[3]; EOS_INTEGER nopts = 0; - + // Set up density/energy unit scaling impl_eospac::SetUpDensityEnergyScalingOptions(options, values, nopts, transform); @@ -747,8 +747,7 @@ class EOSPAC : public EosBase { EOS_INTEGER nopts = 0; // Set up density/energy unit scaling - impl_eospac::SetUpDensityEnergyScalingOptions(options, values, nopts, - transform); + impl_eospac::SetUpDensityEnergyScalingOptions(options, values, nopts, transform); eosSafeInterpolate(&table, num, R, E, T, dTdr, dTde, "TofRE", Verbosity::Quiet, options, values, nopts); @@ -1007,7 +1006,7 @@ class EOSPAC : public EosBase { // Set up density/energy unit scaling impl_eospac::SetUpDensityEnergyScalingOptions(options, values, nopts, transform); - + eosSafeInterpolate(&table, num, R, E, T, dx, dy, "TofRE", Verbosity::Quiet, options, values, nopts); } diff --git a/singularity-eos/eos/modifiers/eos_unitsystem.hpp b/singularity-eos/eos/modifiers/eos_unitsystem.hpp index d8b4fe5366..8312aac19c 100644 --- a/singularity-eos/eos/modifiers/eos_unitsystem.hpp +++ b/singularity-eos/eos/modifiers/eos_unitsystem.hpp @@ -296,10 +296,9 @@ class UnitSystem : public EosBase> { } template - inline void - MinInternalEnergyFromDensity(const Real *rhos, Real *sies, Real *scratch, - const int num, LambdaIndexer &&lambdas, - Transform &&transform = Transform()) const { + inline void MinInternalEnergyFromDensity(const Real *rhos, Real *sies, Real *scratch, + const int num, LambdaIndexer &&lambdas, + Transform &&transform = Transform()) const { transform.x.apply(rho_unit_); transform.f.apply(sie_unit_); t_.MinInternalEnergyFromDensity(rhos, sies, scratch, num, From 1e7ef6b4ed32aee1e9157d7915dbff21d9312292 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Wed, 15 Nov 2023 19:05:06 -0700 Subject: [PATCH 39/55] Correct bug in heat capacity from density energy --- singularity-eos/eos/eos_eospac.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 3f299b303d..2543c7652c 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -759,8 +759,14 @@ class EOSPAC : public EosBase { EOS_REAL values[2]; EOS_INTEGER nopts = 0; - // Set up density/energy unit scaling - impl_eospac::SetUpDensityEnergyScalingOptions(options, values, nopts, transform); + if (transform.x.is_set()) { + options[nopts] = EOS_X_CONVERT; + values[nopts] = 1.0 / transform.x.get(); + } else { + options[nopts] = EOS_XY_PASSTHRU; + values[nopts] = 1.0; + } + ++nopts; eosSafeInterpolate(&table, num, R, T, NE, DEDR, DEDT, "EofRT", Verbosity::Quiet, options, values, nopts); From e4bba773907dfce6bf9ad886b90e97282b001e66 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Wed, 15 Nov 2023 19:05:51 -0700 Subject: [PATCH 40/55] Clang format --- singularity-eos/eos/eos_eospac.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 2543c7652c..a9cf9ab593 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -760,13 +760,13 @@ class EOSPAC : public EosBase { EOS_INTEGER nopts = 0; if (transform.x.is_set()) { - options[nopts] = EOS_X_CONVERT; - values[nopts] = 1.0 / transform.x.get(); - } else { - options[nopts] = EOS_XY_PASSTHRU; - values[nopts] = 1.0; - } - ++nopts; + options[nopts] = EOS_X_CONVERT; + values[nopts] = 1.0 / transform.x.get(); + } else { + options[nopts] = EOS_XY_PASSTHRU; + values[nopts] = 1.0; + } + ++nopts; eosSafeInterpolate(&table, num, R, T, NE, DEDR, DEDT, "EofRT", Verbosity::Quiet, options, values, nopts); From f449b1a6d251663f21ea447a130545427a2f2038 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Wed, 15 Nov 2023 19:25:07 -0700 Subject: [PATCH 41/55] Unshift the minimum enegies as well --- singularity-eos/eos/modifiers/shifted_eos.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/singularity-eos/eos/modifiers/shifted_eos.hpp b/singularity-eos/eos/modifiers/shifted_eos.hpp index 6160c6a108..0034782650 100644 --- a/singularity-eos/eos/modifiers/shifted_eos.hpp +++ b/singularity-eos/eos/modifiers/shifted_eos.hpp @@ -217,6 +217,7 @@ class ShiftedEOS : public EosBase> { t_.MinInternalEnergyFromDensity(rhos, sies, &scratch[num], num, std::forward(lambdas), std::forward(transform)); + unshift_sies(sies, num); } template From 72b9305a0fbe72e727a65bf6a0b52b5045595e61 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Thu, 16 Nov 2023 12:15:04 -0700 Subject: [PATCH 42/55] Fix fortran compiler complaint about comments on #endif lines --- singularity-eos/eos/singularity_eos.f90 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/singularity-eos/eos/singularity_eos.f90 b/singularity-eos/eos/singularity_eos.f90 index c7c00c181c..89930a42b2 100644 --- a/singularity-eos/eos/singularity_eos.f90 +++ b/singularity-eos/eos/singularity_eos.f90 @@ -599,7 +599,8 @@ integer function init_sg_Helmholtz_f(matindex, eos, filename, rad, gas, coul, io rad, gas, coul, ion, ele, verbose, & c_loc(sg_mods_enabled_use), c_loc(sg_mods_values_use)) end function init_sg_Helmholtz_f -#endif ! SINGULARITY_USE_HELMHOLTZ +#endif +! SINGULARITY_USE_HELMHOLTZ integer function init_sg_SpinerDependsRhoT_f(matindex, eos, filename, id, & sg_mods_enabled, & @@ -649,7 +650,8 @@ integer function init_sg_SpinerDependsRhoSie_f(matindex, eos, filename, id, & c_loc(sg_mods_enabled_use), & c_loc(sg_mods_values_use)) end function init_sg_SpinerDependsRhoSie_f -#endif ! SINGULARITY_USE_SPINER_WITH_HDF5 +#endif +! SINGULARITY_USE_SPINER_WITH_HDF5 #ifdef SINGULARITY_USE_EOSPAC integer function init_sg_eospac_f(matindex, eos, id, sg_mods_enabled, & @@ -671,7 +673,8 @@ integer function init_sg_eospac_f(matindex, eos, id, sg_mods_enabled, & err = init_sg_eospac(matindex-1, eos%ptr, id, c_loc(sg_mods_enabled_use), & c_loc(sg_mods_values_use)) end function init_sg_eospac_f -#endif ! SINGULARITY_USE_EOSPAC +#endif +! SINGULARITY_USE_EOSPAC integer function get_sg_PressureFromDensityInternalEnergy_f(matindex, & eos, rhos, sies, pressures, len) & From 561ca3f2e5cf09addc53fa4e8d429db9b36658aa Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Thu, 16 Nov 2023 12:31:10 -0700 Subject: [PATCH 43/55] Fix accidentally reverted fortran interface for EOSPAC init --- singularity-eos/eos/singularity_eos.f90 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/singularity-eos/eos/singularity_eos.f90 b/singularity-eos/eos/singularity_eos.f90 index 89930a42b2..2c0ef227ec 100644 --- a/singularity-eos/eos/singularity_eos.f90 +++ b/singularity-eos/eos/singularity_eos.f90 @@ -654,24 +654,29 @@ end function init_sg_SpinerDependsRhoSie_f ! SINGULARITY_USE_SPINER_WITH_HDF5 #ifdef SINGULARITY_USE_EOSPAC - integer function init_sg_eospac_f(matindex, eos, id, sg_mods_enabled, & - sg_mods_values) & + integer function init_sg_eospac_f(matindex, eos, id, eospac_opts_values, & + sg_mods_enabled, sg_mods_values) & result(err) integer(c_int), value, intent(in) :: matindex, id type(sg_eos_ary_t), intent(in) :: eos + real(kind=8), dimension(:), target, optional, intent(inout) :: eospac_opts_values integer(kind=c_int), dimension(:), target, optional, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, optional, intent(inout) :: sg_mods_values + real(kind=8), dimension(:), target, optional, intent(inout) :: sg_mods_values + ! local vars integer(kind=c_int), target, dimension(4) :: sg_mods_enabled_use real(kind=8), target, dimension(6) :: sg_mods_values_use + real(kind=8), target, dimension(6) :: eospac_opts_values_use sg_mods_enabled_use = 0 sg_mods_values_use = 0.d0 + eospac_opts_values = 0.d0 + if(present(eospac_opts_values)) eospac_opts_values_use = eospac_opts_values if(present(sg_mods_enabled)) sg_mods_enabled_use = sg_mods_enabled if(present(sg_mods_values)) sg_mods_values_use = sg_mods_values - err = init_sg_eospac(matindex-1, eos%ptr, id, c_loc(sg_mods_enabled_use), & - c_loc(sg_mods_values_use)) + err = init_sg_eospac(matindex-1, eos%ptr, id, c_loc(eospac_opts_values_use), & + c_loc(sg_mods_enabled_use), c_loc(sg_mods_values_use)) end function init_sg_eospac_f #endif ! SINGULARITY_USE_EOSPAC From 9d306de191d3ea3692c99033c715225688c39718 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Thu, 16 Nov 2023 16:48:22 -0700 Subject: [PATCH 44/55] Add error to minimum energy function --- singularity-eos/eos/eos_stiff.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/singularity-eos/eos/eos_stiff.hpp b/singularity-eos/eos/eos_stiff.hpp index 60ad252db3..869f120a2e 100644 --- a/singularity-eos/eos/eos_stiff.hpp +++ b/singularity-eos/eos/eos_stiff.hpp @@ -80,8 +80,8 @@ class StiffGas : public EosBase { PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { - // TODO: Calculate zero temperature minimum equation - return 0.0; + MinInternalEnergyIsNotEnabled("StiffGas"); + return 0.0; }; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( From 2920f4203ddd54432a1315b541ab86f116f0eacb Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Thu, 16 Nov 2023 16:48:44 -0700 Subject: [PATCH 45/55] Add PORTABLE_FUNCTION decorator --- singularity-eos/eos/modifiers/eos_unitsystem.hpp | 1 + singularity-eos/eos/modifiers/scaled_eos.hpp | 1 + 2 files changed, 2 insertions(+) diff --git a/singularity-eos/eos/modifiers/eos_unitsystem.hpp b/singularity-eos/eos/modifiers/eos_unitsystem.hpp index 8312aac19c..bdf6bf97a6 100644 --- a/singularity-eos/eos/modifiers/eos_unitsystem.hpp +++ b/singularity-eos/eos/modifiers/eos_unitsystem.hpp @@ -131,6 +131,7 @@ class UnitSystem : public EosBase> { t_.PressureFromDensityInternalEnergy(rho * rho_unit_, sie * sie_unit_, lambda); return inv_press_unit_ * P; } + PORTABLE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { const Real S = t_.MinInternalEnergyFromDensity(rho * rho_unit_, lambda); return inv_sie_unit_ * S; diff --git a/singularity-eos/eos/modifiers/scaled_eos.hpp b/singularity-eos/eos/modifiers/scaled_eos.hpp index 714d139804..e991cc1c37 100644 --- a/singularity-eos/eos/modifiers/scaled_eos.hpp +++ b/singularity-eos/eos/modifiers/scaled_eos.hpp @@ -96,6 +96,7 @@ class ScaledEOS : public EosBase> { Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { return t_.MinInternalEnergyFromDensity(scale_ * rho, lambda); } + PORTABLE_FUNCTION Real EntropyFromDensityInternalEnergy(const Real rho, const Real sie, Real *lambda = nullptr) const { return scale_ * From f4949f8eb3b3324db73e66f41f62995a684efe84 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Thu, 16 Nov 2023 16:56:25 -0700 Subject: [PATCH 46/55] Avoid warnings on minimum energy functions --- singularity-eos/eos/eos_eospac.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index a9cf9ab593..c18ed53fbd 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -152,7 +152,7 @@ class EOSPAC : public EosBase { SG_PIF_NOWARN PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy( const Real rho, const Real sie, Real *lambda = nullptr) const; - + SG_PIF_NOWARN PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const; SG_PIF_NOWARN @@ -1334,6 +1334,7 @@ PORTABLE_INLINE_FUNCTION Real EOSPAC::PressureFromDensityInternalEnergy( return Real(P[0]); } +SG_PIF_NOWARN PORTABLE_INLINE_FUNCTION Real EOSPAC::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { using namespace EospacWrapper; From 4dbe5fa04a321cc56719de76f3050a606ebda271 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Thu, 16 Nov 2023 17:04:01 -0700 Subject: [PATCH 47/55] Add more EOS to initialization test --- test/test_f_iface.f90 | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/test_f_iface.f90 b/test/test_f_iface.f90 index b69bd7d33f..aa3327ed35 100644 --- a/test/test_f_iface.f90 +++ b/test/test_f_iface.f90 @@ -19,20 +19,30 @@ program test_sg_fortran_interface ! no implicit vars implicit none ! variable declaration -integer :: nmat, res +integer :: nmat, res, mat type(sg_eos_ary_t) :: eos ! set test parameters -nmat = 3 +nmat = 5 ! allocate and initialize eos's res = init_sg_eos_f(nmat, eos) +mat = 1 -res = init_sg_Gruneisen_f(1, eos, 394000.d0, 1.489d0, 0.d0, 0.d0, 2.02d0, 0.47d0,& +res = init_sg_IdealGas_f(mat, eos, 1.4, 1.0d7) + +mat = mat + 1 +res = init_sg_Gruneisen_f(mat, eos, 394000.d0, 1.489d0, 0.d0, 0.d0, 2.02d0, 0.47d0,& 8.93d0, 297.0d0, 1.0d6, 0.383d7) -res = init_sg_DavisReactants_f(2, eos, 1.890d0, 4.115d10, 1.0d6, 297.0d0, 1.8d0,& + +mat = mat + 1 +res = init_sg_JWL_f(mat, eos, 1.36177d13, 7.199d11, 6.2d0, 2.2d0, 0.5d0, 1.895d0, 1.0d7) + +mat = mat + 1 +res = init_sg_DavisReactants_f(mat, eos, 1.890d0, 4.115d10, 1.0d6, 297.0d0, 1.8d0,& 4.6d0, 0.34d0, 0.56d0,0.d0, 0.4265d0, 0.001074d10) -res = init_sg_DavisProducts_f(3, eos, 0.798311d0, 0.58d0, 1.35d0, 2.66182d0,& +mat = mat + 1 +res = init_sg_DavisProducts_f(mat, eos, 0.798311d0, 0.58d0, 1.35d0, 2.66182d0,& 0.75419d0, 3.2d10, 0.001072d10, 0.d0) ! cleanup From 4c437fa268df560b7e880f204d0a4cdc4cdbe2c1 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Thu, 16 Nov 2023 17:06:41 -0700 Subject: [PATCH 48/55] Clang format --- singularity-eos/eos/eos_stiff.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singularity-eos/eos/eos_stiff.hpp b/singularity-eos/eos/eos_stiff.hpp index 869f120a2e..c60f2f60a4 100644 --- a/singularity-eos/eos/eos_stiff.hpp +++ b/singularity-eos/eos/eos_stiff.hpp @@ -81,7 +81,7 @@ class StiffGas : public EosBase { PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { MinInternalEnergyIsNotEnabled("StiffGas"); - return 0.0; + return 0.0; }; PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature( From 00bd3a78c346755cc29ba4dc8abea96dad45af65 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Thu, 16 Nov 2023 17:15:16 -0700 Subject: [PATCH 49/55] Fix float/double type mismatch with fortran literal --- test/test_f_iface.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_f_iface.f90 b/test/test_f_iface.f90 index aa3327ed35..52a92e95cc 100644 --- a/test/test_f_iface.f90 +++ b/test/test_f_iface.f90 @@ -29,7 +29,7 @@ program test_sg_fortran_interface res = init_sg_eos_f(nmat, eos) mat = 1 -res = init_sg_IdealGas_f(mat, eos, 1.4, 1.0d7) +res = init_sg_IdealGas_f(mat, eos, 1.4d0, 1.0d7) mat = mat + 1 res = init_sg_Gruneisen_f(mat, eos, 394000.d0, 1.489d0, 0.d0, 0.d0, 2.02d0, 0.47d0,& From 3be436bdb887eb18e3a3546b904ec76bff7c3822 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Thu, 16 Nov 2023 17:53:20 -0700 Subject: [PATCH 50/55] Change warning to error function in minimum energy --- singularity-eos/eos/eos_vinet.hpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/singularity-eos/eos/eos_vinet.hpp b/singularity-eos/eos/eos_vinet.hpp index 559db4d0db..50a18e8686 100644 --- a/singularity-eos/eos/eos_vinet.hpp +++ b/singularity-eos/eos/eos_vinet.hpp @@ -308,10 +308,7 @@ PORTABLE_INLINE_FUNCTION Real Vinet::PressureFromDensityInternalEnergy( } PORTABLE_INLINE_FUNCTION Real Vinet::MinInternalEnergyFromDensity(const Real rho, Real *lambda) const { -#ifndef NDEBUG - printf("WARNING: MinInternalEnergtyFromDensity is not defined for Vinet EOS."); -#endif - + MinInternalEnergyIsNotEnabled("Vinet"); return 0.0; } PORTABLE_INLINE_FUNCTION Real Vinet::EntropyFromDensityInternalEnergy( From 587904c199359c94e7f95bdfb5936f9215b57bfe Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Thu, 16 Nov 2023 17:53:57 -0700 Subject: [PATCH 51/55] Add shift to minimum energy function --- singularity-eos/eos/modifiers/shifted_eos.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singularity-eos/eos/modifiers/shifted_eos.hpp b/singularity-eos/eos/modifiers/shifted_eos.hpp index 0034782650..fa10c1c445 100644 --- a/singularity-eos/eos/modifiers/shifted_eos.hpp +++ b/singularity-eos/eos/modifiers/shifted_eos.hpp @@ -92,7 +92,7 @@ class ShiftedEOS : public EosBase> { } PORTABLE_FUNCTION Real MinInternalEnergyFromDensity(const Real rho, Real *lambda = nullptr) const { - return t_.MinInternalEnergyFromDensity(rho, lambda); + return t_.MinInternalEnergyFromDensity(rho, lambda) + shift_; } PORTABLE_FUNCTION Real EntropyFromDensityInternalEnergy(const Real rho, const Real sie, From d3726c6d56068536336737ed6a5d6aff5f058177 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Tue, 21 Nov 2023 12:52:01 -0700 Subject: [PATCH 52/55] Revert urls to github rather than gitlab --- spack-repo/packages/singularity-eos/package.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spack-repo/packages/singularity-eos/package.py b/spack-repo/packages/singularity-eos/package.py index 058f1a526d..156891bb5b 100644 --- a/spack-repo/packages/singularity-eos/package.py +++ b/spack-repo/packages/singularity-eos/package.py @@ -12,9 +12,9 @@ class SingularityEos(CMakePackage, CudaPackage): """Singularity-EOS: A collection of closure models and tools useful for multiphysics codes.""" - homepage = "https://re-git.lanl.gov/xcap/oss/singularity-eos" - url = "https://re-git.lanl.gov/xcap/oss/singularity-eos.git" - git = "ssh://git@re-git.lanl.gov:10022/xcap/oss/singularity-eos.git" + homepage = "https://lanl.github.io/singularity-eos/main/index.html" + git = "https://github.com/lanl/singularity-eos.git" + url = "https://github.com/lanl/singularity-eos/archive/refs/tags/release-1.6.1.tar.gz" maintainers = ["rbberger"] From 554d5b6cbc0c35705e06dbcdf6ef901ab030b99b Mon Sep 17 00:00:00 2001 From: Jeff Peterson <83598606+jhp-lanl@users.noreply.github.com> Date: Tue, 21 Nov 2023 12:54:50 -0700 Subject: [PATCH 53/55] Fix scratch for MinInternalEnergyFromDensity() Co-authored-by: Richard Berger --- singularity-eos/eos/eos_eospac.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index c18ed53fbd..6737992413 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -664,7 +664,7 @@ class EOSPAC : public EosBase { using namespace EospacWrapper; EOS_REAL *R = const_cast(&rhos[0]); EOS_REAL *E = &sies[0]; - EOS_REAL *dedr = scratch + 1 * num; + EOS_REAL *dedr = scratch + 0 * num; EOS_INTEGER table = EcofD_table_; EOS_INTEGER options[3]; From 42570b7dd55322598c96e67afb606f78b504017b Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Tue, 21 Nov 2023 12:56:27 -0700 Subject: [PATCH 54/55] Make transforms const for scaling setup functions --- singularity-eos/eos/eos_eospac.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index c18ed53fbd..d0f4296500 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -58,7 +58,7 @@ namespace impl_eospac { inline void SetUpDensityTemperatureScalingOptions(EOS_INTEGER options[], EOS_REAL values[], EOS_INTEGER &nopts, - Transform &transform) { + const Transform &transform) { if (!transform.x.is_set() && !transform.y.is_set()) { // Default singularity units are sesame density-temperature units so use // pass-through @@ -82,7 +82,8 @@ inline void SetUpDensityTemperatureScalingOptions(EOS_INTEGER options[], } inline void SetUpDensityEnergyScalingOptions(EOS_INTEGER options[], EOS_REAL values[], - EOS_INTEGER &nopts, Transform &transform) { + EOS_INTEGER &nopts, + const Transform &transform) { // Density scaling if (transform.x.is_set()) { options[nopts] = EOS_X_CONVERT; @@ -106,7 +107,7 @@ inline void SetUpDensityEnergyScalingOptions(EOS_INTEGER options[], EOS_REAL val } inline void SetUpOutputScalingOption(EOS_INTEGER options[], EOS_REAL values[], - EOS_INTEGER &nopts, Transform &transform) { + EOS_INTEGER &nopts, const Transform &transform) { if (transform.f.is_set()) { options[nopts] = EOS_F_CONVERT; values[nopts] = transform.f.get(); @@ -116,7 +117,7 @@ inline void SetUpOutputScalingOption(EOS_INTEGER options[], EOS_REAL values[], // Overload for when the output needs a singularity conversion as well inline void SetUpOutputScalingOption(EOS_INTEGER options[], EOS_REAL values[], - EOS_INTEGER &nopts, Transform &transform, + EOS_INTEGER &nopts, const Transform &transform, EOS_REAL const singularity_unit_conv) { options[nopts] = EOS_F_CONVERT; values[nopts] = pressureFromSesame(1.0); From 384be5a69b004c858e029a917c61b100821d0510 Mon Sep 17 00:00:00 2001 From: Jeffrey H Peterson Date: Tue, 21 Nov 2023 13:02:55 -0700 Subject: [PATCH 55/55] Remove unused variable --- singularity-eos/eos/eos_eospac.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 00fdb127ad..c6bd2d1604 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -1327,7 +1327,7 @@ PORTABLE_INLINE_FUNCTION Real EOSPAC::PressureFromDensityInternalEnergy( EOS_INTEGER options[]{EOS_Y_CONVERT, EOS_F_CONVERT}; EOS_REAL values[]{sieFromSesame(1.0), pressureFromSesame(1.0)}; EOS_INTEGER nopts = 2; - EOS_REAL R[1] = {rho}, E[1] = {sie}, P[1], dPdr[1], dPde[1], Ec[1]; + EOS_REAL R[1] = {rho}, E[1] = {sie}, P[1], dPdr[1], dPde[1]; EOS_INTEGER nxypairs = 1; EOS_INTEGER table = PofRE_table_; eosSafeInterpolate(&table, nxypairs, R, E, P, dPdr, dPde, "PofRE", Verbosity::Quiet,