diff --git a/include/teqp/derivs.hpp b/include/teqp/derivs.hpp index 41df6906e943797ea51a404b607a7c2d69df5f68..57f651d9f80713004d32a65b200fee6758d9569d 100644 --- a/include/teqp/derivs.hpp +++ b/include/teqp/derivs.hpp @@ -179,6 +179,17 @@ auto get_Bnvir(const Model& model, const TType T, const ContainerType& molefrac) return o; } +template <typename Model, typename TType, typename ContainerType> +typename ContainerType::value_type get_B12vir(const Model& model, const TType T, const ContainerType& molefrac) { + + auto B2 = get_B2vir(model, T, molefrac); // Overall B2 for mixture + auto B20 = get_B2vir(model, T, std::valarray<double>({ 1,0 })); // Pure first component with index 0 + auto B21 = get_B2vir(model, T, std::valarray<double>({ 0,1 })); // Pure second component with index 1 + auto z0 = molefrac[0]; + auto B12 = (B2 - z0*z0*B20 - (1-z0)*(1-z0)*B21)/(2*z0*(1-z0)); + return B12; +} + /*** * \brief Calculate the residual entropy (s^+ = -sr/R) from derivatives of alphar */ diff --git a/src/tests/catch_tests.cxx b/src/tests/catch_tests.cxx index 953bf365f2fbd6b7a6bfd3acfa236250835a9a8c..101a4aa31ff9f1c34437ea0d8db4b7dba75f0a0e 100644 --- a/src/tests/catch_tests.cxx +++ b/src/tests/catch_tests.cxx @@ -145,4 +145,11 @@ TEST_CASE("Trace critical locus for vdW", "[vdW][crit]") std::string filename = ""; trace_critical_arclength_binary(vdW, T0, rhovec0, filename); auto tic1 = std::chrono::steady_clock::now(); +} + +TEST_CASE("TEST B12", "") { + const auto model = build_vdW(); + const double T = 298.15; + const std::valarray<double> molefrac = { 1/3, 2/3 }; + auto B12 = get_B12vir(model, T, molefrac); } \ No newline at end of file