GenericRefrigerant.hpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. /*!
  2. \file
  3. \attention <b> Subject to the EAR </b>
  4. \attention
  5. <b> ECCN: EAR99. </b> This information is subject to the export control laws of the
  6. United States, specifically including the Export Administration Regulations (EAR), 15 C.F.R. Part 730
  7. et seq. Transfer, retransfer or disclosure of this data by any means to a non-US person (individual
  8. or company), whether in the U.S. or abroad, without any required export license or other approval from
  9. the U.S. Govt. is prohibited.
  10. \attention
  11. <b> UTC Proprietary. </b> This material contains proprietary information of United Technologies Corporation.
  12. Any copying, distribution, or dissemination of the contents of this material is strictly prohibited and may be
  13. unlawful without the express written permission of UTC. If you have obtained this material in error, please
  14. notify the UTRC IP Counsel at (860) 610-7339 immediately.
  15. */
  16. #ifndef GENERIC_REFRIGERANT_HPP
  17. #define GENERIC_REFRIGERANT_HPP
  18. //#include <sstream>
  19. //return multiple properties
  20. //#include "RefrigerantInterface.hpp"
  21. //#include "RefrigerantEnum.h"
  22. enum RefrigerantID
  23. {
  24. R1233zd,
  25. R410A,
  26. R134a,
  27. R1234ze,
  28. R22,
  29. R290,
  30. R744,
  31. R452A,
  32. R718,
  33. R404A,
  34. NUM_REFRIGERANTS
  35. };
  36. // convert variable var to string
  37. //template <typename T>
  38. //std::string lexical_cast(T var)
  39. //{
  40. // std::ostringstream os;
  41. // os << var;
  42. // return os.str();
  43. //}
  44. /*
  45. // enumeration of all refrigerant IDs
  46. enum RefrigerantID
  47. {
  48. R1233zd,
  49. R410A,
  50. R134a,
  51. R1234ze,
  52. R22,
  53. R290,
  54. R404A,
  55. R407C,
  56. R744,
  57. R452A,
  58. R718,
  59. NUM_REFRIGERANTS
  60. };//please add refrigerant in the end and do not insert in the middle
  61. static const std::string refName[] = {"R1233zd",
  62. "R410A",
  63. "R134a",
  64. "R1234ze",
  65. "R22",
  66. "R290",
  67. "R404A",
  68. "R407C",
  69. "R744",
  70. "R452A",
  71. "R718"
  72. };
  73. */
  74. #ifdef __cplusplus
  75. extern "C" {
  76. #endif
  77. struct GenRefPropertiesPipev2
  78. {
  79. double T;
  80. double Ts;
  81. double rho;
  82. double Cp;
  83. double mu;
  84. double lambda;
  85. };
  86. struct GenRefPropertiesPipeph
  87. {
  88. double T;
  89. double Ts;
  90. double rho;
  91. double Cp;
  92. double mu;
  93. double lambda;
  94. double ddph;
  95. double ddhp;
  96. };
  97. struct GenRefPropertiesPipepx
  98. {
  99. double T;
  100. double Ts;
  101. double rho;
  102. double h;
  103. double Cp;
  104. double mu;
  105. double lambda;
  106. double dhpx;
  107. double dhxp;
  108. double dvpx;
  109. double dvxp;
  110. };
  111. struct SatRefPropertiesPipe
  112. {
  113. double rhosl; //liquid specific volume
  114. double rhosv;
  115. double hsl;
  116. double hsv;
  117. double Cpsl;
  118. double Cpsv;
  119. double musl;
  120. double musv;
  121. double lambdasl;
  122. double lambdasv;
  123. double sigma;
  124. };
  125. struct GenRefProperties
  126. {
  127. double T;
  128. double Ts;
  129. double v;
  130. double h;
  131. double s;
  132. double Cp;
  133. double mu;
  134. double lambda;
  135. double CpCv;
  136. double n_is; //isentropic exponent
  137. double c; //sonic velocity
  138. double dTglide; //temperature gliding
  139. };
  140. struct SatRefProperties
  141. {
  142. double vsl; //liquid specific volume
  143. double vsv;
  144. double hsl;
  145. double hsv;
  146. double ssl;
  147. double ssv;
  148. double Cpsl;
  149. double Cpsv;
  150. double musl;
  151. double musv;
  152. double lambdasl;
  153. double lambdasv;
  154. double sigma;
  155. double csl;
  156. double csv;
  157. };
  158. struct GenRefPropertiesAll
  159. {
  160. double p;
  161. double x;
  162. double T;
  163. double Ts;
  164. double v;
  165. double h;
  166. double s;
  167. double Cp;
  168. double mu;
  169. double lambda;
  170. double CpCv;
  171. double n_is; //isentropic exponent
  172. double c; //sonic velocity
  173. double dTglide; //temperature gliding
  174. };
  175. struct pxProperties
  176. {
  177. double p;
  178. double x;
  179. };
  180. void computeGenValuesPipePH_px(int ID, const double p, const double x,struct GenRefPropertiesPipeph* GenPropPipe,int errorFlag);
  181. void computeGenValuesPipePX_px(int ID, const double p, const double x,struct GenRefPropertiesPipepx* GenPropPipe,int errorFlag);
  182. void computeGenValuesPipev2_px(int ID, const double p, const double x,struct GenRefPropertiesPipev2* GenPropPipe,int errorFlag);
  183. void computeSatValuesPipe_px(int ID, const double p, const double x, struct SatRefPropertiesPipe* SatPropPipe,int errorFlag);
  184. void computeGenValues_px(int ID, const double p, const double x, struct GenRefProperties* GenProp,int errorFlag);
  185. void computeGenValues2_px(int ID, const double p, const double x, struct GenRefProperties* GenProp, int errorFlag);
  186. void computeSatValues_px(int ID, const double p, const double x, struct SatRefProperties* SatProp,int errorFlag);
  187. void computeGenDxValues_px(int ID, const double p, const double x, struct GenRefProperties* GenDxProp,int errorFlag);
  188. void computeSatDxValues_px(int ID, const double p, const double x, struct SatRefProperties* SatDxProp,int errorFlag);
  189. void computeGenDpValues_px(int ID, const double p, const double x, struct GenRefProperties* GenDpProp,int errorFlag);
  190. void computeSatDpValues_px(int ID, const double p, const double x, struct SatRefProperties* SatDpProp,int errorFlag);
  191. void computeGenThermalValues_px(int ID, double p, double x, struct GenThermalPro* GenThermal, int errorFlag); //added 12-15
  192. void computeGenTransportValues_px(int ID, double p, double x, struct GenTransportPro* GenTransport, int errorFlag); //added 12-15
  193. void computeSatThermalValues_px(int ID, double p, double x, struct SatThermalPro* SatThermal, int errorFlag); //added 12-15
  194. void computeSatTransportValues_px(int ID, double p, double x, struct SatTransportPro* SatTransport, int errorFlag); //added 12-15
  195. void computeConcentration_px(int ID, double p, double x, struct Concentration * concentration); //added 12-15
  196. ///////////////////////////
  197. void computeGenValues_ph(int ID, const double p, const double h, struct GenRefPropertiesAll* GenProp,int errorFlag);
  198. void computeSatValues_ph(int ID, const double p, const double h, struct SatRefProperties* SatProp,int errorFlag);
  199. double x_pT (int ID, const double p, const double T);
  200. void computeGenValues_pT(int ID, const double p, const double T, struct GenRefPropertiesAll* GenProp,int errorFlag);
  201. void computeSatValues_pT(int ID, const double p, const double T, struct SatRefProperties* SatProp,int errorFlag);
  202. void px_TTs (int ID,const double T, const double Ts, struct pxProperties* pxProp,int errorFlag);
  203. void computeGenValues_TTs(int ID, const double T, const double Ts, struct GenRefPropertiesAll* GenProp,int errorFlag);
  204. void computeSatValues_TTs(int ID, const double T, const double Ts, struct SatRefProperties* SatProp,int errorFlag);
  205. void px_Th (int ID,const double T, const double h, struct pxProperties* pxProp,int errorFlag);
  206. void computeGenValues_Th(int ID, const double T, const double h, struct GenRefPropertiesAll* GenProp,int errorFlag);
  207. void computeSatValues_Th(int ID, const double T, const double h, struct SatRefProperties* SatProp,int errorFlag);
  208. void computeGenValues_Tx(int ID, const double T, const double x, struct GenRefPropertiesAll* GenProp,int errorFlag);
  209. void computeSatValues_Tx(int ID, const double T, const double x, struct SatRefProperties* SatProp,int errorFlag);
  210. double p_Tsx (int ID, const double Ts, const double x);
  211. void computeGenValues_Tsx(int ID, const double Ts, const double x, struct GenRefPropertiesAll* GenProp,int errorFlag);
  212. void computeSatValues_Tsx(int ID, const double Ts, const double x, struct SatRefProperties* SatProp,int errorFlag);
  213. double p_hx (int ID, const double h, const double x);
  214. void computeGenValues_hx(int ID, const double h, const double x, struct GenRefPropertiesAll* GenProp,int errorFlag);
  215. void computeSatValues_hx(int ID, const double h, const double x, struct SatRefProperties* SatProp,int errorFlag);
  216. double p_vx (int ID, const double v, const double x);
  217. void computeGenValues_vx(int ID, const double v, const double x, struct GenRefPropertiesAll* GenProp,int errorFlag);
  218. void computeSatValues_vx(int ID, const double v, const double x, struct SatRefProperties* SatProp,int errorFlag);
  219. double p_dTshx (int ID, const double dTsh, const double x);
  220. void computeGenValues_dTshx(int ID, const double dTsh, const double x, struct GenRefPropertiesAll* GenProp,int errorFlag);
  221. void computeSatValues_dTshx(int ID, const double dTsh, const double x, struct SatRefProperties* SatProp,int errorFlag);
  222. double p_sx (int ID, const double s, const double x);
  223. void computeGenValues_sx(int ID, const double s, const double x, struct GenRefPropertiesAll* GenProp,int errorFlag);
  224. void computeSatValues_sx(int ID, const double s, const double x, struct SatRefProperties* SatProp,int errorFlag);
  225. void px_TdTsh (int ID,const double T, const double dTsh, struct pxProperties* pxProp,int errorFlag);
  226. void computeGenValues_TdTsh(int ID, const double T, const double dTsh, struct GenRefPropertiesAll* GenProp,int errorFlag);
  227. void computeSatValues_TdTsh(int ID, const double T, const double dTsh, struct SatRefProperties* SatProp,int errorFlag);
  228. void px_Ts (int ID,const double T, const double s, struct pxProperties* pxProp,int errorFlag);
  229. void computeGenValues_Ts(int ID, const double T, const double s, struct GenRefPropertiesAll* GenProp,int errorFlag);
  230. void computeSatValues_Ts(int ID, const double T, const double s, struct SatRefProperties* SatProp,int errorFlag);
  231. void px_hs (int ID,const double h, const double s, struct pxProperties* pxProp,int errorFlag);
  232. void computeGenValues_hs(int ID, const double h, const double s, struct GenRefPropertiesAll* GenProp,int errorFlag);
  233. void computeSatValues_hs(int ID, const double h, const double s, struct SatRefProperties* SatProp,int errorFlag);
  234. void px_hdTsh (int ID,const double h, const double dTsh, struct pxProperties* pxProp,int errorFlag);
  235. void computeGenValues_hdTsh(int ID, const double h, const double dTsh, struct GenRefPropertiesAll* GenProp,int errorFlag);
  236. void computeSatValues_hdTsh(int ID, const double h, const double dTsh, struct SatRefProperties* SatProp,int errorFlag);
  237. void px_sdTsh (int ID,const double s, const double dTsh, struct pxProperties* pxProp,int errorFlag);
  238. void computeGenValues_sdTsh(int ID, const double s, const double dTsh, struct GenRefPropertiesAll* GenProp,int errorFlag);
  239. void computeSatValues_sdTsh(int ID, const double s, const double dTsh, struct SatRefProperties* SatProp,int errorFlag);
  240. /* input T & v */
  241. void px_Tv(int ID, double T, double v, struct pxProperties* pxProp, int errorFlag);
  242. void computeGenValues_Tv(int ID, const double T, const double v, struct GenRefPropertiesAll* GenProp,int errorFlag);
  243. void computeSatValues_Tv(int ID, const double T, const double v, struct SatRefProperties* SatProp,int errorFlag);
  244. /* input p & v */
  245. double x_pv (int ID, const double p, const double v, int errorFlag);
  246. void computeGenValues_pv(int ID, const double p, const double v, struct GenRefPropertiesAll* GenProp, int errorFlag); //added 1-7-2016
  247. void computeSatValues_pv(int ID, const double p, const double v, struct SatRefProperties* SatProp, int errorFlag); //added 1-7-2016
  248. /* input p & dTsh */
  249. double x_pdTsh (int ID, const double p, const double dTsh, int errorFlag);
  250. void computeGenValues_pdTsh(int ID, const double p, const double dTsh, struct GenRefPropertiesAll* GenProp, int errorFlag);
  251. void computeSatValues_pdTsh(int ID, const double p, const double dTsh, struct SatRefProperties* SatProp, int errorFlag);
  252. /* input p & s */
  253. double x_ps (int ID, double p, double s, int errorFlag);
  254. void computeGenValues_ps(int ID, double p, double s, struct GenRefPropertiesAll* GenProp, int errorFlag);
  255. void computeSatValues_ps(int ID, double p, double s, struct SatRefProperties* SatProp, int errorFlag);
  256. /* intput Ts & h */
  257. void px_Tsh(int ID, const double Ts, const double h, struct pxProperties *pxProp, int errorFlag);
  258. void computeGenValues_Tsh(int ID, const double Ts, const double h, struct GenRefPropertiesAll* GenProp, int errorFlag);
  259. void computeSatValues_Tsh(int ID, const double Ts, const double h, struct SatRefProperties* SatProp, int errorFlag);
  260. /* intput Ts & v */
  261. void px_Tsv(int ID, const double Ts, const double v, struct pxProperties *pxProp, int errorFlag);
  262. void computeGenValues_Tsv(int ID, const double Ts, const double v, struct GenRefPropertiesAll* GenProp, int errorFlag);
  263. void computeSatValues_Tsv(int ID, const double Ts, const double v, struct SatRefProperties* SatProp, int errorFlag);
  264. /* intput Ts & dTsh */
  265. void computeGenValues_TsdTsh(int ID, const double Ts, const double dTsh, struct GenRefPropertiesAll* GenProp, int errorFlag);
  266. void computeSatValues_TsdTsh(int ID, const double Ts, const double dTsh, struct SatRefProperties* SatProp, int errorFlag);
  267. /* input Ts and s */
  268. void px_Tss(int ID, double Ts, double s, struct pxProperties *pxProp, int errorFlag);
  269. void computeGenValues_Tss(int ID, double Ts, double s, struct GenRefPropertiesAll* GenProp, int errorFlag);
  270. void computeSatValues_Tss(int ID, double Ts, double s, struct SatRefProperties* SatProp, int errorFlag);
  271. /* input v and dTsh */
  272. void px_vdTsh(int ID, double v, double dTsh, struct pxProperties *pxProp, int errorFlag);
  273. void computeGenValues_vdTsh(int ID, double v, double dTsh, struct GenRefPropertiesAll* GenProp, int errorFlag);
  274. void computeSatValues_vdTsh(int ID, double v, double dTsh, struct SatRefProperties* SatProp, int errorFlag);
  275. /* input v and s */
  276. void px_vs(int ID, double v, double s, struct pxProperties *pxProp, int errorFlag);
  277. void computeGenValues_vs(int ID, double v, double s, struct GenRefPropertiesAll* GenProp, int errorFlag);
  278. void computeSatValues_vs(int ID, double v, double s, struct SatRefProperties* SatProp, int errorFlag);
  279. /* input h and v */
  280. void px_hv(int ID, double h, double v, struct pxProperties *pxProp, int errorFlag);
  281. void computeGenValues_hv(int ID, double h, double v, struct GenRefPropertiesAll* GenProp, int errorFlag);
  282. void computeSatValues_hv(int ID, double h, double v, struct SatRefProperties* SatProp, int errorFlag);
  283. double T_px (int ID, const double p, const double x);
  284. double Ts_px (int ID, const double p, const double x);
  285. double dTsh_px (int ID, const double p, const double x);
  286. double h_px (int ID, const double p, const double x);
  287. double rho_px (int ID, const double p, const double x);
  288. double v_px (int ID, const double p, const double x);
  289. double s_px (int ID, const double p, const double x);
  290. double Cp_px (int ID, const double p, const double x);
  291. double dTdx_px (int ID, const double p, const double x);
  292. double dTdp_px (int ID, const double p, const double x);
  293. double dTsdx_px (int ID, const double p, const double x);
  294. double dTsdp_px (int ID, const double p, const double x);
  295. double dCpdx_px (int ID, const double p, const double x);
  296. double dCpdp_px (int ID, const double p, const double x);
  297. double drhodx2_px (int ID, const double p, const double x);
  298. double drhodp2_px (int ID, const double p, const double x);
  299. double dhdx_px (int ID, const double p, const double x);
  300. double dhdp_px (int ID, const double p, const double x);
  301. double dsdx_px (int ID, const double p, const double x);
  302. double dsdp_px (int ID, const double p, const double x);
  303. double dmudx_px (int ID, const double p, const double x);
  304. double dmudp_px (int ID, const double p, const double x);
  305. double dlambdadx_px (int ID, const double p, const double x);
  306. double dlambdadp_px (int ID, const double p, const double x);
  307. double dCpCvdx_px (int ID, const double p, const double x);
  308. double dCpCvdp_px (int ID, const double p, const double x);
  309. double dn_isdx_px (int ID, const double p, const double x);
  310. double dn_isdp_px (int ID, const double p, const double x);
  311. double dcdx_px (int ID, const double p, const double x);
  312. double dcdp_px (int ID, const double p, const double x);
  313. double ddTglidedx_px (int ID, const double p, const double x);
  314. double ddTglidedp_px (int ID, const double p, const double x);
  315. double dsigmadx_px (int ID, const double p, const double x);
  316. double dsigmadp_px (int ID, const double p, const double x);
  317. double drhosldx_px (int ID, const double p, const double x);
  318. double drhosldp_px (int ID, const double p, const double x);
  319. double drhosvdx_px (int ID, const double p, const double x);
  320. double drhosvdp_px (int ID, const double p, const double x);
  321. double dhsldx_px (int ID, const double p, const double x);
  322. double dhsldp_px (int ID, const double p, const double x);
  323. double dhsvdx_px (int ID, const double p, const double x);
  324. double dhsvdp_px (int ID, const double p, const double x);
  325. double dssldx_px (int ID, const double p, const double x);
  326. double dssldp_px (int ID, const double p, const double x);
  327. double dssvdx_px (int ID, const double p, const double x);
  328. double dssvdp_px (int ID, const double p, const double x);
  329. double dCpsldx_px (int ID, const double p, const double x);
  330. double dCpsldp_px (int ID, const double p, const double x);
  331. double dCpsvdx_px (int ID, const double p, const double x);
  332. double dCpsvdp_px (int ID, const double p, const double x);
  333. double dmusldx_px (int ID, const double p, const double x);
  334. double dmusldp_px (int ID, const double p, const double x);
  335. double dmusvdx_px (int ID, const double p, const double x);
  336. double dmusvdp_px (int ID, const double p, const double x);
  337. double dlambdasldx_px (int ID, const double p, const double x);
  338. double dlambdasldp_px (int ID, const double p, const double x);
  339. double dlambdasvdx_px (int ID, const double p, const double x);
  340. double dlambdasvdp_px (int ID, const double p, const double x);
  341. double dcsldx_px (int ID, const double p, const double x);
  342. double dcsldp_px (int ID, const double p, const double x);
  343. double dcsvdp_px (int ID, const double p, const double x);
  344. double dcsvdx_px (int ID, const double p, const double x);
  345. double lambda_px (int ID, const double p, const double x);
  346. double mu_px (int ID, const double p, const double x);
  347. double nu_px (int ID, const double p, const double x);
  348. double Pr_px (int ID, const double p, const double x);
  349. double CpCv_px (int ID, const double p, const double x);
  350. double n_is_px (int ID, const double p, const double x);
  351. double c_px (int ID, const double p, const double x);
  352. double dTglide_p (int ID, const double p);
  353. double x_ph (int ID, const double p, const double h);
  354. double T_ph (int ID, const double p, const double h);
  355. double Ts_ph (int ID, const double p, const double h);
  356. double dTsh_ph (int ID, const double p, const double h);
  357. double rho_ph (int ID, const double p, const double h);
  358. double s_ph (int ID, const double p, const double h);
  359. double Cp_ph (int ID, const double p, const double h);
  360. double lambda_ph (int ID, const double p, const double h);
  361. double mu_ph (int ID, const double p, const double h);
  362. double nu_ph (int ID, const double p, const double h);
  363. double Pr_ph (int ID, const double p, const double h);
  364. double CpCv_ph (int ID, const double p, const double h);
  365. double n_is_ph (int ID, const double p, const double h);
  366. double c_ph (int ID, const double p, const double h);
  367. double drhodp_ph (int ID, const double p, const double h);
  368. double drhodh_ph (int ID, const double p, const double h);
  369. double hsl_px (int ID, const double p, const double x);
  370. double hsv_px (int ID, const double p, const double x);
  371. double rhosl_px (int ID, const double p, const double x);
  372. double rhosv_px (int ID, const double p, const double x);
  373. double ssl_px (int ID, const double p, const double x);
  374. double ssv_px (int ID, const double p, const double x);
  375. double Cpsl_px (int ID, const double p, const double x);
  376. double Cpsv_px (int ID, const double p, const double x);
  377. double musl_px (int ID, const double p, const double x);
  378. double musv_px (int ID, const double p, const double x);
  379. double lambdasl_px (int ID, const double p, const double x);
  380. double lambdasv_px (int ID, const double p, const double x);
  381. double csl_px (int ID, const double p, const double x);
  382. double csv_px (int ID, const double p, const double x);
  383. double sigma_px (int ID, const double p, const double x);
  384. double p_Tx (int ID, const double T, const double x);
  385. double h_pT (int ID, const double p, const double T);
  386. double h_ps (int ID, const double p, const double s);
  387. double pc (int ID);
  388. double pcPseudo (int ID);
  389. double pchlPseudo (int ID);
  390. double pchvPseudo (int ID);
  391. double Tc (int ID);
  392. double xilMax (int ID);
  393. double MolarMass (int ID);
  394. //Input files
  395. double qbegin (int ID);
  396. double qend (int ID);
  397. double pbegin (int ID);
  398. double pend (int ID);
  399. double qinc (int ID);
  400. double deltap (int ID);
  401. double Tlow (int ID);
  402. double Thigh (int ID);
  403. double Tbeg (int ID);
  404. double Tend (int ID);
  405. double Tinc (int ID);
  406. // supporting functions
  407. char* getName (int ID);
  408. const char* getVersion (int ID);
  409. double FPercentPseudo (int ID);
  410. void getRefComposition( int ID, const char* refCon[]); //added 12-15
  411. int getRefComNum(int ID);
  412. double vx_px (int ID, const double p, const double x);
  413. double vp_px (int ID, const double p, const double x);
  414. double hp_px (int ID, const double p, const double x);
  415. double hx_px (int ID, const double p, const double x);
  416. //
  417. //double F_to_K(const double& T);
  418. /// \todo SK: Are these functions not used, why is ID not passed as a parameter?
  419. double drhodp_px(int ID, const double p, const double x);
  420. double drhodh_px(int ID, const double p, const double x);
  421. #ifdef __cplusplus
  422. } // extern C
  423. #endif
  424. #endif // GENERIC_REFRIGERANT_HPP