Skip to content

Commit

Permalink
Remove the mycp symbolic link, define a single path variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhbell committed Feb 24, 2024
1 parent 8a35f32 commit 7247abe
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 56 deletions.
13 changes: 8 additions & 5 deletions interface/C/teqpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ EXPORT_CODE int CONVENTION get_Arxy(const long long int uuid, const int NT, cons

#include "teqp/json_tools.hpp"

const std::string FLUIDDATAPATH = "../teqp/fluiddata"; // normally defined in src/test/test_common.in

TEST_CASE("Use of C interface","[teqpc]") {

constexpr int errmsg_length = 3000;
Expand All @@ -141,7 +143,7 @@ TEST_CASE("Use of C interface","[teqpc]") {
jmodel["departure"] = "";
jmodel["BIP"] = "";
jmodel["components"] = nlohmann::json::array();
jmodel["components"].push_back("../mycp/dev/fluids/Argon.json");
jmodel["components"].push_back(FLUIDDATAPATH+"/dev/fluids/Argon.json");

nlohmann::json j = {
{"kind", "multifluid"},
Expand All @@ -150,13 +152,14 @@ TEST_CASE("Use of C interface","[teqpc]") {
std::string js = j.dump(2);
int e1 = build_model(js.c_str(), &uuidMF, errmsg, errmsg_length);
REQUIRE(e1 == 0);
CAPTURE(errmsg);
}
{
nlohmann::json jmodel = nlohmann::json::object();
jmodel["departure"] = "";
jmodel["BIP"] = "";
jmodel["components"] = nlohmann::json::array();
jmodel["components"].push_back(load_a_JSON_file("../mycp/dev/fluids/Argon.json"));
jmodel["components"].push_back(load_a_JSON_file(FLUIDDATAPATH+"/dev/fluids/Argon.json"));

nlohmann::json j = {
{"kind", "multifluid"},
Expand All @@ -174,7 +177,7 @@ TEST_CASE("Use of C interface","[teqpc]") {
jmodel["components"] = nlohmann::json::array();
jmodel["components"].push_back("Ethane");
jmodel["components"].push_back("Nitrogen");
jmodel["root"] = "../mycp";
jmodel["root"] = FLUIDDATAPATH;

nlohmann::json j = {
{"kind", "multifluid"},
Expand Down Expand Up @@ -304,7 +307,7 @@ TEST_CASE("Use of C interface","[teqpc]") {
jmodel["departure"] = nlohmann::json::array();
jmodel["BIP"] = nlohmann::json::array();
jmodel["components"] = nlohmann::json::array();
jmodel["components"].push_back("../mycp/dev/fluids/Argon.json");
jmodel["components"].push_back(FLUIDDATAPATH+"/dev/fluids/Argon.json");

nlohmann::json j = {
{"kind", "multifluid"},
Expand All @@ -323,7 +326,7 @@ TEST_CASE("Use of C interface","[teqpc]") {
BENCHMARK("multifluid pure with fluid contents") {
nlohmann::json jmodel = nlohmann::json::object();
jmodel["components"] = nlohmann::json::array();
jmodel["components"].push_back(load_a_JSON_file("../mycp/dev/fluids/Argon.json"));
jmodel["components"].push_back(load_a_JSON_file(FLUIDDATAPATH+"/dev/fluids/Argon.json"));
jmodel["departure"] = nlohmann::json::array();
jmodel["BIP"] = nlohmann::json::array();
jmodel["flags"] = nlohmann::json::object();
Expand Down
1 change: 0 additions & 1 deletion mycp

This file was deleted.

20 changes: 11 additions & 9 deletions src/tests/catch_test_VLLE.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ using Catch::Approx;

using namespace teqp;

#include "test_common.in"

TEST_CASE("Test intersection for trisectrix", "[VLLE]"){
// As in the examples in https://doi.org/10.1021/acs.iecr.1c04703
Eigen::ArrayXd t = Eigen::ArrayXd::LinSpaced(300, -3, 3);
Expand All @@ -29,17 +31,17 @@ TEST_CASE("Test VLLE for nitrogen + ethane for isotherm", "[VLLE]")
// As in the examples in https://doi.org/10.1021/acs.iecr.1c04703
std::vector<std::string> names = {"Nitrogen", "Ethane"};
using namespace teqp::cppinterface;
auto model = make_multifluid_model(names, "../mycp");
auto model = make_multifluid_model(names, FLUIDDATAPATH);
std::vector<decltype(model)> pures;
pures.emplace_back(make_multifluid_model({names[0]}, "../mycp"));
pures.emplace_back(make_multifluid_model({names[1]}, "../mycp"));
pures.emplace_back(make_multifluid_model({names[0]}, FLUIDDATAPATH));
pures.emplace_back(make_multifluid_model({names[1]}, FLUIDDATAPATH));

double T = 120.3420;
std::vector<nlohmann::json> traces;
for (int ipure : {0, 1}){

// Init at the pure fluid endpoint
auto m0 = build_multifluid_model({names[ipure]}, "../mycp");
auto m0 = build_multifluid_model({names[ipure]}, FLUIDDATAPATH);
auto pure0 = nlohmann::json::parse(m0.get_meta()).at("pures")[0];
auto jancillaries = pure0.at("ANCILLARIES");
auto anc = teqp::MultiFluidVLEAncillaries(jancillaries);
Expand Down Expand Up @@ -72,17 +74,17 @@ TEST_CASE("Test VLLE for nitrogen + ethane for isobar", "[VLLE]")
// As in the examples in https://doi.org/10.1021/acs.iecr.1c04703
std::vector<std::string> names = {"Nitrogen", "Ethane"};
using namespace teqp::cppinterface;
auto model = make_multifluid_model(names, "../mycp");
auto model = make_multifluid_model(names, FLUIDDATAPATH);
std::vector<decltype(model)> pures;
pures.emplace_back(make_multifluid_model({names[0]}, "../mycp"));
pures.emplace_back(make_multifluid_model({names[1]}, "../mycp"));
pures.emplace_back(make_multifluid_model({names[0]}, FLUIDDATAPATH));
pures.emplace_back(make_multifluid_model({names[1]}, FLUIDDATAPATH));

double p = 29.0e5; // [Pa] # From Antolovic
std::vector<nlohmann::json> traces;
for (int ipure : {1, 0}){

// Init at the pure fluid endpoint for ethane
auto m0 = build_multifluid_model({names[ipure]}, "../mycp");
auto m0 = build_multifluid_model({names[ipure]}, FLUIDDATAPATH);
auto pure0 = nlohmann::json::parse(m0.get_meta()).at("pures")[0];
auto jancillaries = pure0.at("ANCILLARIES");
auto anc = teqp::MultiFluidVLEAncillaries(jancillaries);
Expand Down Expand Up @@ -114,7 +116,7 @@ TEST_CASE("Test VLLE tracing", "[VLLE]")
// As in the examples in https://doi.org/10.1021/acs.iecr.1c04703
std::vector<std::string> names = {"Nitrogen", "Ethane"};
using namespace teqp::cppinterface;
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
auto model = make_multifluid_model(names, root);
std::vector<decltype(model)> pures;
pures.emplace_back(make_multifluid_model({names[0]}, root));
Expand Down
6 changes: 4 additions & 2 deletions src/tests/catch_test_ammonia_water.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ using namespace autodiff;

using namespace teqp;

#include "test_common.in"

TEST_CASE("Trace critical curve w/ Tillner-Roth", "[NH3H2O]") {
auto model = AmmoniaWaterTillnerRoth();
auto z = (Eigen::ArrayXd(2) << 0.7, 0.3).finished();
Expand All @@ -40,7 +42,7 @@ TEST_CASE("Trace critical curve w/ Tillner-Roth", "[NH3H2O]") {
}

TEST_CASE("Bell et al. REFPROP 10", "[NH3H2O]") {
auto model = build_multifluid_model({ "AMMONIA", "WATER" }, "../mycp", "", {{ "estimate","Lorentz-Berthelot" }});
auto model = build_multifluid_model({ "AMMONIA", "WATER" }, FLUIDDATAPATH, "", {{ "estimate","Lorentz-Berthelot" }});

std::string s = R"({
"0": {
Expand Down Expand Up @@ -82,7 +84,7 @@ TEST_CASE("Bell et al. REFPROP 10", "[NH3H2O]") {
}

TEST_CASE("pure water VLE should not crash for Tillner-Roth model","[NH3H2O]") {
auto pure = build_multifluid_model({ "Water" }, "../mycp");
auto pure = build_multifluid_model({ "Water" }, FLUIDDATAPATH);
auto jancillaries = nlohmann::json::parse(pure.get_meta()).at("pures")[0].at("ANCILLARIES");
auto anc = teqp::MultiFluidVLEAncillaries(jancillaries);
double T = 500;
Expand Down
53 changes: 28 additions & 25 deletions src/tests/catch_test_multifluid.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ using Catch::Approx;
#include <boost/multiprecision/cpp_bin_float.hpp>
using namespace boost::multiprecision;

#include "test_common.in"

using namespace teqp;
using multifluid_t = decltype(build_multifluid_model({""}, ""));

TEST_CASE("Test infinite dilution critical locus derivatives for multifluid", "[crit]")
{
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;

const auto model = build_multifluid_model({ "Nitrogen", "Ethane" }, root);
using ct = CriticalTracing<decltype(model), double, Eigen::ArrayXd>;
Expand Down Expand Up @@ -54,10 +56,11 @@ TEST_CASE("Benchmark CO2 with Span and Wagner model", "[CO2bench]"){
"kind": "multifluid",
"model": {
"components": ["CarbonDioxide"],
"root": "../mycp"
"root": "???"
}
}
)"_json;
contents["model"]["root"] = FLUIDDATAPATH;
auto model = teqp::cppinterface::make_model(contents);
auto z = (Eigen::ArrayXd(1) << 1.0).finished();

Expand All @@ -77,7 +80,7 @@ TEST_CASE("Benchmark CO2 with Span and Wagner model", "[CO2bench]"){

TEST_CASE("Test infinite dilution critical locus derivatives for multifluid with both orders", "[crit]")
{
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;

auto pure_endpoint = [&](const std::vector < std::string> &fluids, int i) {
const auto model = build_multifluid_model(fluids, root);
Expand Down Expand Up @@ -114,13 +117,13 @@ TEST_CASE("Test infinite dilution critical locus derivatives for multifluid with

TEST_CASE("Confirm failure for missing files","[multifluid]") {
CHECK_THROWS(build_multifluid_model({ "BADFLUID" }, "IMPOSSIBLE PATH", "IMPOSSIBLE PATH.json"));
CHECK_THROWS(build_multifluid_model({ "BADFLUID" }, "IMPOSSIBLE PATH", "../mycp/dev/mixtures/mixture_binary_pairs.json"));
CHECK_THROWS(build_multifluid_model({ "BADFLUID" }, "IMPOSSIBLE PATH", FLUIDDATAPATH+"/dev/mixtures/mixture_binary_pairs.json"));
CHECK_THROWS(build_multifluid_model({ "Ethane" }, "IMPOSSIBLE PATH"));
}

TEST_CASE("Trace critical locus for nitrogen + ethane", "[crit],[multifluid]")
{
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
const auto model = build_multifluid_model({ "Nitrogen", "Ethane" }, root);

for (auto ifluid = 0; ifluid < 2; ++ifluid) {
Expand Down Expand Up @@ -151,7 +154,7 @@ TEST_CASE("Trace critical locus for nitrogen + ethane", "[crit],[multifluid]")
}

TEST_CASE("Check that all pure fluid models can be instantiated", "[multifluid],[all]"){
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
SECTION("With absolute paths to json file") {
int counter = 0;
for (auto path : get_files_in_folder(root + "/dev/fluids", ".json")) {
Expand All @@ -177,7 +180,7 @@ TEST_CASE("Check that all pure fluid models can be instantiated", "[multifluid],
}

TEST_CASE("Check that all ancillaries can be instantiated and work properly", "[multifluid],[all]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
SECTION("With absolute paths to json file") {
int counter = 0;
for (auto path : get_files_in_folder(root + "/dev/fluids", ".json")) {
Expand Down Expand Up @@ -214,7 +217,7 @@ TEST_CASE("Check that all ancillaries can be instantiated and work properly", "[
}

TEST_CASE("Check that mixtures can also do absolute paths", "[multifluid],[abspath]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
SECTION("With absolute paths to json file") {
std::vector<std::filesystem::path> paths = { root + "/dev/fluids/Methane.json", root + "/dev/fluids/Ethane.json" };
std::vector<std::string> abspaths;
Expand All @@ -227,7 +230,7 @@ TEST_CASE("Check that mixtures can also do absolute paths", "[multifluid],[abspa
}

TEST_CASE("Check mixing absolute and relative paths and fluid names", "[multifluid],[abspath]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
SECTION("With correct name of fluid") {
std::vector<std::string> paths = { std::filesystem::absolute(root + "/dev/fluids/Methane.json").string(), "Ethane" };
auto model = build_multifluid_model(paths, root, root + "/dev/mixtures/mixture_binary_pairs.json");
Expand All @@ -239,7 +242,7 @@ TEST_CASE("Check mixing absolute and relative paths and fluid names", "[multiflu
}

TEST_CASE("Check specifying some different kinds of sources of BIP", "[multifluidBIP]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
SECTION("Not JSON, should throw") {
std::vector<std::string> paths = { std::filesystem::absolute(root + "/dev/fluids/Nitrogen.json").string(), "Ethane" };
CHECK_THROWS(build_multifluid_model(paths, root, "I am not a JSON formatted string"));
Expand All @@ -256,7 +259,7 @@ TEST_CASE("Check specifying some different kinds of sources of BIP", "[multiflui
}

TEST_CASE("Check that all binary pairs specified in the binary pair file can be instantiated", "[multifluid],[binaries]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
REQUIRE_NOTHROW(build_alias_map(root));
auto amap = build_alias_map(root);
for (auto el : load_a_JSON_file(root + "/dev/mixtures/mixture_binary_pairs.json")) {
Expand All @@ -273,7 +276,7 @@ TEST_CASE("Check that all binary pairs specified in the binary pair file can be
}

TEST_CASE("Check that all pure fluid models can be evaluated at zero density", "[multifluid],[all],[virial]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
SECTION("With filename stems") {
for (auto path : get_files_in_folder(root + "/dev/fluids", ".json")) {
auto stem = path.filename().stem().string(); // filename without the .json
Expand All @@ -295,7 +298,7 @@ TEST_CASE("Check that all pure fluid models can be evaluated at zero density", "
}

TEST_CASE("Check that virial coefficients can be calculated with multiple derivative methods", "[multifluid],[virial]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
std::string stem = "Argon";
CAPTURE(stem);

Expand All @@ -317,7 +320,7 @@ TEST_CASE("Check that virial coefficients can be calculated with multiple deriva
}

TEST_CASE("dpsat/dTsat", "[dpdTsat]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
const auto model = build_multifluid_model({ "Methane", "Ethane" }, root);
using id = IsochoricDerivatives<decltype(model)>;
double T = 200;
Expand All @@ -332,7 +335,7 @@ TEST_CASE("dpsat/dTsat", "[dpdTsat]") {
}

TEST_CASE("Trace a VLE isotherm for CO2 + water", "[isothermCO2water]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
const auto model = build_multifluid_model({ "CarbonDioxide", "Water" }, root);
double T = 308.15;
auto rhovecL = (Eigen::ArrayXd(2) << 0.0, 55174.92375117).finished();
Expand All @@ -342,7 +345,7 @@ TEST_CASE("Trace a VLE isotherm for CO2 + water", "[isothermCO2water]") {
}

TEST_CASE("Trace a VLE isotherm for acetone + benzene", "[isothermacetonebenzene]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
const auto model = build_multifluid_model({ "Acetone", "Benzene" }, root);
double T = 348.05;
auto rhovecL = (Eigen::ArrayXd(2) << 12502.86504072, 0.0).finished();
Expand All @@ -351,7 +354,7 @@ TEST_CASE("Trace a VLE isotherm for acetone + benzene", "[isothermacetonebenzene
}

TEST_CASE("Calculate water at critical point", "[WATERcrit]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
const auto model = build_multifluid_model({ "Water" }, root);

using tdx = TDXDerivatives<decltype(model)>;
Expand All @@ -372,7 +375,7 @@ TEST_CASE("Calculate water at critical point", "[WATERcrit]") {
}

TEST_CASE("Calculate partial molar volume for a CO2 containing mixture", "[partial_molar_volume]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
const auto model = build_multifluid_model({ "CarbonDioxide", "Heptane" }, root);
using id = IsochoricDerivatives<decltype(model), double, Eigen::ArrayXd>;

Expand All @@ -388,7 +391,7 @@ TEST_CASE("Calculate partial molar volume for a CO2 containing mixture", "[parti
}

TEST_CASE("Check that all pure fluid ideal-gas terms can be converted", "[multifluid],[all],[alphaig]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
auto paths = get_files_in_folder(root + "/dev/fluids", ".json");
auto p = GENERATE_REF(from_range(paths));
CHECK(std::filesystem::is_regular_file(p));
Expand All @@ -407,7 +410,7 @@ TEST_CASE("Check that all pure fluid ideal-gas terms can be converted", "[multif
}

TEST_CASE("Check that BIP can be set in a string", "[multifluida]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
double T = 300, rhomolar = 300;
auto z = (Eigen::ArrayXd(2) << 0.4, 0.6).finished();
auto def = build_multifluid_model({"Nitrogen","Ethane"}, root); // default parameters
Expand All @@ -428,7 +431,7 @@ TEST_CASE("Check that BIP can be set in a string", "[multifluida]") {
}

TEST_CASE("Check ammonia+argon", "[multifluidArNH3]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;

// Check that default model (no departure function) prints the right
auto def = build_multifluid_model({"AMMONIA","ARGON"}, root); // default parameters
Expand Down Expand Up @@ -464,7 +467,7 @@ TEST_CASE("Check ammonia+argon", "[multifluidArNH3]") {


TEST_CASE("Check pure fluid throws with composition array of wrong length", "[virial]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;
const auto model = build_multifluid_model({ "CarbonDioxide" }, root);
double T = 300;
auto z = (Eigen::ArrayXd(2) << 0.3, 0.9).finished();
Expand All @@ -477,7 +480,7 @@ TEST_CASE("Test ECS for pure fluids", "[ECS]"){
"kind": "multifluid-ECS-HuberEly1994",
"model": {
"reference_fluid": {
"name": "../mycp/dev/fluids/R113.json",
"name": "../teqp/fluiddata/dev/fluids/R113.json",
"acentric": 0.25253,
"Z_crit": 0.280191,
"T_crit / K": 487.21,
Expand All @@ -501,7 +504,7 @@ TEST_CASE("Test ECS for pure fluids", "[ECS]"){
}

TEST_CASE("Check models for R", "[multifluidR]") {
std::string root = "../mycp";
std::string root = FLUIDDATAPATH;

auto z = (Eigen::ArrayXd(1) << 1.0).finished();

Expand Down Expand Up @@ -542,7 +545,7 @@ TEST_CASE("Ar20 for CO2", "[Ar20CO2]"){
auto z = (Eigen::ArrayXd(1) << 1.0).finished();

using my_float = boost::multiprecision::number<boost::multiprecision::cpp_bin_float<200>>; // Overkill: 200 digits of working precision!
auto model = build_multifluid_model({"CO2"}, "../mycp");
auto model = build_multifluid_model({"CO2"}, FLUIDDATAPATH);

auto f = [&rho, &z, &model](const auto Trecip){ return model.alphar(1.0/Trecip, rho, z); };

Expand Down
Loading

0 comments on commit 7247abe

Please sign in to comment.