From cb538bb06807b2b1d4c775924d85e1b6d26b7a86 Mon Sep 17 00:00:00 2001 From: Ian Bell <ian.bell@nist.gov> Date: Wed, 5 Oct 2022 17:47:08 -0400 Subject: [PATCH] Fix implementation of SW EOS, calculate critical points Yet another forceeval --- include/teqp/models/squarewell.hpp | 4 +++- interface/pybind11_wrapper.cpp | 2 ++ src/tests/catch_test_SW.cxx | 13 +++++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/teqp/models/squarewell.hpp b/include/teqp/models/squarewell.hpp index 76d53bc..c6c1c9f 100644 --- a/include/teqp/models/squarewell.hpp +++ b/include/teqp/models/squarewell.hpp @@ -7,6 +7,8 @@ namespace teqp{ namespace squarewell{ +#include "teqp/types.hpp" + /** Rodolfo EspÃndola-Heredia, Fernando del RÃo and Anatol Malijevsky Optimized equation of the state of the @@ -122,7 +124,7 @@ private: den += thetai[n]*pow(lambda_, n-4); } den = 1.0 + rhostar*den; - return num/den; + return forceeval(num/den); } template<typename RhoType> diff --git a/interface/pybind11_wrapper.cpp b/interface/pybind11_wrapper.cpp index a1d84da..992308a 100644 --- a/interface/pybind11_wrapper.cpp +++ b/interface/pybind11_wrapper.cpp @@ -16,6 +16,7 @@ void add_CPA(py::module& m); void add_multifluid(py::module& m); void add_multifluid_mutant(py::module& m); void add_cubics(py::module& m); +void add_model_potentials(py::module& m); template<typename Model, int iT, int iD, typename Class> void add_ig_deriv_impl(Class& cls) { @@ -169,6 +170,7 @@ void init_teqp(py::module& m) { add_multifluid(m); add_multifluid_mutant(m); add_cubics(m); + add_model_potentials(m); call_method_factory(m, "get_Ar00iso"); call_method_factory(m, "get_Ar10iso"); diff --git a/src/tests/catch_test_SW.cxx b/src/tests/catch_test_SW.cxx index 459c63d..c087b4d 100644 --- a/src/tests/catch_test_SW.cxx +++ b/src/tests/catch_test_SW.cxx @@ -3,6 +3,8 @@ using Catch::Approx; +#include "teqp/algorithms/critical_pure.hpp" + #include "teqp/models/squarewell.hpp" #include "teqp/derivs.hpp" #include <Eigen/Dense> @@ -13,13 +15,16 @@ TEST_CASE("simple evaluation of s^+ for square well EOS", "[squarewell]") { auto model = squarewell::EspindolaHeredia2009(1.5); std::valarray<double> z = {1.0}; - auto ar = model.alphar(1.3144366466267958, 0.2862336473147125, z); + auto Tstar=1.3144366466267958, rhostar = 0.2862336473147125; + auto ar = model.alphar(Tstar, rhostar, z); using id = IsochoricDerivatives<decltype(model)>; - auto rhovec = (Eigen::ArrayXd(1) << 0.2862336473147125).finished(); - auto splus = id::get_splus(model, 1.3144366466267958, rhovec); + auto rhovec = (Eigen::ArrayXd(1) << rhostar).finished(); + auto splus = id::get_splus(model, Tstar, rhovec); auto alphar_target = -0.8061758248466638; auto splus_target = 1.0031288550954747; CHECK(splus_target == Approx(splus)); - + + auto cr = teqp::get_pure_critical_conditions_Jacobian(model, Tstar, rhostar); + CHECK(std::isfinite(std::get<1>(cr)(0,0))); } -- GitLab