CoolProp 8.0.0
An open-source fluid property and humid air property database
IncompressibleBackend.h
Go to the documentation of this file.
1
2#ifndef INCOMPRESSIBLEBACKEND_H_
3#define INCOMPRESSIBLEBACKEND_H_
4
9
10#include <vector>
11
12namespace CoolProp {
13
15{
16
17 protected:
19 //double _T, _p; // From AbstractState
20 std::vector<CoolPropDbl> _fractions;
21
25
29
31
33
36 void set_fractions(const std::vector<CoolPropDbl>& fractions);
37
38 public:
40 virtual ~IncompressibleBackend() = default;
41 std::string backend_name() override {
43 }
44
50 IncompressibleBackend(const std::string& fluid_name);
53 IncompressibleBackend(const std::vector<std::string>& component_names);
54
55 // Incompressible backend uses different compositions
56 bool using_mole_fractions() override {
57 return this->fluid->getxid() == IFRAC_MOLE;
58 };
59 bool using_mass_fractions() override {
60 return (this->fluid->getxid() == IFRAC_MASS || this->fluid->getxid() == IFRAC_PURE);
61 };
62 bool using_volu_fractions() override {
63 return this->fluid->getxid() == IFRAC_VOLUME;
64 };
65
67
75 void update(CoolProp::input_pairs input_pair, double value1, double value2) override;
76
77 std::string fluid_param_string(const std::string& ParamName) override {
78 if (!ParamName.compare("long_name")) {
79 return calc_name();
80 } else {
81 throw ValueError(format("Input value [%s] is invalid.", ParamName.c_str()));
82 }
83 }
84
86 bool clear() override;
87
89 void set_reference_state(double T0 = 20 + 273.15, double p0 = 101325, double x0 = 0.0, double h0 = 0.0, double s0 = 0.0);
90
92
95 void set_mole_fractions(const std::vector<CoolPropDbl>& mole_fractions) override;
96 const std::vector<CoolPropDbl>& get_mole_fractions() override {
97 throw NotImplementedError("get_mole_fractions not implemented for this backend");
98 };
99
101
104 void set_mass_fractions(const std::vector<CoolPropDbl>& mass_fractions) override;
105
107
110 void set_volu_fractions(const std::vector<CoolPropDbl>& volu_fractions) override;
111
113 void check_status();
114
121 double rhomass();
123 double hmass();
125 double smass();
127 double umass();
129 double cmass();
130
131 double drhodTatPx();
132 double dsdTatPx();
133 double dhdTatPx();
134 double dsdTatPxdT();
135 double dhdTatPxdT();
136 double dsdpatTx();
137 double dhdpatTx();
138
140 double T_ref();
142 double p_ref();
144 double x_ref();
146 double h_ref();
148 double s_ref();
149
151 double hmass_ref();
153 double smass_ref();
154
159
166
173
179
180 // CoolPropDbl PUmass_flash(CoolPropDbl p, CoolPropDbl umass); // not implemented
181
182 // Molar quantities are not meaningful for incompressible solutions,
183 // which are formulated entirely on a mass basis with no fixed
184 // composition / molecular weight (#1908). Throw a controlled
185 // exception with a helpful pointer at the mass-basis equivalents
186 // instead of silently returning the AbstractState default
187 // (-_HUGE) which surfaced as "PropsSI failed ungracefully".
189 throw NotImplementedError("Molar mass is not defined for the INCOMP (incompressible) backend; INCOMP fluids are mass-based.");
190 }
192 throw NotImplementedError("Dmolar / rhomolar is not defined for the INCOMP backend; use Dmass / rhomass instead.");
193 }
195 throw NotImplementedError("Hmolar / hmolar is not defined for the INCOMP backend; use Hmass / hmass instead.");
196 }
198 throw NotImplementedError("Smolar / smolar is not defined for the INCOMP backend; use Smass / smass instead.");
199 }
201 throw NotImplementedError("Umolar / umolar is not defined for the INCOMP backend; use Umass / umass instead.");
202 }
204 throw NotImplementedError("Cpmolar / cpmolar is not defined for the INCOMP backend; use Cpmass / cpmass instead.");
205 }
207 throw NotImplementedError("Cvmolar / cvmolar is not defined for the INCOMP backend; use Cvmass / cvmass instead.");
208 }
209
212 return fluid->rho(_T, _p, _fractions[0]);
213 };
215 return fluid->c(_T, _p, _fractions[0]);
216 };
218 return cmass();
219 };
221 return cmass();
222 };
224 return fluid->visc(_T, _p, _fractions[0]);
225 };
227 return fluid->cond(_T, _p, _fractions[0]);
228 };
230 // No update is called - T_freeze is a trivial output
232 return fluid->Tfreeze(_p, _fractions[0]);
233 };
234 CoolPropDbl calc_melting_line(int param, int given, CoolPropDbl value) override;
235 CoolPropDbl calc_umass() override;
236
238 CoolPropDbl calc_hmass() override;
239 CoolPropDbl calc_smass() override;
240
241 public:
243 CoolPropDbl raw_calc_hmass(double T, double p, double x);
244 CoolPropDbl raw_calc_smass(double T, double p, double x);
245
246 protected:
249
250 /* Below are direct calculations of the derivatives. Nothing
251 * special is going on, we simply use the polynomial class to
252 * derive the different functions with respect to temperature.
253 */
255 double calc_drhodTatPx(double T, double p, double x) {
256 return fluid->drhodTatPx(T, p, x);
257 };
259 double calc_dsdTatPx(double T, double p, double x) {
260 return fluid->c(T, p, x) / T;
261 };
263 double calc_dhdTatPx(double T, double p, double x) {
264 return fluid->c(T, p, x);
265 };
269 double calc_dsdTatPxdT(double T, double p, double x) {
270 return fluid->dsdTatPxdT(T, p, x);
271 };
275 double calc_dhdTatPxdT(double T, double p, double x) {
276 return fluid->dhdTatPxdT(T, p, x);
277 };
278
279 /* Other useful derivatives
280 */
283 double calc_dsdpatTx(double rho, double drhodTatPx);
286 double calc_dhdpatTx(double T, double rho, double drhodTatPx);
287
288 public:
291 return fluid->getTmax();
292 };
294 return fluid->getTmin();
295 };
297 return fluid->getxmin();
298 };
300 return fluid->getxmax();
301 };
302 std::string calc_name() override {
303 return fluid->getName();
304 };
305 std::string calc_description() override {
306 return fluid->getDescription();
307 };
308};
309
310} /* namespace CoolProp */
311#endif /* INCOMPRESSIBLEBACKEND_H_ */