CoolProp  6.6.0
An open-source fluid property and humid air property database
UNIFACLibrary.h
Go to the documentation of this file.
1 #ifndef UNIFAC_LIBRARY_H
2 #define UNIFAC_LIBRARY_H
3 
4 #include <vector>
5 #include <exception>
6 
7 #include "rapidjson_include.h"
8 #include "CoolPropFluid.h"
9 
10 namespace UNIFACLibrary {
11 
13 struct Group
14 {
15  int sgi,
16  mgi;
17  double R_k,
18  Q_k;
19 };
20 
23 {
24  int mgi1,
25  mgi2;
26  double a_ij,
27  a_ji,
28  b_ij,
29  b_ji,
30  c_ij,
31  c_ji;
33  void swap() {
34  std::swap(a_ij, a_ji);
35  std::swap(b_ij, b_ji);
36  std::swap(c_ij, c_ji);
37  }
39  void zero_out() {
40  a_ij = 0;
41  a_ji = 0;
42  b_ij = 0;
43  b_ji = 0;
44  c_ij = 0;
45  c_ji = 0;
46  }
47 };
48 
51 {
52  int count;
55 };
56 
58 struct Component
59 {
60  std::string name,
64  double Tc,
65  pc,
68  std::vector<ComponentGroup> groups;
69  std::string alpha_type;
70  std::vector<double> alpha_coeffs;
72 };
73 
84 {
85  private:
86  bool m_populated;
87  std::vector<Group> groups;
88  std::vector<InteractionParameters> interaction_parameters;
89  std::vector<Component> components;
90 
92  void jsonize(std::string& s, rapidjson::Document& doc);
93 
95  void populate(rapidjson::Value& group_data, rapidjson::Value& interaction_data, rapidjson::Value& decomp_data);
96 
97  public:
98  UNIFACParameterLibrary() : m_populated(false){};
99 
101  bool is_populated() {
102  return m_populated;
103  };
104 
106  void populate(std::string& group_data, std::string& interaction_data, std::string& decomp_data);
107 
109  Group get_group(int sgi) const;
110 
112  bool has_group(int sgi) const;
113 
115  Component get_component(const std::string& identifier, const std::string& value) const;
116 
118  InteractionParameters get_interaction_parameters(int mgi1, int mgi2) const;
119 };
120 
121 }; /* namespace UNIFACLibrary*/
122 
123 #endif