1 #ifndef PHASE_ENVELOPE_H 2 #define PHASE_ENVELOPE_H 4 #include "Exceptions.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; 48 PHASE_ENVELOPE_VECTORS
53 #define X(name) std::vector<std::vector<double>> name; 54 PHASE_ENVELOPE_MATRICES
57 PhaseEnvelopeData() : TypeI(false), built(false), iTsat_max(-1), ipsat_max(-1), icrit(-1) {}
59 void resize(std::size_t N) {
67 #define X(name) name.clear(); 68 PHASE_ENVELOPE_VECTORS
70 #define X(name) name.clear(); 71 PHASE_ENVELOPE_MATRICES
74 void insert_variables(
const CoolPropDbl T,
const CoolPropDbl p,
const CoolPropDbl rhomolar_liq,
const CoolPropDbl rhomolar_vap,
75 const CoolPropDbl hmolar_liq,
const CoolPropDbl hmolar_vap,
const CoolPropDbl smolar_liq,
const CoolPropDbl smolar_vap,
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);
105 void store_variables(
const CoolPropDbl T,
const CoolPropDbl p,
const CoolPropDbl rhomolar_liq,
const CoolPropDbl rhomolar_vap,
106 const CoolPropDbl hmolar_liq,
const CoolPropDbl hmolar_vap,
const CoolPropDbl smolar_liq,
const CoolPropDbl smolar_vap,
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);
std::size_t icrit
The index of the point corresponding to the critical point.
Definition: PhaseEnvelope.h:41
A data structure to hold the data for a phase envelope.
Definition: PhaseEnvelope.h:36
Definition: Exceptions.h:45
std::size_t ipsat_max
The index of the point corresponding to the maximum pressure for Type-I mixtures. ...
Definition: PhaseEnvelope.h:41
std::size_t iTsat_max
The index of the point corresponding to the maximum temperature for Type-I mixtures.
Definition: PhaseEnvelope.h:41
bool built
True if the phase envelope has been constructed.
Definition: PhaseEnvelope.h:40
bool TypeI
True if it is a Type-I mixture that has a phase envelope that looks like a pure fluid more or less...
Definition: PhaseEnvelope.h:39
This file contains flash routines in which the state is unknown, and a solver of some kind must be us...
Definition: AbstractState.h:19