Skip to content

Commit

Permalink
Merge pull request #99 from usnistgov/compderivs
Browse files Browse the repository at this point in the history
Add composition derivatives to teqp interface
  • Loading branch information
ianhbell authored Mar 3, 2024
2 parents d219378 + 48171cc commit 50381dd
Show file tree
Hide file tree
Showing 10 changed files with 501 additions and 82 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build_cibuildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macOS-11]
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -36,8 +36,9 @@ jobs:
CIBW_ARCHS: auto64
CIBW_ARCHS_MACOS: universal2
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=10.15
CIBW_ENVIRONMENT_LINUX: CXXFLAGS='-fconcepts'
CIBW_BUILD_VERBOSITY_WINDOWS: 2
CIBW_SKIP: "*pypy* *pp* *cp36*"
CIBW_SKIP: "*pypy* *pp* *cp36* *musl*"

- uses: actions/upload-artifact@v3
with:
Expand Down
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ option (TEQP_COMPLEXSTEP_ENABLED


#### SETUP
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)

set(ZIPFN "${CMAKE_CURRENT_SOURCE_DIR}/dev/docker/boost_bcp_docker/boost_teqp.tar.xz")
set(OUTFN "${CMAKE_CURRENT_SOURCE_DIR}/boost_teqp/boost/version.hpp")
Expand Down Expand Up @@ -137,9 +137,11 @@ if (NOT TEQP_NO_TEQPCPP)

if(MSVC)
target_compile_options(teqpcpp PRIVATE /W4 ) # or add /WX to turn warnings into errors
target_compile_options(teqpcpp PUBLIC /wc5054)
else()
# Turn on all warnings, and then disable selectively
target_compile_options(teqpcpp PRIVATE -Wall -Wextra -Wpedantic -Wno-deprecated-copy -Wno-language-extension-token) # or add -Werror to turn warnings into errors
target_compile_options(teqpcpp PRIVATE -Wall -Wextra -Wpedantic -Wno-deprecated-copy -Wno-language-extension-token) # or add -Werror to turn warnings into errors
target_compile_options(teqpcpp PUBLIC -Wno-deprecated-anon-enum-enum-conversion)
endif()

if (TEQP_TESTTEQPCPP)
Expand Down
24 changes: 23 additions & 1 deletion include/teqp/cpp/deriv_adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,28 @@ class DerivativeAdapter : public teqp::cppinterface::AbstractModel{
return VirialDerivatives<decltype(mp.get_cref()), double, EArrayd>::get_dmBnvirdTm_runtime(Nderiv, NTderiv, mp.get_cref(), T, molefrac);
};

// Composition derivatives with temperature and density as the working variables
virtual double get_ATrhoXi(const double T, const int NT, const double rhomolar, const int ND, const EArrayd& molefrac, const int i, const int NXi) const override {
return TDXDerivatives<decltype(mp.get_cref()), double, EArrayd>::get_ATrhoXi_runtime(mp.get_cref(), T, NT, rhomolar, ND, molefrac, i, NXi);
};
virtual double get_ATrhoXiXj(const double T, const int NT, const double rhomolar, const int ND, const EArrayd& molefrac, const int i, const int NXi, const int j, const int NXj) const override {
return TDXDerivatives<decltype(mp.get_cref()), double, EArrayd>::get_ATrhoXiXj_runtime(mp.get_cref(), T, NT, rhomolar, ND, molefrac, i, NXi, j, NXj);
};
virtual double get_ATrhoXiXjXk(const double T, const int NT, const double rhomolar, const int ND, const EArrayd& molefrac, const int i, const int NXi, const int j, const int NXj, const int k, const int NXk) const override {
return TDXDerivatives<decltype(mp.get_cref()), double, EArrayd>::get_ATrhoXiXjXk_runtime(mp.get_cref(), T, NT, rhomolar, ND, molefrac, i, NXi, j, NXj, k, NXk);
};

