Loading .gitlab-ci.yml +25 −37 Original line number Diff line number Diff line Loading @@ -10,36 +10,25 @@ stages: - build - deploy #Primarily concerned with setting up micromamba for the appropriate platforms #All the build requirements excepting some compiler magic is there .bash_before: &bash_before - export MAMBA_ROOT_PREFIX="$CI_PROJECT_DIR/tools/micromamba" - source ./ci/setup_mamba.sh - micromamba activate saline_39 - pip install build .powershell_before: &powershell_before - $env:MAMBA_ROOT_PREFIX="$CI_PROJECT_DIR/tools/micromamba" - . $CI_PROJECT_DIR/ci/setup_mamba.ps1 - micromamba activate saline_39 - pip install build build_macos: stage: build variables: GIT_SUBMODULE_STRATEGY: normal tags: - macOS before_script: - *bash_before script: - source $HOME/spack/share/spack/setup-env.sh - spack env activate saline - pip install delocate - echo $PATH - cmake -S $CI_PROJECT_DIR -B "$CI_PROJECT_DIR/build" -DCMAKE_BUILD_TYPE=RELEASE -Dsaline_ENABLE_Fortran=ON -DCMAKE_Fortran_FLAGS:STRING="-ffree-line-length-none" -Dsaline_ENABLE_Python=ON -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -Dsaline_ENABLE_Python=ON -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -Dsaline_ENABLE_hdf5=ON -DPython_EXECUTABLE=`which python` - cmake --build "$CI_PROJECT_DIR/build" - cmake --build "$CI_PROJECT_DIR/build" --target SalinePy_wheel - ctest --test-dir "$CI_PROJECT_DIR/build" - cmake --install build --prefix install - delocate-wheel -w ${CI_PROJECT_DIR}/install/wheelhouse ${CI_PROJECT_DIR}/build/src/python/dist/SalinePy*.whl - delocate-wheel -w ${CI_PROJECT_DIR}/install/wheelhouse ${CI_PROJECT_DIR}/build/src/python/dist/salinepy*.whl - tar -czf darwin_arm.tar.gz install artifacts: name: darwin Loading @@ -49,15 +38,16 @@ build_macos: build_windows: stage: build variables: GIT_SUBMODULE_STRATEGY: normal tags: - windows before_script: - *powershell_before script: - pip install delvewheel - cmake -S $CI_PROJECT_DIR -B build - $env:MAMBA_ROOT_PREFIX="$CI_PROJECT_DIR/tools/micromamba" - . $CI_PROJECT_DIR/ci/setup_mamba.ps1 - micromamba activate saline_39 - pip install build delvewheel - cmake -S $CI_PROJECT_DIR -B build -Dsaline_ENABLE_Fortran=OFF -Dsaline_ENABLE_Python=ON -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE Loading @@ -75,22 +65,21 @@ build_windows: build_linux: stage: build variables: GIT_SUBMODULE_STRATEGY: normal rules: - when: always tags: - linux before_script: - *bash_before - docker script: - pip install auditwheel - pip install patchelf - cmake -S $CI_PROJECT_DIR -B build -DCMAKE_BUILD_TYPE=RELEASE -Dsaline_ENABLE_Fortran=ON -DCMAKE_Fortran_FLAGS:STRING="-ffree-line-length-none" -Dsaline_ENABLE_Python=ON - cmake --build build -Dsaline_ENABLE_Python=ON -Dsaline_ENABLE_hdf5=ON - cmake --build "$CI_PROJECT_DIR/build" - cmake --build "$CI_PROJECT_DIR/build" --target SalinePy_wheel - ctest --test-dir build --output-on-failure - cmake --install build --prefix install - auditwheel repair -w ${CI_PROJECT_DIR}/install/wheelhouse --plat manylinux_2_34_x86_64 ${CI_PROJECT_DIR}/build/src/python/dist/SalinePy*.whl - auditwheel repair -w ${CI_PROJECT_DIR}/install/wheelhouse --plat manylinux_2_28_x86_64 ${CI_PROJECT_DIR}/build/src/python/dist/salinepy*.whl - tar -czf linux_x86.tar.gz install artifacts: name: linux_x86 Loading @@ -100,15 +89,14 @@ build_linux: deploy_code: stage: deploy image: saline_deploy:latest tags: - linux - docker rules: - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH when: never - when: manual needs: [build_linux,build_windows,build_macos] before_script: - *bash_before script: # Code - CODE_SALINE_URL="https://code.ornl.gov/api/v4/projects/10738/packages" Loading .gitmodules 0 → 100644 +3 −0 Original line number Diff line number Diff line [submodule "thirdparty/nlohmann_json"] path = thirdparty/nlohmann_json url = https://github.com/nlohmann/json.git CMakeLists.txt +7 −3 Original line number Diff line number Diff line Loading @@ -13,9 +13,13 @@ project(saline ) # Supported standards set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 17) #c++20 is not fully supported on likely compilers set(CMAKE_CXX_STANDARD_REQUIRED ON) # option(${PROJECT_NAME}_USE_EXTERNAL_JSON "Use an external JSON library" OFF) add_subdirectory(thirdparty) # Configure the library add_subdirectory(src) Loading ci/build_env.yml +1 −0 Original line number Diff line number Diff line Loading @@ -7,3 +7,4 @@ dependencies: - swig=4.2.1 - setuptools - twine - hdf5 include/default_data_store.hh +291 −272 Original line number Diff line number Diff line Loading @@ -8,19 +8,23 @@ */ //---------------------------------------------------------------------------// #include "data_store.hh" #include <cmath> #include <iostream> #include <ostream> #include <istream> #include <limits> #include <list> #include <ostream> #include <string> #include <vector> #include <list> namespace saline { #include <nlohmann/json.hpp> #ifdef SALINE_USE_HDF5 #include <hdf5.h> #endif #include "data_store.hh" namespace saline { //===========================================================================// /*! * \class Default_Data_Store Loading @@ -28,22 +32,21 @@ namespace saline * * The default data is transcribed from * * Jerden, James. Molten Salt Thermophysical Properties Database Development: 2019 Update. * United States: N. p., 2019. Web. doi:10.2172/1559846. * Jerden, James. Molten Salt Thermophysical Properties Database Development: * 2019 Update. United States: N. p., 2019. Web. doi:10.2172/1559846. * * Units: * Conductivity - Watts per Meter-Kelvin (W/m K) * Pressure - Kilopascal (kPa) * Temperature - Kelvin (K) * Enthalpy - Joule per mole (J/mole) * Viscosity - Centipoise (cP) or milli Newton-second per square Meter (mN.s/m^2) * Specific Heat - Joules per Kelvin Mole (J/K mole) * Density - Grams per Cubic Centimeter (g/cc) * Viscosity - Centipoise (cP) or milli Newton-second per square Meter * (mN.s/m^2) Specific Heat - Joules per Kelvin Mole (J/K mole) Density - * Grams per Cubic Centimeter (g/cc) */ //===========================================================================// enum DataQualifier { enum DataQualifier { NONE, // Default assignment // /* Represent variations on melting and boiling data PRESSURIZED, Loading @@ -53,10 +56,8 @@ enum DataQualifier NONSPECIFIC // This is targeted at uncharacterized data (uncertainty). }; class Default_Data_Store : public Data_Store { class Default_Data_Store : public Data_Store { public: //@{ //! Types using Id = std::size_t; Loading @@ -78,32 +79,40 @@ class Default_Data_Store : public Data_Store Vec_Name names(Id id) const { return compounds[id].names; } // specific heat double cp(Id id, Id data_id, double temperature, double pressure = 101.325) const; double cp_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; double cp(Id id, Id data_id, double temperature, double pressure = 101.325) const; double cp_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; virtual bool valid_cp(Id id, Id data_id) const; double cp_unc(Id id, Id data_id) const; std::pair<double, double> cp_rng(Id id, Id data_id) const; std::string cp_ref(Id id, Id data_id) const; // viscosity double mu(Id id, Id data_id, double temperature, double pressure = 101.325) const; double mu_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; double mu(Id id, Id data_id, double temperature, double pressure = 101.325) const; double mu_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; virtual bool valid_mu(Id id, Id data_id) const; double mu_unc(Id id, Id data_id) const; std::pair<double, double> mu_rng(Id id, Id data_id) const; std::string mu_ref(Id id, Id data_id) const; // conductivity double k(Id id, Id data_id, double temperature, double pressure = 101.325) const; double k_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; double k(Id id, Id data_id, double temperature, double pressure = 101.325) const; double k_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; virtual bool valid_k(Id id, Id data_id) const; double k_unc(Id id, Id data_id) const; std::pair<double, double> k_rng(Id id, Id data_id) const; std::string k_ref(Id id, Id data_id) const; // density double rho(Id id, Id data_id, double temperature, double pressure = 101.325) const; double rho_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; double rho(Id id, Id data_id, double temperature, double pressure = 101.325) const; double rho_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; virtual bool valid_rho(Id id, Id data_id) const; double rho_unc(Id id, Id data_id) const; std::pair<double, double> rho_rng(Id id, Id data_id) const; Loading Loading @@ -135,7 +144,12 @@ class Default_Data_Store : public Data_Store std::size_t constituent_count(Id id) const; void load(const std::string &fPath); [[deprecated("Use from_json(std::istream& inFile) instead.")]] void load(std::istream &inFile); void from_json(nlohmann::json); #ifdef SALINE_USE_HDF5 void from_h5(hid_t file); #endif View setView(const Vec_Name &names, const Vec_Mole &mole_percents); Loading @@ -144,7 +158,8 @@ class Default_Data_Store : public Data_Store bool valid(Vec_Name &names) const { return valid(names_to_id(names)); }; bool valid(Name &name) const { return valid(name_to_id(name)); }; // obtain data store id given a set of compound names (e.g., LiF-NaF-KF, LiF-BeF2-ZrF4-ThF4) // obtain data store id given a set of compound names (e.g., LiF-NaF-KF, // LiF-BeF2-ZrF4-ThF4) Id names_to_id(Vec_Name names) const; // obtain data store id given a compound name (e.g., BeF2, NaCl) Id name_to_id(Name &name) const; Loading @@ -155,14 +170,11 @@ class Default_Data_Store : public Data_Store // The list accessible salt names Vec_Name getSaltKeys() const; std::vector<std::vector<double>> getSaltComps(Vec_Name names) const; void to_json(nlohmann::json &j) const; private: class Data { class Data { public: void to_stream(std::ostream& s) const; Vec_Mole &mole_percents() { return m_mole_percents; }; const Vec_Mole &mole_percents() const { return m_mole_percents; }; Loading Loading @@ -193,13 +205,17 @@ class Default_Data_Store : public Data_Store double rho_b() const { return m_rho_b; } // viscosity double mu(double t) const {return std::isnan(m_mu_c) ? m_mu_a * std::exp(m_mu_b / t) : std::pow(10.0,m_mu_a + (m_mu_b/t) + (m_mu_c/(t*t)));} double mu(double t) const { return std::isnan(m_mu_c) ? m_mu_a * std::exp(m_mu_b / t) : std::pow(10.0, m_mu_a + (m_mu_b / t) + (m_mu_c / (t * t))); } double mu_h(double h) const { return mu(h_to_t(h)); } bool valid_mu() const {return std::isnan(m_mu_c) ? (mu_a() != 0.0 ) : ((mu_a() != 0.0) || (mu_b() != 0.0) || (m_mu_c != 0.0));} bool valid_mu() const { return std::isnan(m_mu_c) ? (mu_a() != 0.0) : ((mu_a() != 0.0) || (mu_b() != 0.0) || (m_mu_c != 0.0)); } double mu_unc() const { return m_mu_unc; } std::string mu_ref() const { return m_mu_ref; } Loading @@ -220,10 +236,15 @@ class Default_Data_Store : public Data_Store double k_b() const { return m_k_b; } // specific heat double cp(double t) const {double t2 = t * t; return m_cp_a + m_cp_b * t + m_cp_c * 1/(t2) + m_cp_d * t2;} double cp(double t) const { double t2 = t * t; return m_cp_a + m_cp_b * t + m_cp_c * 1 / (t2) + m_cp_d * t2; } double cp_h(double h) const { return cp(h_to_t(h)); } bool valid_cp() const {return ((cp_a() != 0.0) || (cp_b() != 0.0) || (cp_c() != 0.0) || (cp_d() != 0.0)); } bool valid_cp() const { return ((cp_a() != 0.0) || (cp_b() != 0.0) || (cp_c() != 0.0) || (cp_d() != 0.0)); } double cp_unc() const { return m_cp_unc; } std::string cp_ref() const { return m_cp_ref; } Loading @@ -248,9 +269,9 @@ class Default_Data_Store : public Data_Store Vec_Mole m_mole_percents; // Melting Temperature double m_melt; double m_melt = 0.0; DataQualifier m_melt_qualifier; double m_melt_unc; double m_melt_unc = 0.0; DataQualifier m_melt_unc_qualifier; std::string m_melt_ref; Loading @@ -258,43 +279,43 @@ class Default_Data_Store : public Data_Store double m_mole_weight; // Boiling Temperature double m_boil; double m_boil = 0.0; DataQualifier m_boil_qualifier; double m_boil_unc; double m_boil_unc = 0.0; DataQualifier m_boil_unc_qualifier; std::string m_boil_ref; // density double m_rho_a; double m_rho_b; double m_rho_unc; double m_rho_a = 0.0; double m_rho_b = 0.0; double m_rho_unc = 0.0; DataQualifier m_rho_unc_qualifier; std::pair<double, double> m_rho_rng; std::string m_rho_ref; // viscosity double m_mu_a; double m_mu_b; double m_mu_c; double m_mu_unc; double m_mu_a = 0.0; double m_mu_b = 0.0; double m_mu_c = std::numeric_limits<double>::quiet_NaN(); double m_mu_unc = 0.0; DataQualifier m_mu_unc_qualifier; std::pair<double, double> m_mu_rng; std::string m_mu_ref; // conductivity double m_k_a; double m_k_b; double m_k_unc; double m_k_a = 0.0; double m_k_b = 0.0; double m_k_unc = 0.0; DataQualifier m_k_unc_qualifier; std::pair<double, double> m_k_rng; std::string m_k_ref; // specific heat double m_cp_a; double m_cp_b; double m_cp_c; double m_cp_d; double m_cp_unc; double m_cp_a = 0.0; double m_cp_b = 0.0; double m_cp_c = 0.0; double m_cp_d = 0.0; double m_cp_unc = 0.0; DataQualifier m_cp_unc_qualifier; std::pair<double, double> m_cp_rng; std::string m_cp_ref; Loading @@ -307,17 +328,16 @@ class Default_Data_Store : public Data_Store // h(t)'s E simplification (a * melt + b * melt^2 + d * melt^3 - c / melt) double m_e; }; void to_json(nlohmann::json &j, Data &d) const; using Vec_Data = std::vector<Data>; struct Compound { struct Compound { Vec_Name names; Vec_Data data; }; private: private: // >>> DATA void parse_data_qualifier(std::string &, DataQualifier &); void parse_data_token(std::string &, double &); Loading @@ -332,7 +352,6 @@ class Default_Data_Store : public Data_Store void setup_enthalpy_tables(); Default_Data_Store::Data &getDataReference(std::string, std::string); }; } // namespace saline Loading Loading
.gitlab-ci.yml +25 −37 Original line number Diff line number Diff line Loading @@ -10,36 +10,25 @@ stages: - build - deploy #Primarily concerned with setting up micromamba for the appropriate platforms #All the build requirements excepting some compiler magic is there .bash_before: &bash_before - export MAMBA_ROOT_PREFIX="$CI_PROJECT_DIR/tools/micromamba" - source ./ci/setup_mamba.sh - micromamba activate saline_39 - pip install build .powershell_before: &powershell_before - $env:MAMBA_ROOT_PREFIX="$CI_PROJECT_DIR/tools/micromamba" - . $CI_PROJECT_DIR/ci/setup_mamba.ps1 - micromamba activate saline_39 - pip install build build_macos: stage: build variables: GIT_SUBMODULE_STRATEGY: normal tags: - macOS before_script: - *bash_before script: - source $HOME/spack/share/spack/setup-env.sh - spack env activate saline - pip install delocate - echo $PATH - cmake -S $CI_PROJECT_DIR -B "$CI_PROJECT_DIR/build" -DCMAKE_BUILD_TYPE=RELEASE -Dsaline_ENABLE_Fortran=ON -DCMAKE_Fortran_FLAGS:STRING="-ffree-line-length-none" -Dsaline_ENABLE_Python=ON -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -Dsaline_ENABLE_Python=ON -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 -Dsaline_ENABLE_hdf5=ON -DPython_EXECUTABLE=`which python` - cmake --build "$CI_PROJECT_DIR/build" - cmake --build "$CI_PROJECT_DIR/build" --target SalinePy_wheel - ctest --test-dir "$CI_PROJECT_DIR/build" - cmake --install build --prefix install - delocate-wheel -w ${CI_PROJECT_DIR}/install/wheelhouse ${CI_PROJECT_DIR}/build/src/python/dist/SalinePy*.whl - delocate-wheel -w ${CI_PROJECT_DIR}/install/wheelhouse ${CI_PROJECT_DIR}/build/src/python/dist/salinepy*.whl - tar -czf darwin_arm.tar.gz install artifacts: name: darwin Loading @@ -49,15 +38,16 @@ build_macos: build_windows: stage: build variables: GIT_SUBMODULE_STRATEGY: normal tags: - windows before_script: - *powershell_before script: - pip install delvewheel - cmake -S $CI_PROJECT_DIR -B build - $env:MAMBA_ROOT_PREFIX="$CI_PROJECT_DIR/tools/micromamba" - . $CI_PROJECT_DIR/ci/setup_mamba.ps1 - micromamba activate saline_39 - pip install build delvewheel - cmake -S $CI_PROJECT_DIR -B build -Dsaline_ENABLE_Fortran=OFF -Dsaline_ENABLE_Python=ON -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE Loading @@ -75,22 +65,21 @@ build_windows: build_linux: stage: build variables: GIT_SUBMODULE_STRATEGY: normal rules: - when: always tags: - linux before_script: - *bash_before - docker script: - pip install auditwheel - pip install patchelf - cmake -S $CI_PROJECT_DIR -B build -DCMAKE_BUILD_TYPE=RELEASE -Dsaline_ENABLE_Fortran=ON -DCMAKE_Fortran_FLAGS:STRING="-ffree-line-length-none" -Dsaline_ENABLE_Python=ON - cmake --build build -Dsaline_ENABLE_Python=ON -Dsaline_ENABLE_hdf5=ON - cmake --build "$CI_PROJECT_DIR/build" - cmake --build "$CI_PROJECT_DIR/build" --target SalinePy_wheel - ctest --test-dir build --output-on-failure - cmake --install build --prefix install - auditwheel repair -w ${CI_PROJECT_DIR}/install/wheelhouse --plat manylinux_2_34_x86_64 ${CI_PROJECT_DIR}/build/src/python/dist/SalinePy*.whl - auditwheel repair -w ${CI_PROJECT_DIR}/install/wheelhouse --plat manylinux_2_28_x86_64 ${CI_PROJECT_DIR}/build/src/python/dist/salinepy*.whl - tar -czf linux_x86.tar.gz install artifacts: name: linux_x86 Loading @@ -100,15 +89,14 @@ build_linux: deploy_code: stage: deploy image: saline_deploy:latest tags: - linux - docker rules: - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH when: never - when: manual needs: [build_linux,build_windows,build_macos] before_script: - *bash_before script: # Code - CODE_SALINE_URL="https://code.ornl.gov/api/v4/projects/10738/packages" Loading
.gitmodules 0 → 100644 +3 −0 Original line number Diff line number Diff line [submodule "thirdparty/nlohmann_json"] path = thirdparty/nlohmann_json url = https://github.com/nlohmann/json.git
CMakeLists.txt +7 −3 Original line number Diff line number Diff line Loading @@ -13,9 +13,13 @@ project(saline ) # Supported standards set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 17) #c++20 is not fully supported on likely compilers set(CMAKE_CXX_STANDARD_REQUIRED ON) # option(${PROJECT_NAME}_USE_EXTERNAL_JSON "Use an external JSON library" OFF) add_subdirectory(thirdparty) # Configure the library add_subdirectory(src) Loading
ci/build_env.yml +1 −0 Original line number Diff line number Diff line Loading @@ -7,3 +7,4 @@ dependencies: - swig=4.2.1 - setuptools - twine - hdf5
include/default_data_store.hh +291 −272 Original line number Diff line number Diff line Loading @@ -8,19 +8,23 @@ */ //---------------------------------------------------------------------------// #include "data_store.hh" #include <cmath> #include <iostream> #include <ostream> #include <istream> #include <limits> #include <list> #include <ostream> #include <string> #include <vector> #include <list> namespace saline { #include <nlohmann/json.hpp> #ifdef SALINE_USE_HDF5 #include <hdf5.h> #endif #include "data_store.hh" namespace saline { //===========================================================================// /*! * \class Default_Data_Store Loading @@ -28,22 +32,21 @@ namespace saline * * The default data is transcribed from * * Jerden, James. Molten Salt Thermophysical Properties Database Development: 2019 Update. * United States: N. p., 2019. Web. doi:10.2172/1559846. * Jerden, James. Molten Salt Thermophysical Properties Database Development: * 2019 Update. United States: N. p., 2019. Web. doi:10.2172/1559846. * * Units: * Conductivity - Watts per Meter-Kelvin (W/m K) * Pressure - Kilopascal (kPa) * Temperature - Kelvin (K) * Enthalpy - Joule per mole (J/mole) * Viscosity - Centipoise (cP) or milli Newton-second per square Meter (mN.s/m^2) * Specific Heat - Joules per Kelvin Mole (J/K mole) * Density - Grams per Cubic Centimeter (g/cc) * Viscosity - Centipoise (cP) or milli Newton-second per square Meter * (mN.s/m^2) Specific Heat - Joules per Kelvin Mole (J/K mole) Density - * Grams per Cubic Centimeter (g/cc) */ //===========================================================================// enum DataQualifier { enum DataQualifier { NONE, // Default assignment // /* Represent variations on melting and boiling data PRESSURIZED, Loading @@ -53,10 +56,8 @@ enum DataQualifier NONSPECIFIC // This is targeted at uncharacterized data (uncertainty). }; class Default_Data_Store : public Data_Store { class Default_Data_Store : public Data_Store { public: //@{ //! Types using Id = std::size_t; Loading @@ -78,32 +79,40 @@ class Default_Data_Store : public Data_Store Vec_Name names(Id id) const { return compounds[id].names; } // specific heat double cp(Id id, Id data_id, double temperature, double pressure = 101.325) const; double cp_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; double cp(Id id, Id data_id, double temperature, double pressure = 101.325) const; double cp_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; virtual bool valid_cp(Id id, Id data_id) const; double cp_unc(Id id, Id data_id) const; std::pair<double, double> cp_rng(Id id, Id data_id) const; std::string cp_ref(Id id, Id data_id) const; // viscosity double mu(Id id, Id data_id, double temperature, double pressure = 101.325) const; double mu_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; double mu(Id id, Id data_id, double temperature, double pressure = 101.325) const; double mu_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; virtual bool valid_mu(Id id, Id data_id) const; double mu_unc(Id id, Id data_id) const; std::pair<double, double> mu_rng(Id id, Id data_id) const; std::string mu_ref(Id id, Id data_id) const; // conductivity double k(Id id, Id data_id, double temperature, double pressure = 101.325) const; double k_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; double k(Id id, Id data_id, double temperature, double pressure = 101.325) const; double k_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; virtual bool valid_k(Id id, Id data_id) const; double k_unc(Id id, Id data_id) const; std::pair<double, double> k_rng(Id id, Id data_id) const; std::string k_ref(Id id, Id data_id) const; // density double rho(Id id, Id data_id, double temperature, double pressure = 101.325) const; double rho_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; double rho(Id id, Id data_id, double temperature, double pressure = 101.325) const; double rho_h(Id id, Id data_id, double enthalpy, double pressure = 101.325) const; virtual bool valid_rho(Id id, Id data_id) const; double rho_unc(Id id, Id data_id) const; std::pair<double, double> rho_rng(Id id, Id data_id) const; Loading Loading @@ -135,7 +144,12 @@ class Default_Data_Store : public Data_Store std::size_t constituent_count(Id id) const; void load(const std::string &fPath); [[deprecated("Use from_json(std::istream& inFile) instead.")]] void load(std::istream &inFile); void from_json(nlohmann::json); #ifdef SALINE_USE_HDF5 void from_h5(hid_t file); #endif View setView(const Vec_Name &names, const Vec_Mole &mole_percents); Loading @@ -144,7 +158,8 @@ class Default_Data_Store : public Data_Store bool valid(Vec_Name &names) const { return valid(names_to_id(names)); }; bool valid(Name &name) const { return valid(name_to_id(name)); }; // obtain data store id given a set of compound names (e.g., LiF-NaF-KF, LiF-BeF2-ZrF4-ThF4) // obtain data store id given a set of compound names (e.g., LiF-NaF-KF, // LiF-BeF2-ZrF4-ThF4) Id names_to_id(Vec_Name names) const; // obtain data store id given a compound name (e.g., BeF2, NaCl) Id name_to_id(Name &name) const; Loading @@ -155,14 +170,11 @@ class Default_Data_Store : public Data_Store // The list accessible salt names Vec_Name getSaltKeys() const; std::vector<std::vector<double>> getSaltComps(Vec_Name names) const; void to_json(nlohmann::json &j) const; private: class Data { class Data { public: void to_stream(std::ostream& s) const; Vec_Mole &mole_percents() { return m_mole_percents; }; const Vec_Mole &mole_percents() const { return m_mole_percents; }; Loading Loading @@ -193,13 +205,17 @@ class Default_Data_Store : public Data_Store double rho_b() const { return m_rho_b; } // viscosity double mu(double t) const {return std::isnan(m_mu_c) ? m_mu_a * std::exp(m_mu_b / t) : std::pow(10.0,m_mu_a + (m_mu_b/t) + (m_mu_c/(t*t)));} double mu(double t) const { return std::isnan(m_mu_c) ? m_mu_a * std::exp(m_mu_b / t) : std::pow(10.0, m_mu_a + (m_mu_b / t) + (m_mu_c / (t * t))); } double mu_h(double h) const { return mu(h_to_t(h)); } bool valid_mu() const {return std::isnan(m_mu_c) ? (mu_a() != 0.0 ) : ((mu_a() != 0.0) || (mu_b() != 0.0) || (m_mu_c != 0.0));} bool valid_mu() const { return std::isnan(m_mu_c) ? (mu_a() != 0.0) : ((mu_a() != 0.0) || (mu_b() != 0.0) || (m_mu_c != 0.0)); } double mu_unc() const { return m_mu_unc; } std::string mu_ref() const { return m_mu_ref; } Loading @@ -220,10 +236,15 @@ class Default_Data_Store : public Data_Store double k_b() const { return m_k_b; } // specific heat double cp(double t) const {double t2 = t * t; return m_cp_a + m_cp_b * t + m_cp_c * 1/(t2) + m_cp_d * t2;} double cp(double t) const { double t2 = t * t; return m_cp_a + m_cp_b * t + m_cp_c * 1 / (t2) + m_cp_d * t2; } double cp_h(double h) const { return cp(h_to_t(h)); } bool valid_cp() const {return ((cp_a() != 0.0) || (cp_b() != 0.0) || (cp_c() != 0.0) || (cp_d() != 0.0)); } bool valid_cp() const { return ((cp_a() != 0.0) || (cp_b() != 0.0) || (cp_c() != 0.0) || (cp_d() != 0.0)); } double cp_unc() const { return m_cp_unc; } std::string cp_ref() const { return m_cp_ref; } Loading @@ -248,9 +269,9 @@ class Default_Data_Store : public Data_Store Vec_Mole m_mole_percents; // Melting Temperature double m_melt; double m_melt = 0.0; DataQualifier m_melt_qualifier; double m_melt_unc; double m_melt_unc = 0.0; DataQualifier m_melt_unc_qualifier; std::string m_melt_ref; Loading @@ -258,43 +279,43 @@ class Default_Data_Store : public Data_Store double m_mole_weight; // Boiling Temperature double m_boil; double m_boil = 0.0; DataQualifier m_boil_qualifier; double m_boil_unc; double m_boil_unc = 0.0; DataQualifier m_boil_unc_qualifier; std::string m_boil_ref; // density double m_rho_a; double m_rho_b; double m_rho_unc; double m_rho_a = 0.0; double m_rho_b = 0.0; double m_rho_unc = 0.0; DataQualifier m_rho_unc_qualifier; std::pair<double, double> m_rho_rng; std::string m_rho_ref; // viscosity double m_mu_a; double m_mu_b; double m_mu_c; double m_mu_unc; double m_mu_a = 0.0; double m_mu_b = 0.0; double m_mu_c = std::numeric_limits<double>::quiet_NaN(); double m_mu_unc = 0.0; DataQualifier m_mu_unc_qualifier; std::pair<double, double> m_mu_rng; std::string m_mu_ref; // conductivity double m_k_a; double m_k_b; double m_k_unc; double m_k_a = 0.0; double m_k_b = 0.0; double m_k_unc = 0.0; DataQualifier m_k_unc_qualifier; std::pair<double, double> m_k_rng; std::string m_k_ref; // specific heat double m_cp_a; double m_cp_b; double m_cp_c; double m_cp_d; double m_cp_unc; double m_cp_a = 0.0; double m_cp_b = 0.0; double m_cp_c = 0.0; double m_cp_d = 0.0; double m_cp_unc = 0.0; DataQualifier m_cp_unc_qualifier; std::pair<double, double> m_cp_rng; std::string m_cp_ref; Loading @@ -307,17 +328,16 @@ class Default_Data_Store : public Data_Store // h(t)'s E simplification (a * melt + b * melt^2 + d * melt^3 - c / melt) double m_e; }; void to_json(nlohmann::json &j, Data &d) const; using Vec_Data = std::vector<Data>; struct Compound { struct Compound { Vec_Name names; Vec_Data data; }; private: private: // >>> DATA void parse_data_qualifier(std::string &, DataQualifier &); void parse_data_token(std::string &, double &); Loading @@ -332,7 +352,6 @@ class Default_Data_Store : public Data_Store void setup_enthalpy_tables(); Default_Data_Store::Data &getDataReference(std::string, std::string); }; } // namespace saline Loading