1 #ifndef PHASE_ENVELOPE_H
2 #define PHASE_ENVELOPE_H
6 #define PHASE_ENVELOPE_MATRICES X(K) X(lnK) X(x) X(y)
7 #define PHASE_ENVELOPE_VECTORS \
47 #define X(name) std::vector<double> name;
53 #define X(name) std::vector<std::vector<double>> name;
67 #define X(name) name.clear();
70 #define X(name) name.clear();
76 const std::vector<CoolPropDbl>& x,
const std::vector<CoolPropDbl>& y, std::size_t i) {
77 std::size_t N = K.size();
79 throw CoolProp::ValueError(
"Cannot insert variables in phase envelope since resize() function has not been called");
81 this->p.insert(this->p.begin() + i, p);
82 this->T.insert(this->T.begin() + i, T);
83 this->lnT.insert(this->lnT.begin() + i, log(T));
84 this->lnp.insert(this->lnp.begin() + i, log(p));
85 this->rhomolar_liq.insert(this->rhomolar_liq.begin() + i, rhomolar_liq);
86 this->rhomolar_vap.insert(this->rhomolar_vap.begin() + i, rhomolar_vap);
87 this->hmolar_liq.insert(this->hmolar_liq.begin() + i, hmolar_liq);
88 this->hmolar_vap.insert(this->hmolar_vap.begin() + i, hmolar_vap);
89 this->smolar_liq.insert(this->smolar_liq.begin() + i, smolar_liq);
90 this->smolar_vap.insert(this->smolar_vap.begin() + i, smolar_vap);
91 this->lnrhomolar_liq.insert(this->lnrhomolar_liq.begin() + i, log(rhomolar_liq));
92 this->lnrhomolar_vap.insert(this->lnrhomolar_vap.begin() + i, log(rhomolar_vap));
93 for (
unsigned int j = 0; j < N; j++) {
94 this->K[j].insert(this->K[j].begin() + i, y[j] / x[j]);
95 this->lnK[j].insert(this->lnK[j].begin() + i, log(y[j] / x[j]));
96 this->x[j].insert(this->x[j].begin() + i, x[j]);
97 this->y[j].insert(this->y[j].begin() + i, y[j]);
99 if (rhomolar_liq > rhomolar_vap) {
100 this->Q.insert(this->Q.begin() + i, 1);
102 this->Q.insert(this->Q.begin() + i, 0);
107 const std::vector<CoolPropDbl>& x,
const std::vector<CoolPropDbl>& y) {
108 std::size_t N = K.size();
110 throw CoolProp::ValueError(
"Cannot store variables in phase envelope since resize() function has not been called");
112 this->p.push_back(p);
113 this->T.push_back(T);
114 this->lnT.push_back(log(T));
115 this->lnp.push_back(log(p));
116 this->rhomolar_liq.push_back(rhomolar_liq);
117 this->rhomolar_vap.push_back(rhomolar_vap);
118 this->hmolar_liq.push_back(hmolar_liq);
119 this->hmolar_vap.push_back(hmolar_vap);
120 this->smolar_liq.push_back(smolar_liq);
121 this->smolar_vap.push_back(smolar_vap);
122 this->lnrhomolar_liq.push_back(log(rhomolar_liq));
123 this->lnrhomolar_vap.push_back(log(rhomolar_vap));
124 for (
unsigned int i = 0; i < N; i++) {
125 this->K[i].push_back(y[i] / x[i]);
126 this->lnK[i].push_back(log(y[i] / x[i]));
127 this->x[i].push_back(x[i]);
128 this->y[i].push_back(y[i]);
130 if (rhomolar_liq > rhomolar_vap) {
131 this->Q.push_back(1);
133 this->Q.push_back(0);