// Composition derivatives with tau and delta as the working variables
virtual double get_AtaudeltaXi(const double tau, const int NT, const double delta, const int ND, const EArrayd& molefrac, const int i, const int NXi) const override {
return TDXDerivatives<decltype(mp.get_cref()), double, EArrayd>::get_AtaudeltaXi_runtime(mp.get_cref(), tau, NT, delta, ND, molefrac, i, NXi);
};
virtual double get_AtaudeltaXiXj(const double tau, const int NT, const double delta, const int ND, const EArrayd& molefrac, const int i, const int NXi, const int j, const int NXj) const override {
return TDXDerivatives<decltype(mp.get_cref()), double, EArrayd>::get_AtaudeltaXiXj_runtime(mp.get_cref(), tau, NT, delta, ND, molefrac, i, NXi, j, NXj);
};
virtual double get_AtaudeltaXiXjXk(const double tau, const int NT, const double delta, const int ND, const EArrayd& molefrac, const int i, const int NXi, const int j, const int NXj, const int k, const int NXk) const override {
return TDXDerivatives<decltype(mp.get_cref()), double, EArrayd>::get_AtaudeltaXiXjXk_runtime(mp.get_cref(), tau, NT, delta, ND, molefrac, i, NXi, j, NXj, k, NXk);
};

// Derivatives from isochoric thermodynamics (all have the same signature within each block), and they differ by their output argument
#define X(f) virtual double f(const double T, const EArrayd& rhovec) const override { return IsochoricDerivatives<decltype(mp.get_cref()), double, EArrayd>::f(mp.get_cref(), T, rhovec); };
ISOCHORIC_double_args
Expand All @@ -115,7 +137,7 @@ class DerivativeAdapter : public teqp::cppinterface::AbstractModel{
};

virtual EArray33d get_deriv_mat2(const double T, double rho, const EArrayd& z ) const override {
return DerivativeHolderSquare<2, AlphaWrapperOption::residual>(mp.get_cref(), T, rho, z).derivs;
return DerivativeHolderSquare<2>(mp.get_cref(), T, rho, z).derivs;
};
};

Expand Down
9 changes: 9 additions & 0 deletions include/teqp/cpp/teqpcpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ namespace teqp {
virtual double get_B12vir(const double T, const EArrayd& z) const = 0;
virtual double get_dmBnvirdTm(const int Nderiv, const int NTderiv, const double T, const EArrayd& z) const = 0;

// Composition derivatives
virtual double get_ATrhoXi(const double T, const int NT, const double rhomolar, int ND, const EArrayd& molefrac, const int i, const int NXi) const = 0;
virtual double get_ATrhoXiXj(const double T, const int NT, const double rhomolar, int ND, const EArrayd& molefrac, const int i, const int NXi, const int j, const int NXj) const = 0;
virtual double get_ATrhoXiXjXk(const double T, const int NT, const double rhomolar, int ND, const EArrayd& molefrac, const int i, const int NXi, const int j, const int NXj, const int k, const int NXk) const = 0;

virtual double get_AtaudeltaXi(const double tau, const int Ntau, const double delta, int Ndelta, const EArrayd& molefrac, const int i, const int NXi) const = 0;
virtual double get_AtaudeltaXiXj(const double tau, const int Ntau, const double delta, int Ndelta, const EArrayd& molefrac, const int i, const int NXi, const int j, const int NXj) const = 0;
virtual double get_AtaudeltaXiXjXk(const double tau, const int Ntau, const double delta, int Ndelta, const EArrayd& molefrac, const int i, const int NXi, const int j, const int NXj, const int k, const int NXk) const = 0;

// Derivatives from isochoric thermodynamics (all have the same signature whithin each block)
#define X(f) virtual double f(const double T, const EArrayd& rhovec) const = 0;
ISOCHORIC_double_args
Expand Down
Loading

0 comments on commit 50381dd

Please sign in to comment.