Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Apg/sap integration #278

Merged
merged 68 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
7291277
Readd SAP api
annapiegra Feb 13, 2023
2e97918
remove spiner dep from f90 hack
annapiegra Mar 23, 2023
45686ac
Merge branch 'main' into apg/sap_integration
annapiegra Mar 23, 2023
7525c24
SAP integration: most results agree, some outliers (phase boundaries?)
annapiegra May 5, 2023
818f7c1
unit fixes
annapiegra May 23, 2023
f5896df
continue ramp treatment into neg pressures, consistent w/ pagosa
annapiegra Jun 30, 2023
648893c
Starting to add eospac options for pagosa
annapiegra Jun 30, 2023
ad44cb2
added Pagosa setOptions to Eospac table intitialization
annapiegra Jul 19, 2023
30d8a82
Remove cold curve as eospac_opt, will be implemented as an API call
annapiegra Jul 24, 2023
a02d53f
Merge branch 'main' into apg/sap_integration
annapiegra Jul 24, 2023
8084259
Add MinInternalEnergyFromDensity, needed for pagosa integration
annapiegra Jul 25, 2023
953eaf4
Fix capitalization typo
jhp-lanl Jul 26, 2023
9c8b039
Merge branch 'apg/sap_integration' of github.com:lanl/singularity-eos…
jhp-lanl Jul 26, 2023
fe9363b
Remove copy/paste bug
jhp-lanl Jul 26, 2023
99d35b1
Fix variable name errors and add scratch
jhp-lanl Jul 26, 2023
92b3238
mods by format.sh
annapiegra Jul 28, 2023
edb8259
fix format
annapiegra Jul 28, 2023
7d2568d
format mods
annapiegra Jul 28, 2023
e8006f4
Start adding enums
annapiegra Jul 28, 2023
528b5fd
Fix bug when commentLen for eospac tables is zero
annapiegra Jul 31, 2023
ca899d4
Merge branch 'apg/sap_integration_enum' into apg/sap_integration
annapiegra Aug 1, 2023
d9bfa85
Add enum for eospac split and monotonicity options
annapiegra Aug 3, 2023
b8a2328
Add warnings to stub mininternalenergy functions when in debug mode
annapiegra Aug 3, 2023
a59a059
Merge master, spiner commented out in singularity_eos.f90
annapiegra Aug 3, 2023
1597c46
clang format
annapiegra Aug 4, 2023
69ddf7d
Merge branch 'main' into apg/sap_integration
annapiegra Aug 8, 2023
743d081
Update submodule hashes
annapiegra Aug 11, 2023
ba72772
Fix eospac empty comment check
annapiegra Aug 17, 2023
fd0d5ed
Merge branch 'main' into apg/sap_integration
annapiegra Aug 17, 2023
723fd9f
fix merge issues
annapiegra Aug 17, 2023
3069376
More merge fixes
annapiegra Aug 17, 2023
e4cc9b7
clang format
jhp-lanl Sep 18, 2023
95d0400
Merge branch 'main' of github.com:lanl/singularity-eos into apg/sap_i…
jhp-lanl Sep 18, 2023
edbf05e
Use C preprocessor on fortran files
jhp-lanl Sep 19, 2023
9b83dd4
Add preprocessor #ifdefs around initialization functions
jhp-lanl Sep 19, 2023
b150ac4
Add minimum energy not enabled function
jhp-lanl Sep 29, 2023
6000aa7
Switch to using default error message funciton for non-enabled minimu…
jhp-lanl Sep 29, 2023
dd1dfc5
Add performance warning for vector lookups without scratch. Correct u…
jhp-lanl Sep 29, 2023
f1f8a93
Fix unit conversions in EOSPAC
jhp-lanl Oct 10, 2023
178793d
Merge branch 'main' of github.com:lanl/singularity-eos into apg/sap_i…
jhp-lanl Oct 10, 2023
a29e1ad
Improve error message
jhp-lanl Oct 26, 2023
06ed148
clang format
jhp-lanl Oct 27, 2023
6c6f209
Update changelog
jhp-lanl Oct 27, 2023
186e98d
Merge branch 'main' of github.com:lanl/singularity-eos into apg/sap_i…
jhp-lanl Oct 27, 2023
3f46bac
Make indentation consistent
jhp-lanl Nov 8, 2023
6d86a43
Eliminate unnneded scratch memory for PressureFromDensityInternalEnergy
jhp-lanl Nov 14, 2023
fde9ceb
Add scratch version of 'InternalEnergyFromDensity()' to unit system
jhp-lanl Nov 16, 2023
684eefa
Rework unit scaling to ensure EOSPAC is given correct units always. C…
jhp-lanl Nov 16, 2023
d5eb549
Clang format
jhp-lanl Nov 16, 2023
1e7ef6b
Correct bug in heat capacity from density energy
jhp-lanl Nov 16, 2023
e4bba77
Clang format
jhp-lanl Nov 16, 2023
5a65339
Merge branch 'main' into apg/sap_integration
jhp-lanl Nov 16, 2023
f449b1a
Unshift the minimum enegies as well
jhp-lanl Nov 16, 2023
72b9305
Fix fortran compiler complaint about comments on #endif lines
jhp-lanl Nov 16, 2023
561ca3f
Fix accidentally reverted fortran interface for EOSPAC init
jhp-lanl Nov 16, 2023
9d306de
Add error to minimum energy function
jhp-lanl Nov 16, 2023
2920f42
Add PORTABLE_FUNCTION decorator
jhp-lanl Nov 16, 2023
f4949f8
Avoid warnings on minimum energy functions
jhp-lanl Nov 16, 2023
4dbe5fa
Add more EOS to initialization test
jhp-lanl Nov 17, 2023
4c437fa
Clang format
jhp-lanl Nov 17, 2023
00bd3a7
Fix float/double type mismatch with fortran literal
jhp-lanl Nov 17, 2023
3be436b
Change warning to error function in minimum energy
jhp-lanl Nov 17, 2023
587904c
Add shift to minimum energy function
jhp-lanl Nov 17, 2023
d3726c6
Revert urls to github rather than gitlab
jhp-lanl Nov 21, 2023
554d5b6
Fix scratch for MinInternalEnergyFromDensity()
jhp-lanl Nov 21, 2023
42570b7
Make transforms const for scaling setup functions
jhp-lanl Nov 21, 2023
0030aa5
Merge branch 'apg/sap_integration' of github.com:lanl/singularity-eos…
jhp-lanl Nov 21, 2023
384be5a
Remove unused variable
jhp-lanl Nov 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 79 additions & 11 deletions eospac-wrapper/eospac_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <regex>
#include <string>
#include <vector>

