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