CoolProp  6.6.1dev
An open-source fluid property and humid air property database
IncompressibleLibrary.cpp
Go to the documentation of this file.
2 #include "MatrixMath.h"
3 #include "DataStructures.h"
4 //#include "crossplatform_shared_ptr.h"
5 #include "rapidjson_include.h"
6 #include "all_incompressibles_JSON.h" // Makes a std::string variable called all_incompressibles_JSON
7 
8 namespace CoolProp {
9 
12 // * to bridge the gap between the solution functions
13 // * used in the paper by Pátek and Klomfar:
14 // * http://dx.doi.org/10.1016/j.ijrefrig.2005.10.007
15 // *
16 // * We owe gratitude to the authors for providing
17 // * both access to the paper as well as the equations
18 // * in the form of C source code. */
19 //
20 //double const LiBrSolution::M_H2O = 0.018015268; /* kg/mol, molar mass of H2O */
21 //double const LiBrSolution::M_LiBr = 0.08685; /* kg/mol, molar mass of LiBr */
22 //double const LiBrSolution::T0 = 221; /* K, constant */
23 //
25 //double const LiBrSolution::Tc_H2O = 647.096; /* K, temperature */
26 //double const LiBrSolution::pc_H2O = 22.064; /* MPa, pressure */
27 //double const LiBrSolution::rhoc_H2O = 17873; /* mol/m^3 (322 kg/m^3), molar density */
28 //double const LiBrSolution::hc_H2O = 37548.5; /* J/mol, molar enthalpy */
29 //double const LiBrSolution::sc_H2O = 79.3933; /* J/(mol.K) molar entropy*/
30 //
32 //double const LiBrSolution::Tt_H2O = 273.16; /* K, temperature */
33 //double const LiBrSolution::cpt_H2O = 76.0226; /* J/(mol.K), molar isobaric heat capacity*/
34 //
35 //double LiBrSolution::ps_mix(double T, double x)
37 //{
38 // static double m[8] = { 3.0, 4.0, 4.0, 8.0, 1.0, 1.0, 4.0, 6.0 };
39 // static double n[8] = { 0.0, 5.0, 6.0, 3.0, 0.0, 2.0, 6.0, 0.0 };
40 // static double t[8] = { 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 };
41 // static double a[8] = { -2.41303e2, 1.91750e7, -1.75521e8, 3.25430e7,
42 // 3.92571e2, -2.12626e3, 1.85127e8, 1.91216e3 };
43 // double tau, suma = 0.0;
44 // int i;
45 //
46 // tau = T / Tc_H2O;
47 // for (i = 0; i <= 7; i++)
48 // suma += a[i] * pow(x, m[i]) * pow(0.4 - x, n[i]) * pow(tau, t[i]);
49 // return (ps_H2O(T - suma));
50 //
51 //} /* end function ps_mix */
52 //
53 //double LiBrSolution::rho_mix(double T, double x)
55 //{
56 // static double m[2] = { 1.0, 1.0 };
57 // static double n[2] = { 0.0, 6.0 };
58 // static double a[2] = { 1.746, 4.709 };
59 //
60 // double tau, suma = 0.0;
61 // int i;
62 //
63 // tau = T / Tc_H2O;
64 // for (i = 0; i <= 1; i++)
65 // suma += a[i] * pow(x, m[i]) * pow(tau, n[i]);
66 //
67 // return ((1.0 - x) * rho_H2O(T) + rhoc_H2O * suma);
68 //
69 //} /* end function rho_mix */
70 //
71 //double LiBrSolution::cp_mix(double T, double x)
73 //{
74 // static double m[8] = { 2.0, 3.0, 3.0, 3.0, 3.0, 2.0, 1.0, 1.0 };
75 // static double n[8] = { 0.0, 0.0, 1.0, 2.0, 3.0, 0.0, 3.0, 2.0 };
76 // static double t[8] = { 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 3.0, 4.0 };
77 // static double a[8] = { -1.42094e1, 4.04943e1, 1.11135e2, 2.29980e2,
78 // 1.34526e3, -1.41010e-2, 1.24977e-2, -6.83209e-4 };
79 //
80 // double tau, suma = 0.0;
81 // int i;
82 //
83 // tau = Tc_H2O / (T - T0);
84 // for (i = 0; i <= 7; i++)
85 // suma += a[i] * pow(x, m[i]) * pow(0.4 - x, n[i]) * pow(tau, t[i]);
86 //
87 // return ((1.0 - x) * cp_H2O(T) + cpt_H2O * suma);
88 //
89 //} /* end function cp_mix */
90 //
91 //double LiBrSolution::h_mix(double T, double x)
93 //{
94 // static double m[30] = { 1.0, 1.0, 2.0, 3.0, 6.0, 1.0, 3.0, 5.0, 4.0,
95 // 5.0, 5.0, 6.0, 6.0, 1.0, 2.0, 2.0, 2.0, 5.0, 6.0, 7.0, 1.0, 1.0,
96 // 2.0, 2.0, 2.0, 3.0, 1.0, 1.0, 1.0, 1.0 };
97 //
98 // static double n[30] = { 0.0, 1.0, 6.0, 6.0, 2.0, 0.0, 0.0, 4.0, 0.0,
99 // 4.0, 5.0, 5.0, 6.0, 0.0, 3.0, 5.0, 7.0, 0.0, 3.0, 1.0, 0.0, 4.0,
100 // 2.0, 6.0, 7.0, 0.0, 0.0, 1.0, 2.0, 3.0 };
101 //
102 // static double t[30] = { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 2.0,
103 // 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0,
104 // 4.0, 4.0, 4.0, 4.0, 5.0, 5.0, 5.0, 5.0 };
105 //
106 // static double a[30] = { 2.27431, -7.99511, 3.85239e2, -1.63940e4,
107 // -4.22562e2, 1.13314e-1, -8.33474, -1.73833e4, 6.49763,
108 // 3.24552e3, -1.34643e4, 3.99322e4, -2.58877e5, -1.93046e-3,
109 // 2.80616, -4.04479e1, 1.45342e2, -2.74873, -4.49743e2,
110 // -1.21794e1, -5.83739e-3, 2.33910e-1, 3.41888e-1, 8.85259,
111 // -1.78731e1, 7.35179e-2, -1.79430e-4, 1.84261e-3, -6.24282e-3,
112 // 6.84765e-3 };
113 //
114 // double tau, suma = 0.0;
115 // int i;
116 //
117 // tau = Tc_H2O / (T - T0);
118 // for (i = 0; i <= 29; i++)
119 // suma += a[i] * pow(x, m[i]) * pow(0.4 - x, n[i]) * pow(tau, t[i]);
120 //
121 // return ((1.0 - x) * h_H2O(T) + hc_H2O * suma);
122 //
123 //} /* end function h_mix */
124 //
125 //double LiBrSolution::s_mix(double T, double x)
127 //{
128 // static double m[29] = { 1.0, 1.0, 2.0, 3.0, 6.0, 1.0, 3.0, 5.0, 1.0,
129 // 2.0, 2.0, 4.0, 5.0, 5.0, 6.0, 6.0, 1.0, 3.0, 5.0, 7.0, 1.0, 1.0,
130 // 1.0, 2.0, 3.0, 1.0, 1.0, 1.0, 1.0 };
131 //
132 // static double n[29] = { 0.0, 1.0, 6.0, 6.0, 2.0, 0.0, 0.0, 4.0, 0.0,
133 // 0.0, 4.0, 0.0, 4.0, 5.0, 2.0, 5.0, 0.0, 4.0, 0.0, 1.0, 0.0, 2.0,
134 // 4.0, 7.0, 1.0, 0.0, 1.0, 2.0, 3.0 };
135 //
136 // static double t[29] = { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 2.0,
137 // 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0,
138 // 4.0, 4.0, 4.0, 5.0, 5.0, 5.0, 5.0 };
139 //
140 // static double a[29] = { 1.53091, -4.52564, 6.98302e+2, -2.16664e+4,
141 // -1.47533e+3, 8.47012e-2, -6.59523, -2.95331e+4, 9.56314e-3,
142 // -1.88679e-1, 9.31752, 5.78104, 1.38931e+4, -1.71762e+4,
143 // 4.15108e+2, -5.55647e+4, -4.23409e-3, 3.05242e+1, -1.67620,
144 // 1.48283e+1, 3.03055e-3, -4.01810e-2, 1.49252e-1, 2.59240,
145 // -1.77421e-1, -6.99650e-5, 6.05007e-4, -1.65228e-3, 1.22966e-3 };
146 //
147 // double tau, suma = 0.0;
148 // int i;
149 //
150 // tau = Tc_H2O / (T - T0);
151 // for (i = 0; i <= 28; i++)
152 // suma += a[i] * pow(x, m[i]) * pow(0.4 - x, n[i]) * pow(tau, t[i]);
153 //
154 // return ((1.0 - x) * s_H2O(T) + sc_H2O * suma);
155 //
156 //} /* end function s_mix */
157 //
158 //double LiBrSolution::ps_H2O(double T)
160 //{
161 // static double a[7] = { 0.0, -7.85951783, 1.84408259, -11.7866497,
162 // 22.6807411, -15.9618719, 1.80122502 };
163 //
164 // double tau, ps;
165 //
166 // tau = 1 - T / Tc_H2O;
167 //
168 // ps = pc_H2O
169 // * exp(
170 // Tc_H2O / T
171 // * (a[1] * tau + a[2] * pow(tau, 1.5)
172 // + a[3] * pow(tau, 3.0)
173 // + a[4] * pow(tau, 3.5)
174 // + a[5] * pow(tau, 4.0)
175 // + a[6] * pow(tau, 7.5)));
176 //
177 // return (ps * 1.0e6);
178 //
179 //} /* end function ps_H2O */
180 //
181 //double LiBrSolution::rho_H2O(double T)
183 //{
184 // static double b[7] = { 0.0, 1.99274064, 1.09965342, -0.510839303,
185 // -1.75493479, -45.5170352, -6.7469445e5 };
186 // double theta, rho;
187 //
188 // theta = 1.0 - T / Tc_H2O;
189 //
190 // rho = rhoc_H2O
191 // * (1.0 + b[1] * pow(theta, 1.0 / 3.0)
192 // + b[2] * pow(theta, 2.0 / 3.0)
193 // + b[3] * pow(theta, 5.0 / 3.0)
194 // + b[4] * pow(theta, 16.0 / 3.0)
195 // + b[5] * pow(theta, 43.0 / 3.0)
196 // + b[6] * pow(theta, 110.0 / 3.0));
197 //
198 // return (rho);
199 //} /* end function rho_H2O */
200 //
201 //double LiBrSolution::cp_H2O(double T)
203 //{
204 // static double a[5] =
205 // { 1.38801, -2.95318, 3.18721, -0.645473, 9.18946e5 };
206 // static double b[5] = { 0.0, 2.0, 3.0, 6.0, 34.0 };
207 // static double c[5] = { 0.0, 2.0, 3.0, 5.0, 0.0 };
208 //
209 // double suma = 0.0;
210 // int i;
211 //
212 // for (i = 0; i <= 4; i++)
213 // suma += a[i] * exp(b[i] * log(1.0 - T / Tc_H2O))
214 // * exp(c[i] * log(T / Tt_H2O));
215 //
216 // return (cpt_H2O * suma);
217 //
218 //} /* end function cp_H2O */
219 //
220 //double LiBrSolution::h_H2O(double T)
222 //{
223 // static double a[4] = { -4.37196e-1, 3.03440e-1, -1.29582, -1.76410e-1 };
224 // static double alpha[4] = { 1.0 / 3.0, 2.0 / 3.0, 5.0 / 6.0, 21.0 / 6.0 };
225 //
226 // double suma = 0.0;
227 // int i;
228 //
229 // for (i = 0; i <= 3; i++)
230 // suma += a[i] * exp(alpha[i] * log(1.0 - T / Tc_H2O));
231 //
232 // return (hc_H2O * (1.0 + suma));
233 //
234 //} /* end function h_H2O */
235 //
236 //double LiBrSolution::s_H2O(double T)
238 //{
239 // static double a[4] = { -3.34112e-1, -8.47987e-1, -9.11980e-1, -1.64046 };
240 // static double alpha[4] = { 1.0 / 3.0, 3.0 / 3.0, 8.0 / 3.0, 24.0 / 3.0 };
241 //
242 // double suma = 0.0;
243 // int i;
244 //
245 // for (i = 0; i <= 3; i++)
246 // suma += a[i] * exp(alpha[i] * log(1.0 - T / Tc_H2O));
247 //
248 // return (sc_H2O * (1.0 + suma));
249 //
250 //} /* end function s_H2O */
251 //
252 //
254 // * convert the molar values to mass-based units. */
255 //double LiBrSolution::massToMole(double w)
257 //{
258 // return (w/M_LiBr)/(w/M_LiBr+(1.-w)/M_H2O);
259 // //return (w*M_LiBr)/(w*M_LiBr+(1.-w)*M_H2O);
260 //}
261 //
262 //double LiBrSolution::molarToSpecific(double w, double value)
264 //{
265 // double x = massToMole(w);
266 // //return w/(x*M_LiBr) * value;
267 // return 1. / ( x*M_LiBr + (1.-x)*M_H2O ) * value;
268 //}
269 //
270 //bool const LiBrSolution::debug = false;
271 //
272 //
273 //
274 //LiBrSolution::LiBrSolution():IncompressibleFluid(){
275 // name = std::string("LiBr");
276 // description = std::string("Lithium-Bromide solution from Patek2006");
277 // reference = std::string("Patek2006");
278 //
279 // Tmin = 273.00;
280 // Tmax = 500.00;
281 // TminPsat = Tmin;
282 //
283 // xmin = 0.0;
284 // xmax = 1.0;
285 //
286 // xbase = 0.0;
287 // Tbase = 0.0;
288 //
289 //};
290 //
291 //double LiBrSolution::rho(double T, double p, double x){
292 // checkTPX(T, p, x);
293 // return 1./molarToSpecific(x, 1./rho_mix(T,massToMole(x)));
294 //}
295 //double LiBrSolution::c(double T, double p, double x){
296 // checkTPX(T, p, x);
297 // return molarToSpecific(x, cp_mix(T,massToMole(x)));
298 //}
302 //double LiBrSolution::s(double T, double p, double x){
303 // checkTPX(T, p, x);
304 // return molarToSpecific(x, s_mix(T,massToMole(x)));
305 //}
306 //double LiBrSolution::visc(double T, double p, double x){
307 // throw ValueError("Viscosity is not defined for LiBr-solutions.");
308 //}
309 //double LiBrSolution::cond(double T, double p, double x){
310 // throw ValueError("Thermal conductivity is not defined for LiBr-solutions.");
311 //}
312 //double LiBrSolution::u(double T, double p, double x){
313 // checkTPX(T, p, x);
314 // return molarToSpecific(x, h_mix(T,massToMole(x)));
315 //}
316 //double LiBrSolution::psat(double T, double x){
317 // //checkT(T,p,x);
318 // if (debug) throw ValueError(format("Your concentration is %f in kg/kg and %f in mol/mol.",x,massToMole(x)));
319 // return ps_mix(T,massToMole(x));
320 //};
321 //double LiBrSolution::Tfreeze(double p, double x){
322 // if (debug) throw ValueError(format("No freezing point data available for Lithium-Bromide: p=%f, x=%f",p,x));
323 // return Tmin;
324 //}
325 
328  _is_empty = true;
329  // fluid_map.clear();
330  // name_vector.clear();
331  // string_to_index_map.clear();
332  //
333  // //shared_ptr<double> array (new double [256], ArrayDeleter<double> ());
334 };
335 
338  // freeClear(fluid_map);
339  // fluid_map.clear();
340  // name_vector.clear();
341  // string_to_index_map.clear();
342 };
343 
345 IncompressibleData JSONIncompressibleLibrary::parse_coefficients(rapidjson::Value& obj, const std::string& id, bool vital) {
346  IncompressibleData fluidData;
347  if (obj.HasMember(id.c_str())) {
348  //rapidjson::Value value = obj[id.c_str()];
349  if (obj[id.c_str()].HasMember("type")) {
350  if (obj[id.c_str()].HasMember("coeffs")) {
351  std::string type = cpjson::get_string(obj[id.c_str()], "type");
352  if (!type.compare("polynomial")) {
354  fluidData.coeffs = vec_to_eigen(cpjson::get_double_array2D(obj[id.c_str()]["coeffs"]));
355  return fluidData;
356  } else if (!type.compare("exponential")) {
358  fluidData.coeffs = vec_to_eigen(cpjson::get_double_array(obj[id.c_str()]["coeffs"]));
359  return fluidData;
360  } else if (!type.compare("logexponential")) {
362  fluidData.coeffs = vec_to_eigen(cpjson::get_double_array(obj[id.c_str()]["coeffs"]));
363  return fluidData;
364  } else if (!type.compare("exppolynomial")) {
366  fluidData.coeffs = vec_to_eigen(cpjson::get_double_array2D(obj[id.c_str()]["coeffs"]));
367  return fluidData;
368  } else if (!type.compare("polyoffset")) {
370  fluidData.coeffs = vec_to_eigen(cpjson::get_double_array(obj[id.c_str()]["coeffs"]));
371  return fluidData;
372  } else if (vital) {
373  throw ValueError(format("The type [%s] is not understood for [%s] of incompressible fluids. Please check your JSON file.",
374  type.c_str(), id.c_str()));
375  } else {
376  //std::cout << format("The type [%s] is not understood for [%s] of incompressible fluids. Please check your JSON file.\n", type.c_str(), id.c_str());
377  }
378  } else {
379  throw ValueError(format("Your file does not have an entry for \"coeffs\" in [%s], which is vital for this function.", id.c_str()));
380  }
381  } else {
382  throw ValueError(format("Your file does not have an entry for \"type\" in [%s], which is vital for this function.", id.c_str()));
383  }
384  } else {
385  if (vital) {
386  throw ValueError(format("Your file does not have information for [%s], which is vital for an incompressible fluid.", id.c_str()));
387  }
388  }
389  return fluidData;
390 }
391 
393 double JSONIncompressibleLibrary::parse_value(rapidjson::Value& obj, const std::string& id, bool vital, double def = 0.0) {
394  if (obj.HasMember(id.c_str())) {
395  return cpjson::get_double(obj, id);
396  } else {
397  if (vital) {
398  throw ValueError(format("Your file does not have information for [%s], which is vital for an incompressible fluid.", id.c_str()));
399  } else {
400  return def;
401  }
402  }
403 }
404 
406 composition_types JSONIncompressibleLibrary::parse_ifrac(rapidjson::Value& obj, const std::string& id) {
407  std::string res = cpjson::get_string(obj, id);
408  if (!res.compare("mass")) return IFRAC_MASS;
409  if (!res.compare("mole")) return IFRAC_MOLE;
410  if (!res.compare("volume")) return IFRAC_VOLUME;
411  if (!res.compare("not defined")) return IFRAC_UNDEFINED;
412  if (!res.compare("pure")) return IFRAC_PURE;
413 
414  throw ValueError(format("Cannot recognise the entry for [%s], [%s] is unknown for incompressible fluids.", id.c_str(), res.c_str()));
415  return IFRAC_UNDEFINED;
416 }
417 
419 void JSONIncompressibleLibrary::add_many(rapidjson::Value& listing) {
420  for (rapidjson::Value::ValueIterator itr = listing.Begin(); itr != listing.End(); ++itr) {
421  add_one(*itr);
422  }
423 };
424 
425 void JSONIncompressibleLibrary::add_one(rapidjson::Value& fluid_json) {
426  _is_empty = false;
427 
428  // Get the next index for this fluid
429  std::size_t index = fluid_map.size();
430 
431  // Add index->fluid mapping
432  fluid_map[index] = IncompressibleFluid();
433  //fluid_map[index].reset(new IncompressibleFluid());
434  //fluid_map[index].reset(new IncompressibleFluid());
435 
436  // Create an instance of the fluid
437  IncompressibleFluid& fluid = fluid_map[index];
438  fluid.setName("unloaded");
439  try {
440  fluid.setName(cpjson::get_string(fluid_json, "name"));
441  if (get_debug_level() >= 20) std::cout << format("Incompressible library: Loading base values for %s ", fluid.getName().c_str()) << std::endl;
442  fluid.setDescription(cpjson::get_string(fluid_json, "description"));
443  fluid.setReference(cpjson::get_string(fluid_json, "reference"));
444  fluid.setTmax(parse_value(fluid_json, "Tmax", true, 0.0));
445  fluid.setTmin(parse_value(fluid_json, "Tmin", true, 0.0));
446  fluid.setxmax(parse_value(fluid_json, "xmax", false, 1.0));
447  fluid.setxmin(parse_value(fluid_json, "xmin", false, 0.0));
448  fluid.setxid(parse_ifrac(fluid_json, "xid"));
449  fluid.setTminPsat(parse_value(fluid_json, "TminPsat", false, 0.0));
450 
451  fluid.setTbase(parse_value(fluid_json, "Tbase", false, 0.0));
452  fluid.setxbase(parse_value(fluid_json, "xbase", false, 0.0));
453 
455  if (get_debug_level() >= 20)
456  std::cout << format("Incompressible library: Loading coefficients for %s ", fluid.getName().c_str()) << std::endl;
457  fluid.setDensity(parse_coefficients(fluid_json, "density", true));
458  fluid.setSpecificHeat(parse_coefficients(fluid_json, "specific_heat", true));
459  fluid.setViscosity(parse_coefficients(fluid_json, "viscosity", false));
460  fluid.setConductivity(parse_coefficients(fluid_json, "conductivity", false));
461  fluid.setPsat(parse_coefficients(fluid_json, "saturation_pressure", false));
462  fluid.setTfreeze(parse_coefficients(fluid_json, "T_freeze", false));
463  fluid.setMass2input(parse_coefficients(fluid_json, "mass2input", false));
464  fluid.setVolume2input(parse_coefficients(fluid_json, "volume2input", false));
465  fluid.setMole2input(parse_coefficients(fluid_json, "mole2input", false));
466 
467  //if (get_debug_level()>=20) std::cout << format("Incompressible library: Loading reference state for %s ",fluid.getName().c_str()) << std::endl;
468  //fluid.set_reference_state(
469  // parse_value(fluid_json, "Tref", false, 20+273.15) ,
470  // parse_value(fluid_json, "pref", false, 1.01325e5) ,
471  // parse_value(fluid_json, "xref", false, 0.0) ,
472  // parse_value(fluid_json, "href", false, 0.0) ,
473  // parse_value(fluid_json, "sref", false, 0.0)
474  // );
475 
477  fluid.validate();
478 
479  // Add name->index mapping
480  string_to_index_map[fluid.getName()] = index;
481 
482  // Add name to vector of names
483  if (fluid.is_pure()) {
484  this->name_vector_pure.push_back(fluid.getName());
485  } else {
486  this->name_vector_solution.push_back(fluid.getName());
487  }
488  } catch (std::exception& e) {
489  std::cout << format("Unable to load fluid: %s; error was %s\n", fluid.getName().c_str(), e.what());
490  throw;
491  }
492 };
493 
495  _is_empty = false;
496 
497  // Get the next index for this fluid
498  std::size_t index = fluid_map.size();
499 
500  // Add index->fluid mapping
501  fluid_map[index] = fluid_obj;
502 
503  // Create an instance of the fluid
504  IncompressibleFluid& fluid = fluid_map[index];
505 
507  fluid.validate();
508 
509  // Add name->index mapping
510  string_to_index_map[fluid.getName()] = index;
511 }
512 
513 // Get an IncompressibleFluid instance stored in this library
515  // Try to find it
516  std::map<std::string, std::size_t>::const_iterator it = string_to_index_map.find(key);
517  // If it is found
518  if (it != string_to_index_map.end()) {
519  return get(it->second);
520  } else {
521  throw ValueError(format("key [%s] was not found in string_to_index_map in JSONIncompressibleLibrary", key.c_str()));
522  }
523 };
524 
526 
530  // Try to find it
531  std::map<std::size_t, IncompressibleFluid>::iterator it = fluid_map.find(key);
532  // If it is found
533  if (it != fluid_map.end()) {
534  return it->second;
535  } else {
536  throw ValueError(format("key [%d] was not found in JSONIncompressibleLibrary", key));
537  }
538 };
539 
540 static JSONIncompressibleLibrary library;
541 
543  rapidjson::Document dd;
544  // This json formatted string comes from the all_incompressibles_JSON.h header which is a C++-escaped version of the JSON file
545  dd.Parse<0>(all_incompressibles_JSON.c_str());
546  if (dd.HasParseError()) {
547  throw ValueError("Unable to load all_incompressibles_JSON.json");
548  } else {
549  try {
550  library.add_many(dd);
551  } catch (std::exception& e) {
552  std::cout << e.what() << std::endl;
553  }
554  }
555  // TODO: Implement LiBr in the source code!
556  //library.add_obj(LiBrSolution());
557 }
558 
560  if (library.is_empty()) {
562  }
563  return library;
564 }
565 
566 IncompressibleFluid& get_incompressible_fluid(const std::string& fluid_string) {
567  if (library.is_empty()) {
569  }
570  return library.get(fluid_string);
571 }
572 
573 std::string get_incompressible_list_pure(void) {
574  if (library.is_empty()) {
576  }
577  return library.get_incompressible_list_pure();
578 };
580  if (library.is_empty()) {
582  }
583  return library.get_incompressible_list_solution();
584 };
585 
586 } /* namespace CoolProp */