Skip to content

Commit

Permalink
Add a more explicit test for PCSAFT in multifluid
Browse files Browse the repository at this point in the history
This shows what parts are needed, and to see the JSON structure, uncomment the check at the end
  • Loading branch information
ianhbell committed Dec 19, 2024
1 parent c7d30b0 commit 7c41a1a
Showing 1 changed file with 58 additions and 1 deletion.
59 changes: 58 additions & 1 deletion src/tests/catch_test_multifluid.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ using Catch::Matchers::WithinRel;
#include "teqp/cpp/teqpcpp.hpp"
#include "teqp/cpp/deriv_adapter.hpp"
#include "teqp/filesystem.hpp"
#include "teqp/constants.hpp"
#include "teqp/ideal_eosterms.hpp"
#include "teqp/math/finite_derivs.hpp"

Expand Down Expand Up @@ -663,7 +664,7 @@ TEST_CASE("Check composition derivatives for ternary with all one component", "[
}


TEST_CASE("Check adding cubic EOS as pure fluid contribution in multifluid approach", "[multifluidpuremodels]") {
TEST_CASE("Check adding simpler EOS as pure fluid contribution in multifluid approach", "[multifluidpuremodels]") {
std::string root = FLUIDDATAPATH;

SECTION("cubic EOS"){
Expand Down Expand Up @@ -741,4 +742,60 @@ TEST_CASE("Check adding cubic EOS as pure fluid contribution in multifluid appro
};
auto model_ = cppinterface::make_model(j);
}
SECTION("PC-SAFT cyclopentane+water explicit"){

double Tred_K = 511.72, rhored_molm3=3920;
// Build the residual portion with the PC-SAFT EOS
nlohmann::json alphar = {
// Reducing state variables are taken from critical point
{"Tred / K", Tred_K},
{"rhored / mol/m^3", rhored_molm3},
{"m", 2.3655}, // placeholder value for testing
{"sigma / A", 3.7114}, // placeholder value for testing
{"epsilon_over_k", 265.83}, // placeholder value for testing
{"type", "ResidualHelmholtzPCSAFTGrossSadowski2001"}
};

nlohmann::json alphars; alphars.push_back(alphar);

// The reducing state is needed for mixture models
nlohmann::json reducing = {
{"T", Tred_K},
{"rhomolar", rhored_molm3},
};
nlohmann::json states = {{"reducing", reducing}};
nlohmann::json EOS = {
{"alphar", alphars},
{"STATES", states},
{"gas_constant", constants::R_CODATA2017}
};

// And we need to store some identifiers for use in mixtures
nlohmann::json info = {
{"NAME", "Cyclopentane"},
{"CAS", "287-92-3"},
{"REFPROP_NAME", "CYCLOPEN"},
{"HASH", "43ab1810"}
};
nlohmann::json EOSlist; EOSlist = nlohmann::json::array(); EOSlist.push_back(EOS);
nlohmann::json f = {{"EOS", EOSlist}, {"INFO", info}};

nlohmann::json model = {
{"components", {f, "Water"}},
{"BIP", ""},
{"departure", ""},
{"flags", {{"force-estimate", "yes"},{"estimate","Lorentz-Berthelot"}}}
};
nlohmann::json j = {
{"kind", "multifluid"},
{"model", model}
};

j["model"]["root"] = FLUIDDATAPATH;
std::string as_str = j.dump(2);
CAPTURE(as_str);

auto model_ = cppinterface::make_model(j);
// CHECK(0==1);
}
}

0 comments on commit 7c41a1a

Please sign in to comment.