Newer
Older
catch(...){
return load_a_JSON_file(default_path);
}
};
auto components = spec.at("components");
auto dep = spec.at("departure");
auto BIP = spec.at("BIP");
auto depcollection = nlohmann::json::object();
auto BIPcollection = nlohmann::json::object();
// Only do this if it is a mixture; departure and BIP don't apply for pure fluids
if (components.size() > 1){
depcollection = (dep.is_object()) ? dep : get_json(dep.get<std::string>(), root + "/dev/mixtures/mixture_departure_functions.json");
BIPcollection = (BIP.is_object()) ? BIP : get_json(BIP.get<std::string>(), root+"/dev/mixtures/mixture_binary_pairs.json");
nlohmann::json flags = (spec.contains("flags")) ? spec.at("flags") : nlohmann::json();
return _build_multifluid_model(make_pure_components_JSON(components, root), BIPcollection, depcollection, flags);
}
/// An overload of multifluidfactory that takes in a string
inline auto multifluidfactory(const std::string& specstring) {
return multifluidfactory(nlohmann::json::parse(specstring));
}
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
//class DummyEOS {
//public:
// template<typename TType, typename RhoType> auto alphar(TType tau, const RhoType& delta) const { return tau * delta; }
//};
//class DummyReducingFunction {
//public:
// template<typename MoleFractions> auto get_Tr(const MoleFractions& molefracs) const { return molefracs[0]; }
// template<typename MoleFractions> auto get_rhor(const MoleFractions& molefracs) const { return molefracs[0]; }
//};
//inline auto build_dummy_multifluid_model(const std::vector<std::string>& components) {
// std::vector<DummyEOS> EOSs(2);
// std::vector<std::vector<DummyEOS>> funcs(2); for (auto i = 0; i < funcs.size(); ++i) { funcs[i].resize(funcs.size()); }
// std::vector<std::vector<double>> F(2); for (auto i = 0; i < F.size(); ++i) { F[i].resize(F.size()); }
//
// struct Fwrapper {
// private:
// const std::vector<std::vector<double>> F_;
// public:
// Fwrapper(const std::vector<std::vector<double>> &F) : F_(F){};
// auto operator ()(std::size_t i, std::size_t j) const{ return F_[i][j]; }
// };
// auto ff = Fwrapper(F);
// auto redfunc = DummyReducingFunction();
// return MultiFluid(std::move(redfunc), std::move(CorrespondingStatesContribution(std::move(EOSs))), std::move(DepartureContribution(std::move(ff), std::move(funcs))));
//}
//inline void test_dummy() {
// auto model = build_dummy_multifluid_model({ "A", "B" });
// std::valarray<double> rhovec = { 1.0, 2.0 };
// auto alphar = model.alphar(300.0, rhovec);
//}