CoolProp  6.6.0
An open-source fluid property and humid air property database
PCSAFTFluid.cpp
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 #include <map>
4 #include <math.h>
5 
6 #include "PCSAFTFluid.h"
7 #include "rapidjson_include.h"
8 
9 namespace CoolProp {
10 
11 PCSAFTFluid::PCSAFTFluid(rapidjson::Value::ValueIterator itr) {
12  name = cpjson::get_string(*itr, "name");
13  CAS = cpjson::get_string(*itr, "CAS");
14  params.m = cpjson::get_double(*itr, "m");
15  params.sigma = cpjson::get_double(*itr, "sigma");
16  params.u = cpjson::get_double(*itr, "u");
17 
18  if (itr->HasMember("uAB") && (*itr)["uAB"].IsNumber()) {
19  params.uAB = cpjson::get_double(*itr, "uAB");
20  } else {
21  params.uAB = 0.;
22  }
23 
24  if (itr->HasMember("volA") && (*itr)["volA"].IsNumber()) {
25  params.volA = cpjson::get_double(*itr, "volA");
26  } else {
27  params.volA = 0.;
28  }
29 
30  if (itr->HasMember("assocScheme")) {
31  params.assocScheme = cpjson::get_string_array(*itr, "assocScheme");
32  } else {
33  params.assocScheme = {};
34  }
35 
36  if (itr->HasMember("dipm") && (*itr)["dipm"].IsNumber()) {
37  params.dipm = cpjson::get_double(*itr, "dipm");
38  } else {
39  params.dipm = 0.;
40  }
41 
42  if (itr->HasMember("dipnum") && (*itr)["dipnum"].IsNumber()) {
43  params.dipnum = cpjson::get_double(*itr, "dipnum");
44  } else {
45  params.dipnum = 0.;
46  }
47 
48  if (itr->HasMember("charge") && (*itr)["charge"].IsNumber()) {
49  params.z = cpjson::get_double(*itr, "charge");
50  } else {
51  params.z = 0.;
52  }
53 
54  molemass = cpjson::get_double(*itr, "molemass");
55  aliases = cpjson::get_string_array(*itr, "aliases");
56 }
57 
59  if (t > 473.16) {
60  throw ValueError("The current function for sigma for water is only valid for temperatures below 473.15 K.");
61  } else if (t < 273) {
62  throw ValueError("The current function for sigma for water is only valid for temperatures above 273.15 K.");
63  }
64 
65  params.sigma = 3.8395 + 1.2828 * exp(-0.0074944 * t) - 1.3939 * exp(-0.00056029 * t);
66 }
67 
68 } /* namespace CoolProp */