Skip to content
Snippets Groups Projects
multifluid.hpp 38.9 KiB
Newer Older
  • Learn to ignore specific revisions
  • Ian Bell's avatar
    Ian Bell committed
            catch(...){
                return load_a_JSON_file(default_path);
            }
        };
    
    Ian Bell's avatar
    Ian Bell committed
        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");
    
    Ian Bell's avatar
    Ian Bell committed
        nlohmann::json flags = (spec.contains("flags")) ? spec.at("flags") : nlohmann::json();
    
    Ian Bell's avatar
    Ian Bell committed
        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));
    }
    
    //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);
    //}
    
    
    }; // namespace teqp