#include "eospac_wrapper.hpp"
#include <eos_Interface.h>

Expand Down Expand Up @@ -87,7 +86,8 @@ void eosGetMetadata(int matid, SesameMetadata &metadata, Verbosity eospacWarn) {

comments.resize(static_cast<int>(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];
}
Expand All @@ -107,16 +107,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) {
bool invert_at_setup, double insert_data, eospacMonotonicity monotonicity,
bool apply_smoothing, eospacSplit apply_splitting,
bool linear_interp) {
std::vector<std::string> 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<std::string> &table_names, Verbosity eospacWarn,
bool invert_at_setup) {
bool invert_at_setup, double insert_data, eospacMonotonicity monotonicity,
bool apply_smoothing, eospacSplit apply_splitting,
bool linear_interp) {
EOS_INTEGER NTABLES[] = {ntables};
std::vector<EOS_INTEGER> MATID(ntables, matid);

Expand All @@ -127,19 +132,81 @@ 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_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 == 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) {
eos_SetOption(&(tableHandle[i]), &EOS_MONOTONIC_IN_X, &(EOS_NullVal), &errorCode);
eosCheckError(errorCode, "eospac options: eos_monotonic_in_x", eospacWarn);
}
}
}

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);
}
}

if (apply_smoothing) {
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_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 (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 == 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 == 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);
}
}

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

