5 #include "../Backends/Helmholtz/HelmholtzEOSMixtureBackend.h"
6 #include "../Backends/Helmholtz/HelmholtzEOSBackend.h"
11 #if defined(ENABLE_CATCH)
14 # include <catch2/catch_all.hpp>
20 namespace TransportValidation {
26 std::string in1, in2, out, fluid;
27 double v1, v2, tol, expected;
28 vel(std::string fluid, std::string in1,
double v1, std::string in2,
double v2, std::string out,
double expected,
double tol) {
34 this->expected = expected;
39 vel viscosity_validation_data[] = {
41 vel(
"Propane",
"T", 90,
"Dmolar", 16.52e3,
"V", 7388e-6, 1e-3),
42 vel(
"Propane",
"T", 150,
"Dmolar", 15.14e3,
"V", 656.9e-6, 5e-3),
43 vel(
"Propane",
"T", 600,
"Dmolar", 10.03e3,
"V", 73.92e-6, 5e-3),
44 vel(
"Propane",
"T", 280,
"Dmolar", 11.78e3,
"V", 117.4e-6, 1e-3),
47 vel(
"n-Octane",
"T", 300,
"Dmolar", 6177.2,
"V", 553.60e-6, 1e-3),
48 vel(
"n-Nonane",
"T", 300,
"Dmolar", 5619.1,
"V", 709.53e-6, 1e-3),
49 vel(
"n-Decane",
"T", 300,
"Dmolar", 5150.4,
"V", 926.44e-6, 1e-3),
52 vel(
"n-Dodecane",
"T", 300,
"Dmolar", 4411.5,
"V", 1484.8e-6, 1e-3),
53 vel(
"n-Dodecane",
"T", 500,
"Dmolar", 3444.7,
"V", 183.76e-6, 1e-3),
56 vel(
"R125",
"T", 300,
"Dmolar", 10596.9998,
"V", 177.37e-6, 1e-3),
57 vel(
"R125",
"T", 400,
"Dmolar", 30.631,
"V", 17.070e-6, 1e-3),
60 vel(
"R134a",
"T", 185,
"Q", 0,
"V", 0.0012698376398294414, 1e-3),
61 vel(
"R134a",
"T", 185,
"Q", 1,
"V", 7.4290821400170869e-006, 1e-3),
62 vel(
"R134a",
"T", 360,
"Q", 0,
"V", 7.8146319978982133e-005, 1e-3),
63 vel(
"R134a",
"T", 360,
"Q", 1,
"V", 1.7140264998576107e-005, 1e-3),
66 vel(
"Ethanol",
"T", 300,
"Q", 0,
"V", 0.0010439017679191723, 1e-3),
67 vel(
"Ethanol",
"T", 300,
"Q", 1,
"V", 8.8293820936046416e-006, 1e-3),
68 vel(
"Ethanol",
"T", 500,
"Q", 0,
"V", 6.0979347125450671e-005, 1e-3),
69 vel(
"Ethanol",
"T", 500,
"Q", 1,
"V", 1.7229157141572511e-005, 1e-3),
73 vel(
"Hydrogen",
"T", 35,
"Dmass", 100,
"V", 5.47889e-005, 1e-3),
76 vel(
"DimethylEther",
"T", 253.146,
"Dmass", 734.28,
"V", 0.20444e-3, 3e-3),
77 vel(
"DimethylEther",
"T", 373.132,
"Dmass", 613.78,
"V", 0.09991e-3, 3e-3),
80 vel(
"Ammonia",
"T", 200,
"Dmolar", 3.9,
"V", 6.95e-6, 1e-3),
81 vel(
"Ammonia",
"T", 200,
"Dmolar", 42754.4,
"V", 507.28e-6, 1e-3),
82 vel(
"Ammonia",
"T", 398,
"Dmolar", 7044.7,
"V", 17.67e-6, 1e-3),
83 vel(
"Ammonia",
"T", 398,
"Dmolar", 21066.7,
"V", 43.95e-6, 1e-3),
86 vel(
"Nitrogen",
"T", 100,
"Dmolar", 1e-14,
"V", 6.90349e-6, 1e-3),
87 vel(
"Nitrogen",
"T", 300,
"Dmolar", 1e-14,
"V", 17.8771e-6, 1e-3),
88 vel(
"Nitrogen",
"T", 100,
"Dmolar", 25000,
"V", 79.7418e-6, 1e-3),
89 vel(
"Nitrogen",
"T", 200,
"Dmolar", 10000,
"V", 21.0810e-6, 1e-3),
90 vel(
"Nitrogen",
"T", 300,
"Dmolar", 5000,
"V", 20.7430e-6, 1e-3),
91 vel(
"Nitrogen",
"T", 126.195,
"Dmolar", 11180,
"V", 18.2978e-6, 1e-3),
92 vel(
"Argon",
"T", 100,
"Dmolar", 1e-14,
"V", 8.18940e-6, 1e-3),
93 vel(
"Argon",
"T", 300,
"Dmolar", 1e-14,
"V", 22.7241e-6, 1e-3),
94 vel(
"Argon",
"T", 100,
"Dmolar", 33000,
"V", 184.232e-6, 1e-3),
95 vel(
"Argon",
"T", 200,
"Dmolar", 10000,
"V", 25.5662e-6, 1e-3),
96 vel(
"Argon",
"T", 300,
"Dmolar", 5000,
"V", 26.3706e-6, 1e-3),
97 vel(
"Argon",
"T", 150.69,
"Dmolar", 13400,
"V", 27.6101e-6, 1e-3),
98 vel(
"Oxygen",
"T", 100,
"Dmolar", 1e-14,
"V", 7.70243e-6, 1e-3),
99 vel(
"Oxygen",
"T", 300,
"Dmolar", 1e-14,
"V", 20.6307e-6, 1e-3),
100 vel(
"Oxygen",
"T", 100,
"Dmolar", 35000,
"V", 172.136e-6, 1e-3),
101 vel(
"Oxygen",
"T", 200,
"Dmolar", 10000,
"V", 22.4445e-6, 1e-3),
102 vel(
"Oxygen",
"T", 300,
"Dmolar", 5000,
"V", 23.7577e-6, 1e-3),
103 vel(
"Oxygen",
"T", 154.6,
"Dmolar", 13600,
"V", 24.7898e-6, 1e-3),
104 vel(
"Air",
"T", 100,
"Dmolar", 1e-14,
"V", 7.09559e-6, 1e-3),
105 vel(
"Air",
"T", 300,
"Dmolar", 1e-14,
"V", 18.5230e-6, 1e-3),
106 vel(
"Air",
"T", 100,
"Dmolar", 28000,
"V", 107.923e-6, 1e-3),
107 vel(
"Air",
"T", 200,
"Dmolar", 10000,
"V", 21.1392e-6, 1e-3),
108 vel(
"Air",
"T", 300,
"Dmolar", 5000,
"V", 21.3241e-6, 1e-3),
109 vel(
"Air",
"T", 132.64,
"Dmolar", 10400,
"V", 17.7623e-6, 1e-3),
112 vel(
"Hexane",
"T", 250,
"Dmass", 1e-14,
"V", 5.2584e-6, 1e-3),
113 vel(
"Hexane",
"T", 400,
"Dmass", 1e-14,
"V", 8.4149e-6, 1e-3),
114 vel(
"Hexane",
"T", 550,
"Dmass", 1e-14,
"V", 11.442e-6, 1e-3),
115 vel(
"Hexane",
"T", 250,
"Dmass", 700,
"V", 528.2e-6, 1e-3),
116 vel(
"Hexane",
"T", 400,
"Dmass", 600,
"V", 177.62e-6, 1e-3),
117 vel(
"Hexane",
"T", 550,
"Dmass", 500,
"V", 95.002e-6, 1e-3),
120 vel(
"Heptane",
"T", 250,
"Dmass", 1e-14,
"V", 4.9717e-6, 1e-3),
121 vel(
"Heptane",
"T", 400,
"Dmass", 1e-14,
"V", 7.8361e-6, 1e-3),
122 vel(
"Heptane",
"T", 550,
"Dmass", 1e-14,
"V", 10.7394e-6, 1e-3),
123 vel(
"Heptane",
"T", 250,
"Dmass", 720,
"V", 725.69e-6, 1e-3),
124 vel(
"Heptane",
"T", 400,
"Dmass", 600,
"V", 175.94e-6, 1e-3),
125 vel(
"Heptane",
"T", 550,
"Dmass", 500,
"V", 95.105e-6, 1e-3),
128 vel(
"CO2",
"T", 220,
"Dmass", 2.440,
"V", 11.06e-6, 1e-3),
129 vel(
"CO2",
"T", 300,
"Dmass", 1.773,
"V", 15.02e-6, 1e-3),
130 vel(
"CO2",
"T", 800,
"Dmass", 0.662,
"V", 35.09e-6, 1e-3),
131 vel(
"CO2",
"T", 304,
"Dmass", 254.320,
"V", 20.99e-6, 1e-2),
132 vel(
"CO2",
"T", 220,
"Dmass", 1194.86,
"V", 269.37e-6, 1e-3),
133 vel(
"CO2",
"T", 300,
"Dmass", 1029.27,
"V", 132.55e-6, 1e-3),
134 vel(
"CO2",
"T", 800,
"Dmass", 407.828,
"V", 48.74e-6, 1e-3),
137 vel(
"R123",
"T", 265,
"Dmass", 1545.8,
"V", 627.1e-6, 1e-3),
138 vel(
"R123",
"T", 265,
"Dmass", 1.614,
"V", 9.534e-6, 1e-3),
139 vel(
"R123",
"T", 415,
"Dmass", 1079.4,
"V", 121.3e-6, 1e-3),
140 vel(
"R123",
"T", 415,
"Dmass", 118.9,
"V", 15.82e-6, 1e-3),
143 vel(
"R152A",
"T", 242,
"Dmass", 1025.5,
"V", 347.3e-6, 1e-3),
144 vel(
"R152A",
"T", 242,
"Dmass", 2.4868,
"V", 8.174e-6, 1e-3),
145 vel(
"R152A",
"T", 384,
"Dmass", 504.51,
"V", 43.29e-6, 5e-3),
146 vel(
"R152A",
"T", 384,
"Dmass", 239.35,
"V", 21.01e-6, 10e-3),
149 vel(
"Water",
"T", 298.15,
"Dmass", 998,
"V", 889.735100e-6, 1e-7),
150 vel(
"Water",
"T", 298.15,
"Dmass", 1200,
"V", 1437.649467e-6, 1e-7),
151 vel(
"Water",
"T", 373.15,
"Dmass", 1000,
"V", 307.883622e-6, 1e-7),
152 vel(
"Water",
"T", 433.15,
"Dmass", 1,
"V", 14.538324e-6, 1e-7),
153 vel(
"Water",
"T", 433.15,
"Dmass", 1000,
"V", 217.685358e-6, 1e-7),
154 vel(
"Water",
"T", 873.15,
"Dmass", 1,
"V", 32.619287e-6, 1e-7),
155 vel(
"Water",
"T", 873.15,
"Dmass", 100,
"V", 35.802262e-6, 1e-7),
156 vel(
"Water",
"T", 873.15,
"Dmass", 600,
"V", 77.430195e-6, 1e-7),
157 vel(
"Water",
"T", 1173.15,
"Dmass", 1,
"V", 44.217245e-6, 1e-7),
158 vel(
"Water",
"T", 1173.15,
"Dmass", 100,
"V", 47.640433e-6, 1e-7),
159 vel(
"Water",
"T", 1173.15,
"Dmass", 400,
"V", 64.154608e-6, 1e-7),
160 vel(
"Water",
"T", 647.35,
"Dmass", 122,
"V", 25.520677e-6, 1e-7),
161 vel(
"Water",
"T", 647.35,
"Dmass", 222,
"V", 31.337589e-6, 1e-7),
162 vel(
"Water",
"T", 647.35,
"Dmass", 272,
"V", 36.228143e-6, 1e-7),
163 vel(
"Water",
"T", 647.35,
"Dmass", 322,
"V", 42.961579e-6, 1e-7),
164 vel(
"Water",
"T", 647.35,
"Dmass", 372,
"V", 45.688204e-6, 1e-7),
165 vel(
"Water",
"T", 647.35,
"Dmass", 422,
"V", 49.436256e-6, 1e-7),
168 vel(
"SF6",
"T", 300,
"Dmass", 1e-14,
"V", 15.2887e-6, 1e-4),
169 vel(
"SF6",
"T", 300,
"Dmass", 5.92,
"V", 15.3043e-6, 1e-4),
170 vel(
"SF6",
"T", 300,
"Dmass", 1345.1,
"V", 117.417e-6, 1e-4),
171 vel(
"SF6",
"T", 400,
"Dmass", 1e-14,
"V", 19.6796e-6, 1e-4),
172 vel(
"SF6",
"T", 400,
"Dmass", 278.47,
"V", 24.4272e-6, 1e-4),
173 vel(
"SF6",
"T", 400,
"Dmass", 1123.8,
"V", 84.7835e-6, 1e-4),
176 vel(
"H2S",
"T", 200,
"P", 1000e5,
"V", 0.000460287, 1e-3),
177 vel(
"H2S",
"T", 200,
"P", 0.251702e5,
"V", 8.02322E-06, 1e-3),
178 vel(
"H2S",
"T", 596.961,
"P", 1000e5,
"V", 6.94741E-05, 1e-3),
179 vel(
"H2S",
"T", 596.961,
"P", 1e5,
"V", 2.38654E-05, 1e-3),
200 vel(
"Helium",
"T", 3.6,
"P", 0.180e6,
"V", 3.745e-6, 1e-2),
201 vel(
"Helium",
"T", 50,
"P", 0.180e6,
"V", 6.376e-6, 1e-2),
202 vel(
"Helium",
"T", 400,
"P", 0.180e6,
"V", 24.29e-6, 1e-2),
205 vel(
"R23",
"T", 180,
"Dmolar", 21097,
"V", 353.88e-6, 1e-4),
206 vel(
"R23",
"T", 420,
"Dmolar", 7564,
"V", 39.459e-6, 1e-4),
207 vel(
"R23",
"T", 370,
"Dmolar", 32.62,
"V", 18.213e-6, 1e-4),
210 vel(
"Ethane",
"T", 100,
"Dmolar", 21330,
"V", 878.6e-6, 1e-2),
211 vel(
"Ethane",
"T", 430,
"Dmolar", 12780,
"V", 58.70e-6, 1e-2),
212 vel(
"Ethane",
"T", 500,
"Dmolar", 11210,
"V", 48.34e-6, 1e-2),
215 vel(
"Methanol",
"T", 300,
"Dmass", 0.12955,
"V", 0.009696e-3, 1e-3),
216 vel(
"Methanol",
"T", 300,
"Dmass", 788.41,
"V", 0.5422e-3, 1e-3),
217 vel(
"Methanol",
"T", 630,
"Dmass", 0.061183,
"V", 0.02081e-3, 1e-3),
218 vel(
"Methanol",
"T", 630,
"Dmass", 888.50,
"V", 0.2405e-3, 1e-1),
221 vel(
"n-Butane",
"T", 150,
"Q", 0,
"V", 0.0013697657668, 1e-4),
222 vel(
"n-Butane",
"T", 400,
"Q", 1,
"V", 1.2027464524762453e-005, 1e-4),
223 vel(
"IsoButane",
"T", 120,
"Q", 0,
"V", 0.0060558450757844271, 1e-4),
224 vel(
"IsoButane",
"T", 400,
"Q", 1,
"V", 1.4761041187617117e-005, 2e-4),
225 vel(
"R134a",
"T", 175,
"Q", 0,
"V", 0.0017558494524138289, 1e-4),
226 vel(
"R134a",
"T", 360,
"Q", 1,
"V", 1.7140264998576107e-005, 1e-4),
229 vel(
"Cyclohexane",
"T", 300,
"Dmolar", 1e-10,
"V", 7.058e-6, 1e-4),
230 vel(
"Cyclohexane",
"T", 300,
"Dmolar", 0.0430e3,
"V", 6.977e-6, 1e-4),
231 vel(
"Cyclohexane",
"T", 300,
"Dmolar", 9.1756e3,
"V", 863.66e-6, 1e-4),
232 vel(
"Cyclohexane",
"T", 300,
"Dmolar", 9.9508e3,
"V", 2850.18e-6, 1e-4),
233 vel(
"Cyclohexane",
"T", 500,
"Dmolar", 1e-10,
"V", 11.189e-6, 1e-4),
234 vel(
"Cyclohexane",
"T", 500,
"Dmolar", 6.0213e3,
"V", 94.842e-6, 1e-4),
235 vel(
"Cyclohexane",
"T", 500,
"Dmolar", 8.5915e3,
"V", 380.04e-6, 1e-4),
236 vel(
"Cyclohexane",
"T", 700,
"Dmolar", 1e-10,
"V", 15.093e-6, 1e-4),
237 vel(
"Cyclohexane",
"T", 700,
"Dmolar", 7.4765e3,
"V", 176.749e-6, 1e-4),
240 vel(
"Benzene",
"T", 300,
"Dmass", 1e-10,
"V", 7.625e-6, 1e-4),
241 vel(
"Benzene",
"T", 400,
"Dmass", 1e-10,
"V", 10.102e-6, 1e-4),
242 vel(
"Benzene",
"T", 550,
"Dmass", 1e-10,
"V", 13.790e-6, 1e-4),
243 vel(
"Benzene",
"T", 300,
"Dmass", 875,
"V", 608.52e-6, 1e-4),
244 vel(
"Benzene",
"T", 400,
"Dmass", 760,
"V", 211.74e-6, 1e-4),
245 vel(
"Benzene",
"T", 550,
"Dmass", 500,
"V", 60.511e-6, 1e-4),
248 vel(
"m-Xylene",
"T", 300,
"Dmolar", 1e-10,
"V", 6.637e-6, 1e-4),
249 vel(
"m-Xylene",
"T", 300,
"Dmolar", 0.04 * 1e3,
"V", 6.564e-6, 1e-4),
250 vel(
"m-Xylene",
"T", 300,
"Dmolar", 8.0849 * 1e3,
"V", 569.680e-6, 1e-4),
251 vel(
"m-Xylene",
"T", 300,
"Dmolar", 8.9421 * 1e3,
"V", 1898.841e-6, 1e-4),
252 vel(
"m-Xylene",
"T", 400,
"Dmolar", 1e-10,
"V", 8.616e-6, 1e-4),
253 vel(
"m-Xylene",
"T", 400,
"Dmolar", 0.04 * 1e3,
"V", 8.585e-6, 1e-4),
254 vel(
"m-Xylene",
"T", 400,
"Dmolar", 7.2282 * 1e3,
"V", 238.785e-6, 1e-4),
255 vel(
"m-Xylene",
"T", 400,
"Dmolar", 8.4734 * 1e3,
"V", 718.950e-6, 1e-4),
256 vel(
"m-Xylene",
"T", 600,
"Dmolar", 1e-10,
"V", 12.841e-6, 1e-4),
257 vel(
"m-Xylene",
"T", 600,
"Dmolar", 0.04 * 1e3,
"V", 12.936e-6, 1e-4),
258 vel(
"m-Xylene",
"T", 600,
"Dmolar", 7.6591 * 1e3,
"V", 299.164e-6, 1e-4),
261 vel(
"o-Xylene",
"T", 300,
"Dmolar", 1e-10,
"V", 6.670e-6, 1e-4),
262 vel(
"o-Xylene",
"T", 300,
"Dmolar", 0.04 * 1e3,
"V", 6.598e-6, 1e-4),
263 vel(
"o-Xylene",
"T", 300,
"Dmolar", 8.2369 * 1e3,
"V", 738.286e-6, 1e-4),
264 vel(
"o-Xylene",
"T", 300,
"Dmolar", 8.7845 * 1e3,
"V", 1645.436e-6, 1e-4),
265 vel(
"o-Xylene",
"T", 400,
"Dmolar", 1e-10,
"V", 8.658e-6, 1e-4),
266 vel(
"o-Xylene",
"T", 400,
"Dmolar", 0.04 * 1e3,
"V", 8.634e-6, 1e-4),
267 vel(
"o-Xylene",
"T", 400,
"Dmolar", 7.4060 * 1e3,
"V", 279.954e-6, 1e-4),
268 vel(
"o-Xylene",
"T", 400,
"Dmolar", 8.2291 * 1e3,
"V", 595.652e-6, 1e-4),
269 vel(
"o-Xylene",
"T", 600,
"Dmolar", 1e-10,
"V", 12.904e-6, 1e-4),
270 vel(
"o-Xylene",
"T", 600,
"Dmolar", 0.04 * 1e3,
"V", 13.018e-6, 1e-4),
271 vel(
"o-Xylene",
"T", 600,
"Dmolar", 7.2408 * 1e3,
"V", 253.530e-6, 1e-4),
274 vel(
"p-Xylene",
"T", 300,
"Dmolar", 1e-10,
"V", 6.604e-6, 1e-4),
275 vel(
"p-Xylene",
"T", 300,
"Dmolar", 0.049 * 1e3,
"V", 6.405e-6, 1e-4),
276 vel(
"p-Xylene",
"T", 300,
"Dmolar", 8.0548 * 1e3,
"V", 593.272e-6, 1e-4),
277 vel(
"p-Xylene",
"T", 300,
"Dmolar", 8.6309 * 1e3,
"V", 1266.337e-6, 1e-4),
278 vel(
"p-Xylene",
"T", 400,
"Dmolar", 1e-10,
"V", 8.573e-6, 1e-4),
279 vel(
"p-Xylene",
"T", 400,
"Dmolar", 7.1995 * 1e3,
"V", 239.202e-6, 1e-4),
280 vel(
"p-Xylene",
"T", 400,
"Dmolar", 8.0735 * 1e3,
"V", 484.512e-6, 1e-4),
281 vel(
"p-Xylene",
"T", 600,
"Dmolar", 1e-10,
"V", 12.777e-6, 1e-4),
282 vel(
"p-Xylene",
"T", 600,
"Dmolar", 7.0985 * 1e3,
"V", 209.151e-6, 1e-4),
285 vel(
"EthylBenzene",
"T", 617,
"Dmass", 316,
"V", 33.22e-6, 1e-2),
288 vel(
"HeavyWater",
"T", 0.5000 * 643.847,
"Dmass", 3.07 * 358,
"V", 12.0604912273 * 55.2651e-6, 1e-5),
289 vel(
"HeavyWater",
"T", 0.9000 * 643.847,
"Dmass", 2.16 * 358,
"V", 1.6561616211 * 55.2651e-6, 1e-5),
290 vel(
"HeavyWater",
"T", 1.2000 * 643.847,
"Dmass", 0.8 * 358,
"V", 0.7651099154 * 55.2651e-6, 1e-5),
293 vel(
"Toluene",
"T", 300,
"Dmass", 1e-10,
"V", 7.023e-6, 1e-4),
294 vel(
"Toluene",
"T", 400,
"Dmass", 1e-10,
"V", 9.243e-6, 1e-4),
295 vel(
"Toluene",
"T", 550,
"Dmass", 1e-10,
"V", 12.607e-6, 1e-4),
296 vel(
"Toluene",
"T", 300,
"Dmass", 865,
"V", 566.78e-6, 1e-4),
297 vel(
"Toluene",
"T", 400,
"Dmass", 770,
"V", 232.75e-6, 1e-4),
298 vel(
"Toluene",
"T", 550,
"Dmass", 550,
"V", 80.267e-6, 1e-4),
302 class TransportValidationFixture
306 shared_ptr<CoolProp::AbstractState> pState;
310 TransportValidationFixture() {}
311 ~TransportValidationFixture() {}
312 void set_backend(std::string backend, std::string fluid_name) {
315 void set_pair(std::string& in1,
double v1, std::string& in2,
double v2) {
320 pState->update(pair, o1, o2);
323 actual = pState->keyed_output(key);
327 TEST_CASE_METHOD(TransportValidationFixture,
"Compare viscosities against published data",
"[viscosity],[transport]") {
328 int inputsN =
sizeof(viscosity_validation_data) /
sizeof(viscosity_validation_data[0]);
329 for (
int i = 0; i < inputsN; ++i) {
330 vel el = viscosity_validation_data[i];
331 CHECK_NOTHROW(set_backend(
"HEOS", el.fluid));
338 CHECK_NOTHROW(set_pair(el.in1, el.v1, el.in2, el.v2));
340 CAPTURE(el.expected);
342 CHECK(std::abs(actual / el.expected - 1) < el.tol);
346 vel conductivity_validation_data[] = {
350 vel(
"Hexane",
"T", 250,
"Dmass", 700,
"L", 137.62e-3, 1e-4),
351 vel(
"Hexane",
"T", 400,
"Dmass", 2,
"L", 23.558e-3, 1e-4),
352 vel(
"Hexane",
"T", 400,
"Dmass", 650,
"L", 129.28e-3, 2e-4),
353 vel(
"Hexane",
"T", 510,
"Dmass", 2,
"L", 36.772e-3, 1e-4),
356 vel(
"Heptane",
"T", 250,
"Dmass", 720,
"L", 137.09e-3, 1e-4),
357 vel(
"Heptane",
"T", 400,
"Dmass", 2,
"L", 21.794e-3, 1e-4),
358 vel(
"Heptane",
"T", 400,
"Dmass", 650,
"L", 120.75e-3, 1e-4),
359 vel(
"Heptane",
"T", 535,
"Dmass", 100,
"L", 51.655e-3, 3e-3),
362 vel(
"Ethanol",
"T", 300,
"Dmass", 850,
"L", 209.68e-3, 1e-4),
363 vel(
"Ethanol",
"T", 400,
"Dmass", 2,
"L", 26.108e-3, 1e-4),
364 vel(
"Ethanol",
"T", 400,
"Dmass", 690,
"L", 149.21e-3, 1e-4),
365 vel(
"Ethanol",
"T", 500,
"Dmass", 10,
"L", 39.594e-3, 1e-4),
377 vel(
"SF6",
"T", 298.15,
"Dmass", 1e-13,
"L", 12.952e-3, 1e-4),
378 vel(
"SF6",
"T", 298.15,
"Dmass", 100,
"L", 14.126e-3, 1e-4),
379 vel(
"SF6",
"T", 298.15,
"Dmass", 1600,
"L", 69.729e-3, 1e-4),
380 vel(
"SF6",
"T", 310,
"Dmass", 1e-13,
"L", 13.834e-3, 1e-4),
381 vel(
"SF6",
"T", 310,
"Dmass", 1200,
"L", 48.705e-3, 1e-4),
382 vel(
"SF6",
"T", 480,
"Dmass", 100,
"L", 28.847e-3, 1e-4),
392 vel(
"Hydrogen",
"T", 298.15,
"Dmass", 1e-13,
"L", 185.67e-3, 1e-4),
393 vel(
"Hydrogen",
"T", 298.15,
"Dmass", 0.80844,
"L", 186.97e-3, 1e-4),
394 vel(
"Hydrogen",
"T", 298.15,
"Dmass", 14.4813,
"L", 201.35e-3, 1e-4),
395 vel(
"Hydrogen",
"T", 35,
"Dmass", 1e-13,
"L", 26.988e-3, 1e-4),
396 vel(
"Hydrogen",
"T", 35,
"Dmass", 30,
"L", 0.0770177, 1e-4),
397 vel(
"Hydrogen",
"T", 18,
"Dmass", 1e-13,
"L", 13.875e-3, 1e-4),
398 vel(
"Hydrogen",
"T", 18,
"Dmass", 75,
"L", 104.48e-3, 1e-4),
408 vel(
"R125",
"T", 341,
"Dmass", 600,
"L", 0.0565642978494, 2e-4),
409 vel(
"R125",
"T", 200,
"Dmass", 1e-13,
"L", 0.007036843623086, 2e-4),
410 vel(
"IsoButane",
"T", 390,
"Dmass", 387.09520158645068,
"L", 0.063039, 2e-4),
411 vel(
"IsoButane",
"T", 390,
"Dmass", 85.76703973869482,
"L", 0.036603, 2e-4),
412 vel(
"n-Butane",
"T", 415,
"Dmass", 360.01895129934866,
"L", 0.067045, 2e-4),
413 vel(
"n-Butane",
"T", 415,
"Dmass", 110.3113177144,
"L", 0.044449, 1e-4),
416 vel(
"n-Octane",
"T", 300,
"Dmolar", 6177.2,
"L", 0.12836, 1e-4),
417 vel(
"n-Nonane",
"T", 300,
"Dmolar", 5619.4,
"L", 0.13031, 1e-4),
421 vel(
"n-Dodecane",
"T", 300,
"Dmolar", 4411.5,
"L", 0.13829, 1e-4),
422 vel(
"n-Dodecane",
"T", 500,
"Dmolar", 3444.7,
"L", 0.09384, 1e-4),
423 vel(
"n-Dodecane",
"T", 660,
"Dmolar", 1500.98,
"L", 0.090346, 1e-4),
426 vel(
"n-Propane",
"T", 368,
"Q", 0,
"L", 0.07282154952457, 1e-3),
427 vel(
"n-Propane",
"T", 368,
"Dmolar", 1e-10,
"L", 0.0266135388745317, 1e-4),
440 vel(
"R123",
"T", 180,
"Dmass", 1739,
"L", 110.9e-3, 2e-4),
441 vel(
"R123",
"T", 180,
"Dmass", 0.2873e-2,
"L", 2.473e-3, 1e-3),
442 vel(
"R123",
"T", 430,
"Dmass", 996.35,
"L", 45.62e-3, 1e-3),
443 vel(
"R123",
"T", 430,
"Dmass", 166.9,
"L", 21.03e-3, 1e-3),
446 vel(
"CO2",
"T", 218,
"Q", 0,
"L", 181.09e-3, 1e-4),
447 vel(
"CO2",
"T", 218,
"Q", 1,
"L", 10.837e-3, 1e-4),
448 vel(
"CO2",
"T", 304,
"Q", 0,
"L", 140.3e-3, 1e-4),
449 vel(
"CO2",
"T", 304,
"Q", 1,
"L", 217.95e-3, 1e-4),
450 vel(
"CO2",
"T", 225,
"Dmass", 0.23555,
"L", 11.037e-3, 1e-4),
451 vel(
"CO2",
"T", 275,
"Dmass", 1281.64,
"L", 238.44e-3, 1e-4),
454 vel(
"Ethane",
"T", 100,
"Dmass", 1e-13,
"L", 3.46e-3, 1e-2),
455 vel(
"Ethane",
"T", 230,
"Dmolar", 16020,
"L", 126.2e-3, 1e-2),
456 vel(
"Ethane",
"T", 440,
"Dmolar", 1520,
"L", 45.9e-3, 1e-2),
457 vel(
"Ethane",
"T", 310,
"Dmolar", 4130,
"L", 45.4e-3, 1e-2),
460 vel(
"Nitrogen",
"T", 100,
"Dmolar", 1e-14,
"L", 9.27749e-3, 1e-4),
461 vel(
"Nitrogen",
"T", 300,
"Dmolar", 1e-14,
"L", 25.9361e-3, 1e-4),
462 vel(
"Nitrogen",
"T", 100,
"Dmolar", 25000,
"L", 103.834e-3, 1e-4),
463 vel(
"Nitrogen",
"T", 200,
"Dmolar", 10000,
"L", 36.0099e-3, 1e-4),
464 vel(
"Nitrogen",
"T", 300,
"Dmolar", 5000,
"L", 32.7694e-3, 1e-4),
465 vel(
"Nitrogen",
"T", 126.195,
"Dmolar", 11180,
"L", 675.800e-3, 1e-4),
466 vel(
"Argon",
"T", 100,
"Dmolar", 1e-14,
"L", 6.36587e-3, 1e-4),
467 vel(
"Argon",
"T", 300,
"Dmolar", 1e-14,
"L", 17.8042e-3, 1e-4),
468 vel(
"Argon",
"T", 100,
"Dmolar", 33000,
"L", 111.266e-3, 1e-4),
469 vel(
"Argon",
"T", 200,
"Dmolar", 10000,
"L", 26.1377e-3, 1e-4),
470 vel(
"Argon",
"T", 300,
"Dmolar", 5000,
"L", 23.2302e-3, 1e-4),
471 vel(
"Argon",
"T", 150.69,
"Dmolar", 13400,
"L", 856.793e-3, 1e-4),
472 vel(
"Oxygen",
"T", 100,
"Dmolar", 1e-14,
"L", 8.94334e-3, 1e-4),
473 vel(
"Oxygen",
"T", 300,
"Dmolar", 1e-14,
"L", 26.4403e-3, 1e-4),
474 vel(
"Oxygen",
"T", 100,
"Dmolar", 35000,
"L", 146.044e-3, 1e-4),
475 vel(
"Oxygen",
"T", 200,
"Dmolar", 10000,
"L", 34.6124e-3, 1e-4),
476 vel(
"Oxygen",
"T", 300,
"Dmolar", 5000,
"L", 32.5491e-3, 1e-4),
477 vel(
"Oxygen",
"T", 154.6,
"Dmolar", 13600,
"L", 377.476e-3, 1e-4),
478 vel(
"Air",
"T", 100,
"Dmolar", 1e-14,
"L", 9.35902e-3, 1e-4),
479 vel(
"Air",
"T", 300,
"Dmolar", 1e-14,
"L", 26.3529e-3, 1e-4),
480 vel(
"Air",
"T", 100,
"Dmolar", 28000,
"L", 119.221e-3, 1e-4),
481 vel(
"Air",
"T", 200,
"Dmolar", 10000,
"L", 35.3185e-3, 1e-4),
482 vel(
"Air",
"T", 300,
"Dmolar", 5000,
"L", 32.6062e-3, 1e-4),
483 vel(
"Air",
"T", 132.64,
"Dmolar", 10400,
"L", 75.6231e-3, 1e-4),
486 vel(
"Water",
"T", 298.15,
"Dmass", 1e-14,
"L", 18.4341883e-3, 1e-6),
487 vel(
"Water",
"T", 298.15,
"Dmass", 998,
"L", 607.712868e-3, 1e-6),
488 vel(
"Water",
"T", 298.15,
"Dmass", 1200,
"L", 799.038144e-3, 1e-6),
489 vel(
"Water",
"T", 873.15,
"Dmass", 1e-14,
"L", 79.1034659e-3, 1e-6),
490 vel(
"Water",
"T", 647.35,
"Dmass", 1,
"L", 51.9298924e-3, 1e-6),
491 vel(
"Water",
"T", 647.35,
"Dmass", 122,
"L", 130.922885e-3, 2e-4),
492 vel(
"Water",
"T", 647.35,
"Dmass", 222,
"L", 367.787459e-3, 2e-4),
493 vel(
"Water",
"T", 647.35,
"Dmass", 272,
"L", 757.959776e-3, 2e-4),
494 vel(
"Water",
"T", 647.35,
"Dmass", 322,
"L", 1443.75556e-3, 2e-4),
495 vel(
"Water",
"T", 647.35,
"Dmass", 372,
"L", 650.319402e-3, 2e-4),
496 vel(
"Water",
"T", 647.35,
"Dmass", 422,
"L", 448.883487e-3, 2e-4),
497 vel(
"Water",
"T", 647.35,
"Dmass", 750,
"L", 600.961346e-3, 2e-4),
500 vel(
"R23",
"T", 180,
"Dmolar", 21097,
"L", 143.19e-3, 1e-4),
501 vel(
"R23",
"T", 420,
"Dmolar", 7564,
"L", 50.19e-3, 2e-4),
502 vel(
"R23",
"T", 370,
"Dmolar", 32.62,
"L", 17.455e-3, 1e-4),
505 vel(
"Ammonia",
"T", 310,
"Dmolar", 34320,
"L", 0.45223303481784971, 1e-4),
506 vel(
"Ammonia",
"T", 395,
"Q", 0,
"L", 0.2264480769301, 1e-4),
509 vel(
"Helium",
"T", 800,
"P", 1e5,
"L", 0.3085, 1e-2),
510 vel(
"Helium",
"T", 300,
"P", 1e5,
"L", 0.1560, 1e-2),
511 vel(
"Helium",
"T", 20,
"P", 1e5,
"L", 0.0262, 1e-2),
512 vel(
"Helium",
"T", 8,
"P", 1e5,
"L", 0.0145, 1e-2),
513 vel(
"Helium",
"T", 4,
"P", 20e5,
"L", 0.0255, 1e-2),
514 vel(
"Helium",
"T", 8,
"P", 20e5,
"L", 0.0308, 1e-2),
515 vel(
"Helium",
"T", 20,
"P", 20e5,
"L", 0.0328, 1e-2),
516 vel(
"Helium",
"T", 4,
"P", 100e5,
"L", 0.0385, 3e-2),
517 vel(
"Helium",
"T", 8,
"P", 100e5,
"L", 0.0566, 3e-2),
518 vel(
"Helium",
"T", 20,
"P", 100e5,
"L", 0.0594, 1e-2),
519 vel(
"Helium",
"T", 4,
"P", 1e5,
"L", 0.0186, 1e-2),
520 vel(
"Helium",
"T", 4,
"P", 2e5,
"L", 0.0194, 1e-2),
521 vel(
"Helium",
"T", 5.180,
"P", 2.3e5,
"L", 0.0195, 1e-1),
522 vel(
"Helium",
"T", 5.2,
"P", 2.3e5,
"L", 0.0202, 1e-1),
523 vel(
"Helium",
"T", 5.230,
"P", 2.3e5,
"L", 0.0181, 1e-1),
524 vel(
"Helium",
"T", 5.260,
"P", 2.3e5,
"L", 0.0159, 1e-1),
525 vel(
"Helium",
"T", 5.3,
"P", 2.3e5,
"L", 0.0149, 1e-1),
538 vel(
"R134a",
"T", 240,
"D", 1e-10,
"L", 0.008698768, 1e-4),
539 vel(
"R134a",
"T", 330,
"D", 1e-10,
"L", 0.015907606, 1e-4),
540 vel(
"R134a",
"T", 330,
"Q", 0,
"L", 0.06746432253, 1e-4),
541 vel(
"R134a",
"T", 240,
"Q", 1,
"L", 0.00873242359, 1e-4),
544 vel(
"o-Xylene",
"T", 635,
"D", 270,
"L", 96.4e-3, 1e-2),
545 vel(
"m-Xylene",
"T", 616,
"D", 220,
"L", 79.5232e-3, 1e-2),
546 vel(
"p-Xylene",
"T", 620,
"D", 287,
"L", 107.7e-3, 1e-2),
547 vel(
"EthylBenzene",
"T", 617,
"D", 316,
"L", 140.2e-3, 1e-2),
549 vel(
"o-Xylene",
"T", 300,
"D", 1e-12,
"L", 13.68e-3, 1e-3),
550 vel(
"o-Xylene",
"T", 600,
"D", 1e-12,
"L", 41.6e-3, 1e-3),
551 vel(
"m-Xylene",
"T", 300,
"D", 1e-12,
"L", 9.45e-3, 1e-3),
552 vel(
"m-Xylene",
"T", 600,
"D", 1e-12,
"L", 40.6e-3, 1e-3),
553 vel(
"p-Xylene",
"T", 300,
"D", 1e-12,
"L", 10.57e-3, 1e-3),
554 vel(
"p-Xylene",
"T", 600,
"D", 1e-12,
"L", 41.73e-3, 1e-3),
555 vel(
"EthylBenzene",
"T", 300,
"D", 1e-12,
"L", 9.71e-3, 1e-3),
556 vel(
"EthylBenzene",
"T", 600,
"D", 1e-12,
"L", 41.14e-3, 1e-3),
559 vel(
"Methane",
"T", 100,
"D", 1e-12,
"L", 9.83e-3, 1e-3),
560 vel(
"Methane",
"T", 400,
"D", 1e-12,
"L", 49.96e-3, 1e-3),
561 vel(
"Methane",
"T", 182,
"Q", 0,
"L", 82.5e-3, 5e-3),
562 vel(
"Methane",
"T", 100,
"Dmolar", 28.8e3,
"L", 234e-3, 1e-2),
565 vel(
"Methanol",
"T", 300,
"Dmass", 850,
"L", 241.48e-3, 1e-2),
566 vel(
"Methanol",
"T", 400,
"Dmass", 2,
"L", 25.803e-3, 1e-2),
567 vel(
"Methanol",
"T", 400,
"Dmass", 690,
"L", 183.59e-3, 1e-2),
568 vel(
"Methanol",
"T", 500,
"Dmass", 10,
"L", 40.495e-3, 1e-2),
571 vel(
"HeavyWater",
"T", 0.5000 * 643.847,
"Dmass", 3.07 * 358,
"V", 835.786416818 * 0.742128e-3, 1e-5),
572 vel(
"HeavyWater",
"T", 0.9000 * 643.847,
"Dmass", 2.16 * 358,
"V", 627.777590127 * 0.742128e-3, 1e-5),
573 vel(
"HeavyWater",
"T", 1.2000 * 643.847,
"Dmass", 0.8 * 358,
"V", 259.605241187 * 0.742128e-3, 1e-5),
576 vel(
"Cyclopentane",
"T", 512,
"Dmass", 1e-12,
"L", 37.042e-3, 1e-5),
577 vel(
"Cyclopentane",
"T", 512,
"Dmass", 400,
"L", 69.698e-3, 1e-1),
578 vel(
"Isopentane",
"T", 460,
"Dmass", 1e-12,
"L", 35.883e-3, 1e-4),
579 vel(
"Isopentane",
"T", 460,
"Dmass", 329.914,
"L", 59.649e-3, 1e-1),
580 vel(
"n-Pentane",
"T", 460,
"Dmass", 1e-12,
"L", 34.048e-3, 1e-5),
581 vel(
"n-Pentane",
"T", 460,
"Dmass", 377.687,
"L", 71.300e-3, 1e-1),
584 TEST_CASE_METHOD(TransportValidationFixture,
"Compare thermal conductivities against published data",
"[conductivity],[transport]") {
585 int inputsN =
sizeof(conductivity_validation_data) /
sizeof(conductivity_validation_data[0]);
586 for (
int i = 0; i < inputsN; ++i) {
587 vel el = conductivity_validation_data[i];
588 CHECK_NOTHROW(set_backend(
"HEOS", el.fluid));
594 CHECK_NOTHROW(set_pair(el.in1, el.v1, el.in2, el.v2));
596 CAPTURE(el.expected);
598 CHECK(std::abs(actual / el.expected - 1) < el.tol);
626 class ConsistencyFixture
629 CoolPropDbl hmolar, pmolar, smolar, umolar, rhomolar, T, p, x1, x2;
630 shared_ptr<CoolProp::AbstractState> pState;
634 ConsistencyFixture() {}
635 ~ConsistencyFixture() {}
636 void set_backend(std::string backend, std::string fluid_name) {
656 void get_variables() {
722 void single_phase_consistency_check() {
724 State.
update(pair, x1, x2);
728 if (std::abs(T - State.
T()) > 1e-2)
throw CoolProp::ValueError(
format(
"Error on T [%Lg K] is greater than 1e-2", std::abs(State.
T() - T)));
729 if (std::abs(p - State.
p()) / p * 100 > 1e-2)
732 void subcritical_pressure_liquid() {
734 int inputsN =
sizeof(inputs) /
sizeof(inputs[0]);
735 for (
double p = pState->p_triple() * 1.1; p < pState->p_critical(); p *= 3) {
736 double Ts =
PropsSI(
"T",
"P", p,
"Q", 0,
"Water");
738 for (
double T = Tmelt; T < Ts - 0.1; T += 0.1) {
739 CHECK_NOTHROW(set_TP(T, p));
741 for (
int i = 0; i < inputsN; ++i) {
752 CHECK_NOTHROW(single_phase_consistency_check());
753 double rhomolar_RP =
PropsSI(
"Dmolar",
"P", p,
"T", T,
"REFPROP::Water");
755 CAPTURE(rhomolar_RP);
757 CHECK(std::abs((rhomolar_RP - rhomolar) / rhomolar) < 1e-3);
765 TEST_CASE_METHOD(ConsistencyFixture,
"Test all input pairs for Water using all valid backends",
"[consistency]") {
766 CHECK_NOTHROW(set_backend(
"HEOS",
"Water"));
767 subcritical_pressure_liquid();
793 TEST_CASE(
"Test saturation properties for a few fluids",
"[saturation],[slow]") {
797 SECTION(
"All pressures are ok")
798 for (std::
size_t i = 0; i < pv.size(); ++i) {
805 class HumidAirDewpointFixture
808 shared_ptr<CoolProp::AbstractState> AS;
809 std::vector<std::string> fluids;
810 std::vector<double> z;
811 void setup(
double zH2O) {
812 double z_Air[4] = {0.7810, 0.2095, 0.0092, 0.0003};
815 for (
int i = 0; i < 4; ++i) {
816 z[i + 1] = (1 - zH2O) * z_Air[i];
819 void run_p(
double p) {
821 for (
double zH2O = 0.999; zH2O > 0; zH2O -= 0.001) {
823 AS->set_mole_fractions(z);
825 CHECK_NOTHROW(AS->update(
PQ_INPUTS, p, 1));
826 if (AS->T() < 273.15) {
832 fluids =
strsplit(
"Water&Nitrogen&Oxygen&Argon&CO2",
'&');
839 TEST_CASE_METHOD(HumidAirDewpointFixture,
"Humid air dewpoint calculations",
"[humid_air_dewpoint]") {
843 TEST_CASE(
"Test consistency between Gernert models in CoolProp and Gernert models in REFPROP",
"[Gernert]") {
845 std::string mixes[] = {
"CO2[0.7]&Argon[0.3]",
"CO2[0.7]&Water[0.3]",
"CO2[0.7]&Nitrogen[0.3]"};
846 for (
int i = 0; i < 3; ++i) {
847 const char* ykey = mixes[i].c_str();
848 std::ostringstream ss1;
850 SECTION(ss1.str(),
"") {
851 double Tnbp_CP, Tnbp_RP;
852 CHECK_NOTHROW(Tnbp_CP =
PropsSI(
"T",
"P", 101325,
"Q", 1,
"HEOS::" + mixes[i]));
854 CHECK_NOTHROW(Tnbp_RP =
PropsSI(
"T",
"P", 101325,
"Q", 1,
"REFPROP::" + mixes[i]));
856 double diff = std::abs(Tnbp_CP / Tnbp_RP - 1);
862 TEST_CASE(
"Tests for solvers in P,T flash using Water",
"[flash],[PT]") {
863 SECTION(
"Check that T,P for saturated state yields error") {
865 CHECK_NOTHROW(Ts =
PropsSI(
"T",
"P", 101325,
"Q", 0,
"Water"));
867 CHECK_NOTHROW(ps =
PropsSI(
"P",
"T", Ts,
"Q", 0,
"Water"));
871 CHECK_NOTHROW(rho =
PropsSI(
"D",
"T", Ts,
"P", ps,
"Water"));
875 SECTION(
"Subcritical p slightly subcooled should be ok") {
876 double Ts, rho, dT = 1e-4;
877 CHECK_NOTHROW(Ts =
PropsSI(
"T",
"P", 101325,
"Q", 0,
"Water"));
881 CHECK_NOTHROW(rho =
PropsSI(
"D",
"T", Ts - dT,
"P", 101325,
"Water"));
885 SECTION(
"Subcritical p slightly superheated should be ok") {
886 double Ts, rho, dT = 1e-4;
887 CHECK_NOTHROW(Ts =
PropsSI(
"T",
"P", 101325,
"Q", 0,
"Water"));
891 CHECK_NOTHROW(rho =
PropsSI(
"D",
"T", Ts + dT,
"P", 101325,
"Water"));
897 TEST_CASE(
"Tests for solvers in P,Y flash using Water",
"[flash],[PH],[PS],[PU]") {
900 std::string Ykeys[] = {
"H",
"S",
"U",
"Hmass",
"Smass",
"Umass",
"Hmolar",
"Smolar",
"Umolar"};
901 for (
int i = 0; i < 9; ++i) {
902 const char* ykey = Ykeys[i].c_str();
903 std::ostringstream ss1;
904 ss1 <<
"Subcritical superheated P," << ykey;
905 SECTION(ss1.str(),
"") {
907 CHECK_NOTHROW(Ts =
PropsSI(
"T",
"P", 101325,
"Q", 0,
"Water"));
910 CHECK_NOTHROW(y =
PropsSI(ykey,
"T", Ts + dT,
"P", 101325,
"Water"));
914 CHECK_NOTHROW(T2 =
PropsSI(
"T", ykey, y,
"P", 101325,
"Water"));
919 std::ostringstream ss2;
920 ss2 <<
"Subcritical barely superheated P," << ykey;
921 SECTION(ss2.str(),
"") {
923 CHECK_NOTHROW(Ts =
PropsSI(
"T",
"P", 101325,
"Q", 0,
"Water"));
926 CHECK_NOTHROW(y =
PropsSI(ykey,
"T", Ts + dT,
"P", 101325,
"Water"));
930 CHECK_NOTHROW(T2 =
PropsSI(
"T", ykey, y,
"P", 101325,
"Water"));
935 std::ostringstream ss3;
936 ss3 <<
"Subcritical subcooled P," << ykey;
937 SECTION(ss3.str(),
"") {
939 CHECK_NOTHROW(Ts =
PropsSI(
"T",
"P", 101325,
"Q", 0,
"Water"));
942 CHECK_NOTHROW(y =
PropsSI(ykey,
"T", Ts + dT,
"P", 101325,
"Water"));
946 CHECK_NOTHROW(T2 =
PropsSI(
"T", ykey, y,
"P", 101325,
"Water"));
951 std::ostringstream ss4;
952 ss4 <<
"Subcritical barely subcooled P," << ykey;
953 SECTION(ss4.str(),
"") {
955 CHECK_NOTHROW(Ts =
PropsSI(
"T",
"P", 101325,
"Q", 0,
"Water"));
958 CHECK_NOTHROW(y =
PropsSI(ykey,
"T", Ts + dT,
"P", 101325,
"Water"));
962 CHECK_NOTHROW(T2 =
PropsSI(
"T", ykey, y,
"P", 101325,
"Water"));
967 std::ostringstream ss5;
968 ss5 <<
"Supercritical P," << ykey;
969 SECTION(ss5.str(),
"") {
970 double Tc =
Props1SI(
"Water",
"Tcrit");
971 double pc =
Props1SI(
"Water",
"pcrit");
978 CHECK_NOTHROW(y =
PropsSI(ykey,
"P", p,
"T", T,
"Water"));
981 CHECK_NOTHROW(T2 =
PropsSI(
"T", ykey, y,
"P", p,
"Water"));
986 std::ostringstream ss6;
987 ss6 <<
"Supercritical \"gas\" P," << ykey;
988 SECTION(ss6.str(),
"") {
989 double Tc =
Props1SI(
"Water",
"Tcrit");
990 double pc =
Props1SI(
"Water",
"pcrit");
997 CHECK_NOTHROW(y =
PropsSI(ykey,
"P", p,
"T", T,
"Water"));
1000 CHECK_NOTHROW(T2 =
PropsSI(
"T", ykey, y,
"P", p,
"Water"));
1005 std::ostringstream ss7;
1006 ss7 <<
"Supercritical \"liquid\" P," << ykey;
1007 SECTION(ss7.str(),
"") {
1008 double Tc =
Props1SI(
"Water",
"Tcrit");
1009 double pc =
Props1SI(
"Water",
"pcrit");
1011 double T = Tc * 0.5;
1016 CHECK_NOTHROW(y =
PropsSI(ykey,
"P", p,
"T", T,
"Water"));
1019 CHECK_NOTHROW(T2 =
PropsSI(
"T", ykey, y,
"P", p,
"Water"));
1027 TEST_CASE(
"Tests for solvers in P,H flash using Propane",
"[flashdups],[flash],[PH],[consistency]") {
1028 double hmolar, hmass;
1029 SECTION(
"5 times PH with HEOS AbstractState yields same results every time",
"") {
1033 hmolar = AS->hmolar();
1034 hmass = AS->hmass();
1037 hmolar = AS->hmolar();
1038 hmass = AS->hmass();
1041 hmolar = AS->hmolar();
1042 hmass = AS->hmass();
1045 hmolar = AS->hmolar();
1046 hmass = AS->hmass();
1049 hmolar = AS->hmolar();
1050 hmass = AS->hmass();
1056 TEST_CASE(
"Multiple calls to state class are consistent",
"[flashdups],[flash],[PH],[consistency]") {
1057 double hmolar, hmass;
1058 SECTION(
"3 times PH with HEOS AbstractState yields same results every time",
"") {
1062 hmolar = AS->hmolar();
1063 hmass = AS->hmass();
1066 hmolar = AS->hmolar();
1067 hmass = AS->hmass();
1070 hmolar = AS->hmolar();
1071 hmass = AS->hmass();
1077 TEST_CASE(
"Test first partial derivatives using PropsSI",
"[derivatives]") {
1079 SECTION(
"Check drhodp|T 3 ways",
"") {
1084 double drhomolardp__T_PropsSI_num =
1085 (
PropsSI(
"Dmolar",
"T", T,
"P", 101325 + 1e-3,
"n-Propane") -
PropsSI(
"Dmolar",
"T", T,
"P", 101325 - 1e-3,
"n-Propane")) / (2 * 1e-3);
1086 double drhomolardp__T_PropsSI =
PropsSI(
"d(Dmolar)/d(P)|T",
"T", T,
"P", 101325,
"n-Propane");
1088 CAPTURE(drhomolardp__T_AbstractState);
1089 CAPTURE(drhomolardp__T_PropsSI_num);
1090 CAPTURE(drhomolardp__T_PropsSI);
1091 double rel_err_exact = std::abs((drhomolardp__T_AbstractState - drhomolardp__T_PropsSI) / drhomolardp__T_PropsSI);
1092 double rel_err_approx = std::abs((drhomolardp__T_PropsSI_num - drhomolardp__T_PropsSI) / drhomolardp__T_PropsSI);
1093 CHECK(rel_err_exact < 1e-7);
1094 CHECK(rel_err_approx < 1e-7);
1096 SECTION(
"Check drhodp|T 3 ways for water",
"") {
1102 double drhomolardp__T_PropsSI_num =
1103 (
PropsSI(
"Dmolar",
"T", T,
"P", 101325 + 1,
"Water") -
PropsSI(
"Dmolar",
"T", T,
"P", 101325 - 1,
"Water")) / (2 * 1);
1104 double drhomolardp__T_PropsSI =
PropsSI(
"d(Dmolar)/d(P)|T",
"T", T,
"P", 101325,
"Water");
1106 CAPTURE(drhomolardp__T_AbstractState);
1107 CAPTURE(drhomolardp__T_PropsSI_num);
1108 CAPTURE(drhomolardp__T_PropsSI);
1109 double rel_err_exact = std::abs((drhomolardp__T_AbstractState - drhomolardp__T_PropsSI) / drhomolardp__T_PropsSI);
1110 double rel_err_approx = std::abs((drhomolardp__T_PropsSI_num - drhomolardp__T_PropsSI) / drhomolardp__T_PropsSI);
1111 CHECK(rel_err_exact < 1e-4);
1112 CHECK(rel_err_approx < 1e-4);
1114 SECTION(
"Check dpdrho|T 3 ways for water",
"") {
1120 double dpdrhomolar__T_PropsSI_num =
1121 (
PropsSI(
"P",
"T", T,
"Dmolar", rhomolar + 1e-3,
"Water") -
PropsSI(
"P",
"T", T,
"Dmolar", rhomolar - 1e-3,
"Water")) / (2 * 1e-3);
1122 double dpdrhomolar__T_PropsSI =
PropsSI(
"d(P)/d(Dmolar)|T",
"T", T,
"P", 101325,
"Water");
1124 CAPTURE(dpdrhomolar__T_AbstractState);
1125 CAPTURE(dpdrhomolar__T_PropsSI_num);
1126 CAPTURE(dpdrhomolar__T_PropsSI);
1127 double rel_err_exact = std::abs((dpdrhomolar__T_AbstractState - dpdrhomolar__T_PropsSI) / dpdrhomolar__T_PropsSI);
1128 double rel_err_approx = std::abs((dpdrhomolar__T_PropsSI_num - dpdrhomolar__T_PropsSI) / dpdrhomolar__T_PropsSI);
1129 CHECK(rel_err_exact < 1e-6);
1130 CHECK(rel_err_approx < 1e-6);
1132 SECTION(
"Check dpdrho|T 3 ways for water using mass based",
"") {
1138 double dpdrhomass__T_PropsSI_num =
1139 (
PropsSI(
"P",
"T", T,
"Dmass", rhomass + 1e-3,
"Water") -
PropsSI(
"P",
"T", T,
"Dmass", rhomass - 1e-3,
"Water")) / (2 * 1e-3);
1140 double dpdrhomass__T_PropsSI =
PropsSI(
"d(P)/d(Dmass)|T",
"T", T,
"P", 101325,
"Water");
1142 CAPTURE(dpdrhomass__T_AbstractState);
1143 CAPTURE(dpdrhomass__T_PropsSI_num);
1144 CAPTURE(dpdrhomass__T_PropsSI);
1145 double rel_err_exact = std::abs((dpdrhomass__T_AbstractState - dpdrhomass__T_PropsSI) / dpdrhomass__T_PropsSI);
1146 double rel_err_approx = std::abs((dpdrhomass__T_PropsSI_num - dpdrhomass__T_PropsSI) / dpdrhomass__T_PropsSI);
1147 CHECK(rel_err_exact < 1e-7);
1148 CHECK(rel_err_approx < 1e-7);
1150 SECTION(
"Invalid first partial derivatives",
"") {
1157 CHECK(!
ValidNumber(
PropsSI(
"d(Bvirial)/d(P)T",
"T", 300,
"P", 101325,
"n-Propane")));
1162 TEST_CASE(
"Test second partial derivatives",
"[derivatives]") {
1164 SECTION(
"Check d2pdrho2|T 3 ways",
"") {
1166 double rhomolar = 60000;
1170 double d2pdrhomolar2__T_AbstractState =
1174 double d2pdrhomolar2__T_PropsSI_num =
1175 (
PropsSI(
"P",
"T", T,
"Dmolar", rhomolar + del,
"Water") - 2 *
PropsSI(
"P",
"T", T,
"Dmolar", rhomolar,
"Water")
1176 +
PropsSI(
"P",
"T", T,
"Dmolar", rhomolar - del,
"Water"))
1178 double d2pdrhomolar2__T_PropsSI =
PropsSI(
"d(d(P)/d(Dmolar)|T)/d(Dmolar)|T",
"T", T,
"Dmolar", rhomolar,
"Water");
1180 CAPTURE(d2pdrhomolar2__T_AbstractState);
1181 CAPTURE(d2pdrhomolar2__T_PropsSI_num);
1182 double rel_err_exact = std::abs((d2pdrhomolar2__T_AbstractState - d2pdrhomolar2__T_PropsSI) / d2pdrhomolar2__T_PropsSI);
1183 double rel_err_approx = std::abs((d2pdrhomolar2__T_PropsSI_num - d2pdrhomolar2__T_AbstractState) / d2pdrhomolar2__T_AbstractState);
1184 CHECK(rel_err_exact < 1e-5);
1185 CHECK(rel_err_approx < 1e-5);
1187 SECTION(
"Valid second partial derivatives",
"") {
1188 CHECK(
ValidNumber(
PropsSI(
"d(d(Hmolar)/d(P)|T)/d(T)|Dmolar",
"T", 300,
"P", 101325,
"n-Propane")));
1190 SECTION(
"Invalid second partial derivatives",
"") {
1191 CHECK(!
ValidNumber(
PropsSI(
"d(d()/d(P)|T)/d()|",
"T", 300,
"P", 101325,
"n-Propane")));
1192 CHECK(!
ValidNumber(
PropsSI(
"dd(Dmolar)/d()|T)|T",
"T", 300,
"P", 101325,
"n-Propane")));
1194 SECTION(
"Check derivatives with respect to T",
"") {
1196 double rhomolar = 100, dT = 1e-1;
1200 CoolPropDbl T0 = AS->T(), rhomolar0 = AS->rhomolar(), hmolar0 = AS->hmolar(), smolar0 = AS->smolar(), umolar0 = AS->umolar(), p0 = AS->p();
1212 CoolPropDbl Tpt = AS->T(), rhomolarpt = AS->rhomolar(), hmolarpt = AS->hmolar(), smolarpt = AS->smolar(), umolarpt = AS->umolar(),
1216 CoolPropDbl Tmt = AS->T(), rhomolarmt = AS->rhomolar(), hmolarmt = AS->hmolar(), smolarmt = AS->smolar(), umolarmt = AS->umolar(),
1219 CoolPropDbl dhdT_rho_num = (hmolarpt - hmolarmt) / (2 * dT);
1220 CoolPropDbl d2hdT2_rho_num = (hmolarpt - 2 * hmolar0 + hmolarmt) / pow(dT, 2);
1221 CoolPropDbl dsdT_rho_num = (smolarpt - smolarmt) / (2 * dT);
1222 CoolPropDbl d2sdT2_rho_num = (smolarpt - 2 * smolar0 + smolarmt) / pow(dT, 2);
1223 CoolPropDbl dudT_rho_num = (umolarpt - umolarmt) / (2 * dT);
1224 CoolPropDbl d2udT2_rho_num = (umolarpt - 2 * umolar0 + umolarmt) / pow(dT, 2);
1225 CoolPropDbl dpdT_rho_num = (ppt - pmt) / (2 * dT);
1226 CoolPropDbl d2pdT2_rho_num = (ppt - 2 * p0 + pmt) / pow(dT, 2);
1228 CAPTURE(
format(
"%0.15Lg", d2pdT2_rho_ana).c_str());
1231 CHECK(std::abs((dhdT_rho_num - dhdT_rho_ana) / dhdT_rho_ana) < tol);
1232 CHECK(std::abs((d2hdT2_rho_num - d2hdT2_rho_ana) / d2hdT2_rho_ana) < tol);
1233 CHECK(std::abs((dpdT_rho_num - dpdT_rho_ana) / dpdT_rho_ana) < tol);
1234 CHECK(std::abs((d2pdT2_rho_num - d2pdT2_rho_ana) / d2pdT2_rho_ana) < tol);
1235 CHECK(std::abs((dsdT_rho_num - dsdT_rho_ana) / dsdT_rho_ana) < tol);
1236 CHECK(std::abs((d2sdT2_rho_num - d2sdT2_rho_ana) / d2sdT2_rho_ana) < tol);
1237 CHECK(std::abs((dudT_rho_num - dudT_rho_ana) / dudT_rho_ana) < tol);
1238 CHECK(std::abs((d2udT2_rho_num - d2udT2_rho_ana) / d2udT2_rho_ana) < tol);
1241 SECTION(
"Check derivatives with respect to rho",
"") {
1243 double rhomolar = 100, drho = 1e-1;
1247 CoolPropDbl T0 = AS->T(), rhomolar0 = AS->rhomolar(), hmolar0 = AS->hmolar(), smolar0 = AS->smolar(), umolar0 = AS->umolar(), p0 = AS->p();
1259 CoolPropDbl Tpr = AS->T(), rhomolarpr = AS->rhomolar(), hmolarpr = AS->hmolar(), smolarpr = AS->smolar(), umolarpr = AS->umolar(),
1263 CoolPropDbl Tmr = AS->T(), rhomolarmr = AS->rhomolar(), hmolarmr = AS->hmolar(), smolarmr = AS->smolar(), umolarmr = AS->umolar(),
1266 CoolPropDbl dhdrho_T_num = (hmolarpr - hmolarmr) / (2 * drho);
1267 CoolPropDbl d2hdrho2_T_num = (hmolarpr - 2 * hmolar0 + hmolarmr) / pow(drho, 2);
1268 CoolPropDbl dsdrho_T_num = (smolarpr - smolarmr) / (2 * drho);
1269 CoolPropDbl d2sdrho2_T_num = (smolarpr - 2 * smolar0 + smolarmr) / pow(drho, 2);
1270 CoolPropDbl dudrho_T_num = (umolarpr - umolarmr) / (2 * drho);
1271 CoolPropDbl d2udrho2_T_num = (umolarpr - 2 * umolar0 + umolarmr) / pow(drho, 2);
1272 CoolPropDbl dpdrho_T_num = (ppr - pmr) / (2 * drho);
1273 CoolPropDbl d2pdrho2_T_num = (ppr - 2 * p0 + pmr) / pow(drho, 2);
1275 CAPTURE(
format(
"%0.15Lg", d2pdrho2_T_ana).c_str());
1278 CHECK(std::abs((dhdrho_T_num - dhdrho_T_ana) / dhdrho_T_ana) < tol);
1279 CHECK(std::abs((d2hdrho2_T_num - d2hdrho2_T_ana) / d2hdrho2_T_ana) < tol);
1280 CHECK(std::abs((dpdrho_T_num - dpdrho_T_ana) / dpdrho_T_ana) < tol);
1281 CHECK(std::abs((d2pdrho2_T_num - d2pdrho2_T_ana) / d2pdrho2_T_ana) < tol);
1282 CHECK(std::abs((dsdrho_T_num - dsdrho_T_ana) / dsdrho_T_ana) < tol);
1283 CHECK(std::abs((d2sdrho2_T_num - d2sdrho2_T_ana) / d2sdrho2_T_ana) < tol);
1284 CHECK(std::abs((dudrho_T_num - dudrho_T_ana) / dudrho_T_ana) < tol);
1285 CHECK(std::abs((d2udrho2_T_num - d2udrho2_T_ana) / d2udrho2_T_ana) < tol);
1287 SECTION(
"Check second mixed partial(h,p) with respect to rho",
"") {
1289 double dhmass = 1.0, T = 300;
1296 double deriv_num = (deriv1 - deriv2) / dhmass;
1298 CAPTURE(deriv_analyt);
1301 CHECK(std::abs((deriv_num - deriv_analyt) / deriv_analyt) < tol);
1305 TEST_CASE(
"REFPROP names for coolprop fluids",
"[REFPROPName]") {
1307 for (std::size_t i = 0; i < fluids.size(); ++i) {
1308 std::ostringstream ss1;
1309 ss1 <<
"Check that REFPROP fluid name for fluid " << fluids[i] <<
" is valid";
1310 SECTION(ss1.str(),
"") {
1312 CHECK(!RPName.empty());
1314 if (!RPName.compare(
"N/A")) {
1322 TEST_CASE(
"Backwards compatibility for REFPROP v4 fluid name convention",
"[REFPROP_backwards_compatibility]") {
1323 SECTION(
"REFPROP-",
"") {
1324 double val =
Props1SI(
"REFPROP-Water",
"Tcrit");
1330 SECTION(
"REFPROP-MIX:",
"") {
1331 double val =
PropsSI(
"T",
"P", 101325,
"Q", 0,
"REFPROP-MIX:Methane[0.5]&Ethane[0.5]");
1339 class AncillaryFixture
1345 for (std::size_t i = 0; i < fluids.size(); ++i) {
1350 void do_sat(shared_ptr<CoolProp::AbstractState>& AS) {
1351 for (
double f = 0.1; f < 1; f += 0.4) {
1352 double Tc = AS->T_critical();
1353 double Tt = AS->Ttriple();
1354 double T = f * Tc + (1 - f) * Tt;
1355 name =
strjoin(AS->fluid_names(),
"&");
1366 void check_pL(
const shared_ptr<CoolProp::AbstractState>& AS) {
1367 double p_EOS = AS->saturated_liquid_keyed_output(
iP);
1369 double err = std::abs(p_EOS - p_anc) / p_anc;
1377 void check_pV(
const shared_ptr<CoolProp::AbstractState>& AS) {
1378 double p_EOS = AS->saturated_liquid_keyed_output(
iP);
1380 double err = std::abs(p_EOS - p_anc) / p_anc;
1388 void check_rhoL(
const shared_ptr<CoolProp::AbstractState>& AS) {
1389 double rho_EOS = AS->saturated_liquid_keyed_output(
iDmolar);
1391 double err = std::abs(rho_EOS - rho_anc) / rho_anc;
1399 void check_rhoV(
const shared_ptr<CoolProp::AbstractState>& AS) {
1400 double rho_EOS = AS->saturated_vapor_keyed_output(
iDmolar);
1402 double err = std::abs(rho_EOS - rho_anc) / rho_anc;
1411 TEST_CASE_METHOD(AncillaryFixture,
"Ancillary functions",
"[ancillary]") {
1415 TEST_CASE(
"Triple point checks",
"[triple_point]") {
1417 for (std::size_t i = 0; i < fluids.size(); ++i) {
1418 std::vector<std::string> names(1, fluids[i]);
1421 if (!HEOS->is_pure()) {
1425 std::ostringstream ss1;
1426 ss1 <<
"Minimum saturation temperature state matches for liquid " << fluids[i];
1427 SECTION(ss1.str(),
"") {
1429 double p_EOS = HEOS->p();
1430 double p_sat_min_liquid = HEOS->get_components()[0].EOS().sat_min_liquid.p;
1431 double err_sat_min_liquid = std::abs(p_EOS - p_sat_min_liquid) / p_sat_min_liquid;
1433 CAPTURE(p_sat_min_liquid);
1434 CAPTURE(err_sat_min_liquid);
1438 CHECK(err_sat_min_liquid < 1e-3);
1440 std::ostringstream ss2;
1441 ss2 <<
"Minimum saturation temperature state matches for vapor " << fluids[i];
1442 SECTION(ss2.str(),
"") {
1445 double p_EOS = HEOS->p();
1446 double p_sat_min_vapor = HEOS->get_components()[0].EOS().sat_min_vapor.p;
1447 double err_sat_min_vapor = std::abs(p_EOS - p_sat_min_vapor) / p_sat_min_vapor;
1449 CAPTURE(p_sat_min_vapor);
1450 CAPTURE(err_sat_min_vapor);
1454 CHECK(err_sat_min_vapor < 1e-3);
1456 std::ostringstream ss3;
1457 ss3 <<
"Minimum saturation temperature state matches for vapor " << fluids[i];
1458 SECTION(ss3.str(),
"") {
1461 double T_EOS = HEOS->T();
1462 double T_sat_min_vapor = HEOS->get_components()[0].EOS().sat_min_vapor.T;
1463 double err_sat_min_vapor = std::abs(T_EOS - T_sat_min_vapor);
1465 CAPTURE(T_sat_min_vapor);
1466 CAPTURE(err_sat_min_vapor);
1467 CHECK(err_sat_min_vapor < 1e-3);
1469 std::ostringstream ss4;
1470 ss4 <<
"Minimum saturation temperature state matches for liquid " << fluids[i];
1471 SECTION(ss4.str(),
"") {
1473 double T_EOS = HEOS->T();
1474 double T_sat_min_vapor = HEOS->get_components()[0].EOS().sat_min_vapor.T;
1475 double err_sat_min_vapor = std::abs(T_EOS - T_sat_min_vapor);
1477 CAPTURE(T_sat_min_vapor);
1478 CAPTURE(err_sat_min_vapor);
1479 CHECK(err_sat_min_vapor < 1e-3);
1515 for (std::size_t i = 0; i < fluids.size(); ++i) {
1520 void do_sat(shared_ptr<CoolProp::AbstractState>& AS) {
1521 Tc = AS->T_critical();
1522 name =
strjoin(AS->fluid_names(),
"&");
1524 double Tt = AS->Ttriple();
1525 if (AS->fluid_param_string(
"pure") ==
"true") {
1526 Tc = std::min(Tc, AS->T_reducing());
1528 for (
double j = 0.1; j > 1e-10; j /= 10) {
1529 check_QT(AS, Tc - j);
1532 void check_at_Tc(
const shared_ptr<CoolProp::AbstractState>& AS) {
1533 CAPTURE(
"Check @ Tc");
1535 CHECK_NOTHROW(AS->update(
QT_INPUTS, 0, Tc));
1537 void check_QT(
const shared_ptr<CoolProp::AbstractState>& AS,
double T) {
1538 std::string test_name =
"Check --> Tc";
1542 CHECK_NOTHROW(AS->update(
QT_INPUTS, 0, T));
1545 TEST_CASE_METHOD(SatTFixture,
"Test that saturation solvers solve all the way to T = Tc",
"[sat_T_to_Tc]") {
1549 TEST_CASE(
"Check mixtures with fluid name aliases",
"[mixture_name_aliasing]") {
1550 shared_ptr<CoolProp::AbstractState> AS1, AS2;
1553 REQUIRE(AS1->fluid_names().size() == AS2->fluid_names().size());
1554 std::size_t N = AS1->fluid_names().size();
1555 for (std::size_t i = 0; i < N; ++i) {
1557 CHECK(AS1->fluid_names()[i] == AS2->fluid_names()[i]);
1561 TEST_CASE(
"Predefined mixtures",
"[predefined_mixtures]") {
1562 SECTION(
"PropsSI") {
1563 double val =
PropsSI(
"Dmolar",
"P", 101325,
"T", 300,
"Air.mix");
1570 TEST_CASE(
"Test that reference states yield proper values using high-level interface",
"[reference_states]") {
1574 double hmass, smass;
1580 std::string fluids[] = {
"n-Propane",
"R134a",
"R124"};
1581 ref_entry entries[3] = {{
"IIR", 200000, 1000,
"T", 273.15,
"Q", 0}, {
"ASHRAE", 0, 0,
"T", 233.15,
"Q", 0}, {
"NBP", 0, 0,
"P", 101325,
"Q", 0}};
1582 for (std::size_t i = 0; i < 3; ++i) {
1583 for (std::size_t j = 0; j < 3; ++j) {
1584 std::ostringstream ss1;
1585 ss1 <<
"Check state for " << fluids[i] <<
" for " + entries[j].name +
" reference state ";
1586 SECTION(ss1.str(),
"") {
1592 double hmass =
PropsSI(
"Hmass", entries[j].in1, entries[j].val1, entries[j].in2, entries[j].val2, fluids[i]);
1593 double smass =
PropsSI(
"Smass", entries[j].in1, entries[j].val1, entries[j].in2, entries[j].val2, fluids[i]);
1594 CHECK(std::abs(hmass - entries[j].hmass) < 1e-8);
1595 CHECK(std::abs(smass - entries[j].smass) < 1e-8);
1602 TEST_CASE(
"Test that reference states yield proper values using low-level interface",
"[reference_states]") {
1606 double hmass, smass;
1612 std::string fluids[] = {
"n-Propane",
"R134a",
"R124"};
1613 ref_entry entries[3] = {{
"IIR", 200000, 1000,
iT, 273.15,
iQ, 0}, {
"ASHRAE", 0, 0,
iT, 233.15,
iQ, 0}, {
"NBP", 0, 0,
iP, 101325,
iQ, 0}};
1614 for (std::size_t i = 0; i < 3; ++i) {
1615 for (std::size_t j = 0; j < 3; ++j) {
1616 std::ostringstream ss1;
1617 ss1 <<
"Check state for " << fluids[i] <<
" for " + entries[j].name +
" reference state ";
1618 SECTION(ss1.str(),
"") {
1623 AS->update(pair, val1, val2);
1624 double hmass0 = AS->hmass();
1625 double smass0 = AS->smass();
1628 AS->update(pair, val1, val2);
1629 double hmass00 = AS->hmass();
1630 double smass00 = AS->smass();
1631 CHECK(std::abs(hmass00 - hmass0) < 1e-10);
1632 CHECK(std::abs(smass00 - smass0) < 1e-10);
1639 AS->update(pair, val1, val2);
1640 double hmass1 = AS->hmass();
1641 double smass1 = AS->smass();
1642 CHECK(std::abs(hmass1 - hmass0) < 1e-10);
1643 CHECK(std::abs(smass1 - smass0) < 1e-10);
1647 AS2->update(pair, val1, val2);
1648 double hmass2 = AS2->hmass();
1649 double smass2 = AS2->smass();
1650 CHECK(std::abs(hmass2 - entries[j].hmass) < 1e-8);
1651 CHECK(std::abs(smass2 - entries[j].smass) < 1e-8);
1660 class FixedStateFixture
1663 void run_fluid(
const std::string& fluid,
const std::string& state,
const std::string& ref_state) {
1666 if (
Props1SI(
"Ttriple", fluid) > 233.15 && ref_state ==
"ASHRAE") {
1669 if (
Props1SI(
"Tcrit", fluid) < 233.15 && ref_state ==
"ASHRAE") {
1672 if (
Props1SI(
"Tcrit", fluid) < 273.15 && ref_state ==
"IIR") {
1675 if (
Props1SI(
"Ttriple", fluid) > 273.15 && ref_state ==
"IIR") {
1678 if (
Props1SI(
"ptriple", fluid) > 101325 && ref_state ==
"NBP") {
1683 if (ref_state !=
"DEF") {
1688 }
catch (std::exception& e) {
1696 std::ostringstream name;
1697 name <<
"Check state for " << state <<
" for " << fluid <<
" for reference state " << ref_state;
1698 CAPTURE(name.str());
1700 std::vector<std::string> fl(1, fluid);
1704 if (HEOS->is_pure() && (state ==
"max_sat_T" || state ==
"max_sat_p")) {
1713 if ((fluid ==
"Water" || fluid ==
"CarbonDioxide") && (state ==
"reducing" || state ==
"critical")) {
1721 double EOS_hmolar = HEOS->hmolar();
1722 double EOS_smolar = HEOS->smolar();
1723 CAPTURE(EOS_hmolar);
1724 CAPTURE(EOS_smolar);
1725 CHECK(std::abs(EOS_hmolar - _state.
hmolar) < 1e-2);
1726 CHECK(std::abs(EOS_smolar - _state.
smolar) < 1e-2);
1733 for (std::size_t i = 0; i < fluids.size(); ++i) {
1734 std::string ref_state[4] = {
"DEF",
"IIR",
"ASHRAE",
"NBP"};
1735 for (std::size_t j = 0; j < 4; ++j) {
1736 std::string states[] = {
"hs_anchor",
"reducing",
"critical",
"max_sat_T",
"max_sat_p",
"triple_liquid",
"triple_vapor"};
1737 for (std::size_t k = 0; k < 7; ++k) {
1738 run_fluid(fluids[i], states[k], ref_state[j]);
1744 TEST_CASE_METHOD(FixedStateFixture,
"Test that enthalpies and entropies are correct for fixed states for all reference states",
"[fixed_states]") {
1748 TEST_CASE(
"Check the first partial derivatives",
"[first_saturation_partial_deriv]") {
1749 const int number_of_pairs = 10;
1754 pair pairs[number_of_pairs] = {{
iP,
iT}, {
iDmolar,
iT}, {
iHmolar,
iT}, {
iSmolar,
iT}, {
iUmolar,
iT},
1757 for (std::size_t i = 0; i < number_of_pairs; ++i) {
1759 std::ostringstream ss1;
1762 SECTION(ss1.str(),
"") {
1765 CoolPropDbl analytical = AS->first_saturation_deriv(pairs[i].p1, pairs[i].p2);
1766 CAPTURE(analytical);
1768 if (pairs[i].p2 ==
iT) {
1773 numerical = (v1 - v2) / (2e-5);
1774 }
else if (pairs[i].p2 ==
iP) {
1779 numerical = (v1 - v2) / (2e-2);
1784 CHECK(std::abs(numerical / analytical - 1) < 1e-4);
1789 TEST_CASE(
"Check the second saturation derivatives",
"[second_saturation_partial_deriv]") {
1790 const int number_of_pairs = 5;
1795 pair pairs[number_of_pairs] = {{
iT,
iP,
iP}, {
iDmolar,
iP,
iP}, {
iHmolar,
iP,
iP}, {
iSmolar,
iP,
iP}, {
iUmolar,
iP,
iP}};
1797 for (std::size_t i = 0; i < number_of_pairs; ++i) {
1799 std::ostringstream ss1;
1802 SECTION(ss1.str(),
"") {
1805 CoolPropDbl analytical = AS->second_saturation_deriv(pairs[i].p1, pairs[i].p2, pairs[i].p3);
1806 CAPTURE(analytical);
1808 if (pairs[i].p2 ==
iT) {
1810 }
else if (pairs[i].p2 ==
iP) {
1812 CoolPropDbl v1 = AS->first_saturation_deriv(pairs[i].p1, pairs[i].p2);
1814 CoolPropDbl v2 = AS->first_saturation_deriv(pairs[i].p1, pairs[i].p2);
1815 numerical = (v1 - v2) / (2e-2);
1820 CHECK(std::abs(numerical / analytical - 1) < 1e-4);
1825 TEST_CASE(
"Check the first two-phase derivative",
"[first_two_phase_deriv]") {
1826 const int number_of_pairs = 4;
1831 pair pairs[number_of_pairs] = {{
iDmass,
iP,
iHmass}, {
iDmolar,
iP,
iHmolar}, {
iDmolar,
iHmolar,
iP}, {
iDmass,
iHmass,
iP}};
1833 for (std::size_t i = 0; i < number_of_pairs; ++i) {
1835 std::ostringstream ss1;
1838 SECTION(ss1.str(),
"") {
1841 CoolPropDbl analytical = AS->first_two_phase_deriv(pairs[i].p1, pairs[i].p2, pairs[i].p3);
1842 CAPTURE(analytical);
1846 v2base = AS->keyed_output(pairs[i].p2);
1847 v3base = AS->keyed_output(pairs[i].p3);
1851 AS->update(input_pair1, out1, out2);
1854 AS->update(input_pair2, out1, out2);
1857 numerical = (v1 - v2) / (v2plus - v2minus);
1859 CHECK(std::abs(numerical / analytical - 1) < 1e-4);
1864 TEST_CASE(
"Check the second two-phase derivative",
"[second_two_phase_deriv]") {
1865 SECTION(
"d2rhodhdp",
"") {
1869 CAPTURE(analytical);
1870 CoolPropDbl pplus = AS->p() * 1.001, pminus = AS->p() * 0.999, h = AS->hmolar();
1875 CoolPropDbl numerical = (v1 - v2) / (pplus - pminus);
1877 CHECK(std::abs(numerical / analytical - 1) < 1e-6);
1879 SECTION(
"d2rhodhdp using mass",
"") {
1883 CAPTURE(analytical);
1884 CoolPropDbl pplus = AS->p() * 1.001, pminus = AS->p() * 0.999, h = AS->hmass();
1889 CoolPropDbl numerical = (v1 - v2) / (pplus - pminus);
1891 CHECK(std::abs(numerical / analytical - 1) < 1e-6);
1895 TEST_CASE(
"Check the first two-phase derivative using splines",
"[first_two_phase_deriv_splined]") {
1896 const int number_of_pairs = 4;
1901 pair pairs[number_of_pairs] = {{
iDmass,
iP,
iHmass}, {
iDmolar,
iP,
iHmolar}, {
iDmolar,
iHmolar,
iP}, {
iDmass,
iHmass,
iP}};
1903 for (std::size_t i = 0; i < number_of_pairs; ++i) {
1905 std::ostringstream ss1;
1908 SECTION(ss1.str(),
"") {
1911 CoolPropDbl analytical = AS->first_two_phase_deriv_splined(pairs[i].p1, pairs[i].p2, pairs[i].p3, 0.3);
1912 CAPTURE(analytical);
1916 v2base = AS->keyed_output(pairs[i].p2);
1917 v3base = AS->keyed_output(pairs[i].p3);
1922 AS->update(input_pair1, out1, out2);
1923 CoolPropDbl v1 = AS->first_two_phase_deriv_splined(pairs[i].p1, pairs[i].p1, pairs[i].p1, 0.3);
1926 AS->update(input_pair2, out1, out2);
1927 CoolPropDbl v2 = AS->first_two_phase_deriv_splined(pairs[i].p1, pairs[i].p1, pairs[i].p1, 0.3);
1929 numerical = (v1 - v2) / (v2plus - v2minus);
1931 CHECK(std::abs(numerical / analytical - 1) < 1e-8);
1936 TEST_CASE(
"Check the phase flags",
"[phase]") {
1937 SECTION(
"subcooled liquid") {
1942 SECTION(
"superheated gas") {
1947 SECTION(
"supercritical gas") {
1952 SECTION(
"supercritical liquid") {
1957 SECTION(
"supercritical") {
1964 TEST_CASE(
"Check the changing of reducing function constants",
"[reducing]") {
1966 std::vector<double> z(2);
1971 AS1->set_mole_fractions(z);
1972 AS2->set_mole_fractions(z);
1973 std::vector<CoolProp::CriticalState> pts1 = AS1->all_critical_points();
1974 double gammaT = AS2->get_binary_interaction_double(0, 1,
"gammaT");
1975 AS2->set_binary_interaction_double(0, 1,
"gammaT", gammaT * 0.7);
1976 std::vector<CoolProp::CriticalState> pts2 = AS2->all_critical_points();
1977 double Tdiff = abs(pts2[0].T - pts1[0].T);
1978 CHECK(Tdiff > 1e-3);
1981 TEST_CASE(
"Check the PC-SAFT pressure function",
"[pcsaft_pressure]") {
1983 double p_calc =
CoolProp::PropsSI(
"P",
"T", 320.,
"Dmolar", 9033.114359706229,
"PCSAFT::TOLUENE");
1984 CHECK(abs((p_calc / p) - 1) < 1e-5);
1986 p_calc =
CoolProp::PropsSI(
"P",
"T", 274.,
"Dmolar", 55530.40675319466,
"PCSAFT::WATER");
1987 CHECK(abs((p_calc/p) - 1) < 1e-5);
1989 p_calc =
CoolProp::PropsSI(
"P",
"T", 305.,
"Dmolar", 16965.6697209874,
"PCSAFT::ACETIC ACID");
1990 CHECK(abs((p_calc/p) - 1) < 1e-5);
1992 p_calc =
CoolProp::PropsSI(
"P",
"T", 240.,
"Dmolar", 15955.50941242,
"PCSAFT::DIMETHYL ETHER");
1993 CHECK(abs((p_calc/p) - 1) < 1e-5);
1995 p_calc =
CoolProp::PropsSI(
"P",
"T", 298.15,
"Dmolar", 9368.903838750752,
"PCSAFT::METHANOL[0.055]&CYCLOHEXANE[0.945]");
1996 CHECK(abs((p_calc/p) - 1) < 1e-5);
1998 p_calc =
CoolProp::PropsSI(
"P",
"T", 298.15,
"Dmolar", 55740.15826463244,
"PCSAFT::Na+[0.010579869455908]&Cl-[0.010579869455908]&WATER[0.978840261088184]");
1999 CHECK(abs((p_calc/p) - 1) < 1e-5);
2003 double phase =
CoolProp::PropsSI(
"Phase",
"T", 100.,
"Dmolar", rho,
"PCSAFT::PROPANE");
2006 CHECK(abs((p_calc / p) - 1) < 1e-4);
2009 TEST_CASE(
"Check the PC-SAFT density function",
"[pcsaft_density]") {
2010 double den = 9033.114209728405;
2011 double den_calc =
CoolProp::PropsSI(
"Dmolar",
"T|liquid", 320.,
"P", 101325.,
"PCSAFT::TOLUENE");
2012 CHECK(abs((den_calc / den) - 1) < 1e-5);
2014 den = 55530.40512318346;
2015 den_calc =
CoolProp::PropsSI(
"Dmolar",
"T|liquid", 274.,
"P", 101325,
"PCSAFT::WATER");
2016 CHECK(abs((den_calc / den) - 1) < 1e-5);
2019 den_calc =
CoolProp::PropsSI(
"Dmolar",
"T|liquid",305.,
"P",101325,
"PCSAFT::ACETIC ACID");
2020 CHECK(abs((den_calc/den) - 1) < 2e-2);
2022 den = 15955.509146801696;
2023 den_calc =
CoolProp::PropsSI(
"Dmolar",
"T|liquid",240.,
"P",101325,
"PCSAFT::DIMETHYL ETHER");
2024 CHECK(abs((den_calc/den) - 1) < 1e-5);
2026 den = 9368.90368306872;
2027 den_calc =
CoolProp::PropsSI(
"Dmolar",
"T|liquid", 298.15,
"P", 101325,
"PCSAFT::METHANOL[0.055]&CYCLOHEXANE[0.945]");
2028 CHECK(abs((den_calc / den) - 1) < 1e-5);
2030 den = 55740.157290833515;
2031 den_calc =
CoolProp::PropsSI(
"Dmolar",
"T|liquid", 298.15,
"P", 101325,
"PCSAFT::Na+[0.010579869455908]&Cl-[0.010579869455908]&WATER[0.978840261088184]");
2032 CHECK(abs((den_calc / den) - 1) < 1e-5);
2035 den_calc =
CoolProp::PropsSI(
"Dmolar",
"T|liquid", 85.525,
"P", 1.7551e-4,
"PCSAFT::PROPANE");
2036 CHECK(abs((den_calc / den) - 1) < 1e-2);
2039 den_calc =
CoolProp::PropsSI(
"Dmolar",
"T|gas", 85.525,
"P", 1.39e-4,
"PCSAFT::PROPANE");
2040 CHECK(abs((den_calc / den) - 1) < 1e-2);
2043 den_calc =
CoolProp::PropsSI(
"Dmolar",
"T|liquid", 293,
"P", 833240,
"PCSAFT::PROPANE");
2044 CHECK(abs((den_calc / den) - 1) < 1e-2);
2047 den_calc =
CoolProp::PropsSI(
"Dmolar",
"T|liquid", 430,
"P", 2000000,
"PCSAFT::PROPANE");
2048 CHECK(abs((den_calc/den) - 1) < 1e-2);
2051 TEST_CASE(
"Check the PC-SAFT residual enthalpy function",
"[pcsaft_enthalpy]") {
2052 double h = -36809.962122036086;
2053 double h_calc =
CoolProp::PropsSI(
"Hmolar_residual",
"T|liquid", 325.,
"Dmolar", 8983.377722763931,
"PCSAFT::TOLUENE");
2054 CHECK(abs((h_calc / h) - 1) < 1e-5);
2056 h = -362.6832840695562;
2057 h_calc =
CoolProp::PropsSI(
"Hmolar_residual",
"T|gas", 325.,
"Dmolar", 39.44490805826904,
"PCSAFT::TOLUENE");
2058 CHECK(abs((h_calc / h) - 1) < 1e-5);
2060 h = -38925.302571456035;
2061 h_calc =
CoolProp::PropsSI(
"Hmolar_residual",
"T|liquid",325.,
"Dmolar", 16655.853047419932,
"PCSAFT::ACETIC ACID");
2062 CHECK(abs((h_calc/h) - 1) < 1e-5);
2064 h = -15393.870073928741;
2065 h_calc =
CoolProp::PropsSI(
"Hmolar_residual",
"T|gas", 325.,
"Dmolar", 85.70199446609787,
"PCSAFT::ACETIC ACID");
2066 CHECK(abs((h_calc / h) - 1) < 1e-5);
2068 h = -18242.128097841978;
2069 h_calc =
CoolProp::PropsSI(
"Hmolar_residual",
"T|liquid",325.,
"Dmolar", 13141.475980937616,
"PCSAFT::DIMETHYL ETHER");
2070 CHECK(abs((h_calc/h) - 1) < 1e-5);
2072 h = -93.819615173017169;
2073 h_calc =
CoolProp::PropsSI(
"Hmolar_residual",
"T|gas",325.,
"Dmolar", 37.963459290365265,
"PCSAFT::DIMETHYL ETHER");
2074 CHECK(abs((h_calc/h) - 1) < 1e-5);
2077 h =
CoolProp::PropsSI(
"Hmolar_residual",
"T|liquid", 325.,
"Dmolar", 8983.377722763931,
"HEOS::TOLUENE");
2078 h_calc =
CoolProp::PropsSI(
"Hmolar_residual",
"T|liquid", 325.,
"Dmolar", 8983.377722763931,
"PCSAFT::TOLUENE");
2079 CHECK(abs(h_calc - h) < 600.);
2081 h =
CoolProp::PropsSI(
"Hmolar_residual",
"T|gas", 325.,
"Dmolar", 39.44490805826904,
"HEOS::TOLUENE");
2082 h_calc =
CoolProp::PropsSI(
"Hmolar_residual",
"T|gas", 325.,
"Dmolar", 39.44490805826904,
"PCSAFT::TOLUENE");
2083 CHECK(abs(h_calc - h) < 600.);
2085 h =
CoolProp::PropsSI(
"Hmolar_residual",
"T|liquid", 325.,
"Dmolar", 54794.1,
"HEOS::WATER");
2086 h_calc =
CoolProp::PropsSI(
"Hmolar_residual",
"T|liquid", 325.,
"Dmolar", 54794.1,
"PCSAFT::WATER");
2087 CHECK(abs(h_calc - h) < 600.);
2089 h =
CoolProp::PropsSI(
"Hmolar_residual",
"T|gas", 325.,
"Dmolar", 0.370207,
"HEOS::WATER");
2090 h_calc =
CoolProp::PropsSI(
"Hmolar_residual",
"T|gas", 325.,
"Dmolar", 0.370207,
"PCSAFT::WATER");
2091 CHECK(abs(h_calc - h) < 600.);
2094 TEST_CASE(
"Check the PC-SAFT residual entropy function",
"[pcsaft_entropy]") {
2096 double s = -50.81694890352192;
2097 double s_calc =
CoolProp::PropsSI(
"Smolar_residual",
"T|liquid", 325.,
"Dmolar", 8983.377722763931,
"PCSAFT::TOLUENE");
2098 CHECK(abs((s_calc / s) - 1) < 1e-5);
2100 s = -0.2929618646219797;
2101 s_calc =
CoolProp::PropsSI(
"Smolar_residual",
"T|gas", 325.,
"Dmolar", 39.44490805826904,
"PCSAFT::TOLUENE");
2102 CHECK(abs((s_calc / s) - 1) < 1e-5);
2104 s = -47.42736805661422;
2105 s_calc =
CoolProp::PropsSI(
"Smolar_residual",
"T|liquid",325.,
"Dmolar", 16655.853047419932,
"PCSAFT::ACETIC ACID");
2106 CHECK(abs((s_calc/s) - 1) < 1e-5);
2108 s = -34.0021996393859;
2109 s_calc =
CoolProp::PropsSI(
"Smolar_residual",
"T|gas", 325.,
"Dmolar", 85.70199446609787,
"PCSAFT::ACETIC ACID");
2110 CHECK(abs((s_calc / s) - 1) < 1e-5);
2112 s = -26.42525828195748;
2113 s_calc =
CoolProp::PropsSI(
"Smolar_residual",
"T|liquid",325.,
"Dmolar", 13141.475980937616,
"PCSAFT::DIMETHYL ETHER");
2114 CHECK(abs((s_calc/s) - 1) < 1e-5);
2116 s = -0.08427662199177874;
2117 s_calc =
CoolProp::PropsSI(
"Smolar_residual",
"T|gas",325.,
"Dmolar", 37.963459290365265,
"PCSAFT::DIMETHYL ETHER");
2118 CHECK(abs((s_calc/s) - 1) < 1e-5);
2121 s =
CoolProp::PropsSI(
"Smolar_residual",
"T|liquid", 325.,
"Dmolar", 8983.377722763931,
"HEOS::TOLUENE");
2122 s_calc =
CoolProp::PropsSI(
"Smolar_residual",
"T|liquid", 325.,
"Dmolar", 8983.377722763931,
"PCSAFT::TOLUENE");
2123 CHECK(abs(s_calc - s) < 3.);
2125 s =
CoolProp::PropsSI(
"Smolar_residual",
"T|gas", 325.,
"Dmolar", 39.44490805826904,
"HEOS::TOLUENE");
2126 s_calc =
CoolProp::PropsSI(
"Smolar_residual",
"T|gas", 325.,
"Dmolar", 39.44490805826904,
"PCSAFT::TOLUENE");
2127 CHECK(abs(s_calc - s) < 3.);
2129 s =
CoolProp::PropsSI(
"Smolar_residual",
"T|liquid", 325.,
"Dmolar", 54794.1,
"HEOS::WATER");
2130 s_calc =
CoolProp::PropsSI(
"Smolar_residual",
"T|liquid", 325.,
"Dmolar", 54794.1,
"PCSAFT::WATER");
2131 CHECK(abs(s_calc - s) < 3.);
2133 s =
CoolProp::PropsSI(
"Smolar_residual",
"T|gas", 325.,
"Dmolar", 0.370207,
"HEOS::WATER");
2134 s_calc =
CoolProp::PropsSI(
"Smolar_residual",
"T|gas", 325.,
"Dmolar", 0.370207,
"PCSAFT::WATER");
2135 CHECK(abs(s_calc - s) < 3.);
2138 TEST_CASE(
"Check the PC-SAFT residual gibbs energy function",
"[pcsaft_gibbs]") {
2139 double g = -5489.471870270737;
2140 double g_calc =
CoolProp::PropsSI(
"Gmolar_residual",
"T|liquid", 325.,
"Dmolar", 8983.377872003264,
"PCSAFT::TOLUENE");
2141 CHECK(abs((g_calc / g) - 1) < 1e-5);
2143 g = -130.63592030187894;
2144 g_calc =
CoolProp::PropsSI(
"Gmolar_residual",
"T|gas", 325.,
"Dmolar", 39.44491269148218,
"PCSAFT::TOLUENE");
2145 CHECK(abs((g_calc / g) - 1) < 1e-5);
2147 g = -7038.128334100866;
2148 g_calc =
CoolProp::PropsSI(
"Gmolar_residual",
"T|liquid",325.,
"Dmolar", 16655.853314424,
"PCSAFT::ACETIC ACID");
2149 CHECK(abs((g_calc/g) - 1) < 1e-5);
2151 g = -2109.4916554917604;
2152 g_calc =
CoolProp::PropsSI(
"Gmolar_residual",
"T|gas", 325.,
"Dmolar", 85.70199446609787,
"PCSAFT::ACETIC ACID");
2153 CHECK(abs((g_calc / g) - 1) < 1e-5);
2155 g = 6178.973332408309;
2156 g_calc =
CoolProp::PropsSI(
"Gmolar_residual",
"T|liquid",325.,
"Dmolar", 13141.47619110254,
"PCSAFT::DIMETHYL ETHER");
2157 CHECK(abs((g_calc/g) - 1) < 1e-5);
2159 g = -33.038791982589615;
2160 g_calc =
CoolProp::PropsSI(
"Gmolar_residual",
"T|gas",325.,
"Dmolar", 37.96344503293008,
"PCSAFT::DIMETHYL ETHER");
2161 CHECK(abs((g_calc/g) - 1) < 1e-5);
2164 TEST_CASE(
"Check vapor pressures calculated using PC-SAFT",
"[pcsaft_vapor_pressure]") {
2165 double vp = 3290651.18080112;
2166 double vp_calc =
CoolProp::PropsSI(
"P",
"T", 572.6667,
"Q", 0,
"PCSAFT::TOLUENE");
2167 CHECK(abs((vp_calc / vp) - 1) < 1e-3);
2169 vp = 66917.67387203;
2171 CHECK(abs((vp_calc / vp) - 1) < 1e-3);
2173 vp = 190061.78088909;
2175 CHECK(abs((vp_calc / vp) - 1) < 1e-3);
2179 CHECK(abs((vp_calc/vp) - 1) < 1e-3);
2188 CHECK(abs((vp_calc / vp) - 1) < 0.01);
2192 CHECK(abs((vp_calc / vp) - 1) < 0.01);
2195 TEST_CASE(
"Check PC-SAFT interaction parameter functions",
"[pcsaft_binary_interaction]") {
2197 std::string CAS_aacid =
"64-19-7";
2202 TEST_CASE(
"Check bubble pressures calculated using PC-SAFT",
"[pcsaft_bubble_pressure]")
2204 double vp = 1816840.45112607;
2205 double vp_calc =
CoolProp::PropsSI(
"P",
"T", 421.05,
"Q", 0,
"PCSAFT::METHANE[0.0252]&BENZENE[0.9748]");
2206 CHECK(abs((vp_calc / vp) - 1) < 1e-3);
2214 vp_calc =
CoolProp::PropsSI(
"P",
"T", 327.48,
"Q", 0,
"PCSAFT::METHANOL[0.3]&CYCLOHEXANE[0.7]");
2215 CHECK(abs((vp_calc / vp) - 1) < 1e-3);
2219 std::string CAS_aacid =
"64-19-7";
2227 vp = 274890.39985918;
2228 vp_calc =
CoolProp::PropsSI(
"P",
"T", 403.574,
"Q", 0,
"PCSAFT::WATER[0.9898662364]&ACETIC ACID[0.0101337636]");
2229 CHECK(abs((vp_calc / vp) - 1) < 1e-2);
2231 vp = 72915.92217342;
2232 vp_calc =
CoolProp::PropsSI(
"P",
"T", 372.774,
"Q", 0,
"PCSAFT::WATER[0.2691800943]&ACETIC ACID[0.7308199057]");
2233 CHECK(abs((vp_calc / vp) - 1) < 2e-2);
2236 vp_calc =
CoolProp::PropsSI(
"P",
"T", 298.15,
"Q", 0,
"PCSAFT::Na+[0.0907304774758426]&Cl-[0.0907304774758426]&WATER[0.818539045048315]");
2237 CHECK(abs((vp_calc/vp) - 1) < 0.23);
2240 TEST_CASE(
"Check bubble temperatures calculated using PC-SAFT",
"[pcsaft_bubble_temperature]") {
2241 double t = 572.6667;
2242 double t_calc =
CoolProp::PropsSI(
"T",
"P", 3290651.18080112,
"Q", 0,
"PCSAFT::TOLUENE");
2243 CHECK(abs((t_calc / t) - 1) < 1e-3);
2247 CHECK(abs((t_calc / t) - 1) < 1e-3);
2250 t_calc =
CoolProp::PropsSI(
"T",
"P", 190061.78088909,
"Q", 0,
"PCSAFT::ACETIC ACID");
2251 CHECK(abs((t_calc / t) - 1) < 1e-3);
2254 t_calc =
CoolProp::PropsSI(
"T",
"P", 623027.07850612,
"Q", 0,
"PCSAFT::DIMETHYL ETHER");
2255 CHECK(abs((t_calc / t) - 1) < 1e-3);
2263 t_calc =
CoolProp::PropsSI(
"T",
"P", 96634.2439079,
"Q", 0,
"PCSAFT::METHANOL[0.3]&CYCLOHEXANE[0.7]");
2264 CHECK(abs((t_calc / t) - 1) < 1e-3);
2268 std::string CAS_aacid =
"64-19-7";
2277 t_calc =
CoolProp::PropsSI(
"T",
"P", 274890.39985918,
"Q", 0,
"PCSAFT::WATER[0.9898662364]&ACETIC ACID[0.0101337636]");
2278 CHECK(abs((t_calc / t) - 1) < 1e-3);
2281 t_calc =
CoolProp::PropsSI(
"T",
"P", 72915.92217342,
"Q", 0,
"PCSAFT::WATER[0.2691800943]&ACETIC ACID[0.7308199057]");
2282 CHECK(abs((t_calc / t) - 1) < 2e-3);
2285 t_calc =
CoolProp::PropsSI(
"T",
"P", 2387.42669687,
"Q", 0,
"PCSAFT::Na+[0.0907304774758426]&Cl-[0.0907304774758426]&WATER[0.818539045048315]");
2286 CHECK(abs((t_calc / t) - 1) < 1e-2);
2289 TEST_CASE(
"Check phase determination for PC-SAFT backend",
"[pcsaft_phase]") {
2290 double den = 9033.114209728405;
2291 double den_calc =
CoolProp::PropsSI(
"Dmolar",
"T", 320.,
"P", 101325.,
"PCSAFT::TOLUENE");
2292 CHECK(abs((den_calc / den) - 1) < 1e-2);
2293 double phase =
CoolProp::PropsSI(
"Phase",
"T", 320.,
"P", 101325.,
"PCSAFT::TOLUENE");
2297 den_calc =
CoolProp::PropsSI(
"Dmolar",
"T", 320.,
"P", 1000.,
"PCSAFT::TOLUENE");
2298 CHECK(abs((den_calc / den) - 1) < 1e-2);
2303 TEST_CASE(
"Check that indexes for mixtures are assigned correctly, especially for the association term",
"[pcsaft_indexes]")
2311 std::string CAS_aacid =
"64-19-7";
2319 double t = 413.5385;
2320 double rho = 15107.481234283325;
2321 double p =
CoolProp::PropsSI(
"P",
"T", t,
"Dmolar", rho,
"PCSAFT::ACETIC ACID");
2322 double p_extra =
CoolProp::PropsSI(
"P",
"T", t,
"Dmolar", rho,
"PCSAFT::ACETIC ACID[1.0]&WATER[0]");
2323 CHECK(abs((p_extra - p)/ p * 100) < 1e-1);
2328 rho = 10657.129498214763;
2330 p_extra =
CoolProp::PropsSI(
"P",
"T", t,
"Dmolar", rho,
"PCSAFT::WATER[0]&FURFURAL[1.0]");
2331 CHECK(abs((p_extra - p)/ p * 100) < 1e-1);
2336 rho = 55320.89616248148;
2338 p_extra =
CoolProp::PropsSI(
"P",
"T", t,
"Dmolar", rho,
"PCSAFT::Na+[0]&Cl-[0]&WATER[1.0]&DIMETHOXYMETHANE[0]");
2339 CHECK(abs((p_extra - p)/ p * 100) < 1e-1);