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