teqp 0.22.0
Loading...
Searching...
No Matches
multifluid_ancillaries.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <valarray>
4#include "nlohmann/json.hpp"
5#include "teqp/exceptions.hpp"
6
7namespace teqp{
8
10 const double T_r, Tmax, Tmin;
11 const std::string type, description;
12 const std::valarray<double> n, t;
13 const double reducing_value;
14 const bool using_tau_r, noexp;
15
16 VLEAncillary(const nlohmann::json &j) :
17 T_r(j.at("T_r")),
18 Tmax(j.at("Tmax")),
19 Tmin(j.at("Tmin")),
20 type(j.at("type")),
21 description(j.at("description")),
22 n(j.at("n").get<std::valarray<double>>()),
23 t(j.at("t").get<std::valarray<double>>()),
24 reducing_value(j.at("reducing_value")),
25 using_tau_r(j.at("using_tau_r")),
26 noexp(type == "rhoLnoexp"){};
27
28 double operator() (double T) const{
29 if (T > T_r) {
30 throw teqp::InvalidArgument("Input temperature of " + std::to_string(T) + " K is above the reducing temperature of " + std::to_string(T_r) + " K");
31 }
32 auto Theta = 1-T/T_r;
33 auto RHS = (pow(Theta, t)*n).sum();
34 if (using_tau_r){
35 RHS *= T_r/T;
36 }
37 if (noexp){
38 return reducing_value*(1+RHS);
39 }
40 else{
41 return exp(RHS)*reducing_value;
42 }
43 };
44 };
45
48 MultiFluidVLEAncillaries(const nlohmann::json& j) :
49 rhoL(VLEAncillary(j.at("rhoL"))),
50 rhoV(VLEAncillary(j.at("rhoV"))),
51 pL((j.contains("pS")) ? VLEAncillary(j.at("pS")) : VLEAncillary(j.at("pL"))),
52 pV((j.contains("pS")) ? VLEAncillary(j.at("pS")) : VLEAncillary(j.at("pV"))){}
53 };
54}
auto pow(const double &x, const double &e)
Definition types.hpp:195
MultiFluidVLEAncillaries(const nlohmann::json &j)
VLEAncillary(const nlohmann::json &j)
const std::valarray< double > n
const std::string description
const std::valarray< double > t
double operator()(double T) const