CoolProp 8.0.0
An open-source fluid property and humid air property database
Ancillaries.h
Go to the documentation of this file.
1#ifndef ANCILLARIES_H
2#define ANCILLARIES_H
3
5#include <utility>
6#include <vector>
7#include "CoolProp/detail/tools.h" // for CoolPropDbl
8#include "Eigen/Core"
10
11namespace CoolProp {
12
26{
27 public:
28 std::vector<CoolPropDbl> a,
29 n,
30 s;
32 std::size_t N;
33 std::string BibTeX;
34
35 SurfaceTensionCorrelation() : Tc(_HUGE), N(0) {}
36
41 struct Values
42 {
43 std::vector<CoolPropDbl> a, n;
44 CoolPropDbl Tc = _HUGE;
45 std::string BibTeX;
46 };
47
49 : a(v.a), n(v.n), s(v.n), Tc(v.Tc), N(v.n.size()), BibTeX(v.BibTeX) {}
50
53 if (a.empty()) {
54 throw NotImplementedError(format("surface tension curve not provided"));
55 }
56 if (T > Tc) {
57 throw ValueError(format("Must be saturated state : T <= Tc"));
58 }
59 CoolPropDbl THETA = 1 - T / Tc;
60 for (std::size_t i = 0; i < N; ++i) {
61 s[i] = a[i] * pow(THETA, n[i]);
62 }
63 return std::accumulate(s.begin(), s.end(), 0.0);
64 }
65};
91{
92 public:
94 {
99 };
100
106 struct Values
107 {
109 Eigen::MatrixXd num_coeffs, den_coeffs;
110 std::vector<double> n, t;
112 bool using_tau_r = false;
114 CoolPropDbl Tmin = _HUGE, Tmax = _HUGE;
115 };
116
117 private:
118 Eigen::MatrixXd num_coeffs,
119 den_coeffs;
120 std::vector<double> n, t, s; // For TYPE_NOT_EXPONENTIAL & TYPE_EXPONENTIAL
121 union
122 {
124 struct
125 { // For TYPE_NOT_EXPONENTIAL & TYPE_EXPONENTIAL
129 std::size_t N;
130 };
131 };
132 CoolPropDbl Tmax,
133 Tmin;
135
136 public:
138 : type(TYPE_NOT_SET), Tmin(_HUGE), Tmax(_HUGE) {
139
140 };
141
144 explicit SaturationAncillaryFunction(const Values& v);
145
147 bool enabled() {
148 return type != TYPE_NOT_SET;
149 }
150
154 return max_abs_error;
155 };
156
160 double evaluate(double T);
161
167 double invert(double value, double min_bound = -1, double max_bound = -1);
168
170 double get_Tmin() {
171 return Tmin;
172 };
173
175 double get_Tmax() {
176 return Tmax;
177 };
178};
179
180// ****************************************************************************
181// ****************************************************************************
182// MELTING LINE
183// ****************************************************************************
184// ****************************************************************************
185
187{
189};
191{
192 std::vector<MeltingLinePiecewiseSimonSegment> parts;
193};
194
203{
204 public:
205 std::vector<CoolPropDbl> a, t;
208 CoolPropDbl summer = 0;
209 for (std::size_t i = 0; i < a.size(); ++i) {
210 summer += a[i] * (pow(T / T_0, t[i]) - 1);
211 }
212 return p_0 * (1 + summer);
213 }
214};
216{
217 std::vector<MeltingLinePiecewisePolynomialInTrSegment> parts;
218};
219
228{
229 public:
230 std::vector<CoolPropDbl> a, t;
232
234 CoolPropDbl summer = 0;
235 for (std::size_t i = 0; i < a.size(); ++i) {
236 summer += a[i] * pow(T / T_0 - 1, t[i]);
237 }
238 return p_0 * (1 + summer);
239 }
240};
242{
243 std::vector<MeltingLinePiecewisePolynomialInThetaSegment> parts;
244};
245
247{
248 public:
250 {
255 };
260
261 std::string BibTeX;
268 int type;
269
270 MeltingLineVariables() : Tmin(_HUGE), Tmax(_HUGE), pmin(_HUGE), pmax(_HUGE), T_m(_HUGE), type(MELTING_LINE_NOT_SET) {};
271
278 CoolPropDbl evaluate(int OF, int GIVEN, CoolPropDbl value);
279
281 void set_limits();
282
284 bool enabled() {
285 return type != MELTING_LINE_NOT_SET;
286 };
287
289 [[nodiscard]] std::vector<std::pair<CoolPropDbl, CoolPropDbl>> get_parts_pranges() const;
290};
291
292} /* namespace CoolProp */
293#endif