Expand Down Expand Up @@ -181,6 +248,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);
Expand Down
12 changes: 9 additions & 3 deletions eospac-wrapper/eospac_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@

#include <eos_Interface.h> // 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; }
Expand Down Expand Up @@ -87,11 +89,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,
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<std::string> &table_names, Verbosity eospacWarn,
bool invert_at_setup = false);
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);

// output is boolean mask. 1 for no errors. 0 for errors.
bool eosSafeInterpolate(EOS_INTEGER *table, EOS_INTEGER nxypairs, EOS_REAL xVals[],
Expand Down
30 changes: 30 additions & 0 deletions singularity-eos/eos/eos_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ char *StrCat(char *destination, const char *source) {
using EosBase<EOSDERIVED>::InternalEnergyFromDensityTemperature; \
using EosBase<EOSDERIVED>::PressureFromDensityTemperature; \
using EosBase<EOSDERIVED>::PressureFromDensityInternalEnergy; \
using EosBase<EOSDERIVED>::MinInternalEnergyFromDensity; \
jhp-lanl marked this conversation as resolved.
Show resolved Hide resolved
using EosBase<EOSDERIVED>::SpecificHeatFromDensityTemperature; \
using EosBase<EOSDERIVED>::SpecificHeatFromDensityInternalEnergy; \
using EosBase<EOSDERIVED>::BulkModulusFromDensityTemperature; \
Expand Down Expand Up @@ -262,6 +263,35 @@ class EosBase {
PressureFromDensityInternalEnergy(rhos, sies, pressures, num,
std::forward<LambdaIndexer>(lambdas));
}
///
template <typename RealIndexer, typename ConstRealIndexer, typename LambdaIndexer>
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<CRTP const *>(this));
portableFor(
cname, 0, num, PORTABLE_LAMBDA(const int i) {
sies[i] = copy.MinInternalEnergyFromDensity(rhos[i], lambdas[i]);
});
}
template <typename RealIndexer, typename ConstRealIndexer, typename LambdaIndexer,
typename = std::enable_if_t<!is_raw_pointer<RealIndexer, Real>::value>>
inline void MinInternalEnergyFromDensity(ConstRealIndexer &&rhos, RealIndexer &&sies,
Real * /*scratch*/, const int num,
LambdaIndexer &&lambdas) const {
MinInternalEnergyFromDensity(std::forward<ConstRealIndexer>(rhos),
std::forward<RealIndexer>(sies), num,
std::forward<LambdaIndexer>(lambdas));
}
template <typename LambdaIndexer>
inline void MinInternalEnergyFromDensity(const Real *rhos, Real *sies,
Real * /*scratch*/, const int num,
LambdaIndexer &&lambdas,
Transform && = Transform()) const {
MinInternalEnergyFromDensity(rhos, num, std::forward<LambdaIndexer>(lambdas));
}
///
jhp-lanl marked this conversation as resolved.
Show resolved Hide resolved
template <typename RealIndexer, typename ConstRealIndexer, typename LambdaIndexer>
inline void EntropyFromDensityTemperature(ConstRealIndexer &&rhos,
ConstRealIndexer &&temperatures,
Expand Down
13 changes: 13 additions & 0 deletions singularity-eos/eos/eos_davis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ class DavisReactants : public EosBase<DavisReactants> {
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 {
#ifndef NDEBUG
printf(
"WARNING: MinInternalEnergtyFromDensity is not defined for Davis EOS.");
#endif
return 0.0;
}
PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature(
const Real rho, const Real temperature, Real *lambda = nullptr) const {
EntropyIsNotEnabled("DavisReactants");
Expand Down Expand Up @@ -162,6 +171,10 @@ class DavisProducts : public EosBase<DavisProducts> {
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 {
EntropyIsNotEnabled("DavisProducts");
Expand Down
Loading