CoolProp 8.0.0
An open-source fluid property and humid air property database
IncompressibleLibrary.h
Go to the documentation of this file.
1
2#ifndef INCOMPRESSIBLELIBRARY_H
3#define INCOMPRESSIBLELIBRARY_H
4
7//#include "crossplatform_shared_ptr.h"
8
10
11#include <map>
12
13namespace CoolProp {
14
15// Forward declaration of the necessary debug function to avoid including the whole header
16extern int get_debug_level();
17
20// * to bridge the gap between the solution functions
21// * used in the paper by Pátek and Klomfar:
22// * http://dx.doi.org/10.1016/j.ijrefrig.2005.10.007
23// *
24// * We owe gratitude to the authors for providing
25// * both access to the paper as well as the equations
26// * in the form of C source code. */
27//class LiBrSolution : public IncompressibleFluid{
28//
29//protected:
30// static double const M_H2O; /* kg/mol, molar mass of H2O */
31// static double const M_LiBr; /* kg/mol, molar mass of LiBr */
32// static double const T0; /* K, constant */
33//
34// /* Critical point of H2O */
35// static double const Tc_H2O; /* K, temperature */
36// static double const pc_H2O; /* MPa, pressure */
37// static double const rhoc_H2O; /* mol/m^3 (322 kg/m^3), molar density */
38// static double const hc_H2O; /* J/mol, molar enthalpy */
39// static double const sc_H2O; /* J/(mol.K) molar entropy*/
40//
41// /*Triple point of H2O */
42// static double const Tt_H2O; /* K, temperature */
43// static double const cpt_H2O; /* J/(mol.K), molar isobaric heat capacity*/
44//
45// double ps_mix(double T, double x);
46// double rho_mix(double T, double x);
47// double cp_mix(double T, double x);
48// double h_mix(double T, double x);
49// double s_mix(double T, double x);
50// double ps_H2O(double T);
51// double rho_H2O(double T);
52// double cp_H2O(double T);
53// double h_H2O(double T);
54// double s_H2O(double T);
55//
56// /** Finished with the code from the paper. Now we need to
57// * convert the molar values to mass-based units. */
58// double massToMole(double w);
59// double molarToSpecific(double w, double value);
60//
61// static const bool debug;
62//
63//public:
64//
65// LiBrSolution();
66//
67// double rho(double T, double p, double x);
68// double c(double T, double p, double x);
69// //double h(double T_K, double p, double x);
70// double s(double T, double p, double x);
71// double visc(double T, double p, double x);
72// double cond(double T, double p, double x);
73// double u(double T, double p, double x);
74// double psat(double T, double x);
75// double Tfreeze(double p, double x);
76//
77// /* Some functions can be inverted directly, those are listed
78// * here. It is also possible to solve for other quantities, but
79// * that involves some more sophisticated processing and is not
80// * done here, but in the backend, T(h,p) for example.
81// */
82// /// Temperature as a function of density, pressure and composition.
83// double T_rho (double Dmass, double p, double x){throw NotImplementedError(format("%s (%d): T from density is not implemented for LiBr.",__FILE__,__LINE__));}
84// /// Temperature as a function of heat capacities as a function of temperature, pressure and composition.
85// double T_c (double Cmass, double p, double x){throw NotImplementedError(format("%s (%d): T from heat capacity is not implemented for LiBr.",__FILE__,__LINE__));}
86// /// Temperature as a function of entropy as a function of temperature, pressure and composition.
87// double T_s (double Smass, double p, double x){throw NotImplementedError(format("%s (%d): T from entropy is not implemented for LiBr.",__FILE__,__LINE__));}
88// /// Temperature as a function of internal energy as a function of temperature, pressure and composition.
89// double T_u (double Umass, double p, double x){throw NotImplementedError(format("%s (%d): T from internal energy is not implemented for LiBr.",__FILE__,__LINE__));}
90// /// Temperature as a function of enthalpy, pressure and composition.
91// //double T_h (double Hmass, double p, double x){throw NotImplementedError(format("%s (%d): T from enthalpy is not implemented in the fluid, use the backend.",__FILE__,__LINE__));}
92// /// Viscosity as a function of temperature, pressure and composition.
93// double T_visc(double visc, double p, double x){throw NotImplementedError(format("%s (%d): T from viscosity is not implemented.",__FILE__,__LINE__));}
94// /// Thermal conductivity as a function of temperature, pressure and composition.
95// double T_cond(double cond, double p, double x){throw NotImplementedError(format("%s (%d): T from conductivity is not implemented.",__FILE__,__LINE__));}
96// /// Saturation pressure as a function of temperature and composition.
97// double T_psat(double psat, double x){throw NotImplementedError(format("%s (%d): T from psat is not implemented.",__FILE__,__LINE__));}
98// /// Composition as a function of freezing temperature and pressure.
99// double x_Tfreeze( double Tfreeze, double p){throw NotImplementedError(format("%s (%d): x from T_freeze is not implemented.",__FILE__,__LINE__));}
100//
101//
102// /// Overwrite some standard functions that cannot be used with LiBr
103// void setName(std::string name){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
104// void setDescription(std::string description){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
105// void setReference(std::string reference){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
106// void setTmax(double Tmax){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
107// void setTmin(double Tmin){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
108// void setxmax(double xmax){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
109// void setxmin(double xmin){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
110// void setTminPsat(double TminPsat){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
111//
112// void setTbase(double Tbase){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
113// void setxbase(double xbase){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
114//
115// void setDensity(IncompressibleData density){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
116// void setSpecificHeat(IncompressibleData specific_heat){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
117// void setViscosity(IncompressibleData viscosity){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
118// void setConductivity(IncompressibleData conductivity){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
119// void setPsat(IncompressibleData p_sat){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
120// void setTfreeze(IncompressibleData T_freeze){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
121// void setVolToMass(IncompressibleData volToMass){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
122// void setMassToMole(IncompressibleData massToMole){throw ValueError(format("%s (%d): Cannot change property of LiBr class",__FILE__,__LINE__));}
123//
124// bool is_pure() {return false;};
125//
126//};
127//
128
130
136//typedef shared_ptr<IncompressibleFluid> IncompressibleFluidPointer;
137
139{
141
144 std::map<std::size_t, IncompressibleFluid> fluid_map;
145 std::vector<std::string> name_vector_pure, name_vector_solution;
146 std::map<std::string, std::size_t> string_to_index_map;
147 bool _is_empty;
148
149 protected:
151 IncompressibleData parse_coefficients(const nlohmann::json& obj, const std::string& id, bool vital);
152 double parse_value(const nlohmann::json& obj, const std::string& id, bool vital, double def);
153 composition_types parse_ifrac(const nlohmann::json& obj, const std::string& id);
154
155 public:
156 // Default constructor;
159
160 bool is_empty() {
161 return _is_empty;
162 };
163
165 void add_many(const nlohmann::json& listing);
166 void add_one(const nlohmann::json& fluid_json);
167 void add_obj(const IncompressibleFluid& fluid_obj);
168
173 IncompressibleFluid& get(const std::string& name);
174
179 IncompressibleFluid& get(std::size_t key);
180
183 return strjoin(name_vector_pure, ",");
184 };
187 return strjoin(name_vector_solution, ",");
188 };
189};
190
192JSONIncompressibleLibrary& get_incompressible_library();
193
195std::string get_incompressible_list_pure();
196
199
201IncompressibleFluid& get_incompressible_fluid(const std::string& fluid_string);
202
203} /* namespace CoolProp */
204#endif