PYroMat 2.2.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1010) hide show
  1. PYroMat-2.2.5.dist-info/LICENSE.txt +644 -0
  2. PYroMat-2.2.5.dist-info/METADATA +94 -0
  3. PYroMat-2.2.5.dist-info/RECORD +1010 -0
  4. PYroMat-2.2.5.dist-info/WHEEL +5 -0
  5. PYroMat-2.2.5.dist-info/top_level.txt +5 -0
  6. pyromat/__init__.py +395 -0
  7. pyromat/config.py +166 -0
  8. pyromat/dat.py +574 -0
  9. pyromat/data/ig/Al_H.hpd +464 -0
  10. pyromat/data/ig/Al_H_O.hpd +464 -0
  11. pyromat/data/ig/Al_H_O2.hpd +446 -0
  12. pyromat/data/ig/Al_H_O_1.hpd +482 -0
  13. pyromat/data/ig/B10_H14.hpd +362 -0
  14. pyromat/data/ig/B2_Be_O4.hpd +464 -0
  15. pyromat/data/ig/B2_Cl4.hpd +446 -0
  16. pyromat/data/ig/B2_F4.hpd +466 -0
  17. pyromat/data/ig/B2_F4_O.hpd +465 -0
  18. pyromat/data/ig/B2_H4_O4.hpd +465 -0
  19. pyromat/data/ig/B3_F2_H_O3.hpd +466 -0
  20. pyromat/data/ig/B3_F_H2_O3.hpd +466 -0
  21. pyromat/data/ig/B3_H3_O3.hpd +464 -0
  22. pyromat/data/ig/B3_H3_O6.hpd +465 -0
  23. pyromat/data/ig/B5_H9.hpd +358 -0
  24. pyromat/data/ig/B_Br.hpd +446 -0
  25. pyromat/data/ig/B_Br2.hpd +446 -0
  26. pyromat/data/ig/B_Br2_Cl.hpd +446 -0
  27. pyromat/data/ig/B_Br2_F.hpd +464 -0
  28. pyromat/data/ig/B_Br2_H.hpd +465 -0
  29. pyromat/data/ig/B_Br3.hpd +390 -0
  30. pyromat/data/ig/B_Br_Cl.hpd +447 -0
  31. pyromat/data/ig/B_Br_Cl2.hpd +464 -0
  32. pyromat/data/ig/B_Br_F.hpd +465 -0
  33. pyromat/data/ig/B_Br_F2.hpd +464 -0
  34. pyromat/data/ig/B_Br_O.hpd +465 -0
  35. pyromat/data/ig/B_Cl2_F.hpd +465 -0
  36. pyromat/data/ig/B_Cl2_H.hpd +466 -0
  37. pyromat/data/ig/B_Cl_F2.hpd +465 -0
  38. pyromat/data/ig/B_F2_H.hpd +465 -0
  39. pyromat/data/ig/B_F2_H_O.hpd +466 -0
  40. pyromat/data/ig/B_F4_K.hpd +356 -0
  41. pyromat/data/ig/B_H.hpd +464 -0
  42. pyromat/data/ig/B_H2.hpd +463 -0
  43. pyromat/data/ig/B_H2_O2.hpd +465 -0
  44. pyromat/data/ig/B_H3.hpd +464 -0
  45. pyromat/data/ig/B_H3_O3.hpd +494 -0
  46. pyromat/data/ig/B_H_O.hpd +465 -0
  47. pyromat/data/ig/B_H_O2.hpd +464 -0
  48. pyromat/data/ig/B_H_S.hpd +464 -0
  49. pyromat/data/ig/B_I.hpd +446 -0
  50. pyromat/data/ig/B_I2.hpd +446 -0
  51. pyromat/data/ig/B_I3.hpd +449 -0
  52. pyromat/data/ig/Ba_H2_O2.hpd +322 -0
  53. pyromat/data/ig/Ba_H_O.hpd +447 -0
  54. pyromat/data/ig/Ba_I.hpd +445 -0
  55. pyromat/data/ig/Ba_I2.hpd +263 -0
  56. pyromat/data/ig/Be2.hpd +445 -0
  57. pyromat/data/ig/Be2_Cl4.hpd +445 -0
  58. pyromat/data/ig/Be_F3_Li.hpd +320 -0
  59. pyromat/data/ig/Be_H.hpd +464 -0
  60. pyromat/data/ig/Be_H2_O2.hpd +464 -0
  61. pyromat/data/ig/Be_H_O.hpd +465 -0
  62. pyromat/data/ig/Br2_Fe.hpd +319 -0
  63. pyromat/data/ig/Br2_H2_Si.hpd +465 -0
  64. pyromat/data/ig/Br2_K2.hpd +445 -0
  65. pyromat/data/ig/Br2_Li2.hpd +445 -0
  66. pyromat/data/ig/Br2_Mo.hpd +463 -0
  67. pyromat/data/ig/Br2_Na2.hpd +445 -0
  68. pyromat/data/ig/Br2_Sr.hpd +249 -0
  69. pyromat/data/ig/Br2_Ti.hpd +463 -0
  70. pyromat/data/ig/Br2_Zr.hpd +319 -0
  71. pyromat/data/ig/Br3_H_Si.hpd +466 -0
  72. pyromat/data/ig/Br3_Mo.hpd +445 -0
  73. pyromat/data/ig/Br3_O_P.hpd +448 -0
  74. pyromat/data/ig/Br3_P.hpd +455 -0
  75. pyromat/data/ig/Br3_P_S.hpd +448 -0
  76. pyromat/data/ig/Br3_Ti.hpd +445 -0
  77. pyromat/data/ig/Br3_Zr.hpd +445 -0
  78. pyromat/data/ig/Br4_Fe2.hpd +445 -0
  79. pyromat/data/ig/Br4_Mg2.hpd +445 -0
  80. pyromat/data/ig/Br4_Mo.hpd +445 -0
  81. pyromat/data/ig/Br4_Ti.hpd +389 -0
  82. pyromat/data/ig/Br4_Zr.hpd +445 -0
  83. pyromat/data/ig/Br5_Nb.hpd +398 -0
  84. pyromat/data/ig/Br5_W.hpd +389 -0
  85. pyromat/data/ig/Br6_W.hpd +445 -0
  86. pyromat/data/ig/Br_Cl.hpd +447 -0
  87. pyromat/data/ig/Br_F.hpd +446 -0
  88. pyromat/data/ig/Br_F3.hpd +445 -0
  89. pyromat/data/ig/Br_F5.hpd +446 -0
  90. pyromat/data/ig/Br_F5_S.hpd +465 -0
  91. pyromat/data/ig/Br_H.hpd +476 -0
  92. pyromat/data/ig/Br_H3_Si.hpd +465 -0
  93. pyromat/data/ig/Br_Hg.hpd +446 -0
  94. pyromat/data/ig/Br_I.hpd +465 -0
  95. pyromat/data/ig/Br_K.hpd +285 -0
  96. pyromat/data/ig/Br_Li.hpd +320 -0
  97. pyromat/data/ig/Br_Mo.hpd +463 -0
  98. pyromat/data/ig/Br_N.hpd +445 -0
  99. pyromat/data/ig/Br_N_O.hpd +465 -0
  100. pyromat/data/ig/Br_P.hpd +446 -0
  101. pyromat/data/ig/Br_Ti.hpd +445 -0
  102. pyromat/data/ig/Br_W.hpd +445 -0
  103. pyromat/data/ig/Br_Zr.hpd +463 -0
  104. pyromat/data/ig/C2_Be.hpd +463 -0
  105. pyromat/data/ig/C2_F3_N.hpd +468 -0
  106. pyromat/data/ig/C2_F6.hpd +476 -0
  107. pyromat/data/ig/C4_Ni_O4.hpd +441 -0
  108. pyromat/data/ig/C_B.hpd +464 -0
  109. pyromat/data/ig/C_Br.hpd +446 -0
  110. pyromat/data/ig/C_Br4.hpd +455 -0
  111. pyromat/data/ig/C_Br_F3.hpd +485 -0
  112. pyromat/data/ig/C_Br_N.hpd +484 -0
  113. pyromat/data/ig/C_F3_I.hpd +472 -0
  114. pyromat/data/ig/C_F4_O.hpd +464 -0
  115. pyromat/data/ig/C_F8_S.hpd +469 -0
  116. pyromat/data/ig/C_H3_Cl3_Si.hpd +147 -0
  117. pyromat/data/ig/C_H3_F3_Si.hpd +138 -0
  118. pyromat/data/ig/C_H_F.hpd +465 -0
  119. pyromat/data/ig/C_H_F_O.hpd +465 -0
  120. pyromat/data/ig/C_H_P.hpd +464 -0
  121. pyromat/data/ig/C_I_N.hpd +465 -0
  122. pyromat/data/ig/C_N2_1.hpd +464 -0
  123. pyromat/data/ig/Ca_H2_O2.hpd +446 -0
  124. pyromat/data/ig/Ca_H_O.hpd +447 -0
  125. pyromat/data/ig/Cl10_W2.hpd +445 -0
  126. pyromat/data/ig/Cl2_Co.hpd +319 -0
  127. pyromat/data/ig/Cl2_F_O_P.hpd +466 -0
  128. pyromat/data/ig/Cl2_H2_Si.hpd +465 -0
  129. pyromat/data/ig/Cl2_Hg.hpd +354 -0
  130. pyromat/data/ig/Cl2_Mo_O2.hpd +446 -0
  131. pyromat/data/ig/Cl2_O2_W.hpd +464 -0
  132. pyromat/data/ig/Cl2_W.hpd +463 -0
  133. pyromat/data/ig/Cl2_Zr.hpd +319 -0
  134. pyromat/data/ig/Cl3_Co.hpd +447 -0
  135. pyromat/data/ig/Cl3_F_Si.hpd +447 -0
  136. pyromat/data/ig/Cl3_H_Si.hpd +466 -0
  137. pyromat/data/ig/Cl3_O_P.hpd +483 -0
  138. pyromat/data/ig/Cl3_P_S.hpd +448 -0
  139. pyromat/data/ig/Cl3_Zr.hpd +463 -0
  140. pyromat/data/ig/Cl4_Co2.hpd +445 -0
  141. pyromat/data/ig/Cl4_Mg2.hpd +445 -0
  142. pyromat/data/ig/Cl4_Mo.hpd +354 -0
  143. pyromat/data/ig/Cl4_O_W.hpd +390 -0
  144. pyromat/data/ig/Cl4_W.hpd +445 -0
  145. pyromat/data/ig/Cl4_Zr.hpd +445 -0
  146. pyromat/data/ig/Cl5_Mo.hpd +375 -0
  147. pyromat/data/ig/Cl5_Nb.hpd +403 -0
  148. pyromat/data/ig/Cl5_P.hpd +446 -0
  149. pyromat/data/ig/Cl5_Ta.hpd +403 -0
  150. pyromat/data/ig/Cl5_W.hpd +354 -0
  151. pyromat/data/ig/Cl6_Mo.hpd +445 -0
  152. pyromat/data/ig/Cl6_W.hpd +354 -0
  153. pyromat/data/ig/Cl_Co.hpd +463 -0
  154. pyromat/data/ig/Cl_F2_O_P.hpd +470 -0
  155. pyromat/data/ig/Cl_F3_Si.hpd +465 -0
  156. pyromat/data/ig/Cl_F5.hpd +464 -0
  157. pyromat/data/ig/Cl_F5_S.hpd +466 -0
  158. pyromat/data/ig/Cl_F_Li2.hpd +464 -0
  159. pyromat/data/ig/Cl_F_O3.hpd +472 -0
  160. pyromat/data/ig/Cl_H.hpd +493 -0
  161. pyromat/data/ig/Cl_H3_Si.hpd +466 -0
  162. pyromat/data/ig/Cl_H_O.hpd +465 -0
  163. pyromat/data/ig/Cl_Hg.hpd +445 -0
  164. pyromat/data/ig/Cl_I.hpd +390 -0
  165. pyromat/data/ig/Cl_Li_O.hpd +465 -0
  166. pyromat/data/ig/Cl_P.hpd +446 -0
  167. pyromat/data/ig/Cl_W.hpd +463 -0
  168. pyromat/data/ig/Cl_Zr.hpd +463 -0
  169. pyromat/data/ig/Co.hpd +242 -0
  170. pyromat/data/ig/Co_F2.hpd +249 -0
  171. pyromat/data/ig/Cs2_H2_O2.hpd +464 -0
  172. pyromat/data/ig/Cs_H_O.hpd +322 -0
  173. pyromat/data/ig/D_H.hpd +464 -0
  174. pyromat/data/ig/D_H_O.hpd +467 -0
  175. pyromat/data/ig/F10_Mo2.hpd +445 -0
  176. pyromat/data/ig/F10_S2.hpd +465 -0
  177. pyromat/data/ig/F15_Mo3.hpd +445 -0
  178. pyromat/data/ig/F2_Fe.hpd +249 -0
  179. pyromat/data/ig/F2_H2_Si.hpd +465 -0
  180. pyromat/data/ig/F2_Hg.hpd +321 -0
  181. pyromat/data/ig/F2_Mo.hpd +445 -0
  182. pyromat/data/ig/F2_N2_1.hpd +469 -0
  183. pyromat/data/ig/F2_O_Si.hpd +465 -0
  184. pyromat/data/ig/F2_O_Ti.hpd +446 -0
  185. pyromat/data/ig/F2_S2_1.hpd +446 -0
  186. pyromat/data/ig/F2_Ti.hpd +463 -0
  187. pyromat/data/ig/F2_Zr.hpd +249 -0
  188. pyromat/data/ig/F3_Fe.hpd +445 -0
  189. pyromat/data/ig/F3_H_Si.hpd +465 -0
  190. pyromat/data/ig/F3_Mo.hpd +445 -0
  191. pyromat/data/ig/F3_O_P.hpd +471 -0
  192. pyromat/data/ig/F3_P_S.hpd +465 -0
  193. pyromat/data/ig/F3_Ti.hpd +445 -0
  194. pyromat/data/ig/F3_Zr.hpd +463 -0
  195. pyromat/data/ig/F4_Mo.hpd +463 -0
  196. pyromat/data/ig/F4_Mo_O.hpd +446 -0
  197. pyromat/data/ig/F4_O_W.hpd +390 -0
  198. pyromat/data/ig/F4_Ti.hpd +447 -0
  199. pyromat/data/ig/F4_Zr.hpd +446 -0
  200. pyromat/data/ig/F5_I.hpd +446 -0
  201. pyromat/data/ig/F5_Mo.hpd +445 -0
  202. pyromat/data/ig/F6_Mo.hpd +394 -0
  203. pyromat/data/ig/F6_W.hpd +396 -0
  204. pyromat/data/ig/F7_I.hpd +447 -0
  205. pyromat/data/ig/F_Fe.hpd +445 -0
  206. pyromat/data/ig/F_H.hpd +464 -0
  207. pyromat/data/ig/F_H3_Si.hpd +466 -0
  208. pyromat/data/ig/F_H_O.hpd +465 -0
  209. pyromat/data/ig/F_H_O3_S.hpd +467 -0
  210. pyromat/data/ig/F_Hg.hpd +445 -0
  211. pyromat/data/ig/F_I.hpd +446 -0
  212. pyromat/data/ig/F_Mo.hpd +463 -0
  213. pyromat/data/ig/F_O_Ti.hpd +464 -0
  214. pyromat/data/ig/F_P_S.hpd +464 -0
  215. pyromat/data/ig/F_Ti.hpd +463 -0
  216. pyromat/data/ig/F_W.hpd +463 -0
  217. pyromat/data/ig/F_Zr.hpd +463 -0
  218. pyromat/data/ig/Fe2_I4.hpd +445 -0
  219. pyromat/data/ig/Fe_H2_O2.hpd +466 -0
  220. pyromat/data/ig/Fe_I2.hpd +319 -0
  221. pyromat/data/ig/Fe_S.hpd +194 -0
  222. pyromat/data/ig/Ga.hpd +291 -0
  223. pyromat/data/ig/H2_Mo_O4.hpd +465 -0
  224. pyromat/data/ig/H2_O4_W.hpd +466 -0
  225. pyromat/data/ig/H2_P.hpd +464 -0
  226. pyromat/data/ig/H_Hg.hpd +463 -0
  227. pyromat/data/ig/H_Pb.hpd +463 -0
  228. pyromat/data/ig/H_Zr.hpd +463 -0
  229. pyromat/data/ig/Hf.hpd +116 -0
  230. pyromat/data/ig/Hg_I.hpd +446 -0
  231. pyromat/data/ig/Hg_I2.hpd +355 -0
  232. pyromat/data/ig/Hg_O.hpd +447 -0
  233. pyromat/data/ig/I2_K2.hpd +446 -0
  234. pyromat/data/ig/I2_Li2.hpd +445 -0
  235. pyromat/data/ig/I2_Mo.hpd +464 -0
  236. pyromat/data/ig/I2_Ti.hpd +463 -0
  237. pyromat/data/ig/I2_Zr.hpd +319 -0
  238. pyromat/data/ig/I3_Mo.hpd +446 -0
  239. pyromat/data/ig/I3_Si.hpd +446 -0
  240. pyromat/data/ig/I3_Ti.hpd +445 -0
  241. pyromat/data/ig/I3_Zr.hpd +445 -0
  242. pyromat/data/ig/I4_Mo.hpd +446 -0
  243. pyromat/data/ig/I4_Si.hpd +410 -0
  244. pyromat/data/ig/I4_Ti.hpd +354 -0
  245. pyromat/data/ig/I4_Zr.hpd +445 -0
  246. pyromat/data/ig/I_K.hpd +285 -0
  247. pyromat/data/ig/I_Li.hpd +285 -0
  248. pyromat/data/ig/I_N_O.hpd +465 -0
  249. pyromat/data/ig/I_Sr.hpd +463 -0
  250. pyromat/data/ig/I_Ti.hpd +463 -0
  251. pyromat/data/ig/I_Zr.hpd +445 -0
  252. pyromat/data/ig/Li_Na_O.hpd +464 -0
  253. pyromat/data/ig/Mn.hpd +298 -0
  254. pyromat/data/ig/Mo.hpd +116 -0
  255. pyromat/data/ig/Mo_O.hpd +447 -0
  256. pyromat/data/ig/Mo_O2.hpd +465 -0
  257. pyromat/data/ig/N_P.hpd +464 -0
  258. pyromat/data/ig/O12_W4.hpd +445 -0
  259. pyromat/data/ig/O2_W.hpd +463 -0
  260. pyromat/data/ig/O3_W.hpd +250 -0
  261. pyromat/data/ig/O6_P4.hpd +463 -0
  262. pyromat/data/ig/O6_W2.hpd +445 -0
  263. pyromat/data/ig/O8_W3.hpd +464 -0
  264. pyromat/data/ig/O9_W3.hpd +445 -0
  265. pyromat/data/ig/O_W.hpd +464 -0
  266. pyromat/data/ig/P_S.hpd +446 -0
  267. pyromat/data/ig/Rb.hpd +414 -0
  268. pyromat/data/ig/Rb2.hpd +463 -0
  269. pyromat/data/ig/S3.hpd +444 -0
  270. pyromat/data/ig/S4.hpd +444 -0
  271. pyromat/data/ig/S5.hpd +444 -0
  272. pyromat/data/ig/S6.hpd +451 -0
  273. pyromat/data/ig/S7.hpd +444 -0
  274. pyromat/data/ig2/Al+.hpd +39 -0
  275. pyromat/data/ig2/Al-.hpd +39 -0
  276. pyromat/data/ig2/Al.hpd +43 -0
  277. pyromat/data/ig2/Al2.hpd +42 -0
  278. pyromat/data/ig2/Al2_Br6.hpd +42 -0
  279. pyromat/data/ig2/Al2_Cl6.hpd +48 -0
  280. pyromat/data/ig2/Al2_F6.hpd +42 -0
  281. pyromat/data/ig2/Al2_I6.hpd +43 -0
  282. pyromat/data/ig2/Al2_O+.hpd +40 -0
  283. pyromat/data/ig2/Al2_O.hpd +42 -0
  284. pyromat/data/ig2/Al2_O2+.hpd +40 -0
  285. pyromat/data/ig2/Al2_O2.hpd +42 -0
  286. pyromat/data/ig2/Al_B_O2.hpd +43 -0
  287. pyromat/data/ig2/Al_Br.hpd +42 -0
  288. pyromat/data/ig2/Al_Br3.hpd +42 -0
  289. pyromat/data/ig2/Al_Cl+.hpd +40 -0
  290. pyromat/data/ig2/Al_Cl.hpd +43 -0
  291. pyromat/data/ig2/Al_Cl2+.hpd +40 -0
  292. pyromat/data/ig2/Al_Cl2-.hpd +40 -0
  293. pyromat/data/ig2/Al_Cl2.hpd +42 -0
  294. pyromat/data/ig2/Al_Cl2_F.hpd +44 -0
  295. pyromat/data/ig2/Al_Cl3.hpd +42 -0
  296. pyromat/data/ig2/Al_Cl_F+.hpd +41 -0
  297. pyromat/data/ig2/Al_Cl_F.hpd +43 -0
  298. pyromat/data/ig2/Al_Cl_F2.hpd +44 -0
  299. pyromat/data/ig2/Al_Cl_O.hpd +43 -0
  300. pyromat/data/ig2/Al_F+.hpd +40 -0
  301. pyromat/data/ig2/Al_F.hpd +43 -0
  302. pyromat/data/ig2/Al_F2+.hpd +40 -0
  303. pyromat/data/ig2/Al_F2-.hpd +40 -0
  304. pyromat/data/ig2/Al_F2.hpd +42 -0
  305. pyromat/data/ig2/Al_F2_O-.hpd +41 -0
  306. pyromat/data/ig2/Al_F2_O.hpd +43 -0
  307. pyromat/data/ig2/Al_F3.hpd +45 -0
  308. pyromat/data/ig2/Al_F4-.hpd +40 -0
  309. pyromat/data/ig2/Al_F4_Li.hpd +43 -0
  310. pyromat/data/ig2/Al_F4_Na.hpd +43 -0
  311. pyromat/data/ig2/Al_F_O.hpd +43 -0
  312. pyromat/data/ig2/Al_I.hpd +42 -0
  313. pyromat/data/ig2/Al_I3.hpd +42 -0
  314. pyromat/data/ig2/Al_N.hpd +44 -0
  315. pyromat/data/ig2/Al_O+.hpd +40 -0
  316. pyromat/data/ig2/Al_O-.hpd +40 -0
  317. pyromat/data/ig2/Al_O.hpd +43 -0
  318. pyromat/data/ig2/Al_O2-.hpd +40 -0
  319. pyromat/data/ig2/Al_O2.hpd +42 -0
  320. pyromat/data/ig2/Al_S.hpd +43 -0
  321. pyromat/data/ig2/Ar+.hpd +39 -0
  322. pyromat/data/ig2/Ar.hpd +38 -0
  323. pyromat/data/ig2/B+.hpd +39 -0
  324. pyromat/data/ig2/B-.hpd +39 -0
  325. pyromat/data/ig2/B.hpd +42 -0
  326. pyromat/data/ig2/B2.hpd +38 -0
  327. pyromat/data/ig2/B2_O.hpd +42 -0
  328. pyromat/data/ig2/B2_O2.hpd +42 -0
  329. pyromat/data/ig2/B2_O3.hpd +42 -0
  330. pyromat/data/ig2/B3_Cl3_O3.hpd +44 -0
  331. pyromat/data/ig2/B3_F3_O3.hpd +44 -0
  332. pyromat/data/ig2/B_Be_O2.hpd +40 -0
  333. pyromat/data/ig2/B_Cl+.hpd +40 -0
  334. pyromat/data/ig2/B_Cl.hpd +43 -0
  335. pyromat/data/ig2/B_Cl2+.hpd +40 -0
  336. pyromat/data/ig2/B_Cl2-.hpd +40 -0
  337. pyromat/data/ig2/B_Cl2.hpd +43 -0
  338. pyromat/data/ig2/B_Cl3.hpd +52 -0
  339. pyromat/data/ig2/B_Cl_F.hpd +44 -0
  340. pyromat/data/ig2/B_Cl_O.hpd +43 -0
  341. pyromat/data/ig2/B_F.hpd +44 -0
  342. pyromat/data/ig2/B_F2+.hpd +40 -0
  343. pyromat/data/ig2/B_F2-.hpd +40 -0
  344. pyromat/data/ig2/B_F2.hpd +43 -0
  345. pyromat/data/ig2/B_F2_O.hpd +43 -0
  346. pyromat/data/ig2/B_F3.hpd +52 -0
  347. pyromat/data/ig2/B_F_O.hpd +43 -0
  348. pyromat/data/ig2/B_K_O2.hpd +43 -0
  349. pyromat/data/ig2/B_Li_O2.hpd +43 -0
  350. pyromat/data/ig2/B_N.hpd +43 -0
  351. pyromat/data/ig2/B_Na_O2.hpd +43 -0
  352. pyromat/data/ig2/B_O.hpd +43 -0
  353. pyromat/data/ig2/B_O2-.hpd +40 -0
  354. pyromat/data/ig2/B_O2.hpd +42 -0
  355. pyromat/data/ig2/B_S.hpd +43 -0
  356. pyromat/data/ig2/Ba.hpd +38 -0
  357. pyromat/data/ig2/Ba_Br.hpd +42 -0
  358. pyromat/data/ig2/Ba_Br2.hpd +42 -0
  359. pyromat/data/ig2/Ba_Cl.hpd +39 -0
  360. pyromat/data/ig2/Ba_Cl2.hpd +44 -0
  361. pyromat/data/ig2/Ba_F+.hpd +40 -0
  362. pyromat/data/ig2/Ba_F.hpd +43 -0
  363. pyromat/data/ig2/Ba_F2.hpd +43 -0
  364. pyromat/data/ig2/Ba_S.hpd +44 -0
  365. pyromat/data/ig2/Be+.hpd +39 -0
  366. pyromat/data/ig2/Be.hpd +42 -0
  367. pyromat/data/ig2/Be2_F2_O.hpd +43 -0
  368. pyromat/data/ig2/Be2_O.hpd +42 -0
  369. pyromat/data/ig2/Be2_O2.hpd +42 -0
  370. pyromat/data/ig2/Be3_O3.hpd +39 -0
  371. pyromat/data/ig2/Be4_O4.hpd +39 -0
  372. pyromat/data/ig2/Be_Br.hpd +42 -0
  373. pyromat/data/ig2/Be_Br2.hpd +44 -0
  374. pyromat/data/ig2/Be_Cl+.hpd +40 -0
  375. pyromat/data/ig2/Be_Cl.hpd +43 -0
  376. pyromat/data/ig2/Be_Cl2.hpd +42 -0
  377. pyromat/data/ig2/Be_Cl_F.hpd +43 -0
  378. pyromat/data/ig2/Be_F.hpd +43 -0
  379. pyromat/data/ig2/Be_F2.hpd +42 -0
  380. pyromat/data/ig2/Be_I.hpd +42 -0
  381. pyromat/data/ig2/Be_I2.hpd +44 -0
  382. pyromat/data/ig2/Be_N.hpd +43 -0
  383. pyromat/data/ig2/Be_O.hpd +44 -0
  384. pyromat/data/ig2/Be_S.hpd +44 -0
  385. pyromat/data/ig2/Br.hpd +42 -0
  386. pyromat/data/ig2/Br2.hpd +49 -0
  387. pyromat/data/ig2/Br2_Ca.hpd +42 -0
  388. pyromat/data/ig2/Br2_Hg.hpd +51 -0
  389. pyromat/data/ig2/Br2_Mg.hpd +42 -0
  390. pyromat/data/ig2/Br2_Pb.hpd +42 -0
  391. pyromat/data/ig2/Br2_Si.hpd +43 -0
  392. pyromat/data/ig2/Br3_Si.hpd +43 -0
  393. pyromat/data/ig2/Br4_Pb.hpd +42 -0
  394. pyromat/data/ig2/Br4_Si.hpd +43 -0
  395. pyromat/data/ig2/Br_Ca.hpd +42 -0
  396. pyromat/data/ig2/Br_Mg.hpd +42 -0
  397. pyromat/data/ig2/Br_Na.hpd +43 -0
  398. pyromat/data/ig2/Br_Pb.hpd +42 -0
  399. pyromat/data/ig2/Br_Si.hpd +43 -0
  400. pyromat/data/ig2/Br_Sr.hpd +42 -0
  401. pyromat/data/ig2/C+.hpd +39 -0
  402. pyromat/data/ig2/C-.hpd +39 -0
  403. pyromat/data/ig2/C.hpd +43 -0
  404. pyromat/data/ig2/C10_H21.hpd +39 -0
  405. pyromat/data/ig2/C10_H8.hpd +39 -0
  406. pyromat/data/ig2/C12_D10.hpd +39 -0
  407. pyromat/data/ig2/C12_D9.hpd +39 -0
  408. pyromat/data/ig2/C12_H10.hpd +39 -0
  409. pyromat/data/ig2/C12_H23.hpd +39 -0
  410. pyromat/data/ig2/C12_H9.hpd +39 -0
  411. pyromat/data/ig2/C2+.hpd +39 -0
  412. pyromat/data/ig2/C2-.hpd +39 -0
  413. pyromat/data/ig2/C2.hpd +42 -0
  414. pyromat/data/ig2/C2_Cl2.hpd +50 -0
  415. pyromat/data/ig2/C2_Cl4.hpd +97 -0
  416. pyromat/data/ig2/C2_Cl6.hpd +69 -0
  417. pyromat/data/ig2/C2_F2.hpd +50 -0
  418. pyromat/data/ig2/C2_F4.hpd +55 -0
  419. pyromat/data/ig2/C2_H.hpd +43 -0
  420. pyromat/data/ig2/C2_H2.hpd +50 -0
  421. pyromat/data/ig2/C2_H2_O.hpd +40 -0
  422. pyromat/data/ig2/C2_H3.hpd +39 -0
  423. pyromat/data/ig2/C2_H3_N.hpd +40 -0
  424. pyromat/data/ig2/C2_H3_O.hpd +40 -0
  425. pyromat/data/ig2/C2_H4.hpd +39 -0
  426. pyromat/data/ig2/C2_H4_O.hpd +40 -0
  427. pyromat/data/ig2/C2_H4_O2.hpd +40 -0
  428. pyromat/data/ig2/C2_H4_O4.hpd +40 -0
  429. pyromat/data/ig2/C2_H5.hpd +39 -0
  430. pyromat/data/ig2/C2_H6.hpd +39 -0
  431. pyromat/data/ig2/C2_H6_N2.hpd +40 -0
  432. pyromat/data/ig2/C2_H6_O.hpd +40 -0
  433. pyromat/data/ig2/C2_H_Cl.hpd +51 -0
  434. pyromat/data/ig2/C2_H_F.hpd +52 -0
  435. pyromat/data/ig2/C2_H_N.hpd +40 -0
  436. pyromat/data/ig2/C2_H_O.hpd +40 -0
  437. pyromat/data/ig2/C2_K2_N2.hpd +43 -0
  438. pyromat/data/ig2/C2_N.hpd +42 -0
  439. pyromat/data/ig2/C2_N2.hpd +61 -0
  440. pyromat/data/ig2/C2_N2_Na2.hpd +44 -0
  441. pyromat/data/ig2/C2_O.hpd +39 -0
  442. pyromat/data/ig2/C2_Si.hpd +42 -0
  443. pyromat/data/ig2/C3.hpd +43 -0
  444. pyromat/data/ig2/C3_H3.hpd +39 -0
  445. pyromat/data/ig2/C3_H4.hpd +39 -0
  446. pyromat/data/ig2/C3_H5.hpd +39 -0
  447. pyromat/data/ig2/C3_H6.hpd +39 -0
  448. pyromat/data/ig2/C3_H6_O.hpd +40 -0
  449. pyromat/data/ig2/C3_H7.hpd +39 -0
  450. pyromat/data/ig2/C3_H8.hpd +39 -0
  451. pyromat/data/ig2/C3_H8_O.hpd +40 -0
  452. pyromat/data/ig2/C3_O2.hpd +46 -0
  453. pyromat/data/ig2/C4.hpd +42 -0
  454. pyromat/data/ig2/C4_H10.hpd +39 -0
  455. pyromat/data/ig2/C4_H12_Si.hpd +54 -0
  456. pyromat/data/ig2/C4_H2.hpd +39 -0
  457. pyromat/data/ig2/C4_H4.hpd +39 -0
  458. pyromat/data/ig2/C4_H6.hpd +39 -0
  459. pyromat/data/ig2/C4_H8.hpd +39 -0
  460. pyromat/data/ig2/C4_H8_O4.hpd +40 -0
  461. pyromat/data/ig2/C4_H9.hpd +39 -0
  462. pyromat/data/ig2/C4_N2.hpd +52 -0
  463. pyromat/data/ig2/C5.hpd +42 -0
  464. pyromat/data/ig2/C5_Fe_O5.hpd +49 -0
  465. pyromat/data/ig2/C5_H10.hpd +39 -0
  466. pyromat/data/ig2/C5_H11.hpd +39 -0
  467. pyromat/data/ig2/C5_H12.hpd +39 -0
  468. pyromat/data/ig2/C5_H6.hpd +39 -0
  469. pyromat/data/ig2/C5_H8.hpd +39 -0
  470. pyromat/data/ig2/C6_D5.hpd +39 -0
  471. pyromat/data/ig2/C6_D6.hpd +39 -0
  472. pyromat/data/ig2/C6_H10.hpd +39 -0
  473. pyromat/data/ig2/C6_H12.hpd +39 -0
  474. pyromat/data/ig2/C6_H13.hpd +39 -0
  475. pyromat/data/ig2/C6_H2.hpd +39 -0
  476. pyromat/data/ig2/C6_H5.hpd +39 -0
  477. pyromat/data/ig2/C6_H5_O.hpd +40 -0
  478. pyromat/data/ig2/C6_H6.hpd +39 -0
  479. pyromat/data/ig2/C6_H6_O.hpd +40 -0
  480. pyromat/data/ig2/C7_H14.hpd +39 -0
  481. pyromat/data/ig2/C7_H15.hpd +39 -0
  482. pyromat/data/ig2/C7_H16.hpd +39 -0
  483. pyromat/data/ig2/C7_H7.hpd +39 -0
  484. pyromat/data/ig2/C7_H8.hpd +39 -0
  485. pyromat/data/ig2/C7_H8_O.hpd +40 -0
  486. pyromat/data/ig2/C8_H10.hpd +39 -0
  487. pyromat/data/ig2/C8_H16.hpd +39 -0
  488. pyromat/data/ig2/C8_H17.hpd +39 -0
  489. pyromat/data/ig2/C8_H18.hpd +39 -0
  490. pyromat/data/ig2/C8_H8.hpd +39 -0
  491. pyromat/data/ig2/C9_H19.hpd +39 -0
  492. pyromat/data/ig2/C_Al.hpd +42 -0
  493. pyromat/data/ig2/C_Cl.hpd +43 -0
  494. pyromat/data/ig2/C_Cl2.hpd +43 -0
  495. pyromat/data/ig2/C_Cl2_F2.hpd +85 -0
  496. pyromat/data/ig2/C_Cl2_O.hpd +65 -0
  497. pyromat/data/ig2/C_Cl3.hpd +43 -0
  498. pyromat/data/ig2/C_Cl3_F.hpd +93 -0
  499. pyromat/data/ig2/C_Cl4.hpd +84 -0
  500. pyromat/data/ig2/C_Cl_F3.hpd +65 -0
  501. pyromat/data/ig2/C_Cl_F_O.hpd +52 -0
  502. pyromat/data/ig2/C_Cl_N.hpd +60 -0
  503. pyromat/data/ig2/C_Cl_O.hpd +44 -0
  504. pyromat/data/ig2/C_F+.hpd +40 -0
  505. pyromat/data/ig2/C_F.hpd +43 -0
  506. pyromat/data/ig2/C_F2+.hpd +40 -0
  507. pyromat/data/ig2/C_F2.hpd +45 -0
  508. pyromat/data/ig2/C_F2_O.hpd +60 -0
  509. pyromat/data/ig2/C_F3+.hpd +40 -0
  510. pyromat/data/ig2/C_F3.hpd +43 -0
  511. pyromat/data/ig2/C_F4.hpd +62 -0
  512. pyromat/data/ig2/C_F_N.hpd +43 -0
  513. pyromat/data/ig2/C_F_O.hpd +43 -0
  514. pyromat/data/ig2/C_H+.hpd +40 -0
  515. pyromat/data/ig2/C_H.hpd +43 -0
  516. pyromat/data/ig2/C_H2.hpd +43 -0
  517. pyromat/data/ig2/C_H2_Cl2.hpd +70 -0
  518. pyromat/data/ig2/C_H2_Cl_F.hpd +56 -0
  519. pyromat/data/ig2/C_H2_F2.hpd +40 -0
  520. pyromat/data/ig2/C_H2_O.hpd +82 -0
  521. pyromat/data/ig2/C_H2_O2.hpd +40 -0
  522. pyromat/data/ig2/C_H3.hpd +43 -0
  523. pyromat/data/ig2/C_H3_Cl.hpd +61 -0
  524. pyromat/data/ig2/C_H3_F.hpd +40 -0
  525. pyromat/data/ig2/C_H3_O.hpd +40 -0
  526. pyromat/data/ig2/C_H4.hpd +39 -0
  527. pyromat/data/ig2/C_H4_O.hpd +40 -0
  528. pyromat/data/ig2/C_H_Cl.hpd +44 -0
  529. pyromat/data/ig2/C_H_Cl2_F.hpd +65 -0
  530. pyromat/data/ig2/C_H_Cl3.hpd +65 -0
  531. pyromat/data/ig2/C_H_Cl_F2.hpd +89 -0
  532. pyromat/data/ig2/C_H_F3.hpd +65 -0
  533. pyromat/data/ig2/C_H_N.hpd +72 -0
  534. pyromat/data/ig2/C_H_N_O.hpd +45 -0
  535. pyromat/data/ig2/C_H_O+.hpd +41 -0
  536. pyromat/data/ig2/C_H_O.hpd +44 -0
  537. pyromat/data/ig2/C_H_O2.hpd +40 -0
  538. pyromat/data/ig2/C_K_N.hpd +43 -0
  539. pyromat/data/ig2/C_N+.hpd +40 -0
  540. pyromat/data/ig2/C_N-.hpd +40 -0
  541. pyromat/data/ig2/C_N.hpd +43 -0
  542. pyromat/data/ig2/C_N2.hpd +43 -0
  543. pyromat/data/ig2/C_N_Na.hpd +43 -0
  544. pyromat/data/ig2/C_N_O.hpd +40 -0
  545. pyromat/data/ig2/C_O+.hpd +40 -0
  546. pyromat/data/ig2/C_O.hpd +59 -0
  547. pyromat/data/ig2/C_O2+.hpd +40 -0
  548. pyromat/data/ig2/C_O2.hpd +61 -0
  549. pyromat/data/ig2/C_O_S.hpd +51 -0
  550. pyromat/data/ig2/C_P.hpd +43 -0
  551. pyromat/data/ig2/C_S.hpd +43 -0
  552. pyromat/data/ig2/C_S2.hpd +65 -0
  553. pyromat/data/ig2/C_Si.hpd +42 -0
  554. pyromat/data/ig2/C_Si2.hpd +42 -0
  555. pyromat/data/ig2/Ca+.hpd +39 -0
  556. pyromat/data/ig2/Ca.hpd +42 -0
  557. pyromat/data/ig2/Ca2.hpd +42 -0
  558. pyromat/data/ig2/Ca_Cl.hpd +43 -0
  559. pyromat/data/ig2/Ca_Cl2.hpd +42 -0
  560. pyromat/data/ig2/Ca_F.hpd +43 -0
  561. pyromat/data/ig2/Ca_F2.hpd +42 -0
  562. pyromat/data/ig2/Ca_I.hpd +42 -0
  563. pyromat/data/ig2/Ca_I2.hpd +42 -0
  564. pyromat/data/ig2/Ca_O.hpd +44 -0
  565. pyromat/data/ig2/Ca_S.hpd +44 -0
  566. pyromat/data/ig2/Cl+.hpd +39 -0
  567. pyromat/data/ig2/Cl-.hpd +39 -0
  568. pyromat/data/ig2/Cl.hpd +42 -0
  569. pyromat/data/ig2/Cl2.hpd +52 -0
  570. pyromat/data/ig2/Cl2_Cs2.hpd +42 -0
  571. pyromat/data/ig2/Cl2_Fe.hpd +42 -0
  572. pyromat/data/ig2/Cl2_K2.hpd +42 -0
  573. pyromat/data/ig2/Cl2_Li2.hpd +42 -0
  574. pyromat/data/ig2/Cl2_Mg.hpd +42 -0
  575. pyromat/data/ig2/Cl2_Na2.hpd +43 -0
  576. pyromat/data/ig2/Cl2_Ni.hpd +42 -0
  577. pyromat/data/ig2/Cl2_O.hpd +53 -0
  578. pyromat/data/ig2/Cl2_O2_S.hpd +45 -0
  579. pyromat/data/ig2/Cl2_O_Ti.hpd +43 -0
  580. pyromat/data/ig2/Cl2_Pb+.hpd +40 -0
  581. pyromat/data/ig2/Cl2_Pb.hpd +43 -0
  582. pyromat/data/ig2/Cl2_S+.hpd +40 -0
  583. pyromat/data/ig2/Cl2_S.hpd +54 -0
  584. pyromat/data/ig2/Cl2_S2.hpd +55 -0
  585. pyromat/data/ig2/Cl2_Si.hpd +42 -0
  586. pyromat/data/ig2/Cl2_Sr.hpd +42 -0
  587. pyromat/data/ig2/Cl2_Ti.hpd +42 -0
  588. pyromat/data/ig2/Cl3_Cu3.hpd +42 -0
  589. pyromat/data/ig2/Cl3_Fe.hpd +42 -0
  590. pyromat/data/ig2/Cl3_Li3.hpd +42 -0
  591. pyromat/data/ig2/Cl3_P.hpd +59 -0
  592. pyromat/data/ig2/Cl3_Si.hpd +43 -0
  593. pyromat/data/ig2/Cl3_Ti.hpd +42 -0
  594. pyromat/data/ig2/Cl4_Fe2.hpd +42 -0
  595. pyromat/data/ig2/Cl4_Pb.hpd +42 -0
  596. pyromat/data/ig2/Cl4_Si.hpd +59 -0
  597. pyromat/data/ig2/Cl4_Ti.hpd +54 -0
  598. pyromat/data/ig2/Cl4_V.hpd +39 -0
  599. pyromat/data/ig2/Cl6_Fe2.hpd +42 -0
  600. pyromat/data/ig2/Cl_Cs.hpd +44 -0
  601. pyromat/data/ig2/Cl_Cu.hpd +44 -0
  602. pyromat/data/ig2/Cl_D.hpd +44 -0
  603. pyromat/data/ig2/Cl_D_O.hpd +43 -0
  604. pyromat/data/ig2/Cl_F.hpd +44 -0
  605. pyromat/data/ig2/Cl_F3.hpd +42 -0
  606. pyromat/data/ig2/Cl_F_Mg.hpd +43 -0
  607. pyromat/data/ig2/Cl_F_O2_S.hpd +57 -0
  608. pyromat/data/ig2/Cl_Fe.hpd +42 -0
  609. pyromat/data/ig2/Cl_K.hpd +43 -0
  610. pyromat/data/ig2/Cl_Li.hpd +43 -0
  611. pyromat/data/ig2/Cl_Mg+.hpd +40 -0
  612. pyromat/data/ig2/Cl_Mg.hpd +43 -0
  613. pyromat/data/ig2/Cl_N_O.hpd +53 -0
  614. pyromat/data/ig2/Cl_N_O2.hpd +43 -0
  615. pyromat/data/ig2/Cl_Na.hpd +44 -0
  616. pyromat/data/ig2/Cl_Ni.hpd +44 -0
  617. pyromat/data/ig2/Cl_O.hpd +43 -0
  618. pyromat/data/ig2/Cl_O2.hpd +53 -0
  619. pyromat/data/ig2/Cl_O_Ti.hpd +43 -0
  620. pyromat/data/ig2/Cl_Pb+.hpd +40 -0
  621. pyromat/data/ig2/Cl_Pb.hpd +42 -0
  622. pyromat/data/ig2/Cl_S.hpd +43 -0
  623. pyromat/data/ig2/Cl_S2.hpd +43 -0
  624. pyromat/data/ig2/Cl_Si.hpd +43 -0
  625. pyromat/data/ig2/Cl_Sr.hpd +43 -0
  626. pyromat/data/ig2/Cl_Ti.hpd +42 -0
  627. pyromat/data/ig2/Cr.hpd +42 -0
  628. pyromat/data/ig2/Cr_N.hpd +44 -0
  629. pyromat/data/ig2/Cr_O.hpd +43 -0
  630. pyromat/data/ig2/Cr_O2.hpd +43 -0
  631. pyromat/data/ig2/Cr_O3.hpd +42 -0
  632. pyromat/data/ig2/Cs+.hpd +39 -0
  633. pyromat/data/ig2/Cs.hpd +38 -0
  634. pyromat/data/ig2/Cs2.hpd +42 -0
  635. pyromat/data/ig2/Cs2_F2.hpd +42 -0
  636. pyromat/data/ig2/Cs2_O.hpd +42 -0
  637. pyromat/data/ig2/Cs2_O4_S.hpd +43 -0
  638. pyromat/data/ig2/Cs_F.hpd +44 -0
  639. pyromat/data/ig2/Cs_O.hpd +43 -0
  640. pyromat/data/ig2/Cu+.hpd +39 -0
  641. pyromat/data/ig2/Cu.hpd +38 -0
  642. pyromat/data/ig2/Cu2.hpd +42 -0
  643. pyromat/data/ig2/Cu_F.hpd +43 -0
  644. pyromat/data/ig2/Cu_F2.hpd +42 -0
  645. pyromat/data/ig2/Cu_O.hpd +44 -0
  646. pyromat/data/ig2/D+.hpd +39 -0
  647. pyromat/data/ig2/D-.hpd +39 -0
  648. pyromat/data/ig2/D.hpd +38 -0
  649. pyromat/data/ig2/D2+.hpd +39 -0
  650. pyromat/data/ig2/D2-.hpd +39 -0
  651. pyromat/data/ig2/D2.hpd +44 -0
  652. pyromat/data/ig2/D2_N.hpd +42 -0
  653. pyromat/data/ig2/D2_N2.hpd +43 -0
  654. pyromat/data/ig2/D2_O.hpd +43 -0
  655. pyromat/data/ig2/D2_S.hpd +42 -0
  656. pyromat/data/ig2/D3_N.hpd +43 -0
  657. pyromat/data/ig2/D_F.hpd +44 -0
  658. pyromat/data/ig2/D_N.hpd +43 -0
  659. pyromat/data/ig2/D_O.hpd +43 -0
  660. pyromat/data/ig2/D_S.hpd +43 -0
  661. pyromat/data/ig2/F+.hpd +39 -0
  662. pyromat/data/ig2/F-.hpd +39 -0
  663. pyromat/data/ig2/F.hpd +42 -0
  664. pyromat/data/ig2/F2.hpd +42 -0
  665. pyromat/data/ig2/F2_K-.hpd +40 -0
  666. pyromat/data/ig2/F2_K2.hpd +42 -0
  667. pyromat/data/ig2/F2_Li-.hpd +40 -0
  668. pyromat/data/ig2/F2_Li2.hpd +42 -0
  669. pyromat/data/ig2/F2_Mg+.hpd +40 -0
  670. pyromat/data/ig2/F2_Mg.hpd +43 -0
  671. pyromat/data/ig2/F2_N.hpd +43 -0
  672. pyromat/data/ig2/F2_N2.hpd +53 -0
  673. pyromat/data/ig2/F2_Na-.hpd +40 -0
  674. pyromat/data/ig2/F2_Na2.hpd +42 -0
  675. pyromat/data/ig2/F2_O.hpd +52 -0
  676. pyromat/data/ig2/F2_O2_S.hpd +56 -0
  677. pyromat/data/ig2/F2_O_S.hpd +51 -0
  678. pyromat/data/ig2/F2_P+.hpd +40 -0
  679. pyromat/data/ig2/F2_P.hpd +43 -0
  680. pyromat/data/ig2/F2_Pb.hpd +42 -0
  681. pyromat/data/ig2/F2_S+.hpd +40 -0
  682. pyromat/data/ig2/F2_S-.hpd +40 -0
  683. pyromat/data/ig2/F2_S.hpd +43 -0
  684. pyromat/data/ig2/F2_S2.hpd +43 -0
  685. pyromat/data/ig2/F2_Si.hpd +43 -0
  686. pyromat/data/ig2/F2_Sr.hpd +42 -0
  687. pyromat/data/ig2/F3_Li3.hpd +39 -0
  688. pyromat/data/ig2/F3_N.hpd +50 -0
  689. pyromat/data/ig2/F3_N_O.hpd +51 -0
  690. pyromat/data/ig2/F3_P.hpd +50 -0
  691. pyromat/data/ig2/F3_S+.hpd +40 -0
  692. pyromat/data/ig2/F3_S-.hpd +40 -0
  693. pyromat/data/ig2/F3_S.hpd +43 -0
  694. pyromat/data/ig2/F3_Si.hpd +43 -0
  695. pyromat/data/ig2/F4_Mg2.hpd +42 -0
  696. pyromat/data/ig2/F4_N2.hpd +50 -0
  697. pyromat/data/ig2/F4_Pb.hpd +42 -0
  698. pyromat/data/ig2/F4_S+.hpd +40 -0
  699. pyromat/data/ig2/F4_S-.hpd +40 -0
  700. pyromat/data/ig2/F4_S.hpd +50 -0
  701. pyromat/data/ig2/F4_Si.hpd +49 -0
  702. pyromat/data/ig2/F5_P.hpd +48 -0
  703. pyromat/data/ig2/F5_S+.hpd +40 -0
  704. pyromat/data/ig2/F5_S-.hpd +40 -0
  705. pyromat/data/ig2/F5_S.hpd +43 -0
  706. pyromat/data/ig2/F6_S-.hpd +40 -0
  707. pyromat/data/ig2/F6_S.hpd +51 -0
  708. pyromat/data/ig2/F_K.hpd +43 -0
  709. pyromat/data/ig2/F_Li.hpd +43 -0
  710. pyromat/data/ig2/F_Li_O.hpd +44 -0
  711. pyromat/data/ig2/F_Mg+.hpd +40 -0
  712. pyromat/data/ig2/F_Mg.hpd +43 -0
  713. pyromat/data/ig2/F_N.hpd +43 -0
  714. pyromat/data/ig2/F_N_O.hpd +44 -0
  715. pyromat/data/ig2/F_N_O2.hpd +43 -0
  716. pyromat/data/ig2/F_N_O3.hpd +44 -0
  717. pyromat/data/ig2/F_Na.hpd +43 -0
  718. pyromat/data/ig2/F_O.hpd +43 -0
  719. pyromat/data/ig2/F_O2.hpd +39 -0
  720. pyromat/data/ig2/F_P+.hpd +40 -0
  721. pyromat/data/ig2/F_P-.hpd +40 -0
  722. pyromat/data/ig2/F_P.hpd +43 -0
  723. pyromat/data/ig2/F_Pb.hpd +42 -0
  724. pyromat/data/ig2/F_S+.hpd +40 -0
  725. pyromat/data/ig2/F_S-.hpd +40 -0
  726. pyromat/data/ig2/F_S.hpd +43 -0
  727. pyromat/data/ig2/F_Si.hpd +44 -0
  728. pyromat/data/ig2/F_Sr+.hpd +40 -0
  729. pyromat/data/ig2/F_Sr.hpd +43 -0
  730. pyromat/data/ig2/Fe+.hpd +39 -0
  731. pyromat/data/ig2/Fe-.hpd +39 -0
  732. pyromat/data/ig2/Fe.hpd +42 -0
  733. pyromat/data/ig2/Fe_O.hpd +44 -0
  734. pyromat/data/ig2/H+.hpd +39 -0
  735. pyromat/data/ig2/H-.hpd +39 -0
  736. pyromat/data/ig2/H.hpd +38 -0
  737. pyromat/data/ig2/H2+.hpd +39 -0
  738. pyromat/data/ig2/H2-.hpd +39 -0
  739. pyromat/data/ig2/H2.hpd +49 -0
  740. pyromat/data/ig2/H2_B.hpd +39 -0
  741. pyromat/data/ig2/H2_Ba_O2.hpd +40 -0
  742. pyromat/data/ig2/H2_Be_O2.hpd +40 -0
  743. pyromat/data/ig2/H2_Br2_Si.hpd +40 -0
  744. pyromat/data/ig2/H2_Ca_O2.hpd +40 -0
  745. pyromat/data/ig2/H2_Cl2_Si.hpd +40 -0
  746. pyromat/data/ig2/H2_Cs2_O2.hpd +40 -0
  747. pyromat/data/ig2/H2_F2.hpd +39 -0
  748. pyromat/data/ig2/H2_F2_Si.hpd +40 -0
  749. pyromat/data/ig2/H2_F_N.hpd +40 -0
  750. pyromat/data/ig2/H2_Fe_O2.hpd +40 -0
  751. pyromat/data/ig2/H2_I2_Si.hpd +44 -0
  752. pyromat/data/ig2/H2_K2_O2.hpd +43 -0
  753. pyromat/data/ig2/H2_Li2_O2.hpd +44 -0
  754. pyromat/data/ig2/H2_Mg_O2.hpd +43 -0
  755. pyromat/data/ig2/H2_N.hpd +43 -0
  756. pyromat/data/ig2/H2_N2.hpd +42 -0
  757. pyromat/data/ig2/H2_N2_O2.hpd +40 -0
  758. pyromat/data/ig2/H2_Na2_O2.hpd +44 -0
  759. pyromat/data/ig2/H2_O+.hpd +40 -0
  760. pyromat/data/ig2/H2_O.hpd +50 -0
  761. pyromat/data/ig2/H2_O2.hpd +43 -0
  762. pyromat/data/ig2/H2_O2_Sr.hpd +44 -0
  763. pyromat/data/ig2/H2_O4_S.hpd +68 -0
  764. pyromat/data/ig2/H2_S.hpd +65 -0
  765. pyromat/data/ig2/H2_Si.hpd +39 -0
  766. pyromat/data/ig2/H3_B.hpd +39 -0
  767. pyromat/data/ig2/H3_B3_O3.hpd +40 -0
  768. pyromat/data/ig2/H3_B3_O6.hpd +40 -0
  769. pyromat/data/ig2/H3_Br_Si.hpd +40 -0
  770. pyromat/data/ig2/H3_Cl_Si.hpd +40 -0
  771. pyromat/data/ig2/H3_F3.hpd +39 -0
  772. pyromat/data/ig2/H3_F_Si.hpd +40 -0
  773. pyromat/data/ig2/H3_I_Si.hpd +44 -0
  774. pyromat/data/ig2/H3_N.hpd +50 -0
  775. pyromat/data/ig2/H3_N_O.hpd +40 -0
  776. pyromat/data/ig2/H3_O+.hpd +40 -0
  777. pyromat/data/ig2/H3_P.hpd +54 -0
  778. pyromat/data/ig2/H3_Si.hpd +39 -0
  779. pyromat/data/ig2/H4_F4.hpd +39 -0
  780. pyromat/data/ig2/H4_N+.hpd +40 -0
  781. pyromat/data/ig2/H4_N2.hpd +52 -0
  782. pyromat/data/ig2/H4_Si.hpd +50 -0
  783. pyromat/data/ig2/H5_F5.hpd +39 -0
  784. pyromat/data/ig2/H6_F6.hpd +39 -0
  785. pyromat/data/ig2/H7_F7.hpd +39 -0
  786. pyromat/data/ig2/H_Al.hpd +39 -0
  787. pyromat/data/ig2/H_Al_O+.hpd +41 -0
  788. pyromat/data/ig2/H_Al_O-.hpd +41 -0
  789. pyromat/data/ig2/H_Al_O.hpd +40 -0
  790. pyromat/data/ig2/H_Al_O2.hpd +40 -0
  791. pyromat/data/ig2/H_B.hpd +39 -0
  792. pyromat/data/ig2/H_B_F2.hpd +40 -0
  793. pyromat/data/ig2/H_B_O+.hpd +41 -0
  794. pyromat/data/ig2/H_B_O-.hpd +41 -0
  795. pyromat/data/ig2/H_B_O.hpd +40 -0
  796. pyromat/data/ig2/H_B_O2.hpd +40 -0
  797. pyromat/data/ig2/H_B_S+.hpd +41 -0
  798. pyromat/data/ig2/H_B_S.hpd +40 -0
  799. pyromat/data/ig2/H_Ba_O+.hpd +41 -0
  800. pyromat/data/ig2/H_Ba_O.hpd +40 -0
  801. pyromat/data/ig2/H_Be+.hpd +40 -0
  802. pyromat/data/ig2/H_Be.hpd +39 -0
  803. pyromat/data/ig2/H_Be_O+.hpd +41 -0
  804. pyromat/data/ig2/H_Be_O.hpd +40 -0
  805. pyromat/data/ig2/H_Br.hpd +39 -0
  806. pyromat/data/ig2/H_Br3_Si.hpd +40 -0
  807. pyromat/data/ig2/H_Ca_O+.hpd +41 -0
  808. pyromat/data/ig2/H_Ca_O.hpd +40 -0
  809. pyromat/data/ig2/H_Cl.hpd +39 -0
  810. pyromat/data/ig2/H_Cl3_Si.hpd +40 -0
  811. pyromat/data/ig2/H_Cl_O.hpd +40 -0
  812. pyromat/data/ig2/H_Cs_O+.hpd +41 -0
  813. pyromat/data/ig2/H_Cs_O.hpd +40 -0
  814. pyromat/data/ig2/H_D+.hpd +40 -0
  815. pyromat/data/ig2/H_D-.hpd +40 -0
  816. pyromat/data/ig2/H_D.hpd +39 -0
  817. pyromat/data/ig2/H_D_O.hpd +40 -0
  818. pyromat/data/ig2/H_F.hpd +39 -0
  819. pyromat/data/ig2/H_F2_N.hpd +40 -0
  820. pyromat/data/ig2/H_F3_Si.hpd +40 -0
  821. pyromat/data/ig2/H_F_N.hpd +40 -0
  822. pyromat/data/ig2/H_F_O.hpd +40 -0
  823. pyromat/data/ig2/H_F_O3_S.hpd +41 -0
  824. pyromat/data/ig2/H_I.hpd +43 -0
  825. pyromat/data/ig2/H_I3_Si.hpd +44 -0
  826. pyromat/data/ig2/H_K.hpd +43 -0
  827. pyromat/data/ig2/H_K_O+.hpd +41 -0
  828. pyromat/data/ig2/H_K_O.hpd +44 -0
  829. pyromat/data/ig2/H_Li.hpd +43 -0
  830. pyromat/data/ig2/H_Li_O+.hpd +41 -0
  831. pyromat/data/ig2/H_Li_O.hpd +43 -0
  832. pyromat/data/ig2/H_Mg.hpd +43 -0
  833. pyromat/data/ig2/H_Mg_O+.hpd +41 -0
  834. pyromat/data/ig2/H_Mg_O.hpd +44 -0
  835. pyromat/data/ig2/H_N+.hpd +40 -0
  836. pyromat/data/ig2/H_N.hpd +43 -0
  837. pyromat/data/ig2/H_N3.hpd +39 -0
  838. pyromat/data/ig2/H_N_O.hpd +44 -0
  839. pyromat/data/ig2/H_N_O2.hpd +40 -0
  840. pyromat/data/ig2/H_N_O3.hpd +44 -0
  841. pyromat/data/ig2/H_Na.hpd +43 -0
  842. pyromat/data/ig2/H_Na_O+.hpd +41 -0
  843. pyromat/data/ig2/H_Na_O.hpd +44 -0
  844. pyromat/data/ig2/H_O+.hpd +40 -0
  845. pyromat/data/ig2/H_O-.hpd +40 -0
  846. pyromat/data/ig2/H_O.hpd +43 -0
  847. pyromat/data/ig2/H_O2.hpd +43 -0
  848. pyromat/data/ig2/H_O_Sr+.hpd +41 -0
  849. pyromat/data/ig2/H_O_Sr.hpd +44 -0
  850. pyromat/data/ig2/H_P.hpd +43 -0
  851. pyromat/data/ig2/H_S.hpd +43 -0
  852. pyromat/data/ig2/H_Si+.hpd +40 -0
  853. pyromat/data/ig2/H_Si.hpd +43 -0
  854. pyromat/data/ig2/He+.hpd +39 -0
  855. pyromat/data/ig2/He.hpd +38 -0
  856. pyromat/data/ig2/Hg.hpd +42 -0
  857. pyromat/data/ig2/I.hpd +42 -0
  858. pyromat/data/ig2/I2.hpd +57 -0
  859. pyromat/data/ig2/I2_Mg.hpd +42 -0
  860. pyromat/data/ig2/I2_Pb.hpd +42 -0
  861. pyromat/data/ig2/I2_Si.hpd +43 -0
  862. pyromat/data/ig2/I2_Sr.hpd +42 -0
  863. pyromat/data/ig2/I4_Pb.hpd +42 -0
  864. pyromat/data/ig2/I_Mg.hpd +42 -0
  865. pyromat/data/ig2/I_Na.hpd +39 -0
  866. pyromat/data/ig2/I_Pb.hpd +42 -0
  867. pyromat/data/ig2/I_Si.hpd +43 -0
  868. pyromat/data/ig2/K+.hpd +39 -0
  869. pyromat/data/ig2/K.hpd +42 -0
  870. pyromat/data/ig2/K2.hpd +42 -0
  871. pyromat/data/ig2/K2_O4_S.hpd +43 -0
  872. pyromat/data/ig2/K_O-.hpd +40 -0
  873. pyromat/data/ig2/K_O.hpd +43 -0
  874. pyromat/data/ig2/Kr+.hpd +39 -0
  875. pyromat/data/ig2/Kr.hpd +38 -0
  876. pyromat/data/ig2/Li+.hpd +39 -0
  877. pyromat/data/ig2/Li.hpd +42 -0
  878. pyromat/data/ig2/Li2.hpd +42 -0
  879. pyromat/data/ig2/Li2_O.hpd +44 -0
  880. pyromat/data/ig2/Li2_O2.hpd +42 -0
  881. pyromat/data/ig2/Li2_O4_S.hpd +43 -0
  882. pyromat/data/ig2/Li_N.hpd +43 -0
  883. pyromat/data/ig2/Li_N_O.hpd +43 -0
  884. pyromat/data/ig2/Li_O-.hpd +40 -0
  885. pyromat/data/ig2/Li_O.hpd +43 -0
  886. pyromat/data/ig2/Mg+.hpd +39 -0
  887. pyromat/data/ig2/Mg.hpd +42 -0
  888. pyromat/data/ig2/Mg2.hpd +42 -0
  889. pyromat/data/ig2/Mg_N.hpd +42 -0
  890. pyromat/data/ig2/Mg_O.hpd +44 -0
  891. pyromat/data/ig2/Mg_S.hpd +44 -0
  892. pyromat/data/ig2/Mo2_O6.hpd +39 -0
  893. pyromat/data/ig2/Mo3_O9.hpd +39 -0
  894. pyromat/data/ig2/Mo4_O12.hpd +39 -0
  895. pyromat/data/ig2/Mo5_O15.hpd +39 -0
  896. pyromat/data/ig2/Mo_O3.hpd +42 -0
  897. pyromat/data/ig2/N+.hpd +39 -0
  898. pyromat/data/ig2/N-.hpd +39 -0
  899. pyromat/data/ig2/N.hpd +42 -0
  900. pyromat/data/ig2/N2+.hpd +39 -0
  901. pyromat/data/ig2/N2-.hpd +39 -0
  902. pyromat/data/ig2/N2.hpd +50 -0
  903. pyromat/data/ig2/N2_O+.hpd +40 -0
  904. pyromat/data/ig2/N2_O.hpd +55 -0
  905. pyromat/data/ig2/N2_O3.hpd +43 -0
  906. pyromat/data/ig2/N2_O4.hpd +44 -0
  907. pyromat/data/ig2/N2_O5.hpd +44 -0
  908. pyromat/data/ig2/N3.hpd +38 -0
  909. pyromat/data/ig2/N_O+.hpd +40 -0
  910. pyromat/data/ig2/N_O.hpd +50 -0
  911. pyromat/data/ig2/N_O2-.hpd +40 -0
  912. pyromat/data/ig2/N_O2.hpd +52 -0
  913. pyromat/data/ig2/N_O3-.hpd +40 -0
  914. pyromat/data/ig2/N_O3.hpd +44 -0
  915. pyromat/data/ig2/N_S.hpd +43 -0
  916. pyromat/data/ig2/N_Si.hpd +43 -0
  917. pyromat/data/ig2/N_Si2.hpd +42 -0
  918. pyromat/data/ig2/N_V.hpd +44 -0
  919. pyromat/data/ig2/N_Zr.hpd +39 -0
  920. pyromat/data/ig2/Na+.hpd +39 -0
  921. pyromat/data/ig2/Na.hpd +42 -0
  922. pyromat/data/ig2/Na2.hpd +42 -0
  923. pyromat/data/ig2/Na2_O.hpd +39 -0
  924. pyromat/data/ig2/Na2_O4_S.hpd +47 -0
  925. pyromat/data/ig2/Na_O-.hpd +40 -0
  926. pyromat/data/ig2/Na_O.hpd +44 -0
  927. pyromat/data/ig2/Nb.hpd +38 -0
  928. pyromat/data/ig2/Nb_O.hpd +44 -0
  929. pyromat/data/ig2/Nb_O2.hpd +44 -0
  930. pyromat/data/ig2/Ne+.hpd +39 -0
  931. pyromat/data/ig2/Ne.hpd +38 -0
  932. pyromat/data/ig2/Ni.hpd +42 -0
  933. pyromat/data/ig2/Ni_O.hpd +39 -0
  934. pyromat/data/ig2/Ni_S.hpd +39 -0
  935. pyromat/data/ig2/O+.hpd +39 -0
  936. pyromat/data/ig2/O-.hpd +39 -0
  937. pyromat/data/ig2/O.hpd +38 -0
  938. pyromat/data/ig2/O10_P4.hpd +39 -0
  939. pyromat/data/ig2/O2+.hpd +39 -0
  940. pyromat/data/ig2/O2-.hpd +39 -0
  941. pyromat/data/ig2/O2.hpd +50 -0
  942. pyromat/data/ig2/O2_P.hpd +43 -0
  943. pyromat/data/ig2/O2_S.hpd +58 -0
  944. pyromat/data/ig2/O2_Si.hpd +49 -0
  945. pyromat/data/ig2/O2_Ta.hpd +43 -0
  946. pyromat/data/ig2/O2_Ti.hpd +45 -0
  947. pyromat/data/ig2/O2_V.hpd +43 -0
  948. pyromat/data/ig2/O2_Zr.hpd +42 -0
  949. pyromat/data/ig2/O3.hpd +42 -0
  950. pyromat/data/ig2/O3_S.hpd +44 -0
  951. pyromat/data/ig2/O_P.hpd +43 -0
  952. pyromat/data/ig2/O_Pb.hpd +39 -0
  953. pyromat/data/ig2/O_S.hpd +43 -0
  954. pyromat/data/ig2/O_S2.hpd +43 -0
  955. pyromat/data/ig2/O_Si.hpd +43 -0
  956. pyromat/data/ig2/O_Sr.hpd +44 -0
  957. pyromat/data/ig2/O_Ta.hpd +43 -0
  958. pyromat/data/ig2/O_Ti.hpd +44 -0
  959. pyromat/data/ig2/O_V.hpd +44 -0
  960. pyromat/data/ig2/O_Zr.hpd +44 -0
  961. pyromat/data/ig2/P+.hpd +39 -0
  962. pyromat/data/ig2/P.hpd +44 -0
  963. pyromat/data/ig2/P2.hpd +42 -0
  964. pyromat/data/ig2/P4.hpd +41 -0
  965. pyromat/data/ig2/Pb.hpd +38 -0
  966. pyromat/data/ig2/Pb2.hpd +41 -0
  967. pyromat/data/ig2/Pb_S.hpd +44 -0
  968. pyromat/data/ig2/S+.hpd +39 -0
  969. pyromat/data/ig2/S-.hpd +39 -0
  970. pyromat/data/ig2/S.hpd +45 -0
  971. pyromat/data/ig2/S2.hpd +42 -0
  972. pyromat/data/ig2/S8.hpd +54 -0
  973. pyromat/data/ig2/S_Si.hpd +43 -0
  974. pyromat/data/ig2/S_Sr.hpd +44 -0
  975. pyromat/data/ig2/Si+.hpd +39 -0
  976. pyromat/data/ig2/Si.hpd +42 -0
  977. pyromat/data/ig2/Si2.hpd +42 -0
  978. pyromat/data/ig2/Si3.hpd +43 -0
  979. pyromat/data/ig2/Sr.hpd +42 -0
  980. pyromat/data/ig2/Ta.hpd +42 -0
  981. pyromat/data/ig2/Ti+.hpd +39 -0
  982. pyromat/data/ig2/Ti-.hpd +39 -0
  983. pyromat/data/ig2/Ti.hpd +42 -0
  984. pyromat/data/ig2/V.hpd +42 -0
  985. pyromat/data/ig2/Xe+.hpd +39 -0
  986. pyromat/data/ig2/Xe.hpd +38 -0
  987. pyromat/data/ig2/Zn-.hpd +39 -0
  988. pyromat/data/ig2/Zn.hpd +42 -0
  989. pyromat/data/ig2/Zr.hpd +42 -0
  990. pyromat/data/ig2/e.hpd +38 -0
  991. pyromat/data/igmix/air.hpd +12 -0
  992. pyromat/data/igmix/f5.hpd +10 -0
  993. pyromat/data/igmix/h35.hpd +10 -0
  994. pyromat/data/mp/C2_H2_F4.hpd +332 -0
  995. pyromat/data/mp/C3_H2_F4_1.hpd +373 -0
  996. pyromat/data/mp/C_H4.hpd +454 -0
  997. pyromat/data/mp/C_O2.hpd +512 -0
  998. pyromat/data/mp/H2_O.hpd +592 -0
  999. pyromat/data/mp/N2.hpd +434 -0
  1000. pyromat/data/mp/O2.hpd +381 -0
  1001. pyromat/igtools.py +1800 -0
  1002. pyromat/reg.py +379 -0
  1003. pyromat/registry/_example.py +85 -0
  1004. pyromat/registry/if97.py +2278 -0
  1005. pyromat/registry/ig.py +1931 -0
  1006. pyromat/registry/ig2.py +1400 -0
  1007. pyromat/registry/igmix.py +1230 -0
  1008. pyromat/registry/mp1.py +4460 -0
  1009. pyromat/units.py +617 -0
  1010. pyromat/utility.py +841 -0
@@ -0,0 +1,4460 @@
1
+ # MP1
2
+ # PYroMat Multi-phase generalist class
3
+ # Calculates physical properties from a fit for the helmholtz free
4
+ # energy in terms of density and temperature.
5
+
6
+
7
+ import numpy as np
8
+ import pyromat as pm
9
+ import os,sys
10
+
11
+
12
+ class mp1(pm.reg.__basedata__):
13
+ """The PYroMat multi-phase generalist class 1
14
+
15
+ ** Available Property Methods **
16
+ MP1 provides property methods:
17
+ cp() Isobaric specific heat
18
+ cv() Isochoric specific heat
19
+ gam() Specific heat ratio
20
+ e() Internal energy
21
+ f() Free (Helmholtz) energy
22
+ g() Gibbs energy
23
+ h() Enthalpy
24
+ s() Entropy
25
+ T() Temperature
26
+ p() Pressure
27
+ d() Density
28
+ v() Specific volume
29
+ x() Quality
30
+ state() Calculates all properties
31
+
32
+ All of the above methods accept a standardized call signature, which
33
+ accepts any of the following arguments: T, p, d, v, e, h, s, x
34
+
35
+ For example, enthalpy might be called
36
+ h(T=300., p=1.01325)
37
+ h(T=300., d=990.)
38
+ h(T=300., x=0.5)
39
+ h(s=6., p=2.5)
40
+
41
+ In the back end, all properties are calculated from temperature and density,
42
+ so providing this interface flexibility has a numerical cost. Once T and d
43
+ are known, additional property evaluations should always be made in terms
44
+ of them.
45
+
46
+ Most property pairs are supported, but several are not. For example, e,
47
+ s, and h must be specified with a "basic" property; T, d, p, v, or x.
48
+ This limitation is to prevent the costly numerical iteration that occurs
49
+ when two "higher" properties need to be simultaneously inverted.
50
+
51
+ Furthermore, since it is impossible to specify a saturated mixture with
52
+ temperature and pressure alone, there is a special case, which permits
53
+ three properties: T, p, x. When x is negative, it is ignored, but for all
54
+ points where it is between 0 and 1, pressure is ignored, and presumed to
55
+ be the saturation pressure at the specified temperature. For performance
56
+ reasons, this condition is not tested, so if it is violated, an error will
57
+ not be raised.
58
+
59
+ Most property methods also accept the "quality" as an optional keyword. When
60
+ it is set to True, the property will also return the vapor/liquid mixture
61
+ quality in a tuple with the property value. For example,
62
+ h,x = h(T,d,quality=True)
63
+
64
+ ** Saturation Properties **
65
+ There are also saturation property methods:
66
+ es() Saturation internal energy
67
+ hs() Saturation enthalpy
68
+ ss() Saturation entropy
69
+
70
+ And saturation equations of state methods:
71
+ Ts() Saturaiton temperature
72
+ ds() Saturation densities
73
+ vs() Saturation specific volumes
74
+ ps() Saturation pressure
75
+
76
+ Saturation methods accept either temperature or pressure as an argument.
77
+ The density saturation method returns both liquid and vapor densities in a
78
+ tuple pair. See their in-line documentaiton for more details.
79
+
80
+ ** Other Properties **
81
+ There are other methods that return useful information, but that do
82
+ not depend on the state.
83
+ atoms() Returns a dictionary specifying the chemical composition.
84
+ mw() Returns the molecular weight/mass
85
+ R() Returns the ideal gas constant
86
+ Tlim() Returns [Tmin, Tmax] valid temperature range
87
+ plim() Returns [pmin, pmax] valid pressure range
88
+ critical() Returns the state at the critical point
89
+ triple() Returns the state at the triple point
90
+
91
+ ** Depreciated Properties **
92
+ As of version 2.2.0, inverse routines like T_s(), T_h(), d_s(), and the
93
+ hsd() have been labeled as "depreciated" in favor of the standard property
94
+ methods, which are now sufficiently flexible to handle s and h as
95
+ arguments. These methods are still included for reverse compatibility,
96
+ but they will be removed when the major version bumps to 3. Future
97
+ software should not use them.
98
+
99
+ *** MORE DOCUMENTATION ***
100
+ MP1 models thermo-physical properties of a liquid-gas system using a
101
+ general fit for helmholtz free energy. These "Span & Wagner" fits are
102
+ evaluated in a polynomial form with exponential post factors.
103
+
104
+ The MP1 class is divided into three layers of methods (routines).
105
+
106
+ --- USER ROUTINES ---
107
+ Accept data in any format (array or scalar) and in whatever units are
108
+ configured in the PYroMat configuration object. These routines rely on
109
+ _argparse and _sat_argparse to standardize their call signatures, to
110
+ convert to the correct units, and to enforce that all inner routines
111
+ receive correctly broadcast ndarray objects.
112
+
113
+ Values from these methods are returned in appropriately broadcast arrays
114
+ in the correctly configured units.
115
+
116
+ --- INNER ROUTINES ---
117
+ These methods presume that all arguments are numpy arrays and that they
118
+ are in a common unit system. This prevents redundant calls to the unit
119
+ conversion functions as MP1 methods call one another.
120
+ Energy: J
121
+ Matter kg
122
+ Pressure: Pa
123
+ Temperature:K
124
+
125
+ Inner routines begin with a "_" to emphasize that they are not part of
126
+ the standard interface. Most property functions are wrappers for inner
127
+ routine property functions, so they may call each other when needed.
128
+ Inner routine property functions (like _h, _s, _p, etc...) have standard
129
+ call signatures that require temperature and density, and return the
130
+ property and its derivatives to temperature and density.
131
+
132
+ VERY rarely, these routines might be called by the user. They are
133
+ faster than the user routines because they do not have the overhead of
134
+ unit conversions, array broadcasting, and call signature conversion, but
135
+ they have stringent requirements on the format of data. Users should
136
+ beware.
137
+
138
+ 1) All arguments must be a numpy NDARRAY object of dimension 1 or
139
+ greater.
140
+ 2) Array broadcasting must be done BEFORE passing arguments to the inner
141
+ routines.
142
+ 3) The above units MUST be respected regardless of PYroMat's settings.
143
+ 4) Many of these functions also return their derivatives to facilitate
144
+ numerical inversion. Check the documentation to verify the call
145
+ signature of each inner routine BEFORE implementing it in your code.
146
+
147
+ --- PRIMATIVE ROUTINES ---
148
+ Methods that have been labeled as primative routines should UNDER NO
149
+ CIRCUMSTANCES be called by the user. They accept non-dimensionalized
150
+ arguments and return non-dimensional parameters. These are encapsulated
151
+ as independent methods either because they are complicated and need to
152
+ be called by a number of other methods, or because separating them made
153
+ sense for numerical efficiency. In summary: these aren't the methods
154
+ you're looking for.
155
+
156
+ --- DATA DICTIONARY ---
157
+ The MP1 data dictionary must have certain data "groups" to define the
158
+ various empirical fits. Each group is a dictionary (within the
159
+ dictionary) that defines the various parameters necessary for at least
160
+ one of the inner methods.
161
+
162
+ PSgroup Saturated pressure data group
163
+ Tscale Temperature scale for normalizing T in the fit
164
+ pscale Pressure scale for re-scaling the result
165
+ coef a coefficient group to be passed to _satfit()
166
+ fn An integer index identifying the fit form to use
167
+ (see the _satfit method for details)
168
+
169
+ DSLgroup Saturated liquid density data group
170
+ Tscale Temperature scale for normalizing T in the fit
171
+ dscale Density scale for re-scaling the result
172
+ coef a coefficient group to be passed to _poly1()
173
+ fn An integer index identifying the fit form to use
174
+ (see the _satfit method for details)
175
+
176
+ DSVgroup Saturated vapor density data group; a dict containing:
177
+ Tscale Temperature scale for normalizing T in the fit
178
+ dscale Density scale for re-scaling the result
179
+ coef a coefficient group to be passed to _poly1()
180
+ fn An integer index identifying the fit form to use
181
+ (see the _satfit method for details)
182
+
183
+ AOgroup Helmholtz free energy ideal gas group; a dict containing:
184
+ Tscale Temperature scale for normalizing T
185
+ dscale density scale for normalizing d
186
+ logt a scalar coefficient of a log(tt) term
187
+ coef0 a coefficient list to be passed to _poly1() to build p0 below
188
+ coef1 a simple Nx2 coefficient list used to build q(tt) below
189
+ If tt = Tscale/T <=== INVERSE!
190
+ and dd = d/dscale
191
+ ao = log(d) + LOGT*log(tt) + TLOGT*tt*log(tt) + p0(tt) + q(tt)
192
+ q(tt) = sum_k coef1[k,1] * log(1 - exp(-tt*coef[k,0]))
193
+ Ao = ao * R * T
194
+ where LOGT is the coefficient defined by the 'logt' parameter, and p is
195
+ the polynomial defined by the coef list
196
+
197
+ ARgroup Helmholtz free energy residual group; a dict containing:
198
+ Tscale Temperature scale for normalizing T
199
+ dscale density scale for normalizing d
200
+ coef0 a nested list of coefficient lists
201
+ coef1 an optional nested list of coefficients
202
+ coef2 an optional nested list of coefficients
203
+
204
+ The Tscale and dscale are used to non-dimensionalize temperature and
205
+ density.
206
+ tt = Tscale/T <=== INVERSE!
207
+ dd = d/dscale
208
+
209
+ Each element of coef0 is, itself a coefficient list intended to be
210
+ passed to _poly2(). After the first element, each individual polynomial
211
+ is multiplied by exp(-dd**k) where k is the index in the coef list.
212
+ ar0 = p0(tt,dd) + exp(-dd)*p1(tt,dd) + exp(-dd**2)*p2(tt,dd) + ...
213
+ Ar0 = ar0 * R * T
214
+
215
+ coef1 is an optional list of lists of coefficients forming a matrix
216
+ [...
217
+ [ t, d, b, a, gam, ep, c ], ...
218
+ ]
219
+ ar1 = c * dd**d * tt**t * exp(-a*(dd-ep)**2 - b*(tt-gam)**2) + ...
220
+ Ar1 = ar1 * R * T
221
+ If coef1 is defined it will be combined with the other coefficients
222
+ to form the residual. If coef1 is not defined, it will be ignored.
223
+
224
+ coef2 is an optional list of lists of coefficients forming a matrix
225
+ [...
226
+ [ a, b, m, A, B, C, D, c ], ...
227
+ ]
228
+ X = ((1-tt) + A*((dd-1)**2)**(0.5/m))**2 + B*((dd-1)**2)**a
229
+ ar2 = c * X**b * d * exp(-C*(dd-1)**2 - D*(tt-1)**2) + ...
230
+ Ar2 = ar2 * R * T
231
+
232
+ Additionally, there are a number of parameters that define static
233
+ properties
234
+
235
+ Tlim A two-element list of the upper and lower temperatures
236
+ for which the data set is valid.
237
+ plim A two-element list of the upper and lower pressures for
238
+ which the data set is valid.
239
+ dlim A two-element list the represent practical maximum and
240
+ minimum densities over the entire data set. These are
241
+ NOT guaranteed limits of validity.
242
+ Tc, pc, dc Critical temperature, pressure, and density
243
+ Tt, pt Triple-point temperature and pressure
244
+ R Ideal gas constant 8.314 / mw
245
+ mw Molecular weight
246
+ atoms A dictionary with a key for each atom and a value for
247
+ its count in the molecule. For example, CO2 would
248
+ have content = {'C':1, 'O':2}
249
+
250
+ There are also the typical mandatory PYroMat meta data elements:
251
+ id What substance is this?
252
+ doc Where did it come from?
253
+ class What class should be used to evaluate the data?
254
+ """
255
+
256
+
257
+ def _test(self, tab, sattab, report=None, basic=False):
258
+ """Test the MP1 class model
259
+ _test(tab, sattab) # Prints to stdout
260
+ OR
261
+ _test(tab, sattab, report_file='/path/to/report') # Prints to a file
262
+ OR
263
+ _test(tab, sattab, report_file=open_file_descriptor) # Prints to a file
264
+
265
+ tab and sattab are nested lists or 2D numpy arrays forming tables of "truth"
266
+ data used for validation of the core data and property methods.
267
+
268
+ If the optional "basic" keyword is set to True, only the data integrity checks
269
+ are completed (see below).
270
+
271
+ ** tab **
272
+ The TAB table is used to test the core properties, and should have columns
273
+ and units
274
+
275
+ T (K) p (Pa) d (kg/m3) cp (kJ/kg/K) s (kJ/kg/K) h (kJ/kg)
276
+
277
+ The units are selected to match those typically used in the publication of
278
+ so-called Span and Wagner equations of state.
279
+
280
+ ** sattab **
281
+ The SATTAB table is used to test the saturation property functions, and should
282
+ have columns and units
283
+
284
+ T (K) p (Pa) dL (kg/m3) dV (kg/m3)
285
+
286
+ where dL and dV are the liquid and vapor densities respectively.
287
+
288
+ Test criteria:
289
+ (0) Data Integrity
290
+ 0.1 AOgroup must contain positive scalars, Tscale, dscale
291
+ 0.2 AOgroup's logt parameter must be a scalar
292
+ 0.2 AOgroup's coef0 parameter must be a legal poly1 group
293
+ 0.4 AOgroup's coef1 parameter must be a table with two columns
294
+ 0.5 ARgroup must contain Tscale, dscale
295
+ 0.6 ARgroup's coef0 must be a list of legal poly2 groups
296
+ 0.7 ARgroup's coef1 must be a table with seven columns
297
+ 0.8 ARgroup's coef2 must be a table with eight columns
298
+ 0.9 PSgroup must contain positive scalars Tscale, pscale and integer, fn
299
+ 0.10 PSgroup's coef must be a legal poly1 group
300
+ 0.11 DSLgroup must contain positive scalars Tscale, dscale and integer, fn
301
+ 0.12 DSLgroup's coef must be a legal poly1 group
302
+ 0.13 DSVgroup must contain positive scalars Tscale, dscale and integer, fn
303
+ 0.14 DSVgroup's coef must be a legal poly1 group
304
+ (1) Saturation
305
+ 1.1 Saturation pressure agrees to within 0.01%
306
+ 1.2 Liquid saturation density agrees to within 0.01%
307
+ 1.3 Vapor saturation density agrees to within 0.01%
308
+ (2) Inverse Saturation
309
+ 2.1 Saturation temperature agrees to within 0.01%
310
+ (3) Equation of State
311
+ 3.1 Density must agree to within 0.01%
312
+ 3.2 Pressure must agree to within 0.01%
313
+ 3.3 Temperature must agree to within 0.01%
314
+ (4) Core Properties
315
+ 4.1 Specific heat (cp) must agree to within 0.01%
316
+ 4.2 Entropy must agree to within 0.01%
317
+ 4.3 Enthalpy must agree to within 0.01%
318
+ (5) Inverse Properties
319
+ 5.1 Temperature from entropy and pressure must agree to within 0.01%
320
+ 5.2 Temperature from entropy and density must agree to within 0.01%
321
+ 5.3 Density from entropy and temperature must agree to within 0.01%
322
+ 5.4 Temperature from enthalpy and pressure must agree to within 0.01%
323
+ 5.5 Temperature from enthalpy and density must agree to within 0.01%
324
+
325
+ """
326
+ # Recurse with a fresh file descriptor if the file is a string
327
+ if isinstance(report, str):
328
+ with open(report, 'w') as ff:
329
+ return self._test(report=ff)
330
+ elif report is None:
331
+ report = sys.stdout
332
+
333
+ result = True
334
+
335
+ report.write('PYroMat version: ' + pm.config['version'] + '\n')
336
+ report.write('Species: ' + self.data['id'] + '\n')
337
+
338
+ # CRITERION 0
339
+ # Basic Data integrity
340
+ def _check_poly1(coef):
341
+ # Loop through the coefficient groups
342
+ for cgi,cc in enumerate(coef):
343
+ if not isinstance(cc, (list,tuple)):
344
+ return True, f'Coef. group {cgi} was neither a list nor a tuple.'
345
+ # Check pre- and post-exponents
346
+ pre = cc[0]
347
+ post = cc[1]
348
+ if not isinstance(pre, (int,float)):
349
+ return True, f'In coef. group {cgi} pre-exponent must be scalar. Found: {pre}'
350
+ if not isinstance(post, (int,float)):
351
+ return True, f'In coef. group {cgi} post-exponent must be scalar. Found: {post}'
352
+ for ti, term in enumerate(cc[2:]):
353
+ if not isinstance(term,(list,tuple)):
354
+ return True, f'In coef. group {cgi}, the {ti} term is neither a list nor a tuple: {term}'
355
+ if len(term) != 2:
356
+ return True, f'In coef. group {cgi}, the {ti} term should have 2 elements. Found: {term}'
357
+ if not isinstance(term[0], int) or term[0] <0:
358
+ return True, f'In coef. group {cgi}, the {ti} term exponent was not a non-negative integer. {term}'
359
+
360
+ return False, ''
361
+
362
+ def _check_poly2(coef):
363
+ # Loop through the coefficient groups
364
+ for cgi,cc in enumerate(coef):
365
+ if not isinstance(cc, (list,tuple)):
366
+ return True, f'Coef. group {cgi} was neither a list nor a tuple.'
367
+ # Check pre- and post-exponents
368
+ pre = cc[0]
369
+ post = cc[1]
370
+ if not isinstance(pre, list) or len(pre) != 2:
371
+ return True, f'In coef. group {cgi} pre-exponent must be a two-element list. Found: {pre}'
372
+ if not isinstance(post, list) or len(post) != 2:
373
+ return True, f'In coef. group {cgi} post-exponent must be a two-element list. Found: {post}'
374
+ prex,prey = pre
375
+ postx,posty = post
376
+ if not isinstance(prex, (int,float)) or not isinstance(prey, (int,float)) or not isinstance(postx, (int,float)) or not isinstance(posty, (int,float)):
377
+ return True, f'In coef. group {cgi}, pre- and post-exponents must be scalars. Pre: {pre}, Post: {post}'
378
+
379
+ for ti, term in enumerate(cc[2:]):
380
+ if not isinstance(term,(list,tuple)):
381
+ return True, f'In coef. group {cgi}, the {ti} term is neither a list nor a tuple: {term}'
382
+ if len(term) != 3:
383
+ return True, f'In coef. group {cgi}, the {ti} term should have 3 elements. Found: {term}'
384
+ if not isinstance(term[0], int) or term[0] <0:
385
+ return True, f'In coef. group {cgi}, the {ti} term exponent was not a non-negative integer. {term}'
386
+
387
+ return False, ''
388
+
389
+ #0.1 AOgroup must contain positive scalars, Tscale, dscale
390
+ error = False
391
+ for test in ['Tscale', 'dscale']:
392
+ if test in self.data['AOgroup']:
393
+ pass
394
+ elif self.data['AOgroup'][test] > 0:
395
+ pass
396
+ else:
397
+ error = True
398
+ break
399
+ if error:
400
+ report.write('[FAILED] 0.1 AOgroup must contain positive scalars, Tscale, dscale\n')
401
+ report.write(' ' + test + ' = ' + repr(self.data['AOgroup'][test]) + '\n')
402
+ result = False
403
+ else:
404
+ report.write('[passed] 0.1 AOgroup must contain positive scalars, Tscale, dscale\n')
405
+
406
+ #0.2 AOgroup's logt parameter must be a scalar
407
+ if 'logt' in self.data['AOgroup'] and not isinstance(self.data['AOgroup']['logt'], (float,int)):
408
+ report.write('[FAILED] 0.2 AOgroup logt parameter must be a scalar\n')
409
+ report.write(' logt = ' + repr(self.data['AOgroup']['logt']) + '\n')
410
+ result = False
411
+ else:
412
+ report.write('[passed] 0.2 AOgroup logt parameter must be a scalar\n')
413
+
414
+ #0.3 AOgroup's coef0 parameter must be a legal poly1 group
415
+ error = False
416
+ if 'coef0' in self.data['AOgroup']:
417
+ error,message = _check_poly1(self.data['AOgroup']['coef0'])
418
+ if error:
419
+ report.write('[FAILED] 0.3 AOgroup coef0 parameter must be a legal poly1 group\n')
420
+ report.write(' ' + message + '\n')
421
+ result = False
422
+ else:
423
+ report.write('[passed] 0.3 AOgroup coef0 parameter must be a legal poly1 group\n')
424
+
425
+ #0.4 AOgroup's coef1 parameter must be a table with two columns
426
+ error = False
427
+ if 'coef1' in self.data['AOgroup']:
428
+ if not isinstance(self.data['AOgroup']['coef1'], (list,tuple)):
429
+ error = True
430
+ message = 'coef1 was not iterable.'
431
+ else:
432
+ for row in self.data['AOgroup']['coef1']:
433
+ if not isinstance(row, (list,tuple)) or len(row) != 2:
434
+ error = True
435
+ message = 'coef1 has at least one row without 2 columns'
436
+ if error:
437
+ report.write('[FAILED] 0.4 AOgroup coef1 parameter must be a table with two columns\n')
438
+ report.write(' ' + message + '\n')
439
+ result = False
440
+ else:
441
+ report.write('[passed] 0.4 AOgroup coef1 parameter must be a table with two columns\n')
442
+
443
+ #0.5 ARgroup must contain Tscale, dscale
444
+ error = False
445
+ for test in ['Tscale', 'dscale']:
446
+ if test in self.data['ARgroup']:
447
+ pass
448
+ elif self.data['ARgroup'][test] > 0:
449
+ pass
450
+ else:
451
+ error = True
452
+ break
453
+ if error:
454
+ report.write('[FAILED] 0.5 ARgroup must contain positive scalars, Tscale, dscale\n')
455
+ report.write(' ' + test + ' = ' + repr(self.data['ARgroup'][test]) + '\n')
456
+ result = False
457
+ else:
458
+ report.write('[passed] 0.5 ARgroup must contain positive scalars, Tscale, dscale\n')
459
+
460
+ #0.6 ARgroup's coef0 must be a list of legal poly2 groups
461
+ error = False
462
+ message = ''
463
+ if 'coef0' in self.data['ARgroup']:
464
+ if not isinstance(self.data['ARgroup']['coef0'], (list,tuple)):
465
+ error = True
466
+ message = 'coef0 was not iterable.'
467
+ else:
468
+ for cgi,cg in enumerate(self.data['ARgroup']['coef0']):
469
+ error,message = _check_poly2(cg)
470
+ if error:
471
+ message = 'Error in term number ' + str(cgi) + '\n ' + message
472
+ break
473
+ if error:
474
+ result = False
475
+ report.write('[FAILED] ARgroup coef0 must be a list of legal poly2 groups\n')
476
+ report.write(' ' + message + '\n')
477
+ else:
478
+ report.write('[passed] ARgroup coef0 must be a list of legal poly2 groups\n')
479
+
480
+ #0.7 ARgroup's coef1 must be a table with seven columns
481
+ error = False
482
+ message = ''
483
+ if 'coef1' in self.data['ARgroup']:
484
+ if not isinstance(self.data['ARgroup']['coef1'], (list,tuple)):
485
+ error = True
486
+ message = 'coef1 was not iterable.'
487
+ else:
488
+ for row in self.data['ARgroup']['coef1']:
489
+ if len(row) != 7:
490
+ error = True
491
+ message = 'coef1 has at least one row without 7 columns'
492
+ if error:
493
+ result = False
494
+ report.write('[FAILED] ARgroup coef1 must be a table with seven columns\n')
495
+ report.write(' ' + message + '\n')
496
+ else:
497
+ report.write('[passed] ARgroup coef1 must be a table with seven columns\n')
498
+
499
+ #0.8 ARgroup's coef2 must be a table with eight columns
500
+ error = False
501
+ message = ''
502
+ if 'coef2' in self.data['ARgroup']:
503
+ if not isinstance(self.data['ARgroup']['coef2'], (list,tuple)):
504
+ error = True
505
+ message = 'coef2 was not iterable.'
506
+ else:
507
+ for row in self.data['ARgroup']['coef2']:
508
+ if len(row) != 8:
509
+ error = True
510
+ message = 'coef2 has at least one row without 8 columns'
511
+ if error:
512
+ result = False
513
+ report.write('[FAILED] ARgroup coef2 must be a table with eight columns\n')
514
+ report.write(' ' + message + '\n')
515
+ else:
516
+ report.write('[passed] ARgroup coef2 must be a table with eight columns\n')
517
+
518
+ #0.9 PSgroup must contain positive scalars Tscale, pscale and integer, fn
519
+ #0.10 PSgroup's coef must be a legal poly1 group
520
+ #0.11 DSLgroup must contain positive scalars Tscale, dscale and integer, fn
521
+ #0.12 DSLgroup's coef must be a legal poly1 group
522
+ #0.13 DSVgroup must contain positive scalars Tscale, dscale and integer, fn
523
+ #0.14 DSVgroup's coef must be a legal poly1 group
524
+
525
+ if basic:
526
+ return result
527
+
528
+ # First, extract the sattab columns
529
+ sattab = np.asarray(sattab, dtype=float)
530
+ T = pm.units.temperature_scale(sattab[:,0], from_units='K')
531
+ p = pm.units.pressure(sattab[:,1], from_units='Pa')
532
+ dL = pm.units.matter(self.data['mw'], sattab[:,2], from_units='kg')
533
+ pm.units.volume(dL, from_units='m3', inplace=True)
534
+ dV = pm.units.matter(self.data['mw'], sattab[:,3], from_units='kg')
535
+ pm.units.volume(dV, from_units='m3', inplace=True)
536
+
537
+ # CRITERION 1
538
+ # Saturation numerical integrity
539
+ report.write('\n1. Saturation Properties\n')
540
+ result = pm.utility.proptest(self.ps, {'T':T}, truth=p, ep=.0001,
541
+ text='1.1 Saturation pressure must agree to within .01%',
542
+ report=report) or result
543
+ result = pm.utility.proptest(self.ds, {'T':T}, truth=dL, ep=.0001,
544
+ text='1.2 Liquid saturation density must agree to within .01%',
545
+ report=report, findex=0) or result
546
+ result = pm.utility.proptest(self.ds, {'T':T}, truth=dV, ep=.0001,
547
+ text='1.3 Vapor saturation density must agree to within .01%',
548
+ report=report, findex=1) or result
549
+ # CRITERION 2
550
+ # Inverse saturation
551
+ report.write('2. Inverse Saturation Properties\n')
552
+ result = pm.utility.proptest(self.Ts, {'p':p}, truth=T, ep=.0001,
553
+ text='2.1 Saturation temperature must agree to within .01%',
554
+ report=report, findex=1) or result
555
+ # Throw away the saturation table values; we're done with those
556
+ # Switch to the core property table
557
+ T = pm.units.temperature_scale(tab[:,0], from_units='K')
558
+ p = pm.units.pressure(tab[:,1], from_units='Pa')
559
+ d = pm.units.matter(self.data['mw'], tab[:,2], from_units='kg')
560
+ pm.units.volume(d, from_units='m3', exponent=-1, inplace=True)
561
+ cp = pm.units.energy(tab[:,3], from_units='kJ')
562
+ pm.units.temperature(cp, from_units='K', exponent=-1, inplace=True)
563
+ pm.units.matter(self.data['mw'], cp, from_units='kg', exponent=-1, inplace=True)
564
+ s = pm.units.energy(tab[:,4], from_units='kJ')
565
+ pm.units.temperature(s, from_units='K', exponent=-1, inplace=True)
566
+ pm.units.matter(self.data['mw'], s, from_units='kg', exponent=-1, inplace=True)
567
+ h = pm.units.energy(tab[:,5], from_units='kJ')
568
+ pm.units.matter(self.data['mw'], h, from_units='kg', exponent=-1, inplace=True)
569
+
570
+ # CRITERION 3
571
+ # Equation of state
572
+
573
+ return result
574
+
575
+
576
+ def _poly2(self,x,y,group,diff=2):
577
+ """Polynomial evaluation (primative routine)
578
+ (p, px, py, pxx, pxy, pyy) = _poly(x,y,coef,diff=2)
579
+
580
+ Evaluates a polynomial on x and y and its derivatives.
581
+ x x value
582
+ y y value
583
+ param coefficient list
584
+ diff the highest order derivative to evaluate (0,1, or 2)
585
+
586
+ Returns
587
+ p polynomial value at p(x,y)
588
+ px dp/dx
589
+ py dp/dy
590
+ pxx d2p/dx2
591
+ pxy d2p/dxdy
592
+ pyy d2p/dy2
593
+
594
+ The behavior of poly2 is very much the same as poly1, but for functions
595
+ of two variables. The pre- and post- exponents for poly2 are expected
596
+ to be lists or tuples: [prex, prey], [postx, posty]
597
+ The innermost lists defining the terms must contain three elements:
598
+ [powxN, powyN, coefN]. The coefficients must be sorted by x-power and
599
+ then by y-power in descending order.
600
+
601
+ A coefficient list might appear
602
+
603
+ coef = [
604
+ [
605
+ [prex, prey],
606
+ [postx, posty],
607
+ [powxN, powyN, coefN],
608
+ ...
609
+ [powx0, powy0, coef0]
610
+ ],
611
+ [
612
+ [prex, prey],
613
+ [postx, posty],
614
+ [powxN, powyN, coefN],
615
+ ...
616
+ [powx0, powy0, coef0]
617
+ ]
618
+ ]
619
+
620
+ The pre-exponents are applied to the arguments to the polynomial, and
621
+ the post-exponents are applied after the polynomial is evaluated, so
622
+ that the value returned is
623
+ x**postx * y**posty * p(x**prex, y**prey)
624
+
625
+ Starting with the third element (element 2) of the coefficient list,
626
+ each element of coef is a three-element list defining a term in the
627
+ polynomial; the x-exponent, the y-exponent, and the corresponding
628
+ coefficient. It must be sorted in descending order by the first column
629
+ and then the second column.
630
+
631
+ For example, the list,
632
+ [[[1,1], [0,0], [1, 1, 0.1], [0, 2, 0.2], [0, 1, 1.2], [0, 0, 0.5]]]
633
+ corresponds to the polynomial
634
+ p(x,y) = .5 + 1.2y + .2y**2 + 0.1xy
635
+
636
+ Efficient polynomial evaluation algorithms are normally restricted to
637
+ positive integer exponents, but many thermodynamic property models use
638
+ much more interesting polynomials. The pre- and post- exponents can be
639
+ used to acheive a much wider range of functions.
640
+
641
+ For example,
642
+ p(x,y) = x**(-1.5) + x**(3.5)
643
+ might be expressed as a coefficient list
644
+ [[[0.5,1], [-1.5, 0], [10, 0, 1], [0, 0, 1]]]
645
+ The pre- and post- exponents make this equivalent to
646
+ xx = x**0.5
647
+ p(x,y) = x**(-1.5) (xx**10 + 1)
648
+ which is equivalent to the original polynomial, except that the core of
649
+ the evaluation algorithm only operates on positive integers.
650
+ """
651
+
652
+ g = 0. # total group
653
+ gx = 0.
654
+ gy = 0.
655
+ gxx = 0.
656
+ gxy = 0.
657
+ gyy = 0.
658
+
659
+ for coef in group:
660
+ # initialize the final polynomial and its derivatives
661
+ p = 0. # total polynomial
662
+ px = 0.
663
+ py = 0.
664
+ pxx = 0.
665
+ pxy = 0.
666
+ pyy = 0.
667
+
668
+ # collect the pre- and post-exponentials
669
+ prex,prey = coef[0]
670
+ postx,posty = coef[1]
671
+
672
+ # Apply the pre-exponentials
673
+ if prex!=1.:
674
+ x_0 = x**prex
675
+ if diff>0:
676
+ x_1 = x_0*prex/x
677
+ else:
678
+ x_1 = 0.
679
+ if diff>1:
680
+ x_2 = x_1*(prex-1.)/x
681
+ else:
682
+ x_2 = 0.
683
+ else:
684
+ x_0 = x
685
+ x_1 = 1.
686
+ x_2 = 0.
687
+
688
+ if prey!=1.:
689
+ y_0 = y**prey
690
+ if diff>0:
691
+ y_1 = y_0*prey/y
692
+ else:
693
+ y_1 = 0.
694
+ if diff>1:
695
+ y_2 = y_1*(prey-1.)/y
696
+ else:
697
+ y_2 = 0.
698
+ else:
699
+ y_0 = y
700
+ y_1 = 1.
701
+ y_2 = 0.
702
+
703
+ # From here, we loop over terms of the form a*(x**ii)*(y**jj)
704
+ # If a particular ii,jj combination is not found in the data, then
705
+ # its coefficient is treated as zero.
706
+ # What is the largest ii?
707
+ II = coef[2][0]
708
+
709
+ # On which coefficient are we currently operating?
710
+ index = 2
711
+ # This is a flag that indicates the active index was used in
712
+ # the last loop, so it needs to be incremented.
713
+
714
+ for ii in range(II,-1,-1):
715
+ # If the current x-exponent is the same one represented in
716
+ # the active coefficient row, then calculate q.
717
+ if index<len(coef) and coef[index][0] == ii:
718
+ # For this value of ii, what is the largest jj?
719
+ JJ = coef[index][1]
720
+ # q is a sub-polynomial on y that represents the
721
+ # variation on y of all terms that share the same
722
+ # power in x. This inner loop is much like the loop
723
+ # on ii, except that it looks at both the x and y
724
+ # exponents.
725
+ q = 0
726
+ qy = 0
727
+ qyy = 0
728
+ for jj in range(JJ,-1,-1):
729
+ if diff > 1:
730
+ qyy = 2*qy + y_0*qyy
731
+ if diff > 0:
732
+ qy = q + y_0*qy
733
+ # If the current y-exponent is represented in the
734
+ # active coefficient row, then fold it into the q
735
+ # expansion.
736
+ if index<len(coef) and coef[index][0] == ii and coef[index][1] == jj:
737
+ q = coef[index][2] + y_0*q
738
+ # increment the active index
739
+ index += 1
740
+ else:
741
+ q *= y_0
742
+
743
+ # Fold the current q values into the p expansion
744
+ # Update the highest derivatives first since they depend
745
+ # on the historical values of the lower derivatives
746
+ if diff > 1:
747
+ pyy = qyy + x_0 * pyy
748
+ pxx = 2*px + x_0 * pxx
749
+ pxy = py + x_0 * pxy
750
+ if diff > 0:
751
+ px = p + x_0 * px
752
+ py = qy + x_0 * py
753
+ p = q + x_0 * p
754
+ # If the current x exponent is not represented, execute a
755
+ # p-expansion with zero q.
756
+ else:
757
+ if diff > 0:
758
+ if diff > 1:
759
+ pyy = x_0 * pyy
760
+ pxx = 2*px + x_0 * pxx
761
+ pxy = py + x_0 * pxy
762
+ px = p + x_0 * px
763
+ py = x_0 * py
764
+ p = x_0 * p
765
+
766
+ # Modify the derivatives for the pre-exponnetials
767
+ if prex!=1.:
768
+ if diff>0:
769
+ if diff>1:
770
+ pxx = pxx*x_1*x_1 + px*x_2
771
+ pyy = pyy*y_1*y_1 + py*y_2
772
+ pxy = pxy*x_1*y_1
773
+ px *= x_1
774
+ py *= y_1
775
+
776
+ # Apply the post-exponentials
777
+ if postx!=0:
778
+ f = x**postx
779
+ if diff>0:
780
+ fx = postx*f/x
781
+ if diff>1:
782
+ fxx = fx*(postx-1)/x
783
+ pxx = pxx*f + 2.*px*fx + p*fxx
784
+ pyy = pyy*f
785
+ pxy = pxy*f + py*fx
786
+ px = px*f + p*fx
787
+ py = py*f
788
+ p *= f
789
+ if posty!=0:
790
+ f = y**posty
791
+ if diff>0:
792
+ fy = posty*f/y
793
+ if diff>1:
794
+ fyy = fy*(posty-1)/y
795
+ pyy = pyy*f + 2.*py*fy + p*fyy
796
+ pxx = pxx*f
797
+ pxy = pxy*f + px*fy
798
+ py = py*f + p*fy
799
+ px = px*f
800
+ p *= f
801
+
802
+ # If the group has only one coefficient set, just return
803
+ if len(group) == 1:
804
+ return p,px,py,pxx,pxy,pyy
805
+
806
+ g += p
807
+ if diff>0:
808
+ gx += px
809
+ gy += py
810
+ if diff>1:
811
+ gxx += pxx
812
+ gxy += pxy
813
+ gyy += pyy
814
+
815
+ return g,gx,gy,gxx,gxy,gyy
816
+
817
+
818
+ def _poly1(self,x,group,diff=2):
819
+ """Polynomial evaluation (primative routine)
820
+ (p, px, pxx) = _poly1(x,coef,diff=2)
821
+
822
+ Evaluates a polynomial on x and y and its derivatives.
823
+ x x value
824
+ coef coefficient list
825
+ diff the highest order derivative to evaluate (0,1, or 2)
826
+
827
+ Returns
828
+ p polynomial value at p(x)
829
+ px dp/dx
830
+ pxx d2p/dx2
831
+
832
+ When diff is less than 2, the corresponding values of px and pxx are
833
+ returned as 0. The default for diff is 2 to protect against careless
834
+ treatment as if these values ARE zero, but reducing diff will make poly1
835
+ execute more efficiently.
836
+
837
+ The coefficient list represents a nested list structure defining a poly-
838
+ nomial series. The inner-most lists contain two elements, specifying
839
+ an integer exponent and a coefficient: [power, coefficient] for each
840
+ term. They are contained in a list that represents groups of terms.
841
+ The groups must be sorted by power from highest to lowest.
842
+
843
+ Each group is lead by two elements that define a pre- and post-
844
+ exponents.
845
+ [pre, post, [powN, coefN], ... , [pow0, coef0]]
846
+
847
+ This defines a polynomial of the form
848
+ x**post * p(x**pre)
849
+
850
+ The powers must be integers, but no such restriciton exists on the pre-
851
+ and post- exponents. This permits efficient evaluaiton of polynomials
852
+ with rational exponents.
853
+
854
+ The highest level list contains a list of these groups, so that separate
855
+ pre- and post- exponentials may be applied to certain terms of the
856
+ polynomial.
857
+
858
+ coef = [
859
+ [
860
+ pre,
861
+ post,
862
+ [
863
+ [powN, coefN],
864
+ ...,
865
+ [pow0, coef0]
866
+ ]
867
+ ],
868
+ [
869
+ pre,
870
+ post,
871
+ [
872
+ [powN, coefN],
873
+ ...,
874
+ [pow0, coef0]
875
+ ]
876
+ ]
877
+ ]
878
+
879
+ In a simple example, the polynomial,
880
+ p(x) = 2*x**-1.5 - x**0.5
881
+
882
+ might be specified
883
+ [[ 0.5, -1.5, [0, 2.], [4, -1.]]]
884
+ """
885
+ g = 0.
886
+ gx = 0.
887
+ gxx = 0.
888
+
889
+ for coef in group:
890
+ # initialize the final polynomial and its derivatives
891
+ p = 0. # total polynomial
892
+ px = 0.
893
+ pxx = 0.
894
+
895
+ # collect the pre- and post-exponentials
896
+ pre = coef[0]
897
+ post = coef[1]
898
+
899
+ # Apply the pre-exponentials
900
+ if pre!=1.:
901
+ x_0 = x**pre
902
+ if diff>0:
903
+ x_1 = x_0*pre/x
904
+ else:
905
+ x_1 = 0.
906
+ if diff>1:
907
+ x_2 = x_1*(pre-1.)/x
908
+ else:
909
+ x_2 = 0.
910
+ else:
911
+ x_0 = x
912
+ x_1 = 1.
913
+ x_2 = 0.
914
+
915
+ # From here, we loop over terms of the form a*(x**ii)
916
+ # If a particular ii,jj combination is not found in the data, then
917
+ # its coefficient is treated as zero.
918
+ # What is the largest ii?
919
+ II = coef[2][0]
920
+
921
+ # On which coefficient are we currently operating?
922
+ index = 2
923
+ # This is a flag that indicates the active index was used in
924
+ # the last loop, so it needs to be incremented.
925
+
926
+ for ii in range(II,-1,-1):
927
+ # If the current x-exponent is the same one represented in
928
+ # the active coefficient row, then calculate q.
929
+ if index<len(coef) and coef[index][0] == ii:
930
+ # Fold the current coefficient into the p expansion
931
+ # Update the highest derivatives first since they depend
932
+ # on the historical values of the lower derivatives
933
+ if diff>0:
934
+ if diff > 1:
935
+ pxx = 2*px + x_0 * pxx
936
+ px = p + x_0 * px
937
+ p = coef[index][1] + x_0 * p
938
+ index += 1
939
+ # If the current x exponent is not represented, execute a
940
+ # p-expansion with zero q.
941
+ else:
942
+ if diff > 0:
943
+ if diff > 1:
944
+ pxx = 2*px + x_0 * pxx
945
+ px = p + x_0 * px
946
+ p = x_0 * p
947
+
948
+ # Modify the derivatives for the pre-exponnetials
949
+ if pre!=1.:
950
+ if diff>0:
951
+ if diff>1:
952
+ pxx = pxx*x_1*x_1 + px*x_2
953
+ px *= x_1
954
+
955
+ # Apply the post-exponentials
956
+ if post!=0:
957
+ f = x**post
958
+ if diff>0:
959
+ fx = post*f/x
960
+ if diff>1:
961
+ fxx = fx*(post-1)/x
962
+ pxx = pxx*f + 2.*px*fx + p*fxx
963
+ px = px*f + p*fx
964
+ p *= f
965
+
966
+ if len(group)==1:
967
+ return p,px,pxx
968
+
969
+ g += p
970
+ if diff>0:
971
+ gx += px
972
+ if diff>1:
973
+ gxx += pxx
974
+
975
+ return g,gx,gxx
976
+
977
+
978
+ def _iter1(self, fn, prop, y, x, Ids, xmin, xmax,
979
+ ep=1e-6, Nmax=20, fx_index=1,
980
+ verbose=False, param={}):
981
+ """Modified Newton iteration on a 1D inner routine. (primative routine)
982
+
983
+ _iter1(fn, prop, y, x, Ids, xmin, xmax,)
984
+
985
+ *** Required Parameters ***
986
+ fn The inner routine (method) to be inverted. It must have a
987
+ call signature
988
+ f, fx0, ... = fn(x0, x1, ..., diff)
989
+ where f is the value of fn, and fx0 is the derivative of fn
990
+ with respect to prop0. The fx_index keyword can be used to
991
+ change where fx is found in the returned tuple. By default
992
+ it is 1.
993
+ prop The string keyword index of the property to be calculated.
994
+ y An array of N target values for fn().
995
+ x The result array. It should be an N-element floating point
996
+ array.
997
+ Ids A down-select boolean index array; only x[Ids],y[Ids] will
998
+ be evaluated. This allows iteration in-place on data sets
999
+ where only a portion of the data require iteration. If y is
1000
+ a floating point array with N elements, Ids must be a bool
1001
+ array with N elements. It will specify a down-selected
1002
+ data set with M elements, where M<=N.
1003
+ xmin, xmax Upper and lower limit arrays for the x values. These must
1004
+ broadcastable to match x and y. Even values outside of the
1005
+ down-select region should have legal values. Note that
1006
+ these arrays are volatile, and will be written to by the
1007
+ bisection process.
1008
+ *** Optional Parameters ***
1009
+ ep Epsilon; fractional error permitted in y (default 1e-6)
1010
+ Nmax Maximum number of iterations (default 20)
1011
+ fx_index The location of the property derivative in the call
1012
+ signature (default 1)
1013
+ param A dicitonary of keyword arguments are passed directly to the
1014
+ inner routine being inverted.
1015
+
1016
+ """
1017
+ # As the iteration progresses, the number of True elements in
1018
+ # Ids will decrease until they are all false
1019
+ # There are some important intermediate values that will also
1020
+ # require indexable arrays
1021
+ dx = np.zeros_like(y, dtype=float)
1022
+ error = np.zeros_like(dx, dtype=float)
1023
+ IooB = np.zeros_like(Ids, dtype=bool)
1024
+
1025
+ if verbose:
1026
+ print('Iterating on "' + prop + '"')
1027
+ print('Target values:')
1028
+ print(y)
1029
+ print('Limits:')
1030
+ print(xmin,xmax)
1031
+ print('x', 'yvalue', 'dydx', 'dx', 'Ids')
1032
+
1033
+
1034
+ # Create an argument dictionary
1035
+ arg = param.copy()
1036
+ count = 0
1037
+ while Ids.any():
1038
+ # Build the new argument list
1039
+ for k,v in param.items():
1040
+ # For any array arguments, shrink them along with Ids
1041
+ if isinstance(v,np.ndarray):
1042
+ arg[k] = v[Ids]
1043
+ # Shrink the primary property array
1044
+ arg[prop] = x[Ids]
1045
+ # Evaluate the funciton and isolate its derivative
1046
+ FF = fn( diff=1, **arg)
1047
+ yy = FF[0]
1048
+ yyx = FF[fx_index]
1049
+ # note that x[Ids], yy, yyx, and all the other floating
1050
+ # intermediates are now in m-space; the sub-set of values
1051
+ # still under iteration.
1052
+ # Calculate the error, the linear change in x, and the new x
1053
+ error[Ids] = y[Ids] - yy
1054
+ dx[Ids] = error[Ids] / yyx
1055
+ if verbose:
1056
+ print(x, yy, yyx, dx, Ids)
1057
+ x[Ids] += dx[Ids]
1058
+ # An out-of-bounds index
1059
+ #IooB = np.logical_or( x < xmin, x > xmax)
1060
+ IooB[Ids] = np.logical_or( x[Ids] < xmin[Ids], x[Ids] > xmax[Ids])
1061
+ count_oob = 0
1062
+ while IooB[Ids].any():
1063
+ dx[IooB] /= 2.
1064
+ x[IooB] -= dx[IooB]
1065
+ IooB[Ids] = np.logical_or( x[Ids] < xmin[Ids], x[Ids] > xmax[Ids])
1066
+ # Prevent a while-loop-trap
1067
+ count_oob += 1
1068
+ if count_oob>Nmax:
1069
+ raise pm.utility.PMAnalysisError(
1070
+ '_iter1() failed to produce a guess that was in-bounds')
1071
+
1072
+ # Check the iteration convergence
1073
+ Ids[Ids] = abs(error[Ids]) > abs(ep*y[Ids])
1074
+ # Prevent a while-loop-trap
1075
+ count += 1
1076
+ if count>Nmax:
1077
+ pm.utility.print_warning(\
1078
+ '_iter1() failed to converge for %d elements after %d attempts'%(\
1079
+ Ids.sum(), Nmax))
1080
+ return
1081
+
1082
+
1083
+ def _hybrid1(self, fn, prop, y, x, Ids, xmin, xmax,
1084
+ ep=1e-6, Nmax=20, fx_index=1,
1085
+ verbose=False, paranoid=True, param={}):
1086
+ """Hybrid numerical inversion of an inner routine (primative routine)
1087
+
1088
+ _hybrid1(fn, prop, y, x, Ids, xmin, xmax,)
1089
+
1090
+ This hybrid iteration algorithm is named for being a hybrid of biseciton
1091
+ and Newton iteration. On "well behaved" functions it converges as
1092
+ quickly as the Newton algorithm, but on "badly behaved" functions, it
1093
+ is extremely stable.
1094
+
1095
+ Iteration is performed in-place on the x array until fn(x) == y. The
1096
+ hybrid1 algorithm depends on the xmax and xmin values to bracket a
1097
+ solution. The funciton, fn, and its derivative are evaluated at the
1098
+ maximum and minimum, and Newton's method is used to generate two
1099
+ candidate next guesses. The point bisecting the maximum and minimum is
1100
+ calculated, providing a third candidate guess. Of the three candidates,
1101
+ the one in the middle is selected for the next iteration step. If the
1102
+ middle point lies outside of xmax and xmin, then the bisection point is
1103
+ selected instead.
1104
+
1105
+ Once a next guess is selected, the function and its derivative are
1106
+ evaluated there. This guess is used to replace either xmin or xmax,
1107
+ just like would be done in a bisection algorithm, but then the three-
1108
+ candidate voting algorithm is repeated. Since the calculated next guess
1109
+ of the boundaries is unchanged from the last iteration step, only one
1110
+ function evaluation is required per step, making the computational cost
1111
+ comparable with Newton's method.
1112
+
1113
+ *** Required Parameters ***
1114
+ fn The inner routine (method) to be inverted. It must have a
1115
+ call signature
1116
+ f, fx0, ... = fn(x0, x1, ..., diff)
1117
+ where f is the value of fn, and fx0 is the derivative of fn
1118
+ with respect to prop0. The fx_index keyword can be used to
1119
+ change where fx is found in the returned tuple. By default
1120
+ it is 1.
1121
+ prop The string keyword index of the property to be calculated.
1122
+ y An array of N target values for fn().
1123
+ x The result array. It should be an N-element floating point
1124
+ array.
1125
+ Ids A down-select boolean index array; only x[Ids],y[Ids] will
1126
+ be evaluated. This allows iteration in-place on data sets
1127
+ where only a portion of the data require iteration. If y is
1128
+ a floating point array with N elements, Ids must be a bool
1129
+ array with N elements. It will specify a down-selected
1130
+ data set with M elements, where M<=N.
1131
+ xmin, xmax Upper and lower limit arrays for the x values. These must
1132
+ broadcastable to match x and y. Even values outside of the
1133
+ down-select region should have legal values. Note that
1134
+ these arrays are volatile, and will be written to by the
1135
+ bisection process.
1136
+ *** Optional Parameters ***
1137
+ ep Epsilon; fractional error permitted in y (default 1e-6)
1138
+ Nmax Maximum number of iterations (default 20)
1139
+ fx_index The location of the property derivative in the call
1140
+ signature (default 1)
1141
+ paranoid If any of the candidate guesses is out of bounds, the revert to
1142
+ bisection. Otherwise, only test the median guess. Paranoid
1143
+ operation can be essential in functions with +/- slope inflections
1144
+ in the domain.
1145
+ param A dicitonary of keyword arguments are passed directly to the
1146
+ inner routine being inverted.
1147
+
1148
+ """
1149
+ #================================#
1150
+ # Initialize intermediate arrays #
1151
+ #================================#
1152
+ # Produce arrays of candidate guesses xa and xb are produced by
1153
+ # the Newton algorithm from xmin and xmax respectively.
1154
+ # xc is produced by bisection.
1155
+ xa = np.zeros_like(x, dtype=float)
1156
+ xb = np.zeros_like(x, dtype=float)
1157
+ xc = np.zeros_like(x, dtype=float)
1158
+
1159
+ # Make local copies of xmax and xmin
1160
+ xmax = np.array(xmax)
1161
+ xmin = np.array(xmin)
1162
+
1163
+ # The Iab, Ibc, and Ica indices are used to store comparsion
1164
+ # truth values for sorting the candidate solutions, and Iwork
1165
+ # is used to assign the values
1166
+ Iab = np.zeros_like(Ids, dtype=bool)
1167
+ Ibc = np.zeros_like(Ids, dtype=bool)
1168
+ Ica = np.zeros_like(Ids, dtype=bool)
1169
+ Iwork = np.zeros_like(Ids, dtype=bool)
1170
+ Iaoob = np.zeros_like(Ids, dtype=bool) # Out-of-bounds arrays
1171
+ Iboob = np.zeros_like(Ids, dtype=bool) #
1172
+ Iswap = np.zeros_like(Ids, dtype=bool) # which were swapped?
1173
+
1174
+ if verbose:
1175
+ print("Fn: " + repr(fn.__name__))
1176
+ print("param: " + repr(param))
1177
+
1178
+ # Initialize an argument dicitonary
1179
+ arg = param.copy()
1180
+
1181
+ # Build the argument list
1182
+ for k,v in param.items():
1183
+ # For any array arguments, shrink them along with Ids
1184
+ if isinstance(v,np.ndarray):
1185
+ arg[k] = v[Ids]
1186
+ # Now, we'll evalaute the funciton at the limits
1187
+ # Start at the minimum
1188
+ arg[prop] = xmin[Ids]
1189
+ FF = fn(diff=1, **arg)
1190
+ yy = FF[0]
1191
+ yyx = FF[fx_index]
1192
+ # Calculate the first candidate solution
1193
+ xa[Ids] = xmin[Ids] + (y[Ids] - yy)/yyx
1194
+ # If f(xmin) > f(xmax) then the nominal slope of the curve is negative
1195
+ # That means that these boundaries will need to be updated in reverse
1196
+ # of the other boundaries.
1197
+ Iswap[Ids] = yy >= y[Ids]
1198
+
1199
+ # Now, evaluate at the maximum
1200
+ arg[prop] = xmax[Ids]
1201
+ FF = fn(diff=1, **arg)
1202
+ yy = FF[0]
1203
+ yyx = FF[fx_index]
1204
+ # Calculate the second candidate solution
1205
+ xb[Ids] = xmax[Ids] + (y[Ids] - yy)/yyx
1206
+
1207
+ # Verify that the limits bracket a solution
1208
+ # Borrow the a out-of-bounds array to hold the result
1209
+ # This is adapted from jranalli's graceful NaN failure edit
1210
+ Iaoob[Ids] = np.logical_not(np.logical_xor(Iswap[Ids], yy >= y[Ids])) # Figure out which meet the condition
1211
+ if Ids.any() and Iaoob[Ids].all(): # All points failed to bracket. Fail and raise Error.
1212
+ pm.utility.print_warning(
1213
+ '_HYBRID1: Failure to bracket a solution. Check function '
1214
+ 'arguments to be sure they reference a valid state. This error '
1215
+ 'usually occurs if the properties are out-of-range.')
1216
+ raise pm.utility.PMParamError(
1217
+ '_HYBRID1: All of the target values appear to be out-of-bounds!')
1218
+ elif Iaoob[Ids].any(): # Only some have failed to bracket
1219
+ # Force the result to the out-of-bounds value
1220
+ x[Iaoob] = pm.config['def_oob']
1221
+ # Clear the corresponding downselect bits
1222
+ Ids[Iaoob] = False
1223
+ pm.utility.print_warning(
1224
+ '_HYBRID1: Failure to bracket a solution for input '
1225
+ 'element(s): {}. Values set to config[\'def_oob\']. Check function '
1226
+ 'arguments to be sure they reference a valid state. This error'
1227
+ ' usually occurs if the properties are out-of-range.'
1228
+ .format(np.flatnonzero(Iaoob)))
1229
+ # Clear the out-of-bounds index we just used.
1230
+ Iaoob[:] = False
1231
+ # If none of the Iaoob values were True, there's no need to
1232
+ # clear them
1233
+
1234
+ # Calculate the thrid candidate solution
1235
+ xc[Ids] = 0.5*(xmin[Ids] + xmax[Ids])
1236
+
1237
+ if verbose:
1238
+ print(" xmin xmax xa xb xc ")
1239
+
1240
+ count = 0
1241
+ while Ids.any():
1242
+ if count>Nmax:
1243
+ pm.utility.print_warning(f'_HYBRID1: Failed to converge for {Ids.sum()} elements in {Nmax} iterations.')
1244
+ return
1245
+
1246
+ if verbose:
1247
+ print(xmin, xmax, xa, xb, xc)
1248
+
1249
+ # Clean the worker indexes
1250
+ Iab[:] = False
1251
+ Ibc[:] = False
1252
+ Ica[:] = False
1253
+ Iwork[:] = False
1254
+
1255
+ # The last step has established three candidate solutions
1256
+ # Which should we select? First, compare the three candidate
1257
+ # solutions to determine which is in the middle
1258
+ Iab[Ids] = xa[Ids] < xb[Ids]
1259
+ Ibc[Ids] = xb[Ids] < xc[Ids]
1260
+ Ica[Ids] = xc[Ids] < xa[Ids]
1261
+
1262
+ # Now, assign all values for which xa is the next guess
1263
+ Iwork[Ids] = Iab[Ids] == Ica[Ids]
1264
+ x[Iwork] = xa[Iwork]
1265
+ # Now, assign all values for which xb is the next guess
1266
+ Iwork[Ids] = Iab[Ids] == Ibc[Ids]
1267
+ x[Iwork] = xb[Iwork]
1268
+ # Now, assign all value for which xc is the next guess
1269
+ Iwork[Ids] = Ibc[Ids] == Ica[Ids]
1270
+ x[Iwork] = xc[Iwork]
1271
+ # finally, deal with the xa and xb out-of-bounds case
1272
+ if paranoid:
1273
+ # In paranoid mode, either xa and xb being out of bounds
1274
+ # forces xc to be selected
1275
+ Iwork[Ids] = np.logical_or(xa[Ids] < xmin[Ids], xa[Ids] > xmax[Ids])
1276
+ x[Iwork] = xc[Iwork]
1277
+ Iwork[Ids] = np.logical_or(xb[Ids] < xmin[Ids], xb[Ids] > xmax[Ids])
1278
+ x[Iwork] = xc[Iwork]
1279
+ else:
1280
+ Iwork[Ids] = np.logical_or(x[Ids] < xmin[Ids], xa[Ids] > xmax[Ids])
1281
+ x[Iwork] = xc[Iwork]
1282
+
1283
+
1284
+ # Build the new argument list
1285
+ for k,v in param.items():
1286
+ # For any array arguments, shrink them along with Ids
1287
+ if isinstance(v,np.ndarray):
1288
+ arg[k] = v[Ids]
1289
+ # Shrink the primary property array
1290
+ arg[prop] = x[Ids]
1291
+ # Evaluate the funciton and isolate its derivative
1292
+ FF = fn( diff=1, **arg)
1293
+ yy = FF[0]
1294
+ yyx = FF[fx_index]
1295
+
1296
+ # use xc as a temporary variable
1297
+ # First, calculate the size of the change in x
1298
+ xc[Ids] = x[Ids] + (y[Ids] - yy) / yyx
1299
+ # x is now the next guess
1300
+ # xc is its next projected guess
1301
+
1302
+ # Where is the guess?
1303
+ # Should it be stored in xmin?
1304
+ # xor with Iswap forces a swap when needed
1305
+ Iwork[Ids] = np.logical_xor(yy <= y[Ids], Iswap[Ids])
1306
+ xmin[Iwork] = x[Iwork]
1307
+ xa[Iwork] = xc[Iwork]
1308
+ # Test OOB
1309
+ Iaoob[Iwork] = np.logical_or(xc[Iwork] <= xmin[Iwork], xc[Iwork] >= xmax[Iwork])
1310
+ # or in xmax
1311
+ Iwork[Ids] = np.logical_not(Iwork[Ids])
1312
+ xmax[Iwork] = x[Iwork]
1313
+ xb[Iwork] = xc[Iwork]
1314
+ Iboob[Iwork] = np.logical_or(xc[Iwork] <= xmin[Iwork], xc[Iwork] >= xmax[Iwork])
1315
+ # Calculate the new bisection point
1316
+ xc[Ids] = 0.5*(xmax[Ids] + xmin[Ids])
1317
+
1318
+ # Check for convergence
1319
+ # if xmax-xmin is small OR
1320
+ # if the y error is small
1321
+ Ids[Ids] = np.logical_and(\
1322
+ np.abs((xmax[Ids] - xmin[Ids])/x[Ids]) > ep,\
1323
+ np.abs((yy - y[Ids])/y[Ids]) > ep)
1324
+
1325
+ # Prevent a while-loop-trap
1326
+ count += 1
1327
+
1328
+ if verbose:
1329
+ print(f"Converged for all elements in {count} iterations.")
1330
+
1331
+
1332
+ def _tditer(self, T, d, fn, diff=1, debug=False):
1333
+ """T,d iterator wrapper (primative routine)
1334
+ _tditer(T,d,fn, diff=1, debug=False)
1335
+
1336
+ This wrapper function evaluates a property inner routine from
1337
+ temperature and density. It is intended to be used to allow ID
1338
+ iteration on a property with respect to temperature with constant
1339
+ density (isochoric).
1340
+
1341
+ _tditer accpets three required arguments:
1342
+ T Temperature numpy array in Kelvin
1343
+ d Density numpy array in kg/m3
1344
+ fn Property inner routine to be evaluated (e.g. self._h or self._s)
1345
+
1346
+ For example, a call to _hybrid1 to calculate temperature while
1347
+ specifying entropy and pressure might appear
1348
+
1349
+ self._hybrid1( self._tditer, # Don't use _s, use _tditer
1350
+ 'T', # We want to calculate T
1351
+ svalues, # Here are the target entropy values
1352
+ T, # The T array
1353
+ Ids, # The pre-initialized down-select array
1354
+ Tmin, Tmax, # T bounds
1355
+ param={'fn':self._s, 'd':dvalues})
1356
+
1357
+ Optional parameters (and their defaults) are:
1358
+ debug (False)
1359
+ Has no effect. It is included only to provide the same call signature as
1360
+ _tpiter().
1361
+
1362
+ diff (1)
1363
+ When 0, returns no derivatives. When 1, returns the first-order
1364
+ derivatives.
1365
+ """
1366
+ y = np.empty_like(T, dtype=float)
1367
+ yt = np.empty_like(T, dtype=float)
1368
+ yd = np.empty_like(T, dtype=float)
1369
+ dsL = np.empty_like(T, dtype=float)
1370
+ dsLt = np.empty_like(T, dtype=float)
1371
+ dsV = np.empty_like(T, dtype=float)
1372
+ dsVt = np.empty_like(T, dtype=float)
1373
+
1374
+ # Only check sub-critical temperatures for saturation
1375
+ I = T < self.data['Tc']
1376
+ dsL[I],dsLt[I],_ = self._dsl(T[I],diff=diff)
1377
+ dsV[I],dsVt[I],_ = self._dsv(T[I],diff=diff)
1378
+ # Down-select for densities between the saturation properties
1379
+ I[I] = np.logical_and(d[I] <= dsL[I], d[I] >= dsV[I])
1380
+ if I.any():
1381
+ # Use xd as a temporary result
1382
+ # Start with the denominator
1383
+ xd = 1./(dsL[I]/dsV[I] - 1.)
1384
+ # Calculate quality
1385
+ x = (dsL[I]/d[I] - 1.) * xd
1386
+ if diff:
1387
+ # Construct quality's deriv. w.r.t. temperature in steps
1388
+ # First, the most complicated term: the denominator's derivative
1389
+ xt = x * xd * (dsL[I]/dsV[I]) * (dsVt[I]/dsV[I] - dsLt[I]/dsL[I])
1390
+ # Continue to construct xt
1391
+ xt += xd*dsLt[I]/d[I]
1392
+ # Finalize xd
1393
+ xd *= -dsL[I] / d[I] / d[I]
1394
+ # Evaluate the saturation properties
1395
+ y[I],yt[I],yd[I] = fn(T[I],dsV[I],diff=diff)
1396
+ yy,yyt,yyd = fn(T[I],dsL[I],diff=diff)
1397
+ # Calculate the mixture properties and derivatives
1398
+ if diff:
1399
+ yt[I] = x*yt[I] + xt*y[I] + (1-x)*yyt - xt*yy
1400
+ yd[I] = x*yd[I] + xd*y[I] + (1-x)*yyd - xd*yy
1401
+ y[I] = x*y[I] + (1-x)*yy
1402
+ # Now deal with points that are not under the dome.
1403
+ I = np.logical_not(I)
1404
+ if I.any():
1405
+ y[I],yt[I],yd[I] = fn(T[I],d[I],diff=diff)
1406
+
1407
+ return y,yt,yd
1408
+
1409
+
1410
+ def _tpiter(self, T, p, fn, diff=1, debug=False):
1411
+ """T,p iterator wrapper (primative routine)
1412
+ _tpiter(T,p,fn, diff=1, debug=False)
1413
+
1414
+ This wrapper function evaluates a property inner routine from
1415
+ temperature and pressure. It is intended to be used to allow 1D
1416
+ iteration on a property with respect to temperature with constant
1417
+ pressure (isobaric). Because the property functions require density
1418
+ and temperature, _tpiter implements an inner hybrid1 iteration routine
1419
+ to determine the density for each value of temperature.
1420
+
1421
+ When diff is 1 (as it needs to be for _hybrid1 to work properly), the
1422
+ property's partial derivatives need to be shifted from constant-density
1423
+ into constant pressure space.
1424
+
1425
+ _tpiter accpets three required arguments:
1426
+ T Temperature numpy array in Kelvin
1427
+ p Pressure numpy array in Pa
1428
+ fn Property inner routine to be evaluated (e.g. self._h or self._s)
1429
+
1430
+ For example, a call to _hybrid1 to calculate temperature while
1431
+ specifying entropy and pressure might appear
1432
+
1433
+ self._hybrid1( self._tpiter, # Don't use _s, use _tpiter
1434
+ 'T', # We want to calculate T
1435
+ svalues, # Here are the target entropy values
1436
+ T, # The T array
1437
+ Ids, # The pre-initialized down-select array
1438
+ Tmin, Tmax, # T bounds
1439
+ param={'fn':self._s, 'p':pvalues})
1440
+
1441
+ Optional parameters (and their defaults) are:
1442
+ debug (False)
1443
+ Passed to the verbose parameter of the inner _hybrid1 routine. This
1444
+ produces quite a bit of text in most iterations. It should not be used
1445
+ by most users.
1446
+
1447
+ diff (1)
1448
+ When 0, returns no derivatives. When 1, returns the first-order
1449
+ derivatives.
1450
+ """
1451
+
1452
+ # Assume a standard inner property routine call signature
1453
+ d = self._d(T,p)
1454
+ y,yt,yd = fn(T,d,diff=diff)
1455
+ # If the derivative is requested, we need to shift from constant
1456
+ # density to constant pressure.
1457
+ if diff>0:
1458
+ _,pt,pd = self._p(T,d,diff=1)
1459
+ # Correct the partial derivatives of the property to be
1460
+ # with respect to T,p instead of T,d. Since d is used for
1461
+ # density, let's use D for derivative and _T or _d for
1462
+ # partial derivatives
1463
+ # The property, y,
1464
+ # Dy(T,d) = y_T DT + y_d Dd <== as evaluated by fn()
1465
+ # Pressure, p,
1466
+ # Dp(T,d) = p_T DT + p_d Dd <== as evaluated by _p()
1467
+ # So, differentials in density w.r.t. temperature while
1468
+ # holding pressure constant, Dp = 0, and
1469
+ # Dd/DT | p=const = -p_T / p_d
1470
+ # Differentials with density w.r.t. pressure while holding
1471
+ # temperature constant, DT = 0, and
1472
+ # Dd/Dp | T=const = 1/p_d
1473
+ # Therefore,
1474
+ # Dd = (-p_T / p_d) DT + (1 / p_d) Dp
1475
+ # Finally,
1476
+ # Dy = (y_T - y_d p_T / p_d) DT + (y_d / p_d) Dp
1477
+ yt = yt - yd * pt / pd
1478
+ yp = yd / pd
1479
+ # Do not support higher derivatives than 1
1480
+ return y,yt,yp
1481
+
1482
+
1483
+
1484
+ def _ao(self, tt, dd, diff=2):
1485
+ """Dimensionless ideal gas helmholtz free energy (primative routine)
1486
+ Evaluates an ideal gas equation of the form
1487
+ a = log(dd) + logt*log(tt) + tlogt*tt*log(tt) + p(t) + ...
1488
+ + c log(1-exp(-theta*tt)) + ...
1489
+
1490
+ where
1491
+ dd = d / dscale
1492
+ tt = Tscale / T
1493
+
1494
+ In the AOgroup dictionary defined by the mp1 data, the polynomial, p,
1495
+ is defined by the 'coef0' list. This list should should be readable
1496
+ by the _poly1() method. The 'logt' and 'tlogt' constants define the
1497
+ coefficients of the log(tt) and tt*log(tt) terms. They are optional.
1498
+
1499
+ The log/exp expansion is defined by the 'coef1' list. Each element of
1500
+ 'coef1' should be a two-element list or tuple containing [theta, c].
1501
+
1502
+ This is a PRIMATIVE ROUTINE. The arguments must already be
1503
+ nondimensionalized, and the returned values are non-dimensionalzied.
1504
+ """
1505
+
1506
+ # Start with the logarithmic terms
1507
+ # Log of density is easy - no coefficients needed
1508
+ A = np.log(dd)
1509
+ At = 0.
1510
+ Ad = 0.
1511
+ Att = 0.
1512
+ Atd = 0.
1513
+ Add = 0.
1514
+
1515
+ if diff>0:
1516
+ At = 0
1517
+ Ad = 1./dd
1518
+ if diff>1:
1519
+ Add = -Ad/dd
1520
+ Att = 0.
1521
+ Atd = 0.
1522
+ # The logt term does not appear in all models, but it does in many
1523
+ logt = None
1524
+ coef = self.data['AOgroup'].get('logt')
1525
+ if coef is not None:
1526
+ # We might need logt again - keep it for later
1527
+ logt = np.log(tt)
1528
+ A += coef * logt
1529
+ if diff>0:
1530
+ pt = coef/tt
1531
+ At += pt
1532
+ if diff>1:
1533
+ Att += -pt/tt
1534
+
1535
+ # In rare cases, the ideal gas model also includes a t * ln(t) term
1536
+ coef = self.data['AOgroup'].get('tlogt')
1537
+ if coef is not None:
1538
+ # Don't repeat the logt call if it has already been made
1539
+ if logt is None:
1540
+ logt = np.log(tt)
1541
+ A += coef * tt * logt
1542
+ if diff>0:
1543
+ At += coef * (logt + 1)
1544
+ if diff>1:
1545
+ Att += coef/tt
1546
+
1547
+
1548
+ # Move on to the polynomial expansion
1549
+ if 'coef0' in self.data['AOgroup']:
1550
+ p,pt,ptt = self._poly1(tt,self.data['AOgroup']['coef0'],diff)
1551
+ A+=p
1552
+ if diff>0:
1553
+ At += pt
1554
+ if diff>1:
1555
+ Att += ptt
1556
+
1557
+ # Now the nested log/exp expansion
1558
+ if 'coef1' in self.data['AOgroup']:
1559
+ for theta,c in self.data['AOgroup']['coef1']:
1560
+ e = np.exp(-theta*tt)
1561
+ p = np.log(1-e)
1562
+ A += c*p
1563
+ if diff>0:
1564
+ pt = theta*e/(1.-e)
1565
+ At += c*pt
1566
+ if diff>1:
1567
+ ptt = -pt*(theta + pt)
1568
+ Att += c*ptt
1569
+
1570
+ return A, At, Ad, Att, Atd, Add
1571
+
1572
+
1573
+ def _ar(self, tt, dd, diff=2):
1574
+ """Dimensionless residual helmhotz free energy (primative routine)
1575
+ Each fit in the group is of the form
1576
+ a = exp(-dd**k) * pk(tt, dd)
1577
+
1578
+ when dd = d / dscale, tt = Tscale / T
1579
+
1580
+ A,Ad,At,Add,Adt,Att = _ar(tt, dd, order=2)
1581
+
1582
+ Returns the Helmholtz free energy and its derivatives up to diff.
1583
+
1584
+ This is a PRIMATIVE ROUTINE. The arguments must already be
1585
+ nondimensionalized, and the returned values are non-dimensionalzied.
1586
+ """
1587
+ # Sparse polynomial evaluation is roughly 2x as fast as dense
1588
+ # polynomial evaluation for the R134a polynomials. The
1589
+ # explicitly defined algorithm is also roughly 2x as fast. the
1590
+ # p_d() algorithm for R134a evaluated in about 80us on a 4 core
1591
+ # AMD A10-9700B R7
1592
+
1593
+ ARgroup = self.data['ARgroup']
1594
+
1595
+ # First evaluate the polynomial without an exponential coefficient
1596
+ A,At,Ad,Att,Atd,Add = self._poly2(tt,dd,ARgroup['coef0'][0],diff)
1597
+
1598
+ k=0
1599
+ ddk = 1.
1600
+ for term in ARgroup['coef0'][1:]:
1601
+ p,pt,pd,ptt,ptd,pdd = self._poly2(tt, dd, term, diff)
1602
+
1603
+ k += 1
1604
+ ddk *= dd
1605
+ e = np.exp(-ddk)
1606
+ if diff>0:
1607
+ # Calculate the derivative of exp(-dd**k) without
1608
+ # the exponential; it will be multiplied through next.
1609
+ ed = -k*ddk/dd
1610
+
1611
+ if diff>1:
1612
+ # Calculate the second derivative of exp(-dd**k) without
1613
+ # the exponential; it will be multiplied through next.
1614
+ edd = ed*((k-1.)/dd + ed)
1615
+ # Multiply the exponential into all the terms
1616
+ pdd = e*(p*edd + 2.*pd*ed + pdd)
1617
+ ptd = e*(ptd + pt*ed)
1618
+ ptt *= e
1619
+
1620
+ Att += ptt
1621
+ Atd += ptd
1622
+ Add += pdd
1623
+
1624
+ pd = e*(p*ed + pd)
1625
+ pt *= e
1626
+
1627
+ At += pt
1628
+ Ad += pd
1629
+
1630
+ p *= e
1631
+
1632
+ A += p
1633
+
1634
+ # Evaluate AR1: c * dd**d * tt**t * exp(-a*(dd-ep)**2 - b*(tt-gam)**2)
1635
+ if 'coef1' in ARgroup:
1636
+ #This is the original table order
1637
+ #for c,d,t,a,b,gam,ep in ARgroup['coef1']:
1638
+ for t,d,b,a,gam,ep,c in ARgroup['coef1']:
1639
+ ddm1 = dd-ep
1640
+ ttm1 = tt-gam
1641
+ e = np.exp(-a*ddm1**2 - b*ttm1**2)
1642
+ p = c * dd**d * tt**t
1643
+
1644
+ if diff>0:
1645
+ pt = t*p/tt
1646
+ pd = d*p/dd
1647
+ et = -2*b*ttm1*e
1648
+ ed = -2*a*ddm1*e
1649
+ if diff>1:
1650
+ ptt = (t-1)*pt/tt
1651
+ pdd = (d-1)*pd/dd
1652
+ ptd = d*pt/dd
1653
+ ett = -2*b*(e + ttm1*et)
1654
+ edd = -2*a*(e + ddm1*ed)
1655
+ etd = -2*b*ttm1*ed
1656
+
1657
+ Att += e*ptt + 2*et*pt + ett*p
1658
+ Atd += e*ptd + ed*pt + et*pd + etd*p
1659
+ Add += e*pdd + 2*ed*pd + edd*p
1660
+ At += e*pt + et*p
1661
+ Ad += e*pd + ed*p
1662
+ A += e*p
1663
+
1664
+ if 'coef2' in ARgroup:
1665
+ for a,b,m,AA,BB,CC,DD,c in ARgroup['coef2']:
1666
+ ddm1 = dd-1
1667
+ ttm1 = tt-1
1668
+ # The model uses 1/m. We will invert it only once.
1669
+ m = 1./m
1670
+
1671
+ # Construct the distance function terms inside-out.
1672
+ # This method allows the derivatives to be efficiently
1673
+ # constructed along with the algebra; preventing
1674
+ # redundant power operations.
1675
+ # Start with the inner-most term, and borrow p as the
1676
+ # temporary variable for construction
1677
+
1678
+ # So long as m > 0, this will be fine, even when ddm1==0
1679
+ # For all data examined so far, m > 0
1680
+ # p = A(dd-1)**m
1681
+ p = AA*(ddm1*ddm1)**(0.5*m)
1682
+
1683
+ if diff>0:
1684
+ # Detect indices where ddm1 is zero. If any elements
1685
+ # of ddm1 are small, then we will use a different
1686
+ # method for calculating derivatives of this term.
1687
+ Ismall = (np.abs(ddm1) < 1e-6).any()
1688
+
1689
+ # Case out the nearly singular densities
1690
+ # When ddm1 is very small, we can't use the trick of
1691
+ # dividing by it to prevent repeated calls to **
1692
+ # c'est la vie
1693
+ if Ismall:
1694
+ # if m < 1, there is an irreconcilable singularity!
1695
+ if m < 1:
1696
+ pm.utility.print_warning('_ar():: m<1 in the ar2 term. This causes signularities in derivatives near critical density.')
1697
+ pd = AA * m * (ddm1*ddm1)**(0.5*m-0.5)
1698
+ if diff>1:
1699
+ if m < 2:
1700
+ pm.utility.print_warning('_ar():: m<2 in the ar2 term. This causes signularities in second derivatives near critical density.')
1701
+ pdd = AA * m * (m-1) * (ddm1*ddm1)**(0.5*m-1)
1702
+ else:
1703
+ pd = m * p / ddm1
1704
+ if diff>1:
1705
+ pdd = pd * (m-1)/ddm1
1706
+
1707
+ # p = (1-tt) + A(dd-1)**m
1708
+ p -= ttm1
1709
+ if diff>0:
1710
+ # It's OK to use a scalar here. We're going to
1711
+ # multiply it by p in a moment, and that will broad-
1712
+ # cast it appropriately.
1713
+ pt = -1.
1714
+ # Forcing ptt and ptd to zero is not necessary
1715
+ # we already know to ignore them in the next term.
1716
+ #if diff>1:
1717
+ #ptt = np.zeros_like(p)
1718
+ #ptd = np.zeros_like(p)
1719
+
1720
+ # Now, square the whole term
1721
+ # p = [(1-tt) + A(dd-1)**m]**2
1722
+ if diff>0:
1723
+ if diff>1:
1724
+ ptt = 2*pt*pt # + 2*p*ptt (but ptt=0)
1725
+ ptd = 2*pt*pd # + 2*p*ptd (but ptd=0)
1726
+ pdd = 2*pd*pd + 2*p*pdd
1727
+ pt = 2*p*pt
1728
+ pd = 2*p*pd
1729
+ p = p*p
1730
+
1731
+ # p = [(1-tt) + A(dd-1)**m]**2 + B(dd-1)**2a
1732
+ # borrow e for the new term
1733
+ e = BB*(ddm1*ddm1)**a
1734
+ p += e
1735
+ if diff>0:
1736
+ # This term can have a singularity from ddm1 near 0 too
1737
+ if Ismall:
1738
+ # If a is small, then this can be singular!
1739
+ if a < 0.5:
1740
+ pm.utility.print_warning('_ar():: a<0.5 in the ar2 term. This causes singularities in derivatives near critical density.')
1741
+
1742
+ pd += BB*2*a*(ddm1*ddm1)**(a-0.5)
1743
+ if diff>1:
1744
+ if a < 1.:
1745
+ pm.utility.print_warning('_ar():: a<1 in the ar2 term. This causes singularities in second derivatives near critical density.')
1746
+ pdd += BB*2*a*(2*a-1)*(ddm1*ddm1)**(a-1)
1747
+ else:
1748
+ ed = 2*a*e/ddm1
1749
+ pd += ed
1750
+ if diff>1:
1751
+ edd = (2*a-1)*ed/ddm1
1752
+ pdd += edd
1753
+
1754
+ # e = {[(1-tt) + A(dd-1)**m]**2 + B(dd-1)**2a}**b
1755
+ # borrow e for the new term
1756
+ # p is now Delta, raise it to the b power.
1757
+ e = p**b
1758
+ if diff>0:
1759
+ # We're done with Ismall, so repurpose it to detect
1760
+ # small values of delta.
1761
+ Ismall = (np.abs(p)<1e-6).any()
1762
+ if Ismall:
1763
+ if b<1:
1764
+ pm.utility.print_warning('_ar():: b<1 in the ar2 term. This causes singularities in derivatives very close to the critical point.')
1765
+ # Use a temporary to hold this expensive intermediate
1766
+ temp = b*p**(b-1)
1767
+ et = temp*pt
1768
+ ed = temp*pd
1769
+ else:
1770
+ et = b*e*pt/p
1771
+ ed = b*e*pd/p
1772
+
1773
+ if diff>1:
1774
+ if Ismall:
1775
+ if b<2:
1776
+ pm.utility.print_warning('_ar():: b<2 in the ar2 term. This causes singularities in second derivatives very close to the critical point.')
1777
+ # First, borrow temp, which is currently holding b*p**(b-1)
1778
+ ett = temp*ptt
1779
+ etd = temp*ptd
1780
+ edd = temp*pdd
1781
+
1782
+ # Now, calculate the second terms
1783
+ temp = b*(b-1)*p**(b-2)
1784
+ ett += temp*pt*pt
1785
+ etd += temp*pt*pd
1786
+ edd += temp*pd*pd
1787
+ else:
1788
+ ett = ((b-1)*et*pt + b*e*ptt)/p
1789
+ etd = ((b-1)*et*pd + b*e*ptt)/p
1790
+ edd = ((b-1)*ed*pd + b*e*pdd)/p
1791
+
1792
+ # p = c * dd * {[(1-tt) + A(dd-1)**m]**2 + B(dd-1)**2a}**b
1793
+ # This moves the intermediate value in e back into p
1794
+ p = c * dd * e
1795
+ if diff>0:
1796
+ pt = c*dd*et
1797
+ pd = c*(e + dd*ed)
1798
+ if diff>1:
1799
+ ptt = c*dd*ett
1800
+ ptd = c*(et + dd*etd)
1801
+ pdd = c*(2*ed + dd*edd)
1802
+
1803
+ # Finally, construct the exponential
1804
+ # e = exp(-C*(dd-1)**2 - D*(tt-1)**2)
1805
+ e = np.exp(-CC*ddm1**2 - DD*ttm1**2)
1806
+ if diff>0:
1807
+ et = -2*DD*ttm1*e
1808
+ ed = -2*CC*ddm1*e
1809
+ if diff>1:
1810
+ ett = -2*DD*(ttm1*et + e)
1811
+ etd = (-2*CC*ddm1)*et
1812
+ edd = -2*CC*(ddm1*ed + e)
1813
+ # Finally done; add the result to A
1814
+ A += p*e
1815
+ if diff>0:
1816
+ At += pt*e + p*et
1817
+ Ad += pd*e + p*ed
1818
+ if diff>1:
1819
+ Att += ptt*e + 2*pt*et + p*ett
1820
+ Atd += ptd*e + pt*ed + pd*et + p*etd
1821
+ Add += pdd*e + 2*pd*ed + p*edd
1822
+
1823
+
1824
+ return A,At,Ad,Att,Atd,Add
1825
+
1826
+
1827
+
1828
+ def _satfit(self, tt, fn, coef, diff=0):
1829
+ """Generic saturated property fit (primative routine)
1830
+ s, st, stt = _satfit(tt, fn=0, diff=0)
1831
+
1832
+ tt = T / Tc
1833
+
1834
+ returns saturation property normalized by its critical value
1835
+
1836
+ fn is an integer indicating which property fit form to use
1837
+ 0 poly(tt)
1838
+ coef is interpreted by poly1
1839
+ 1 poly(1-tt)
1840
+ coef is interpreted by poly1
1841
+ 2 exp(poly(1-tt))
1842
+ coef is interpreted by poly1, and the result is passed to np.exp()
1843
+ 3 exp(1/tt * poly(1-tt))
1844
+ coef is interpreted by poly1, the result is multiplied by 1/tt, and
1845
+ passed to np.exp()
1846
+ """
1847
+
1848
+ if fn == 0:
1849
+ p,pt,ptt = self._poly1(tt, coef, diff=diff)
1850
+ elif fn == 1:
1851
+ p,pt,ptt = self._poly1(1-tt, coef, diff=diff)
1852
+ if diff>0:
1853
+ pt = -pt
1854
+ elif fn == 2:
1855
+ p,pt,ptt = self._poly1(1-tt, coef, diff=diff)
1856
+ p = np.exp(p)
1857
+ if diff>0:
1858
+ pt = -pt
1859
+ if diff>1:
1860
+ ptt = p*(ptt + pt*pt)
1861
+ pt *= p
1862
+ elif fn == 3:
1863
+ p,pt,ptt = self._poly1(1-tt, coef, diff=diff)
1864
+ invt = 1./tt
1865
+ p*=invt
1866
+ if diff>0:
1867
+ pt = invt*(-pt-p)
1868
+ if diff>1:
1869
+ ptt = invt*(ptt-2*pt)
1870
+ p=np.exp(p)
1871
+ if diff>0:
1872
+ if diff>1:
1873
+ ptt = p*(ptt + pt*pt)
1874
+ pt = p * pt
1875
+ return p,pt,ptt
1876
+
1877
+
1878
+ def _dsv(self,T,diff=0):
1879
+ """Saturated vapor density (inner routine)
1880
+ """
1881
+ Tscale = self.data['DSVgroup']['Tscale']
1882
+ dscale = self.data['DSVgroup']['dscale']
1883
+
1884
+ d,dt,dtt = self._satfit(
1885
+ T/Tscale,
1886
+ self.data['DSVgroup']['fn'],
1887
+ self.data['DSVgroup']['coef'],
1888
+ diff)
1889
+ # Rescale
1890
+ d *= dscale
1891
+ if diff>0:
1892
+ dscale /= Tscale
1893
+ dt *= dscale
1894
+ if diff>1:
1895
+ dtt *= dscale/Tscale
1896
+
1897
+ return d,dt,dtt
1898
+
1899
+
1900
+ def _dsl(self,T,diff=0):
1901
+ """Saturated liquid density (inner routine)
1902
+ """
1903
+
1904
+ Tscale = self.data['DSLgroup']['Tscale']
1905
+ dscale = self.data['DSLgroup']['dscale']
1906
+
1907
+ d,dt,dtt = self._satfit(
1908
+ T/Tscale,
1909
+ self.data['DSLgroup']['fn'],
1910
+ self.data['DSLgroup']['coef'],
1911
+ diff)
1912
+ # Rescale
1913
+ d *= dscale
1914
+ if diff>0:
1915
+ dscale /= Tscale
1916
+ dt *= dscale
1917
+ if diff>1:
1918
+ dtt *= dscale/Tscale
1919
+
1920
+ return d,dt,dtt
1921
+
1922
+ def _ds(self, T, diff=0):
1923
+ """Calculate saturated liquid and vapor density (inner routine)
1924
+ dL,dV,dLT,dVT = _ds(T, diff=0)
1925
+
1926
+ Unlike _dsl and _dsv, which use polynomials to estimate the saturation
1927
+ lines, _ds is an iterative routine that calculates saturation from the
1928
+ equation of state using the Maxwell criteria.
1929
+ """
1930
+ # Create an iteration downselect array
1931
+ # and an out-of-bounds array
1932
+ I = np.logical_and(T < self.data['Tc'], T > self.data['Tt'])
1933
+
1934
+ # First, we need guesses for the high and low densities.
1935
+ # If there are polynomial groups available in the data set, use
1936
+ # them. If not, we will make some dangerous initial guesses.
1937
+ if 'DSLgroup' in self.data:
1938
+ d1 = self._dsl(T=T)[0]
1939
+ else:
1940
+ d1 = self.data['dlim'][1]
1941
+
1942
+ if 'DSVgroup' in self.data:
1943
+ d2 = self._dsv(T=T)[0]
1944
+ else:
1945
+ d2 = .001 * d1
1946
+
1947
+ # Obtain the critical density
1948
+ dc = self.data['dc']
1949
+
1950
+ A = np.empty((I.shape + (2,2)), dtype=float)
1951
+ R = np.empty((I.shape + (2,)), dtype=float)
1952
+
1953
+ # Iterate a maximum of 100 times
1954
+ for count in range(100):
1955
+ # Evaluate Gibbs energy at d1 and d2
1956
+ g1,g1T,g1d = self._g(T=T[I], d=d1[I], diff=1)
1957
+ g2,g2T,g2d = self._g(T=T[I], d=d2[I], diff=1)
1958
+ # Evaluate pressures at d1 and d2
1959
+ p1,p1T,p1d = self._p(T=T[I], d=d1[I], diff=1)
1960
+ p2,p2T,p2d = self._p(T=T[I], d=d2[I], diff=1)
1961
+
1962
+ # Formulate a residual array
1963
+ R[I,0] = g1-g2
1964
+ R[I,1] = p1-p2
1965
+
1966
+ # Formulate a solution matrix
1967
+ A[I,0,0] = -g1d
1968
+ A[I,0,1] = g2d
1969
+ A[I,1,0] = -p1d
1970
+ A[I,1,1] = p2d
1971
+
1972
+ # Solve and update the densities
1973
+ D = np.linalg.solve(A[I],R[I])
1974
+
1975
+ # Test for range - force the densities to the correct side
1976
+ # of the critical point. If the test fails, then automatically
1977
+ # fail the convergence check.
1978
+ d1test = d1[I] + D[:,0]
1979
+ d2test = d2[I] + D[:,1]
1980
+
1981
+ d1[I] = d1test
1982
+ d2[I] = d2test
1983
+
1984
+ # Test for convergence
1985
+ I[I] = np.logical_or(np.abs(D[:,0]) > d1[I]*1e-6,
1986
+ np.abs(D[:,1]) > d2[I]*1e-6)
1987
+ if not I.any():
1988
+ break
1989
+
1990
+ if I.any():
1991
+ raise pm.utility.PMAnalysisError('mp1._ds(): Iteration failed to converge at T(K) = ' + repr(T[I]))
1992
+
1993
+ d1T = d2T = None
1994
+ if diff:
1995
+ # Re-evaluate properties everywhere at the solution
1996
+ # Evaluate Gibbs energy at d1 and d2
1997
+ g1,g1T,g1d = self._g(T=T, d=d1, diff=1)
1998
+ g2,g2T,g2d = self._g(T=T, d=d2, diff=1)
1999
+ # Evaluate pressures at d1 and d2
2000
+ p1,p1T,p1d = self._p(T=T, d=d1, diff=1)
2001
+ p2,p2T,p2d = self._p(T=T, d=d2, diff=1)
2002
+
2003
+ A[:,0,0] = -g1d
2004
+ A[:,0,1] = g2d
2005
+ A[:,1,0] = -p1d
2006
+ A[:,1,1] = p2d
2007
+
2008
+ R[:,0] = g1T-g2T
2009
+ R[:,1] = p1T-p2T
2010
+
2011
+ D = np.linalg.solve(A,R)
2012
+ d1T = D[:,0]
2013
+ d2T = D[:,1]
2014
+
2015
+ return d1,d2,d1T,d2T
2016
+
2017
+ def _ps(self,T,diff=0):
2018
+ """Saturation pressure (inner routine)
2019
+ ps, ps_T, ps_TT = _ps(T, diff=0)
2020
+
2021
+ Presumes temperature is in Kelvin, reports pressure in Pa
2022
+ """
2023
+ Tscale = self.data['PSgroup']['Tscale']
2024
+ pscale = self.data['PSgroup']['pscale']
2025
+
2026
+ p,pt,ptt = self._satfit(
2027
+ T/Tscale,
2028
+ self.data['PSgroup']['fn'],
2029
+ self.data['PSgroup']['coef'],
2030
+ diff)
2031
+ # Rescale
2032
+ p *= pscale
2033
+ if diff>0:
2034
+ pscale /= Tscale
2035
+ pt *= pscale
2036
+ if diff>1:
2037
+ ptt *= pscale/Tscale
2038
+
2039
+ return p,pt,ptt
2040
+
2041
+
2042
+
2043
+ def _Ts(self,p):
2044
+ """Saturated temperature from pressure (inner routine)"""
2045
+ # Initialize the result array
2046
+ T = np.ones_like(p, dtype=float) * \
2047
+ 0.5*(self.data['Tt'] + self.data['Tc'])
2048
+ T,Tmin,Tmax = np.broadcast_arrays(T, self.data['Tt']*.99, self.data['Tc'])
2049
+
2050
+ # Create a down-select array
2051
+ Ids = np.logical_and(
2052
+ p >= self.data['pt'],
2053
+ p <= self.data['pc'])
2054
+ # Execute the iteration
2055
+ self._iter1(
2056
+ self._ps, # Invert the saturation pressure
2057
+ 'T', # Solve for temperature
2058
+ p, # such that _ps(T) = p
2059
+ T, # The initial T values
2060
+ Ids, # The down-select array
2061
+ Tmin, # Minimum at the triple temp.
2062
+ Tmax) # Maximum at the critical temp.
2063
+ return T
2064
+
2065
+
2066
+ def _p(self, T, d, diff=0):
2067
+ """Calculate pressure from (T,d) (inner routine)
2068
+ p, pt, pd = _p
2069
+
2070
+ _p() does NOT handle cases where d is "under the dome." _p() expects
2071
+ sub-critical densities to be either purely liquid or vapor.
2072
+ """
2073
+ p = 0.
2074
+ pt = 0.
2075
+ pd = 0.
2076
+
2077
+ Tscale = self.data['ARgroup']['Tscale']
2078
+ dscale = self.data['ARgroup']['dscale']
2079
+ R = self.data['R']
2080
+ # Calculate dimensionless arrays
2081
+ tt = Tscale/T
2082
+ dd = d/dscale
2083
+ # Calculate the Helmholtz free energy
2084
+ _,_,ard,_,artd,ardd = self._ar(tt,dd,diff+1)
2085
+ p = T*d*R*(1. + dd*ard)
2086
+ if diff>0:
2087
+ pt = R*d*(1 + dd*ard - tt*dd*artd)
2088
+ pd = R*T*(1 + 2*dd*ard + dd*dd*ardd)
2089
+
2090
+ return p,pt,pd
2091
+
2092
+
2093
+ def _d(self,T,p,debug=False):
2094
+ """Density iterator - calculate density from T,p (inner routine)
2095
+ T and p MUST be ndarrays
2096
+ """
2097
+ # Benchmarking shows that calls to _p() with fewer than 100
2098
+ # data points are all equivalently expensive; even when
2099
+ # utilizing only a single thread. As a result, iterations must
2100
+ # under no circumstances be conducted in series. This bisection
2101
+ # algorithm acts on all valid data in parallel.
2102
+
2103
+ # Create a down-select array
2104
+ I = np.ones_like(T, dtype=bool)
2105
+ # And initialize a solution array
2106
+ d = np.zeros_like(T, dtype=float)
2107
+ # Initialize upper and lower iteration densities
2108
+ da = np.zeros_like(T, dtype=float)
2109
+ db = np.zeros_like(T, dtype=float)
2110
+
2111
+ # Separate out sub-critical and super-critical values for
2112
+ # initial conditions. For temperatures that are super-critical,
2113
+ # use the extreme density limits of the data set.
2114
+ Itest = T>=self.data['Tc']
2115
+ #da[Itest] = self.data['dlim'][0]
2116
+ # Produce a minimum density from one tenth the ideal gas relationship
2117
+ da[Itest] = 0.1 * p[Itest] / (self.data['R'] * T[Itest])
2118
+ db[Itest] = self.data['dlim'][1]
2119
+ #d[Itest] = 0.5*(self.data['dlim'][0] + self.data['dlim'][1])
2120
+ # For temperatures that are sub-critical, detect whether the
2121
+ # state is liquid or gaseous. Set Itest to sub-critical.
2122
+ Itest = np.logical_not(Itest)
2123
+ if Itest.any():
2124
+ # Now, isolate the vapor points; set the upper density to the
2125
+ # saturated vapor density FORCE Istate to be an ndarray
2126
+ Istate = np.zeros_like(T, dtype=bool)
2127
+ Istate[Itest] = p[Itest] < self._ps(T[Itest], 0)[0]
2128
+ #da[Istate] = self.data['dlim'][0]
2129
+ # Produce a minimum density from half the ideal gas relationship
2130
+ da[Istate] = 0.5 * p[Istate] / (self.data['R'] * T[Istate])
2131
+ db[Istate] = self._dsv(T[Istate], 0)[0]
2132
+ #d[Istate] = db[Istate] - da[Istate]
2133
+ # Move the saturation bounds by 1%
2134
+ db[Istate] *= 1.01
2135
+ # Now, isolate the liquid points; set the lower density to the
2136
+ # saturated liquid density
2137
+ Istate[Itest] = np.logical_not(Istate[Itest])
2138
+ da[Istate] = self._dsl(T[Istate], 0)[0]
2139
+ db[Istate] = self.data['dlim'][1]
2140
+ # Reduce the lower density by 1%
2141
+ da[Istate] *= 0.99
2142
+
2143
+ # Iteratively reduce da until all points are bracketed
2144
+ Itest = self._p(T,da,0)[0] > p
2145
+ while Itest.any():
2146
+ da[Itest]/=2.
2147
+ Itest[Itest] = self._p(T[Itest], da[Itest],0)[0] > p[Itest]
2148
+
2149
+ # perform the iteration
2150
+ #self._iter1(
2151
+ self._hybrid1(
2152
+ self._p,
2153
+ 'd',
2154
+ p,
2155
+ d,
2156
+ I,
2157
+ da,
2158
+ db,
2159
+ Nmax=50,
2160
+ fx_index = 2,
2161
+ param={'T':T},
2162
+ verbose=debug)
2163
+
2164
+ return d
2165
+
2166
+
2167
+ def _T(self,d,p,sat=False):
2168
+ """Temperature iterator - calculate temperature from d,p (inner routine)
2169
+ d and p MUST be ndarrays
2170
+
2171
+ T = _T(d,p,sat=False)
2172
+
2173
+ Unlike _p(), _T() DOES handle cases where d is "under the dome." These
2174
+ calculations are relatively expensive, but they are necessary to the _T
2175
+ inversion process. When sat is set to True, these intermediate
2176
+ calculations are returned to prevent redundent saturation property calls
2177
+
2178
+ T,dsL,dsV,Isat = _T(d,p,sat=True)
2179
+
2180
+ dsL and dsV are the saturation densities at p
2181
+ Isat is a boolean index array that is True at points where d is between
2182
+ dsL and dsV.
2183
+
2184
+ Calling _T() should be avoided when possible, since it is one of the
2185
+ more expensive iterators. It requires iterative steps to calculate
2186
+ the saturation properties in terms of pressure AND the EOS has to be
2187
+ inverted to calculate T
2188
+ """
2189
+ # Benchmarking shows that calls to _p() with fewer than 100
2190
+ # data points are all equivalently expensive; even when
2191
+ # utilizing only a single thread. As a result, iterations must
2192
+ # under no circumstances be conducted in series. This bisection
2193
+ # algorithm acts on all valid data in parallel.
2194
+
2195
+ # Initialize a down-select array
2196
+ I = np.ones_like(d, dtype=bool)
2197
+ # Initialize a saturation index array
2198
+ Isat = np.zeros_like(I, dtype=bool)
2199
+ # Initialize a result array
2200
+ T = np.zeros_like(d, dtype=float)
2201
+ # Initialize upper and lower iteration densities
2202
+ Ta = np.zeros_like(d, dtype=float)
2203
+ Tb = np.zeros_like(d, dtype=float)
2204
+ # Saturaiton density arrays
2205
+ dsL = np.zeros_like(d, dtype=float)
2206
+ dsV = np.zeros_like(d, dtype=float)
2207
+
2208
+ # Separate out sub-critical and super-critical values for
2209
+ # initial conditions. For pressures that are super-critical,
2210
+ # use the extreme temperature limits of the data set.
2211
+ Itest = np.asarray(p>=self.data['pc'], dtype=bool)
2212
+ Ta[Itest] = self.data['Tlim'][0]
2213
+ Tb[Itest] = self.data['Tlim'][1]
2214
+
2215
+ # For pressures that are sub-critical, detect whether the
2216
+ # state is liquid or gaseous. Set Itest to sub-critical.
2217
+ Itest = np.logical_not(Itest)
2218
+ if Itest.any():
2219
+ # Now, identify the points in liquid, vapor, and mixed states
2220
+ # First, we'll need the saturation temperatures... this is
2221
+ # a numerically expensive process since Ts() is iterative.
2222
+ # Let Ta temporarily be the saturation temperature
2223
+ Ta[Itest] = self._Ts(p[Itest])
2224
+ dsL[Itest] = self._dsl(Ta[Itest], 0)[0]
2225
+ dsV[Itest] = self._dsv(Ta[Itest], 0)[0]
2226
+
2227
+ # Now, identify the liquid points
2228
+ Isat[Itest] = d[Itest] > dsL[Itest]
2229
+ # Shift the saturation temperature to Tb
2230
+ Tb[Isat] = Ta[Isat]
2231
+ Ta[Isat] = self.data['Tlim'][0]
2232
+ # Grow the boundary by 1%
2233
+ Tb[Isat] *= 1.01
2234
+
2235
+ # Now, identify the vapor points
2236
+ Isat[Itest] = d[Itest] < dsV[Itest]
2237
+ # Leave Ta as the saturation temperature
2238
+ Tb[Isat] = self.data['Tlim'][1]
2239
+ # Grow the boundary by 1%
2240
+ Ta[Isat] = np.maximum(0.99*Ta[Isat], self.data['Tlim'][0])
2241
+
2242
+ # Now, get the saturated states
2243
+ Isat[Itest] = np.logical_and(
2244
+ d[Itest] >= dsV[Itest],
2245
+ d[Itest] <= dsL[Itest])
2246
+ # We now have the solution at these points.
2247
+ # Assign the value to T
2248
+ T[Isat] = Ta[Isat]
2249
+ # Put safe values in Ta and Tb... just in case
2250
+ Tb[Isat] = self.data['Tlim'][1]
2251
+ Ta[Isat] = self.data['Tlim'][0]
2252
+ # Eliminate these from the down-select array - no iteraiton required.
2253
+ I[Isat] = False
2254
+
2255
+ # Note from v2.2.0... It is necessary to use _tditer instead of
2256
+ # using _p directly. Even when p is super-critical, when d is
2257
+ # under the dome, the lower temeprature guess reverts to a sub-
2258
+ # critical state, and the _p() values diverge wildly there. The
2259
+ # ideal future fix would be to invert the dsL or dsV lines to
2260
+ # find the actual minimum T at the specified density, but for
2261
+ # v2.2.1, we will revert to _tditer().
2262
+ self._hybrid1(
2263
+ self._tditer,
2264
+ 'T',
2265
+ p,
2266
+ T,
2267
+ I,
2268
+ Ta,
2269
+ Tb,
2270
+ param={'d':d, 'fn':self._p})
2271
+
2272
+ if sat:
2273
+ return T, dsL, dsV, Isat
2274
+ return T
2275
+
2276
+
2277
+ def _sat_argparse(self, T=None, p=None):
2278
+ """A standard argument parsing scheme for all user-layer saturation properties
2279
+ T,dL,dV = _sat_argparse(T=None, p=None)
2280
+
2281
+ Enforces that all returned parameters are numpy arrays with at least one
2282
+ dimension. Accepts T and p as scalars or array-like objects in
2283
+ [unit_temperature] and [unit_pressure] respectively.
2284
+
2285
+ Returns
2286
+ T the temperature in K
2287
+ dL and dV are the liquid and vapor densities in kg/m3
2288
+ """
2289
+ if p is None:
2290
+ if T is None:
2291
+ T = pm.config['def_T']
2292
+ T = pm.units.temperature_scale(
2293
+ np.asarray(T, dtype=float),
2294
+ to_units='K')
2295
+ if T.ndim==0:
2296
+ T = np.reshape(T, (1,))
2297
+ if (T<self.data['Tt']).any() or (T>self.data['Tc']).any():
2298
+ raise pm.utility.PMParamError(
2299
+ 'Saturation properties are not available at ' +
2300
+ 'temperatures beyond the triple or critical points.')
2301
+ elif T is None:
2302
+ p = pm.units.pressure(
2303
+ np.asarray(p, dtype=float),
2304
+ to_units='Pa')
2305
+ if p.ndim==0:
2306
+ p = np.reshape(p, (1,))
2307
+ if (p<self.data['pt']).any() or (p>self.data['pc']).any():
2308
+ raise pm.utility.PMParamError(
2309
+ 'Saturation properties are not available at ' +
2310
+ 'pressures beyond the triple or critical points.')
2311
+ T = self._Ts(p)
2312
+ else:
2313
+ raise pm.utility.PMParamError(
2314
+ 'Saturation temperature and pressure cannot be simultaneously specified')
2315
+
2316
+ dL = self._dsl(T,0)[0]
2317
+ dV = self._dsv(T,0)[0]
2318
+ return T, dL, dV
2319
+
2320
+
2321
+ def _argparse(self, *varg, **kwarg):
2322
+ """Present a standard argument scheme for all user-layer property methods
2323
+ T,d1,d2,x,I = _argparse( .. keyword arguments ..)
2324
+
2325
+ Accepts keyword arguments:
2326
+ e internal energy - requires p, d, v, or x
2327
+ h enthalpy - requires p, d, v, or x
2328
+ s entropy - requires T, p, d, v, or x
2329
+ T temperature
2330
+ p pressure
2331
+ d density
2332
+ v specific volume
2333
+ x quality
2334
+
2335
+ T the temperature array in K.
2336
+ d1 and d2 are densities in kg/m3. If the conditions are under the dome,
2337
+ then d1 is the liquid, and d2 is the vapor density.
2338
+ x is the quality. If conditions are not under the dome, it can be
2339
+ ignored.
2340
+ I is a boolean array whose elements will be True for conditions that are
2341
+ under the dome. Its values will be False otherwise.
2342
+
2343
+ returns temperature, density and quality at which the property is to be
2344
+ evaluated as independent arrays. When the conditions are under the dome
2345
+ d1 and d2 represent the liquid and vapor densities respectively. At all
2346
+ other conditions, x<0 and d1 == d2.
2347
+ """
2348
+
2349
+ # 1) Handle varg and kward and their defaults
2350
+ # 2) Apply the argument rules...
2351
+ # 2.1: All arguments must be legal
2352
+ # 2.2: Only 2 arguments unless T,p,x
2353
+ # 2.3: Only 1 inverse property
2354
+ # 2.4: d and v may not be specified together
2355
+ # 3) Convert the arguments to arrays with dim 1 or greater
2356
+ # 4) Convert to standard units
2357
+ # 5) Check for out-of-bounds on basic arguments
2358
+ # 6) Replace specific volume with density if it appears
2359
+ # 7) Case out the possible combinations
2360
+ # 8) Broadcast the arrays appropriately
2361
+ # 9) Calculate T,d1,d2,x, and I
2362
+
2363
+ # Fancy tool for tracking iteration issues
2364
+ debug = False
2365
+
2366
+ # 1) Handle varg and kwarg and apply defaults
2367
+
2368
+ # If varg is specified, assign its values to T,p
2369
+ if len(varg) > 0:
2370
+ if 'T' in kwarg:
2371
+ raise pm.utility.PMParamError('T was specified both positionally and with a keyword.')
2372
+ kwarg['T'] = varg[0]
2373
+ if len(varg) > 1:
2374
+ if 'p' in kwarg:
2375
+ raise pm.utility.PMParamError('p was specified both positionally and with a keyword.')
2376
+ kwarg['p'] = varg[1]
2377
+ if len(varg) > 2:
2378
+ raise pm.utility.PMParamError('Property calls with more than two arguments require keywords.')
2379
+
2380
+ # Count the number of arguments
2381
+ nargs = len(kwarg)
2382
+ if nargs == 1:
2383
+ if 'T' not in kwarg:
2384
+ kwarg['T'] = pm.config.def_T()
2385
+ else:
2386
+ kwarg['p'] = pm.config.def_p()
2387
+ elif nargs == 0:
2388
+ kwarg['T'] = pm.config.def_T()
2389
+ kwarg['p'] = pm.config.def_p()
2390
+
2391
+ # 2) Apply the argument rules
2392
+ # Re-measure the number of arguments and use sets to enforce
2393
+ # the remaining rules
2394
+ nargs = len(kwarg)
2395
+ args = set(kwarg.keys())
2396
+ # inverse_methods is a map between the property names that require
2397
+ # iteration and the inner method that calculates it. Inverse
2398
+ # args is a set of their names that will be used for argument
2399
+ # parsing
2400
+ inverse_methods = {'e':self._e, 'h':self._h, 's':self._s}
2401
+ inverse_args = set(inverse_methods.keys())
2402
+ # basic_args are the remaining legal arguments that do not need
2403
+ # iteration (OK, p does, but it's special).
2404
+ # legal_args are all arguments that can be legally accepted.
2405
+ basic_args = set(['T','p','d','v','x'])
2406
+ legal_args = inverse_args.union(basic_args)
2407
+ # Group the available arguments into basic and inverse sets
2408
+ inverse_args &= args
2409
+ basic_args &= args
2410
+
2411
+ # 2.1: There may only be 2 arguments UNLESS the input is T,p,x
2412
+ if nargs>2 and (args - set(['T','p','x'])):
2413
+ raise pm.utility.PMParamError(
2414
+ 'Specifying more than two simultaneous parameters is illegal (except for T,p,x).')
2415
+
2416
+ # 2.2: All arguments must be "legal" recognized arguments
2417
+ these_args = args - legal_args
2418
+ if these_args:
2419
+ message = 'Unrecognized propert(y/ies):'
2420
+ prefix = ' '
2421
+ for name in these_args:
2422
+ message += prefix + name
2423
+ prefix = ', '
2424
+ raise pm.utility.PMParamError(message)
2425
+
2426
+ # 2.3: Only one inverse property is allowed
2427
+ inverse_args = inverse_args.intersection(args)
2428
+ if len(inverse_args) > 1:
2429
+ message = 'Properties may not be specified together:'
2430
+ prefix = ' '
2431
+ for name in inverse_args:
2432
+ message += prefix + name
2433
+ prefix = ', '
2434
+ raise pm.utility.PMParamError(message)
2435
+
2436
+ # 2.4: Density and specific volume cannot be specified together
2437
+ if 'v' in args and 'd' in args:
2438
+ raise pm.utility.PMParamError('Density (d) and specific volume (v) cannot be specified together.')
2439
+
2440
+
2441
+ # 3) Convert all arguments to numpy arrays
2442
+ # The asarray function does NOT copy the array if it is already
2443
+ # a numpy array.
2444
+ for name,value in kwarg.items():
2445
+ value = np.asarray(value, dtype=float)
2446
+ if value.ndim == 0:
2447
+ value = np.reshape(value, (1,))
2448
+ kwarg[name] = value
2449
+
2450
+ # 4) Convert the units appropriately
2451
+ # This step will only make a copy of the array if the units need
2452
+ # to be converted. Otherwise, the array is passed through verbatim
2453
+ # As a result, the input array will ONLY be copied if it needs to
2454
+ # be reshaped, converted, or retyped.
2455
+ # 5) Check for out-of-bounds on the converted values
2456
+ # Checking before arrays are broadcast minimizes the number of
2457
+ # elements that need to be inspected
2458
+ # 6) Replace v with d if it appears
2459
+ if 'T' in kwarg:
2460
+ kwarg['T'] = pm.units.temperature_scale(kwarg['T'], to_units='K')
2461
+ # Test for out-of-bounds
2462
+ Ioob = np.logical_or(kwarg['T'] < self.data['Tlim'][0],
2463
+ kwarg['T'] > self.data['Tlim'][1])
2464
+ if Ioob.all():
2465
+ pm.utility.print_warning('All of the temperature values are out-of-bounds for this substance.'
2466
+ 'Legal values are between {:f} and {:f} Kelvin.'.format(*self.data['Tlim']))
2467
+ raise pm.utility.PMParamError('_ARGPARSE: Temperature values were all out of range.')
2468
+ elif Ioob.any():
2469
+ kwarg['T'][Ioob] = pm.config['def_oob']
2470
+ pm.utility.print_warning('Some temperature values were out-of-bounds for this substance.')
2471
+ if 'p' in kwarg:
2472
+ kwarg['p'] = pm.units.pressure(kwarg['p'], to_units='Pa')
2473
+ # Test for out-of-bounds
2474
+ Ioob = np.logical_or(kwarg['p'] < self.data['plim'][0],
2475
+ kwarg['p'] > self.data['plim'][1])
2476
+ if Ioob.all():
2477
+ pm.utility.print_warning('All of the pressure values are out-of-bounds for this substance.'
2478
+ 'Legal values are between {:f} and {:f} Pascals.'.format(*self.data['plim']))
2479
+ raise pm.utility.PMParamError('_ARGPARSE: Pressure values were all out of range.')
2480
+ elif Ioob.any():
2481
+ kwarg['p'][Ioob] = pm.config['def_oob']
2482
+ pm.utility.print_warning('Some pressure values were out-of-bounds for this substance.')
2483
+ if 'd' in kwarg:
2484
+ value = pm.units.volume(kwarg['d'], to_units='m3', exponent=-1)
2485
+ kwarg['d'] = pm.units.matter(value, self.data['mw'], to_units='kg')
2486
+ if 'v' in kwarg:
2487
+ # Convert and replace with d at the same time
2488
+ value = pm.units.volume(kwarg['v'], to_units='m3')
2489
+ kwarg['d'] = 1./pm.units.matter(value, self.data['mw'], to_units='kg', exponent=-1)
2490
+ # Update the keywords and argument sets to reflect the
2491
+ # substitution.
2492
+ args.add('d')
2493
+ basic_args.add('d')
2494
+ del kwarg['v']
2495
+ args.remove('v')
2496
+ basic_args.remove('v')
2497
+ if 'h' in kwarg:
2498
+ value = kwarg['h']
2499
+ value = pm.units.energy(value, to_units='J')
2500
+ value = pm.units.matter(value, self.data['mw'], to_units='kg', exponent=-1)
2501
+ kwarg['h'] = value
2502
+ if 'e' in kwarg:
2503
+ value = kwarg['e']
2504
+ value = pm.units.energy(value, to_units='J')
2505
+ value = pm.units.matter(value, self.data['mw'], to_units='kg', exponent=-1)
2506
+ kwarg['e'] = value
2507
+ if 's' in kwarg:
2508
+ value = kwarg['s']
2509
+ value = pm.units.energy(value, to_units='J')
2510
+ value = pm.units.matter(value, self.data['mw'], to_units='kg', exponent=-1)
2511
+ value = pm.units.temperature(value, to_units='K', exponent=-1)
2512
+ kwarg['s'] = value
2513
+ # x is dimensionless - no need to convert anything
2514
+ if 'x' in kwarg:
2515
+ if (kwarg['x'] > 1).any() or (kwarg['x'] < -1).any():
2516
+ raise pm.utility.PMParamError('Quality was found to be outside of the range -1,1.')
2517
+
2518
+
2519
+ # 6) Case out the different combinations
2520
+
2521
+ # If one of the arguments requires an inverse routine...
2522
+ if inverse_args:
2523
+ # Isolate the inverse property argument
2524
+ # Because of rule 2.3, there is only one
2525
+ invp = inverse_args.pop()
2526
+ invfn = inverse_methods[invp]
2527
+
2528
+ # There will only be one basic argument too - see rule 2.1
2529
+ basp = basic_args.pop()
2530
+
2531
+ # TP iteration
2532
+ if basp == 'p':
2533
+ # broadcast
2534
+ # We'll use h for the property (whether it is or not)
2535
+ h,p = np.broadcast_arrays(kwarg[invp],kwarg[basp])
2536
+ # Initialize results
2537
+ T = np.empty_like(h, dtype=float)
2538
+ d1 = np.empty_like(h, dtype=float)
2539
+ d2 = np.empty_like(h, dtype=float)
2540
+
2541
+ # Some important intermediates
2542
+ I = np.zeros_like(h, dtype=bool)
2543
+ Ta = np.empty_like(h, dtype=float)
2544
+ Tb = np.empty_like(h, dtype=float)
2545
+ Tsat = np.empty_like(h, dtype=float)
2546
+
2547
+ # It's tempting not to define these as full-sized arrays, but
2548
+ # They need to be down-selected for points under the dome to
2549
+ # calculate quality.
2550
+ hsL = np.empty_like(h, dtype=float)
2551
+ hsV = np.empty_like(h, dtype=float)
2552
+
2553
+ # Start with super-critical and sub-triple points
2554
+ Iwork = np.logical_or(p >= self.data['pc'], p <= self.data['pt'])
2555
+ Ta[Iwork] = self.data['Tlim'][0]
2556
+ Tb[Iwork] = self.data['Tlim'][1]
2557
+
2558
+ # Now work with the sub-critical points where saturation
2559
+ # is possible
2560
+ Iwork = np.logical_not(Iwork)
2561
+ if Iwork.any():
2562
+ # Get the saturation temperature at the specified pressure
2563
+ Tsat[Iwork] = self._Ts(p[Iwork])
2564
+ # Get the saturation densities at the specified pressure
2565
+ # We'll borrow d1 and d2 for this. The ones that aren't
2566
+ # overwritten later will be needed!
2567
+ d1[Iwork] = self._dsl(Tsat[Iwork],0)[0]
2568
+ d2[Iwork] = self._dsv(Tsat[Iwork],0)[0]
2569
+ # Finally get the saturation "property" values at the specified pressure
2570
+ hsL[Iwork] = invfn(Tsat[Iwork], d1[Iwork] ,0)[0]
2571
+ hsV[Iwork] = invfn(Tsat[Iwork], d2[Iwork] ,0)[0]
2572
+
2573
+ # Isolate points that are liquid
2574
+ # I will temporarily point to liquid states
2575
+ I[Iwork] = h[Iwork] < hsL[Iwork]
2576
+ Ta[I] = self.data['Tlim'][0]
2577
+ Tb[I] = Tsat[I]*(1-1e-6)
2578
+
2579
+ # Isolate points that are vapor
2580
+ # I will temporarily point to vapor states
2581
+ I[Iwork] = h[Iwork] > hsV[Iwork]
2582
+ Ta[I] = Tsat[I]*(1+1e-6)
2583
+ Tb[I] = self.data['Tlim'][1]
2584
+
2585
+ # Finally, isolate points that are saturated
2586
+ # These will be the final values for I
2587
+ I[Iwork] = np.logical_and( h[Iwork]<=hsV[Iwork], h[Iwork]>=hsL[Iwork] )
2588
+ # There's no need to iterate here
2589
+ # These temperatures are equal to Tsat
2590
+ Ta[I] = Tsat[I]
2591
+ Tb[I] = Tsat[I]
2592
+ T[I] = Tsat[I]
2593
+
2594
+ # Iwork is now a down-select array that points to non-
2595
+ # saturated points. These are the only ones that require
2596
+ # iteration.
2597
+ Iwork = np.logical_not(I)
2598
+ self._hybrid1(
2599
+ self._tpiter,
2600
+ 'T',
2601
+ h,
2602
+ T,
2603
+ Iwork,
2604
+ Ta, Tb,
2605
+ param={'fn':invfn, 'p':p, 'debug':False},
2606
+ verbose=debug,
2607
+ Nmax=50)
2608
+
2609
+ # If there were saturated points
2610
+ if I.any():
2611
+ x = -np.ones_like(h, dtype=float)
2612
+ x[I] = (h[I] - hsL[I])/(hsV[I]-hsL[I])
2613
+ # d1 and d2 already contain the liquid and vapor
2614
+ # densities at the saturated points
2615
+ # The remaining points still need to be calculated
2616
+ # use _d() to perform the iterative calculation
2617
+ Iwork = np.logical_not(I)
2618
+ d1[Iwork] = self._d(T=T[Iwork], p=p[Iwork])
2619
+ d2[Iwork] = d1[Iwork]
2620
+ else:
2621
+ x = np.broadcast_to(-1, h.shape)
2622
+ d1 = self._d(T=T,p=p)
2623
+ d2 = d1
2624
+
2625
+ return T,d1,d2,x,I
2626
+
2627
+ # T iteration
2628
+ elif basp == 'd':
2629
+ # set up the iteration
2630
+ # broadcast using h as the property
2631
+ h,d = np.broadcast_arrays(kwarg[invp],kwarg[basp])
2632
+ # Initialize results
2633
+ T = np.empty_like(h, dtype=float)
2634
+ x = -np.ones_like(h,dtype=float)
2635
+ # Some important intermediates
2636
+ Isat = np.ones_like(h, dtype=bool)
2637
+ Ta = np.full_like(h, self.data['Tlim'][0], dtype=float)
2638
+ Tb = np.full_like(h, self.data['Tlim'][1], dtype=float)
2639
+
2640
+ # There is no need to deal with saturation conditions
2641
+ # here - these are handled in the _tditer method since
2642
+ # the saturation densities depend on T.
2643
+ self._hybrid1(
2644
+ self._tditer,
2645
+ 'T',
2646
+ h,
2647
+ T,
2648
+ Isat,
2649
+ Ta, Tb,
2650
+ param={'fn':invfn, 'd':d, 'debug':debug},
2651
+ verbose=debug,
2652
+ Nmax=50)
2653
+
2654
+ # Finally, reconstruct quality and density.
2655
+ # Detect points with sub-critical temperatures.
2656
+ I = T < self.data['Tc']
2657
+ # If there are sub-critical points
2658
+ if I.any():
2659
+ # Repurpose Ta and Tb to be density saturation values
2660
+ # We'll make better use of them when we figure out
2661
+ # which (if any) need to be kept
2662
+ Ta[I] = self._dsl(T[I])[0]
2663
+ Tb[I] = self._dsv(T[I])[0]
2664
+ I[I] = np.logical_and(d[I] >= Tb[I], d[I] <= Ta[I])
2665
+
2666
+ # Finally, check for points under the dome. Otherwise,
2667
+ # we won't copy d - d1 and d2 will be identical
2668
+ if I.any():
2669
+ d1 = d.copy()
2670
+ d2 = d.copy()
2671
+ d1[I] = Ta[I]
2672
+ d2[I] = Tb[I]
2673
+ x = -np.ones(T.shape, dtype = float)
2674
+ x[I] = (Ta[I]/d[I] - 1.)/(Ta[I]/Tb[I] - 1.)
2675
+ else:
2676
+ d1 = d
2677
+ d2 = d
2678
+ x = np.broadcast_to(-1, T.shape)
2679
+
2680
+ return T,d1,d2,x,I
2681
+
2682
+ # Tx iteration
2683
+ elif basp == 'x':
2684
+ # Properties evaluated with arguments (T,x) are not monotonic;
2685
+ # there are multiple values of T that produce the same
2686
+ # property value. This is not a valid way to specify
2687
+ # a state.
2688
+ raise pm.utility.PMParamError('Specifying these properties is not enough information to determine the state: {:s}, {:s}\n'.format(invp,basp))
2689
+
2690
+ # d iteration
2691
+ elif basp == 'T':
2692
+ # broadcast
2693
+ # We'll use "s" for the property value
2694
+ s,T = np.broadcast_arrays(kwarg[invp],kwarg[basp])
2695
+ # Initialize results
2696
+ d1 = np.empty_like(s, dtype=float)
2697
+ d2 = np.empty_like(s, dtype=float)
2698
+ x = -np.ones_like(s, dtype=float)
2699
+
2700
+ # Some important intermediates
2701
+ da = np.zeros_like(s, dtype=float)
2702
+ db = np.full_like(s, self.data['dlim'][1], dtype=float)
2703
+ ssL = np.empty_like(s, dtype=float)
2704
+ ssV = np.empty_like(s, dtype=float)
2705
+ p = np.empty_like(s, dtype=float)
2706
+ I = np.zeros_like(s, dtype=bool)
2707
+
2708
+ # for points with sub-critical temperatures, we will test for
2709
+ # saturation
2710
+ Iwork = T < self.data['Tc']
2711
+ if Iwork.any():
2712
+ # Use upper and lower density limits as temporaries
2713
+ # d1=liquid, d2=vapor
2714
+ d1[Iwork] = self._dsl(T[Iwork])[0]
2715
+ d2[Iwork] = self._dsv(T[Iwork])[0]
2716
+ ssL[Iwork] = invfn(T[Iwork], d1[Iwork])[0]
2717
+ ssV[Iwork] = invfn(T[Iwork], d2[Iwork])[0]
2718
+
2719
+ # Start with liquid points.
2720
+ # I will temporarily point to liquid states
2721
+ I[Iwork] = s[Iwork] < ssL[Iwork]
2722
+ # Adjust the lower bound by 1% to account for numerical inconsistencies
2723
+ da[I] = 0.99 * d1[I]
2724
+ db[I] = self.data['dlim'][1]
2725
+
2726
+ # Now, move on to vapor points
2727
+ # I will temporarily point to vapor states
2728
+ I[Iwork] = s[Iwork] > ssV[Iwork]
2729
+ da[I] = self.data['dlim'][0]
2730
+ # Adjust the upper bound by 1% to account for numerical inconsistencies
2731
+ db[I] = 1.01*d2[I]
2732
+
2733
+ # Finally, deal with points that are saturated
2734
+ I[Iwork] = np.logical_and(ssL[Iwork] <= s[Iwork], s[Iwork] <= ssV[Iwork])
2735
+ # I now has its final value, pointing to saturated points
2736
+
2737
+ # For most data sets, the minim density is zero, but that is not
2738
+ # actually a legal value. If necessary, iterate on the lower
2739
+ # bound until the solution is bracketed
2740
+ Iwork = np.logical_and(da == 0, np.logical_not(I))
2741
+ if Iwork.any():
2742
+ # Come up with a bracketing value for density that is not zero
2743
+ # Most data sets use the minimum density as 0, but that crashes
2744
+ da[Iwork] = .9999 * self.data['dlim'][0] + .0001 * self.data['dlim'][1]
2745
+ # calculate the entropy at the minimum and test to ensure inclusion
2746
+ # Recycle the ssL array as a temporary for the lower-bound entropy
2747
+ ssL[Iwork] = invfn(T=T[Iwork],d=da[Iwork])[0]
2748
+ Iwork[Iwork] = ssL[Iwork] < s[Iwork]
2749
+ count = 0
2750
+ # Keep going as long as the lower bound entropy is less than
2751
+ # the target entropy for any points
2752
+ while Iwork.any():
2753
+ # dump out if this has been going on for too long
2754
+ count += 1
2755
+ if count > 20:
2756
+ raise pm.utility.PMAnalysisError('Failed while searching for a lower density value to bracket a solution.')
2757
+ da[Iwork] = 0.5*(self.data['dlim'][0] + da[Iwork])
2758
+ ssL[Iwork] = invfn(T=T[Iwork], d=da[Iwork])[0]
2759
+ Iwork[Iwork] = ssL[Iwork] < s[Iwork]
2760
+
2761
+ # Now, values are actually bracketed. Now, we can iterate.
2762
+ Iwork = np.logical_not(I)
2763
+ self._hybrid1(
2764
+ invfn,
2765
+ 'd',
2766
+ s,
2767
+ d1,
2768
+ Iwork,
2769
+ da, db,
2770
+ param={'T':T},
2771
+ verbose=debug,
2772
+ fx_index=2,
2773
+ Nmax=50)
2774
+
2775
+ # Finally, check for points under the dome. Otherwise,
2776
+ # we won't copy d - d1 and d2 will be identical
2777
+ if I.any():
2778
+ # d1 and d2 already contain liquid and vapor
2779
+ # densities at saturated points. Everywhere else
2780
+ # they should be equal
2781
+ Iwork = np.logical_not(I)
2782
+ d2[Iwork] = d1[Iwork]
2783
+ x = -np.ones(T.shape, dtype = float)
2784
+ x[I] = (s[I] - ssL[I])/(ssV[I] - ssL[I])
2785
+ else:
2786
+ # Throw away d2 and just return two identical copies
2787
+ # of d1
2788
+ d2 = d1
2789
+ x = np.broadcast_to(-1, T.shape)
2790
+
2791
+ return T, d1, d2, x, I
2792
+
2793
+ # Catch an unhandled parameter bug
2794
+ else:
2795
+ raise pm.utility.PMParamError('Please report a bug: There was an unhandled argument in the inverse_args algorithm: ' + basp)
2796
+
2797
+
2798
+ elif 'T' in args:
2799
+
2800
+ # T,p
2801
+ # If p is defined, then none of the conditions are under the
2802
+ # dome. Use _d() to invert into density units.
2803
+ if 'p' in args:
2804
+ # Deal with the special case that T,p,x are specified
2805
+ if 'x' in args:
2806
+ x = kwarg['x']
2807
+ else:
2808
+ x = np.array([-1], dtype=float)
2809
+
2810
+ # Force compatible arrays
2811
+ T,p,x = np.broadcast_arrays(kwarg['T'],kwarg['p'],x)
2812
+ # Which points are not under the dome?
2813
+ I = x<0.
2814
+
2815
+ # Initialize densities
2816
+ d1 = np.zeros_like(T)
2817
+ d2 = np.zeros_like(T)
2818
+
2819
+ # deal with the non-saturated points
2820
+ d1[I] = self._d(T[I],p[I])
2821
+ d2[I] = d1[I]
2822
+ # Deal with densities under the dome
2823
+ I = np.logical_not(I)
2824
+
2825
+ # Verify that the temperatures are sub-critical values
2826
+ # that fail this test will be set to nan
2827
+ Iwork = np.zeros_like(T, dtype=bool)
2828
+ Iwork[I] = T[I] > self.data['Tc']
2829
+ if Iwork.any():
2830
+ # If T or x do not own their memory, copy them so we
2831
+ # can write to them
2832
+ if T.base is not None:
2833
+ T = np.array(T)
2834
+ if x.base is not None:
2835
+ x = np.array(x)
2836
+ if I.base is not None:
2837
+ I = np.array(I)
2838
+ T[Iwork] = pm.config['def_oob']
2839
+ d1[Iwork] = pm.config['def_oob']
2840
+ d2[Iwork] = pm.config['def_oob']
2841
+ x[Iwork] = pm.config['def_oob']
2842
+ I[Iwork] = False
2843
+ pm.utility.print_warning(
2844
+ 'Quality was specified with temperatures above the critical point.')
2845
+
2846
+ d1[I] = self._dsl(T[I])[0]
2847
+ d2[I] = self._dsv(T[I])[0]
2848
+
2849
+ return T, d1, d2, x, I
2850
+
2851
+ # T,d (or v)
2852
+ elif 'd' in args:
2853
+ # broadcast the arrays
2854
+ T,d1 = np.broadcast_arrays(kwarg['T'], kwarg['d'])
2855
+ # Isolate the sub-critical temperatures
2856
+ I = np.asarray(T<self.data['Tc'])
2857
+ # Calculate the saturation densities
2858
+ dsL = self._dsl(T[I])[0]
2859
+ dsV = self._dsv(T[I])[0]
2860
+ # Identify the densities that are under the dome
2861
+ Isat = np.logical_and(
2862
+ d1[I] < dsL, d1[I] > dsV)
2863
+ # Modify I to include only the points that are saturated
2864
+ I[I] = Isat
2865
+ # If there are any densities under the dome
2866
+ if Isat.any():
2867
+ # Broadcasting can cause elements of d1 to refer to
2868
+ # common locations in memory. If there are
2869
+ # saturated points, we need to modify d1, so this
2870
+ # will force d1 to be a fully populated array.
2871
+ d1 = d1.copy()
2872
+ # Calculate the quality
2873
+ x = -np.ones_like(T, dtype=float)
2874
+ x[I] = (dsL[Isat] / d1[I] - 1.) / (dsL[Isat] / dsV[Isat] - 1.)
2875
+ # Update the densities
2876
+ d2 = d1.copy()
2877
+ d1[I] = dsL[Isat]
2878
+ d2[I] = dsV[Isat]
2879
+ else:
2880
+ d2 = d1
2881
+ x = np.broadcast_to(-1,T.shape)
2882
+ return T, d1, d2, x, I
2883
+
2884
+ # T,x
2885
+ # If quality is defined, then the points MUST be saturated
2886
+ elif 'x' in args:
2887
+ T,x,I = np.broadcast_arrays(kwarg['T'],kwarg['x'],True)
2888
+ if (T>self.data['Tc']).any():
2889
+ raise pm.utility.PMParamError(
2890
+ 'Quality cannot be specified above the critical temperature.')
2891
+ elif (x<0).any():
2892
+ raise pm.utility.PMParamError(
2893
+ 'When specifying T,x together, all values of x must be between 0 and 1.')
2894
+ d1 = self._dsl(T,0)[0]
2895
+ d2 = self._dsv(T,0)[0]
2896
+ return T,d1,d2,x,I
2897
+
2898
+ # This should never happen
2899
+ else:
2900
+ message = 'Please report a bug: Unhandled event [T] in _argparse with args:'
2901
+ prefix = ' '
2902
+ for name in args:
2903
+ message += prefix + name
2904
+ prefix = ', '
2905
+ raise pm.utility.PMParamError(message)
2906
+ # p
2907
+ # If p is the primary parameter
2908
+ elif 'p' in kwarg:
2909
+ # p,d
2910
+ # Pressure, density is an expensive combination since it
2911
+ # involves iteration to determine the saturation properties
2912
+ # AND to recover temperature.
2913
+ if 'd' in kwarg:
2914
+ # Broadcast the arrays
2915
+ d1,p = np.broadcast_arrays(kwarg['d'],kwarg['p'])
2916
+ # This one's an expensive funciton call
2917
+ # Get temperature and the saturation densities
2918
+ T,dsL,dsV,Isat = self._T(d1,p,sat=True)
2919
+ # If there are any saturated points
2920
+ if Isat.any():
2921
+ # Broadcasting can cause elements of d1 to refer to
2922
+ # common locations in memory. If there are
2923
+ # saturated points, we need to modify d1, so this
2924
+ # will force d1 to be a fully populated array.
2925
+ if d1.base is not None:
2926
+ d1 = d1.copy()
2927
+ # Calculate the quality
2928
+ x = -np.ones_like(p, dtype=float)
2929
+ x[Isat] = (dsL[Isat] / d1[Isat] - 1.) / (dsL[Isat] / dsV[Isat] - 1.)
2930
+ # Update the densities
2931
+ d2 = d1.copy()
2932
+ d1[Isat] = dsL[Isat]
2933
+ d2[Isat] = dsV[Isat]
2934
+ else:
2935
+ d2 = d1
2936
+ x = np.broadcast_to(-1,T.shape)
2937
+ return T,d1,d2,x,Isat
2938
+
2939
+ # p,x
2940
+ # If quality is defined, we are saturated
2941
+ elif 'x' in kwarg:
2942
+
2943
+ # Ensure that p is sub-critical at all points
2944
+ # Do this before broadcasting to prevent redundant checks
2945
+ if (kwarg['p']>self.data['pc']).any():
2946
+ raise pm.utility.PMParamError('Quality cannot be specified at pressures above the critical point.')
2947
+ elif (kwarg['x']<0).any():
2948
+ raise pm.utility.PMParamError('When specifying p,x, x must be between 0 and 1 at all points.')
2949
+
2950
+ p,x,I = np.broadcast_arrays(kwarg['p'],kwarg['x'],True)
2951
+ # T is just the saturation temperature
2952
+ T = self._Ts(p)
2953
+ d1 = self._dsl(T,0)[0]
2954
+ d2 = self._dsv(T,0)[0]
2955
+ return T, d1, d2, x, I
2956
+
2957
+ # This should never happen
2958
+ else:
2959
+ message = 'Please report a bug: Unhandled event [p] in _argparse with args:'
2960
+ prefix = ' '
2961
+ for name in args:
2962
+ message += prefix + name
2963
+ prefix = ', '
2964
+ raise pm.utility.PMParamError(message)
2965
+
2966
+ # d
2967
+ elif 'd' in args:
2968
+ # d,x
2969
+ # This combination is not supported!
2970
+ # This represents an expensive inversion problem that is
2971
+ # not certain to have a solution, and it is highly unusual
2972
+ # to specify quality AND density.
2973
+ if 'x' in args:
2974
+ raise pm.utility.PMParamError(
2975
+ 'Specifying properties by density and quality is not currently supported.')
2976
+ # This should never happen
2977
+ else:
2978
+ message = 'Please report a bug: Unhandled event [d] in _argparse with args:'
2979
+ prefix = ' '
2980
+ for name in args:
2981
+ message += prefix + name
2982
+ prefix = ', '
2983
+ raise pm.utility.PMParamError(message)
2984
+ message = 'Please report a bug: Unhandled event [MASTER] in _argparse with args:'
2985
+ prefix = ' '
2986
+ for name in args:
2987
+ message += prefix + name
2988
+ prefix = ', '
2989
+ raise pm.utility.PMParamError(message)
2990
+
2991
+
2992
+
2993
+ def _e(self,T,d,diff=0):
2994
+ """Internal energy (inner routine)
2995
+ e,eT,ed = _e(T,d,diff=0)
2996
+ """
2997
+ eT = None
2998
+ ed = None
2999
+
3000
+ # The IG part
3001
+ R = self.data['R']
3002
+ Tscale = self.data['AOgroup']['Tscale']
3003
+ dscale = self.data['AOgroup']['dscale']
3004
+ tt = Tscale / T
3005
+ dd = d / dscale
3006
+ _,at,_,att,atd,_ = self._ao(tt,dd,diff+1)
3007
+
3008
+ e = at
3009
+ if diff>0:
3010
+ eT = tt*tt*att
3011
+ ed = atd/dscale
3012
+
3013
+ # The residual part
3014
+ Tscale = self.data['ARgroup']['Tscale']
3015
+ dscale = self.data['ARgroup']['dscale']
3016
+ tt = Tscale / T
3017
+ dd = d / dscale
3018
+ _,at,ad,att,atd,add = self._ar(tt,dd,diff+1)
3019
+ e += at
3020
+ e *= R*Tscale
3021
+ if diff>0:
3022
+ eT += tt*tt*att
3023
+ eT *= -R
3024
+ ed += atd/dscale
3025
+ ed *= R*Tscale
3026
+
3027
+ return e,eT,ed
3028
+
3029
+
3030
+ def _h(self,T,d,diff=0):
3031
+ """enthalpy (inner routine)
3032
+ h,hT,hd = _h(T,d,diff=0)
3033
+ """
3034
+ hT = None
3035
+ hd = None
3036
+
3037
+ # The IG part
3038
+ R = self.data['R']
3039
+ Tscale = self.data['AOgroup']['Tscale']
3040
+ dscale = self.data['AOgroup']['dscale']
3041
+ tt = Tscale / T
3042
+ dd = d / dscale
3043
+ _,at,_,att,atd,_ = self._ao(tt,dd,diff+1)
3044
+
3045
+ h = 1. + tt*at
3046
+ if diff>0:
3047
+ hT = 1. - tt*tt*att
3048
+ hd = tt*atd/dscale
3049
+
3050
+ # The residual part
3051
+ Tscale = self.data['ARgroup']['Tscale']
3052
+ dscale = self.data['ARgroup']['dscale']
3053
+ tt = Tscale / T
3054
+ dd = d / dscale
3055
+ _,at,ad,att,atd,add = self._ar(tt,dd,diff+1)
3056
+ h += dd*ad + tt*at
3057
+ h *= R*T
3058
+ if diff>0:
3059
+ hT += dd*ad - tt*(tt*att + dd*atd)
3060
+ hT *= R
3061
+ hd += (ad + dd*add + tt*atd)/dscale
3062
+ hd *= R*T
3063
+
3064
+ return h,hT,hd
3065
+
3066
+ def _s(self,T,d,diff=0):
3067
+ """entropy (inner routine)
3068
+ s,sT,sd = _s(T,d,diff=0)
3069
+ """
3070
+ sT = None
3071
+ sd = None
3072
+
3073
+ # The IG part
3074
+ R = self.data['R']
3075
+ Tscale = self.data['AOgroup']['Tscale']
3076
+ dscale = self.data['AOgroup']['dscale']
3077
+ tt = Tscale / T
3078
+ dd = d / dscale
3079
+ a,at,ad,att,atd,_ = self._ao(tt,dd,diff+1)
3080
+
3081
+ s = tt*at - a
3082
+ if diff>0:
3083
+ sT = tt*tt*att
3084
+ sd = (tt*atd - ad)/dscale
3085
+
3086
+ # The residual part
3087
+ Tscale = self.data['ARgroup']['Tscale']
3088
+ dscale = self.data['ARgroup']['dscale']
3089
+ tt = Tscale / T
3090
+ dd = d / dscale
3091
+ a,at,ad,att,atd,_ = self._ar(tt,dd,diff+1)
3092
+ s += tt*at - a
3093
+ s *= R
3094
+ if diff>0:
3095
+ sT += tt*tt*att
3096
+ sT *= -R/T
3097
+ sd += (tt*atd - ad)/dscale
3098
+ sd *= R
3099
+
3100
+ return s,sT,sd
3101
+
3102
+ def _f(self, T, d, diff=0):
3103
+ """Free energy
3104
+ f,ft,fd = _f(T,d,diff=0)
3105
+
3106
+ """
3107
+ # The IG part
3108
+ R = self.data['R']
3109
+ Tscale = self.data['AOgroup']['Tscale']
3110
+ dscale = self.data['AOgroup']['dscale']
3111
+ tt = Tscale / T
3112
+ dd = d / dscale
3113
+ a,at,ad,_,_,_ = self._ao(tt,dd,diff+1)
3114
+
3115
+ f = a
3116
+ ft = None
3117
+ fd = None
3118
+ if diff:
3119
+ ft = a - tt*at
3120
+ fd = ad/dscale
3121
+
3122
+ # The residual part
3123
+ Tscale = self.data['ARgroup']['Tscale']
3124
+ dscale = self.data['ARgroup']['dscale']
3125
+ tt = Tscale / T
3126
+ dd = d / dscale
3127
+ a,at,ad,_,_,_ = self._ar(tt,dd,diff+1)
3128
+
3129
+ f += a
3130
+ f *= R*T
3131
+ if diff:
3132
+ ft += a - tt*at
3133
+ ft *= R
3134
+ fd += ad/dscale
3135
+ fd *= R*T
3136
+
3137
+ return f,ft,fd
3138
+
3139
+
3140
+
3141
+ def _g(self, T, d, diff=0):
3142
+ """Gibbs energy
3143
+ g,gt,gd = _g(T,d,diff=0)
3144
+
3145
+ """
3146
+ # The IG part
3147
+ R = self.data['R']
3148
+ Tscale = self.data['AOgroup']['Tscale']
3149
+ dscale = self.data['AOgroup']['dscale']
3150
+ tt = Tscale / T
3151
+ dd = d / dscale
3152
+ a,at,ad,_,atd,add = self._ao(tt,dd,diff+1)
3153
+
3154
+ g = a + 1.
3155
+ gt = None
3156
+ gd = None
3157
+ if diff:
3158
+ gt = a + 1. - tt*at
3159
+ gd = ad/dscale
3160
+
3161
+ # The residual part
3162
+ Tscale = self.data['ARgroup']['Tscale']
3163
+ dscale = self.data['ARgroup']['dscale']
3164
+ tt = Tscale / T
3165
+ dd = d / dscale
3166
+ a,at,ad,_,atd,add = self._ar(tt,dd,diff+1)
3167
+
3168
+ g += a + dd*ad
3169
+ g *= R*T
3170
+ if diff:
3171
+ gt += a + dd*ad - tt*(at + dd*atd)
3172
+ gt *= R
3173
+ gd += (2*ad + dd*add)/dscale
3174
+ gd *= R*T
3175
+
3176
+ return g,gt,gd
3177
+
3178
+ def _a(self,T,d):
3179
+ """Speed of sound (inner routine)
3180
+ a = _a(T,d)
3181
+ """
3182
+ R = self.data['R']
3183
+ Tscale = self.data['AOgroup']['Tscale']
3184
+ dscale = self.data['AOgroup']['dscale']
3185
+ tt = Tscale / T
3186
+ dd = d / dscale
3187
+ _,_,_,att,_,_ = self._ao(tt,dd,2)
3188
+
3189
+ # We'll build this in three terms
3190
+ # b - c*c/d
3191
+ B = 1 # The IG portion of b and c are simple
3192
+ C = 1
3193
+ D = tt * tt * att
3194
+
3195
+ # The residual part
3196
+ Tscale = self.data['ARgroup']['Tscale']
3197
+ dscale = self.data['ARgroup']['dscale']
3198
+ tt = Tscale / T
3199
+ dd = d / dscale
3200
+ _,_,ad,att,atd,add = self._ar(tt,dd,2)
3201
+ B += dd*(2*ad + dd*add)
3202
+ C += dd*(ad - tt*atd)
3203
+ D += tt * tt * att
3204
+
3205
+ return np.sqrt(R * T * (B - C*C/D))
3206
+
3207
+
3208
+ def _cp(self,T,d):
3209
+ """Isobaric specific heat (inner routine)
3210
+ cp = _cp(T,d)
3211
+ """
3212
+
3213
+ # The IG part
3214
+ R = self.data['R']
3215
+ Tscale = self.data['AOgroup']['Tscale']
3216
+ dscale = self.data['AOgroup']['dscale']
3217
+ tt = Tscale / T
3218
+ dd = d / dscale
3219
+ _,_,_,att,_,_ = self._ao(tt,dd,2)
3220
+
3221
+ cp = -tt*tt*att
3222
+
3223
+ # The residual part
3224
+ Tscale = self.data['ARgroup']['Tscale']
3225
+ dscale = self.data['ARgroup']['dscale']
3226
+ tt = Tscale / T
3227
+ dd = d / dscale
3228
+ _,_,ad,att,atd,add = self._ar(tt,dd,2)
3229
+
3230
+ temp = 1.+dd*(ad-tt*atd)
3231
+ cp += -tt*tt*att + temp*temp/(1.+dd*(2.*ad+dd*add))
3232
+ cp *= R
3233
+ return cp
3234
+
3235
+
3236
+ def _cv(self,T,d):
3237
+ """Isochoric specific heat (inner routine)
3238
+ cv = _cv(T,d)
3239
+ """
3240
+
3241
+ # The IG part
3242
+ R = self.data['R']
3243
+ Tscale = self.data['AOgroup']['Tscale']
3244
+ dscale = self.data['AOgroup']['dscale']
3245
+ tt = Tscale / T
3246
+ dd = d / dscale
3247
+ _,_,_,att,_,_ = self._ao(tt,dd,2)
3248
+
3249
+ cv = tt*tt*att
3250
+
3251
+ # The residual part
3252
+ Tscale = self.data['ARgroup']['Tscale']
3253
+ dscale = self.data['ARgroup']['dscale']
3254
+ tt = Tscale / T
3255
+ dd = d / dscale
3256
+ _,_,_,att,_,_ = self._ar(tt,dd,2)
3257
+
3258
+ cv += tt*tt*att
3259
+ cv *= -R
3260
+ return cv
3261
+
3262
+
3263
+ # #
3264
+ # USER ROUTINES #
3265
+ # #
3266
+
3267
+
3268
+ # #
3269
+ # Data limits #
3270
+ # #
3271
+ def Tlim(self, p=None):
3272
+ """Return the temperature limits for the data set
3273
+ Tmin, Tmax = Tlim(p=None)
3274
+
3275
+ Tlim accepts pressure as an argument for extensibility, but the MP1
3276
+ class has homogeneous temperature limits.
3277
+
3278
+ Returns the temperature limits in [unit_temperature].
3279
+ """
3280
+ return pm.units.temperature_scale(
3281
+ np.asarray(self.data['Tlim']),
3282
+ from_units='K')
3283
+
3284
+
3285
+ def plim(self, T=None):
3286
+ """Returns the pressure limits for the data set
3287
+ pmin, pmax = plim(T=None)
3288
+
3289
+ plim accepts temperature as an argument for extensibility, but the MP1
3290
+ class has homogeneous pressure limits.
3291
+
3292
+ Returns the pressure limits in [unit_pressure]
3293
+ """
3294
+ return pm.units.pressure(
3295
+ np.asarray(self.data['plim']),
3296
+ from_units='Pa')
3297
+
3298
+ # #
3299
+ # General Properties #
3300
+ # #
3301
+
3302
+ def mw(self):
3303
+ """Molecular weight
3304
+ mw = mw()
3305
+
3306
+ Returns the molecular weight of the substance in
3307
+ [unit_mass / unit_molar]
3308
+ """
3309
+ mw = self.data['mw']
3310
+ mw = pm.units.mass(mw, from_units='kg')
3311
+ mw = pm.units.molar(mw, from_units='kmol', exponent=-1)
3312
+ return mw
3313
+
3314
+ def R(self):
3315
+ """Ideal gas constant
3316
+ R = R()
3317
+
3318
+ Returns the ideal gas constant in
3319
+ [unit_energy / unit_matter / unit_temperature]
3320
+
3321
+ The mp1 data set includes a values for R lifted from the original data set.
3322
+ The gas constant can be independently calculated from the universal gas
3323
+ constant or more precisely from the Boltzmann constant.
3324
+ R = Ru / mw # mw = molecular weight
3325
+ OR
3326
+ R = k * Na / mw # Na = avagadro's number
3327
+
3328
+ The value returned by R is based on the value stored in the species data,
3329
+ from which all other properties are constructed.
3330
+ """
3331
+ # R is stored in in J/kg/K
3332
+ R = pm.units.energy(self.data['R'], from_units = 'J')
3333
+ R = pm.units.matter(R, self.data['mw'], from_units='kg', exponent=-1)
3334
+ R = pm.units.temperature(R, from_units='K', exponent=-1)
3335
+ return R
3336
+
3337
+ # #
3338
+ # Critical and triple points #
3339
+ # #
3340
+
3341
+ def critical(self, density=False):
3342
+ """Critical point
3343
+ Tc, pc = critical()
3344
+
3345
+ To also return the density, set the 'density' keyword to True
3346
+
3347
+ Tc, pc, dc = critical(density=True)
3348
+
3349
+ Returns the critical temperature, pressure, and density in
3350
+ [unit_temperature], [unit_pressure], [unit_matter/unit_volume]
3351
+ """
3352
+ if density:
3353
+ return pm.units.temperature_scale( \
3354
+ self.data['Tc'], from_units='K'),\
3355
+ pm.units.pressure( \
3356
+ self.data['pc'], from_units='Pa'), \
3357
+ pm.units.volume(\
3358
+ pm.units.matter( \
3359
+ self.data['dc'], \
3360
+ self.data['mw'], \
3361
+ from_units='kg'),\
3362
+ from_units='m3', exponent=-1)
3363
+
3364
+ return pm.units.temperature_scale( \
3365
+ self.data['Tc'], from_units='K'),\
3366
+ pm.units.pressure( \
3367
+ self.data['pc'], from_units='Pa')
3368
+
3369
+
3370
+ def triple(self):
3371
+ """Triple point
3372
+ Tt, pt = triple()
3373
+
3374
+ Returns the triple temperature and pressure in a tuple pair in
3375
+ [unit_temperature], [unit_pressure]
3376
+ """
3377
+ return pm.units.temperature_scale( \
3378
+ self.data['Tt'], from_units='K'),\
3379
+ pm.units.pressure( \
3380
+ self.data['pt'], from_units='Pa')
3381
+
3382
+ # #
3383
+ # Saturaiton properties #
3384
+ # #
3385
+
3386
+ def ps(self, T=None):
3387
+ """Saturation pressure
3388
+ psat = ps(T)
3389
+
3390
+ Returns the saturaiton pressure in [unit_pressure]
3391
+
3392
+ Calls to ps() are MUCH faster than calls to Ts(), so when given a choice,
3393
+ specifying saturation states with temperature should always be preferred.
3394
+ The MP1 class exposes ps() as an empirical relationship, while Ts() has
3395
+ to perform iterative numerical inversion.
3396
+
3397
+ Unlike the other saturation properties, ps() and Ts() only accept one
3398
+ argument and only return one value - each calculates the one in terms
3399
+ of the other.
3400
+ """
3401
+ if T is None:
3402
+ T = pm.config['def_T']
3403
+
3404
+ # Replace T with an array of the correct units
3405
+ T = pm.units.temperature_scale(
3406
+ np.asarray(T, dtype=float),
3407
+ to_units='K')
3408
+ # Exclude points outside the triple-critical range
3409
+ if np.logical_or( T<self.data['Tt'], T>self.data['Tc'] ).any():
3410
+ raise pm.utility.PMParamError(
3411
+ 'Saturation properties are not ' +
3412
+ 'available above the critical point Tc=%f K or below the '%self.data['Tc'] +
3413
+ 'triple point Tt=%f K.'%self.data['Tt'] )
3414
+
3415
+ return pm.units.pressure(self._ps(T)[0], from_units='Pa')
3416
+
3417
+
3418
+ def Ts(self, p=None):
3419
+ """Saturation temperature
3420
+ Tsat = Ts(p)
3421
+
3422
+ Calculates the saturation temperature in terms of the pressure.
3423
+
3424
+ Unlike the other saturation properties, ps() and Ts() only accept one
3425
+ argument and only return one value - each calculates the one in terms
3426
+ of the other.
3427
+ """
3428
+ if p is None:
3429
+ p = pm.config['def_p']
3430
+
3431
+ # Replace p with an array of the correct units
3432
+ p = pm.units.pressure(
3433
+ np.asarray(p, dtype=float),
3434
+ to_units='Pa')
3435
+ # Force p to have at least 1 dimension
3436
+ if p.ndim==0:
3437
+ p = np.reshape(p, (1,))
3438
+
3439
+ # Exclude points outside the triple-critical range
3440
+ if np.logical_or( p<self.data['pt'], p>self.data['pc'] ).any():
3441
+ raise pm.utility.PMParamError(
3442
+ 'Saturation properties are not ' +
3443
+ 'available above the critical point pc=%f bar or below the '%(self.data['pc']/1e5) +
3444
+ 'triple point pt=%f bar.'%(self.data['pt']/1e5) )
3445
+
3446
+ return pm.units.temperature_scale( \
3447
+ self._Ts(p), from_units='K')
3448
+
3449
+
3450
+ def ds(self, *varg, **kwarg):
3451
+ """Saturation density
3452
+ dsL, dsV = ds(T)
3453
+
3454
+ If no keyword is specified, saturation properties interpret the argument
3455
+ as temperature. However, pressure can be specified as well
3456
+
3457
+ dsL, dsV = ds(p=pvalue)
3458
+
3459
+ Returns the liquid (dsL) and vapor (dsV) saturation density in units
3460
+ [unit_matter / unit_volume]
3461
+ """
3462
+ _,dL,dV = self._sat_argparse(*varg, **kwarg)
3463
+ # Get a conversion factor
3464
+ conv = pm.units.matter(1., self.data['mw'],
3465
+ from_units='kg')
3466
+ conv = pm.units.volume(conv, from_units='m3', exponent=-1)
3467
+ dL *= conv
3468
+ dV *= conv
3469
+ return dL, dV
3470
+
3471
+ def vs(self, *varg, **kwarg):
3472
+ """Saturation specific volume
3473
+ vsL, vsV = vs(T)
3474
+
3475
+ If no keyword is specified, saturation properties interpret the argument
3476
+ as temperature. However, pressure can be specified as well
3477
+
3478
+ vsL, vsV = vs(p=pvalue)
3479
+
3480
+ Returns the liquid (vsL) and vapor (vsV) saturation density in units
3481
+ [unit_volume / unit_matter]
3482
+ """
3483
+ dL,dV = self.ds(*varg, **kwarg)
3484
+ return 1./dL, 1./dV
3485
+
3486
+
3487
+ def es(self, *varg, **kwarg):
3488
+ """Saturation internal energy
3489
+ esL, esV = es(T)
3490
+
3491
+ If no keyword is specified, saturation properties interpret the argument
3492
+ as temperature. However, pressure can be specified as well
3493
+
3494
+ esL, esV = es(p=pvalue)
3495
+
3496
+ Returns the liquid (esL) and vapor (esV) saturation internal energy in
3497
+ units [unit_energy / unit_matter]
3498
+ """
3499
+ T,dL,dV = self._sat_argparse(*varg, **kwarg)
3500
+ esL = self._e(T,dL,0)[0]
3501
+ esV = self._e(T,dV,0)[0]
3502
+
3503
+ # Get a conversion factor
3504
+ conv = pm.units.energy(1., from_units='J')
3505
+ conv = pm.units.matter(conv, self.data['mw'],
3506
+ from_units='kg', exponent=-1)
3507
+ esL *= conv
3508
+ esV *= conv
3509
+ return esL, esV
3510
+
3511
+
3512
+ def hs(self, *varg, **kwarg):
3513
+ """Saturation enthalpy
3514
+ hsL, hsV = hs(T)
3515
+
3516
+ If no keyword is specified, saturation properties interpret the argument
3517
+ as temperature. However, pressure can be specified as well
3518
+
3519
+ hsL, hsV = hs(p=pvalue)
3520
+
3521
+ Returns the liquid (hsL) and vapor (hsV) saturation enthalpy in
3522
+ units [unit_energy / unit_matter]
3523
+ """
3524
+ T,dL,dV = self._sat_argparse(*varg, **kwarg)
3525
+ hsL = self._h(T,dL,0)[0]
3526
+ hsV = self._h(T,dV,0)[0]
3527
+
3528
+ # Get a conversion factor
3529
+ conv = pm.units.energy(1., from_units='J')
3530
+ conv = pm.units.matter(conv, self.data['mw'],
3531
+ from_units='kg', exponent=-1)
3532
+ hsL *= conv
3533
+ hsV *= conv
3534
+ return hsL, hsV
3535
+
3536
+
3537
+ def ss(self, *varg, **kwarg):
3538
+ """Saturation entropy
3539
+ ssL, ssV = ss(T,p)
3540
+
3541
+ If no keyword is specified, saturation properties interpret the argument
3542
+ as temperature. However, pressure can be specified as well
3543
+
3544
+ ssL, ssV = ss(p=pvalue)
3545
+
3546
+ Returns the liquid (ssL) and vapor (ssV) saturation entropy in
3547
+ units [unit_energy / unit_matter / unit_temperature]
3548
+ """
3549
+ T,dL,dV = self._sat_argparse(*varg, **kwarg)
3550
+ ssL = self._s(T,dL,0)[0]
3551
+ ssV = self._s(T,dV,0)[0]
3552
+
3553
+ # Get a conversion factor
3554
+ conv = pm.units.energy(1., from_units='J')
3555
+ conv = pm.units.matter(conv, self.data['mw'],
3556
+ from_units='kg', exponent=-1)
3557
+ conv = pm.units.temperature(conv,
3558
+ from_units='K', exponent=-1)
3559
+ ssL *= conv
3560
+ ssV *= conv
3561
+ return ssL, ssV
3562
+
3563
+
3564
+ # #
3565
+ # EOS properties T,p,d #
3566
+ # #
3567
+
3568
+ def p(self, *varg, quality=False, **kwarg):
3569
+ """Pressure
3570
+ p(...)
3571
+
3572
+ All properties accept two other properties as flexible inputs.
3573
+ Below are the recognized keywords, their meaning, and the config entries
3574
+ that determine their units.
3575
+ T temperature unit_temperature
3576
+ p pressure unit_pressure
3577
+ d density unit_matter / unit_volume
3578
+ v specific volume unit_volume / unit_matter
3579
+ x quality dimensionless
3580
+ e internal energy unit_energy / unit_matter
3581
+ h enthalpy unit_energy / unit_matter
3582
+ s entropy unit_energy / unit_matter / unit_temperature
3583
+
3584
+ If no keywords are specified, the positional arguments are interpreted
3585
+ as (T,p). To configure their defaults, use the def_T and def_p config
3586
+ entries.
3587
+
3588
+ Additionally, if the optional keyword, "quality" is set to True, the
3589
+ quality of the liquid/vapor mixture is also returned
3590
+ e,x = e(..., quality=True)
3591
+
3592
+ Returns pressure in unit_pressure
3593
+ """
3594
+ T,d1,d2,x,I = self._argparse(*varg, **kwarg)
3595
+ # Use d2. In theory, p(d1) = p(d2), but the liquid is so stiff
3596
+ # that small numerical errors cause huge pressure errors
3597
+ # The problem is solved when the vapor density is used instead.
3598
+ # In all other conditions d1=d2
3599
+ p = self._p(T,d2,0)[0]
3600
+
3601
+ p = pm.units.pressure(p, from_units='Pa')
3602
+
3603
+ if quality:
3604
+ return p,x
3605
+ return p
3606
+
3607
+
3608
+ def d(self, *varg, quality=False, **kwarg):
3609
+ """Density
3610
+ d(...)
3611
+
3612
+ All properties accept two other properties as flexible inputs.
3613
+ Below are the recognized keywords, their meaning, and the config entries
3614
+ that determine their units.
3615
+ T temperature unit_temperature
3616
+ p pressure unit_pressure
3617
+ d density unit_matter / unit_volume
3618
+ v specific volume unit_volume / unit_matter
3619
+ x quality dimensionless
3620
+ e internal energy unit_energy / unit_matter
3621
+ h enthalpy unit_energy / unit_matter
3622
+ s entropy unit_energy / unit_matter / unit_temperature
3623
+
3624
+ If no keywords are specified, the positional arguments are interpreted
3625
+ as (T,p). To configure their defaults, use the def_T and def_p config
3626
+ entries.
3627
+
3628
+ Additionally, if the optional keyword, "quality" is set to True, the
3629
+ quality of the liquid/vapor mixture is also returned
3630
+ e,x = e(..., quality=True)
3631
+
3632
+ Returns density in unit_matter / unit_volume
3633
+ """
3634
+ T,d1,d2,x,I = self._argparse(*varg, **kwarg)
3635
+ if I.any():
3636
+ d1[I] = (1.-x[I])/d1[I]
3637
+ d1[I] += x[I]/d2[I]
3638
+ d1[I] = 1. / d1[I]
3639
+
3640
+ d1 = pm.units.matter(d1, self.data['mw'], from_units='kg')
3641
+ d1 = pm.units.volume(d1, from_units='m3', exponent=-1)
3642
+ if quality:
3643
+ return d1,x
3644
+ return d1
3645
+
3646
+
3647
+ def v(self, *varg, quality=False, **kwarg):
3648
+ """specific volume
3649
+ v(...)
3650
+
3651
+ All properties accept two other properties as flexible inputs.
3652
+ Below are the recognized keywords, their meaning, and the config entries
3653
+ that determine their units.
3654
+ T temperature unit_temperature
3655
+ p pressure unit_pressure
3656
+ d density unit_matter / unit_volume
3657
+ v specific volume unit_volume / unit_matter
3658
+ x quality dimensionless
3659
+ e internal energy unit_energy / unit_matter
3660
+ h enthalpy unit_energy / unit_matter
3661
+ s entropy unit_energy / unit_matter / unit_temperature
3662
+
3663
+ If no keywords are specified, the positional arguments are interpreted
3664
+ as (T,p). To configure their defaults, use the def_T and def_p config
3665
+ entries.
3666
+
3667
+ Additionally, if the optional keyword, "quality" is set to True, the
3668
+ quality of the liquid/vapor mixture is also returned
3669
+ v,x = v(..., quality=True)
3670
+
3671
+ Returns volume in unit_volume / unit_matter
3672
+ """
3673
+ d,x = self.d(*varg, quality=True, **kwarg)
3674
+ if quality:
3675
+ return 1./d, x
3676
+ return 1./d
3677
+
3678
+ def T(self, *varg, quality=False, **kwarg):
3679
+ """Temperature
3680
+ T(...)
3681
+
3682
+ All properties accept two other properties as flexible inputs.
3683
+ Below are the recognized keywords, their meaning, and the config entries
3684
+ that determine their units.
3685
+ T temperature unit_temperature
3686
+ p pressure unit_pressure
3687
+ d density unit_matter / unit_volume
3688
+ v specific volume unit_volume / unit_matter
3689
+ x quality dimensionless
3690
+ e internal energy unit_energy / unit_matter
3691
+ h enthalpy unit_energy / unit_matter
3692
+ s entropy unit_energy / unit_matter / unit_temperature
3693
+
3694
+ If no keywords are specified, the positional arguments are interpreted
3695
+ as (T,p). To configure their defaults, use the def_T and def_p config
3696
+ entries.
3697
+
3698
+ Returns temperature in unit_temperature
3699
+
3700
+ In many applications, it is also necessary to calculate quality to
3701
+ completely specify the state, and since it is an intermediate for any
3702
+ property calculation, it can be returned as well. If the optional
3703
+ "quality" keyword argument is set to True, x is appended in a tuple to
3704
+ save an unnecessary redundant call to x().
3705
+
3706
+ T,x = T(..., quality=True)
3707
+ """
3708
+ T,_,_,x,_ = self._argparse(*varg, **kwarg)
3709
+ T = pm.units.temperature_scale(T, from_units='K')
3710
+ if quality:
3711
+ return T,x
3712
+ return T
3713
+
3714
+ def x(self, *varg, **kwarg):
3715
+ """Quality
3716
+ x(...)
3717
+
3718
+ All properties accept two other properties as flexible inputs.
3719
+ Below are the recognized keywords, their meaning, and the config entries
3720
+ that determine their units.
3721
+ T temperature unit_temperature
3722
+ p pressure unit_pressure
3723
+ d density unit_matter / unit_volume
3724
+ v specific volume unit_volume / unit_matter
3725
+ x quality dimensionless
3726
+ e internal energy unit_energy / unit_matter
3727
+ h enthalpy unit_energy / unit_matter
3728
+ s entropy unit_energy / unit_matter / unit_temperature
3729
+
3730
+ If no keywords are specified, the positional arguments are interpreted
3731
+ as (T,p). To configure their defaults, use the def_T and def_p config
3732
+ entries.
3733
+
3734
+ Returns quality, which is a dimensionless number between 0 and 1 for
3735
+ saturated mixtures and -1 for all other states.
3736
+
3737
+ In many applications quality is one of a few important properties. To
3738
+ avoid redundant function calls, consider using the "quality" keyword in
3739
+ another property method or the state() method.
3740
+ """
3741
+ _,_,_,x,_ = self._argparse(*varg, **kwarg)
3742
+ return x
3743
+
3744
+ # #
3745
+ # Property functions #
3746
+ # #
3747
+
3748
+ def state(self, *varg, **kwarg):
3749
+ """The state method calculates all available properties at once.
3750
+
3751
+ sd = state(...)
3752
+
3753
+ The properties are returned in a dictionary with keys:
3754
+ T temperature unit_temperature
3755
+ p pressure unit_pressure
3756
+ d density unit_matter / unit_volume
3757
+ v specific volume unit_volume / unit_matter
3758
+ x quality dimensionless
3759
+ e internal energy unit_energy / unit_matter
3760
+ f free energy unit_energy / unit_matter
3761
+ g gibbs energy unit_energy / unit_matter
3762
+ h enthalpy unit_energy / unit_matter
3763
+ s entropy unit_energy / unit_matter / unit_temperature
3764
+ cp const. p sp. ht. unit_energy / unit_matter / unit_temperature
3765
+ cv const. v sp. ht. unit_energy / unit_matter / unit_temperature
3766
+
3767
+ Like all of the other property functions, arguments may be any two of
3768
+ T, p, d, v, e, h, s, and x.
3769
+
3770
+ Because calculating cv for saturation conditions is more computationally
3771
+ expensive, and because users rarely need this property, state() will
3772
+ return NaN for cv at saturated conditions. This is a deliberate design
3773
+ decision to preserve the speed and simplicitly of the state() method.
3774
+ For users who do want true constant-volume specific heat is still
3775
+ available by calling the cv() method directly.
3776
+ """
3777
+
3778
+ # Parse the arguments
3779
+ T,d1,d2,x,I = self._argparse(*varg, **kwarg)
3780
+ R = self.data['R']
3781
+
3782
+ # Initialize the output
3783
+ out = {}
3784
+
3785
+ # Start with the vapor (d2) half of the calculation
3786
+ # In saturated cases, d2 should always be used to caluclate
3787
+ # pressure
3788
+ # The IG part
3789
+ Tscale = self.data['AOgroup']['Tscale']
3790
+ dscale = self.data['AOgroup']['dscale']
3791
+ tt = Tscale / T
3792
+ dd = d2 / dscale
3793
+ a,at,ad,att,atd,add = self._ao(tt,dd,2)
3794
+
3795
+ p = 1.
3796
+ e = at
3797
+ h = 1. + tt*at
3798
+ s = tt*at - a
3799
+ cp = -tt*tt*att
3800
+ cv = tt*tt*att
3801
+
3802
+ # The residual part
3803
+ Tscale = self.data['ARgroup']['Tscale']
3804
+ dscale = self.data['ARgroup']['dscale']
3805
+ tt = Tscale / T
3806
+ dd = d2 / dscale
3807
+ a,at,ad,att,atd,add = self._ar(tt,dd,2)
3808
+
3809
+ p += dd*ad
3810
+ p *= T*d2*R
3811
+ e += at
3812
+ e *= R*Tscale
3813
+ h += dd*ad + tt*at
3814
+ h *= R*T
3815
+ s += tt*at - a
3816
+ s *= R
3817
+ temp = 1.+dd*(ad-tt*atd)
3818
+ cp += -tt*tt*att + temp*temp/(1.+dd*(2.*ad+dd*add))
3819
+ cp *= R
3820
+ cv += tt*tt*att
3821
+ cv *= -R
3822
+
3823
+ # Before we go back and calculate the liquid properties,
3824
+ # go ahead and store the vapor calculations
3825
+ out['p'] = p
3826
+ out['T'] = T
3827
+ out['d'] = d1
3828
+ out['x'] = x
3829
+ out['e'] = e
3830
+ out['f'] = e - T*s
3831
+ out['g'] = h - T*s
3832
+ out['h'] = h
3833
+ out['s'] = s
3834
+ out['cp'] = cp
3835
+ out['cv'] = cv
3836
+
3837
+ # Finish with the liquid (d1) half of the calculation
3838
+ # The IG part
3839
+ Tscale = self.data['AOgroup']['Tscale']
3840
+ dscale = self.data['AOgroup']['dscale']
3841
+ tt = Tscale / T[I]
3842
+ dd = d1[I] / dscale
3843
+ a,at,ad,att,atd,add = self._ao(tt,dd,2)
3844
+
3845
+ e = at
3846
+ h = 1. + tt*at
3847
+ s = tt*at - a
3848
+ cp = -tt*tt*att
3849
+ cv = tt*tt*att
3850
+
3851
+ # The residual part
3852
+ Tscale = self.data['ARgroup']['Tscale']
3853
+ dscale = self.data['ARgroup']['dscale']
3854
+ tt = Tscale / T[I]
3855
+ dd = d1[I] / dscale
3856
+ a,at,ad,att,atd,add = self._ar(tt,dd,2)
3857
+
3858
+ e += at
3859
+ e *= R*Tscale
3860
+ h += dd*ad + tt*at
3861
+ h *= R*T[I]
3862
+ s += tt*at - a
3863
+ s *= R
3864
+ temp = 1.+dd*(ad-tt*atd)
3865
+ cp += -tt*tt*att + temp*temp/(1.+dd*(2.*ad+dd*add))
3866
+ cp *= R
3867
+ cv += tt*tt*att
3868
+ cv *= -R
3869
+
3870
+ # Finally, calculate the mixture properties with the appropriate
3871
+ # quality.
3872
+ out['cp'][I] = np.inf
3873
+ out['cv'][I] = np.nan
3874
+ out['e'][I] = out['e'][I]*(x[I]) + e*(1-x[I])
3875
+ out['h'][I] = out['h'][I]*(x[I]) + h*(1-x[I])
3876
+ out['s'][I] = out['s'][I]*(x[I]) + s*(1-x[I])
3877
+ # Overwrite the helmholtz function with the mixture values
3878
+ out['f'][I] = out['e'][I] - out['T'][I]*out['s'][I]
3879
+ # Gibbs energy is constant across an equilibrium phase transition
3880
+ # d is not weighted by x - v is.
3881
+ out['d'][I] = 1./((1-x[I])/d1[I] + x[I]/d2[I])
3882
+
3883
+ # Apply unit conversions
3884
+ c1 = pm.units.energy(1., from_units='J')
3885
+ c1 = pm.units.matter(c1, self.data['mw'], from_units='kg', exponent=-1)
3886
+ out['e'] *= c1
3887
+ out['h'] *= c1
3888
+ out['f'] *= c1
3889
+ out['g'] *= c1
3890
+ c1 = pm.units.temperature(c1, from_units='K',exponent=-1)
3891
+ out['s'] *= c1
3892
+ out['cp'] *= c1
3893
+ out['cv'] *= c1
3894
+ out['gam'] = out['cp'] / out['cv']
3895
+ out['gam'][I] = np.inf
3896
+ out['p'] = pm.units.pressure(out['p'], from_units='Pa')
3897
+ out['T'] = pm.units.temperature_scale(out['T'], from_units='K')
3898
+ c1 = pm.units.volume(1., from_units='m3', exponent=-1)
3899
+ c1 = pm.units.matter(c1, self.data['mw'], from_units='kg')
3900
+ out['d'] *= c1
3901
+ out['v'] = 1./out['d']
3902
+ return out
3903
+
3904
+
3905
+ def e(self, *varg, quality=False, **kwarg):
3906
+ """Internal energy
3907
+ e(...)
3908
+
3909
+ All properties accept two other properties as flexible inputs.
3910
+ Below are the recognized keywords, their meaning, and the config entries
3911
+ that determine their units.
3912
+ T temperature unit_temperature
3913
+ p pressure unit_pressure
3914
+ d density unit_matter / unit_volume
3915
+ v specific volume unit_volume / unit_matter
3916
+ x quality dimensionless
3917
+ e internal energy unit_energy / unit_matter
3918
+ h enthalpy unit_energy / unit_matter
3919
+ s entropy unit_energy / unit_matter / unit_temperature
3920
+
3921
+ If no keywords are specified, the positional arguments are interpreted
3922
+ as (T,p). To configure their defaults, use the def_T and def_p config
3923
+ entries.
3924
+
3925
+ Additionally, if the optional keyword, "quality" is set to True, the
3926
+ quality of the liquid/vapor mixture is also returned
3927
+ e,x = e(..., quality=True)
3928
+
3929
+ Returns energy in unit_energy / unit_matter
3930
+ """
3931
+ T,d1,d2,x,I = self._argparse(*varg, **kwarg)
3932
+ e = self._e(T,d1,0)[0]
3933
+ if I.any():
3934
+ e[I] *= (1.-x[I])
3935
+ e[I] += self._e(T[I],d2[I],0)[0] * x[I]
3936
+ # Convert the units back to user space
3937
+ pm.units.energy(e, from_units='J', inplace=True)
3938
+ pm.units.matter(e, self.data['mw'],
3939
+ from_units='kg', exponent=-1, inplace=True)
3940
+ if quality:
3941
+ return e,x
3942
+ return e
3943
+
3944
+ def f(self, *varg, quality=False, **kwarg):
3945
+ """Free (Helmholtz) energy
3946
+ f(...)
3947
+
3948
+ All properties accept two other properties as flexible inputs.
3949
+ Below are the recognized keywords, their meaning, and the config entries
3950
+ that determine their units.
3951
+ T temperature unit_temperature
3952
+ p pressure unit_pressure
3953
+ d density unit_matter / unit_volume
3954
+ v specific volume unit_volume / unit_matter
3955
+ x quality dimensionless
3956
+ e internal energy unit_energy / unit_matter
3957
+ h enthalpy unit_energy / unit_matter
3958
+ s entropy unit_energy / unit_matter / unit_temperature
3959
+
3960
+ If no keywords are specified, the positional arguments are interpreted
3961
+ as (T,p). To configure their defaults, use the def_T and def_p config
3962
+ entries.
3963
+
3964
+ Additionally, if the optional keyword, "quality" is set to True, the
3965
+ quality of the liquid/vapor mixture is also returned
3966
+ f,x = f(..., quality=True)
3967
+
3968
+ Returns free energy in unit_energy / unit_matter
3969
+ """
3970
+ T,d1,d2,x,I = self._argparse(*varg, **kwarg)
3971
+ f = self._f(T,d1,0)[0]
3972
+ if I.any():
3973
+ f[I] *= (1.-x[I])
3974
+ f[I] += self._f(T[I],d2[I],0)[0] * x[I]
3975
+ # Convert the units back to user space
3976
+ pm.units.energy(f, from_units='J', inplace=True)
3977
+ pm.units.matter(f, self.data['mw'],
3978
+ from_units='kg', exponent=-1, inplace=True)
3979
+ if quality:
3980
+ return f,x
3981
+ return f
3982
+
3983
+ def g(self, *varg, quality=False, **kwarg):
3984
+ """Gibbs energy
3985
+ g(...)
3986
+
3987
+ All properties accept two other properties as flexible inputs.
3988
+ Below are the recognized keywords, their meaning, and the config entries
3989
+ that determine their units.
3990
+ T temperature unit_temperature
3991
+ p pressure unit_pressure
3992
+ d density unit_matter / unit_volume
3993
+ v specific volume unit_volume / unit_matter
3994
+ x quality dimensionless
3995
+ e internal energy unit_energy / unit_matter
3996
+ h enthalpy unit_energy / unit_matter
3997
+ s entropy unit_energy / unit_matter / unit_temperature
3998
+
3999
+ If no keywords are specified, the positional arguments are interpreted
4000
+ as (T,p). To configure their defaults, use the def_T and def_p config
4001
+ entries.
4002
+
4003
+ Additionally, if the optional keyword, "quality" is set to True, the
4004
+ quality of the liquid/vapor mixture is also returned
4005
+ g,x = g(..., quality=True)
4006
+
4007
+ Returns free energy in unit_energy / unit_matter
4008
+ """
4009
+ T,d1,d2,x,I = self._argparse(*varg, **kwarg)
4010
+ g = self._g(T,d1,0)[0]
4011
+ if I.any():
4012
+ g[I] *= (1.-x[I])
4013
+ g[I] += self._g(T[I],d2[I],0)[0] * x[I]
4014
+ # Convert the units back to user space
4015
+ pm.units.energy(g, from_units='J', inplace=True)
4016
+ pm.units.matter(g, self.data['mw'],
4017
+ from_units='kg', exponent=-1, inplace=True)
4018
+ if quality:
4019
+ return g,x
4020
+ return g
4021
+
4022
+ def h(self, *varg, quality=False, **kwarg):
4023
+ """Enthalpy
4024
+ h(...)
4025
+
4026
+ All properties accept two other properties as flexible inputs.
4027
+ Below are the recognized keywords, their meaning, and the config entries
4028
+ that determine their units.
4029
+ T temperature unit_temperature
4030
+ p pressure unit_pressure
4031
+ d density unit_matter / unit_volume
4032
+ v specific volume unit_volume / unit_matter
4033
+ x quality dimensionless
4034
+ e internal energy unit_energy / unit_matter
4035
+ h enthalpy unit_energy / unit_matter
4036
+ s entropy unit_energy / unit_matter / unit_temperature
4037
+
4038
+ If no keywords are specified, the positional arguments are interpreted
4039
+ as (T,p). To configure their defaults, use the def_T and def_p config
4040
+ entries.
4041
+
4042
+ Additionally, if the optional keyword, "quality" is set to True, the
4043
+ quality of the liquid/vapor mixture is also returned
4044
+ h,x = h(..., quality=True)
4045
+
4046
+ Returns enthalpy as unit_energy / unit_matter
4047
+ """
4048
+ T,d1,d2,x,I = self._argparse(*varg, **kwarg)
4049
+ h = self._h(T,d1,0)[0]
4050
+ if I.any():
4051
+ h[I] *= (1.-x[I])
4052
+ h[I] += self._h(T[I],d2[I],0)[0] * x[I]
4053
+ # Convert the units back to user space
4054
+ pm.units.energy(h, from_units='J', inplace=True)
4055
+ pm.units.matter(h, self.data['mw'],
4056
+ from_units='kg', exponent=-1, inplace=True)
4057
+ if quality:
4058
+ return h,x
4059
+ return h
4060
+
4061
+
4062
+ def s(self, *varg, quality=False, **kwarg):
4063
+ """Entropy
4064
+ s(...)
4065
+
4066
+ All properties accept two other properties as flexible inputs.
4067
+ Below are the recognized keywords, their meaning, and the config entries
4068
+ that determine their units.
4069
+ T temperature unit_temperature
4070
+ p pressure unit_pressure
4071
+ d density unit_matter / unit_volume
4072
+ v specific volume unit_volume / unit_matter
4073
+ x quality dimensionless
4074
+ e internal energy unit_energy / unit_matter
4075
+ h enthalpy unit_energy / unit_matter
4076
+ s entropy unit_energy / unit_matter / unit_temperature
4077
+
4078
+ If no keywords are specified, the positional arguments are interpreted
4079
+ as (T,p). To configure their defaults, use the def_T and def_p config
4080
+ entries.
4081
+
4082
+ Additionally, if the optional keyword, "quality" is set to True, the
4083
+ quality of the liquid/vapor mixture is also returned
4084
+ s,x = s(..., quality=True)
4085
+
4086
+ Returns entropy in unit_energy / unit_matter / unit_temperature
4087
+ """
4088
+
4089
+ T,d1,d2,x,I = self._argparse(*varg, **kwarg)
4090
+ s = self._s(T,d1,0)[0]
4091
+ if I.any():
4092
+ s[I] *= (1.-x[I])
4093
+ s[I] += self._s(T[I],d2[I],0)[0] * x[I]
4094
+ # Convert the units back to user space
4095
+ pm.units.energy(s, from_units='J', inplace=True)
4096
+ pm.units.matter(s, self.data['mw'],
4097
+ from_units='kg', exponent=-1, inplace=True)
4098
+ pm.units.temperature(s, from_units='K',
4099
+ exponent=-1, inplace=True)
4100
+ if quality:
4101
+ return s,x
4102
+ return s
4103
+
4104
+
4105
+ def a(self, *varg, quality=False, **kwarg):
4106
+ """Speed of sound
4107
+ a(...)
4108
+
4109
+ All properties accept two other properties as flexible inputs.
4110
+ Below are the recognized keywords, their meaning, and the config entries
4111
+ that determine their units.
4112
+ T temperature unit_temperature
4113
+ p pressure unit_pressure
4114
+ d density unit_matter / unit_volume
4115
+ v specific volume unit_volume / unit_matter
4116
+ x quality dimensionless
4117
+ e internal energy unit_energy / unit_matter
4118
+ h enthalpy unit_energy / unit_matter
4119
+ s entropy unit_energy / unit_matter / unit_temperature
4120
+
4121
+ If no keywords are specified, the positional arguments are interpreted
4122
+ as (T,p). To configure their defaults, use the def_T and def_p config
4123
+ entries.
4124
+
4125
+ Additionally, if the optional keyword, "quality" is set to True, the
4126
+ quality of the liquid/vapor mixture is also returned
4127
+ s,x = s(..., quality=True)
4128
+
4129
+ Returns speed of sound in unit_length / unit_time
4130
+
4131
+ The speed of sound in a two-phase mixture is not currently defined.
4132
+ Normally, the saturated state forms two separate regions of vapor and
4133
+ liquid, each with its own speed of sound, which should be calculated at
4134
+ the saturation line.
4135
+ """
4136
+
4137
+ T,d1,d2,x,I = self._argparse(*varg, **kwarg)
4138
+ a = self._a(T,d1)
4139
+ if I.any():
4140
+ a[I] = pm.config['def_oob']
4141
+ # Convert the units back to user space
4142
+ pm.units.length(a, from_units='m', inplace=True)
4143
+ pm.units.time(a, from_units='s', inplace=True, exponent=-1)
4144
+ if quality:
4145
+ return a,x
4146
+ return a
4147
+
4148
+
4149
+ def hsd(self, *varg, quality = False, **kwarg):
4150
+ """Enthalpy, Entropy, Density
4151
+ ** Deprecated - Use state() **
4152
+
4153
+ h,s,d = hsd(...)
4154
+ OR
4155
+ h,s,d,x = hsd(..., quality=True)
4156
+
4157
+ All properties accept two other properties as flexible inputs.
4158
+ Below are the recognized keywords, their meaning, and the config entries
4159
+ that determine their units.
4160
+ T temperature unit_temperature
4161
+ p pressure unit_pressure
4162
+ d density unit_matter / unit_volume
4163
+ v specific volume unit_volume / unit_matter
4164
+ x quality dimensionless
4165
+ e internal energy unit_energy / unit_matter
4166
+ h enthalpy unit_energy / unit_matter
4167
+ s entropy unit_energy / unit_matter / unit_temperature
4168
+
4169
+ If no keywords are specified, the positional arguments are interpreted
4170
+ as (T,p). To configure their defaults, use the def_T and def_p config
4171
+ entries.
4172
+
4173
+ Additionally, if the optional keyword, "quality" is set to True, the
4174
+ quality of the liquid/vapor mixture is also returned
4175
+ e,x = e(..., quality=True)
4176
+
4177
+ """
4178
+
4179
+ T,d1,d2,x,I = self._argparse(*varg, **kwarg)
4180
+
4181
+ # There is no inner hsd funciton.
4182
+ # We have to do this the hard way.
4183
+
4184
+ # The IG part
4185
+ R = self.data['R']
4186
+ Tscale = self.data['AOgroup']['Tscale']
4187
+ dscale = self.data['AOgroup']['dscale']
4188
+ tt = Tscale / T
4189
+ dd = d1 / dscale
4190
+ a,at,_,_,_,_ = self._ao(tt,dd,1)
4191
+
4192
+ h = 1. + tt*at
4193
+ s = tt*at - a
4194
+
4195
+ # The residual part
4196
+ Tscale = self.data['ARgroup']['Tscale']
4197
+ dscale = self.data['ARgroup']['dscale']
4198
+ tt = Tscale / T
4199
+ dd = d1 / dscale
4200
+ a,at,ad,_,_,_ = self._ar(tt,dd,1)
4201
+ h += dd*ad + tt*at
4202
+ s += tt*at - a
4203
+
4204
+ # If there are data under the dome
4205
+ if I.any():
4206
+ temp = 1-x[I]
4207
+ h[I] *= temp
4208
+ s[I] *= temp
4209
+
4210
+ # The IG part
4211
+ R = self.data['R']
4212
+ Tscale = self.data['AOgroup']['Tscale']
4213
+ dscale = self.data['AOgroup']['dscale']
4214
+ tt = Tscale / T[I]
4215
+ dd = d2[I] / dscale
4216
+ a,at,_,_,_,_ = self._ao(tt,dd,1)
4217
+
4218
+ h[I] += (1. + tt*at)*x[I]
4219
+ s[I] += (tt*at - a)*x[I]
4220
+
4221
+ # The residual part
4222
+ Tscale = self.data['ARgroup']['Tscale']
4223
+ dscale = self.data['ARgroup']['dscale']
4224
+ tt = Tscale / T[I]
4225
+ dd = d2[I] / dscale
4226
+ a,at,ad,_,_,_ = self._ar(tt,dd,1)
4227
+ h[I] += (dd*ad + tt*at)*x[I]
4228
+ s[I] += (tt*at - a)*x[I]
4229
+ # Modify density
4230
+ d1[I] = temp/d1[I]
4231
+ d1[I] += x[I]/d2[I]
4232
+ d1[I] = 1./d1[I]
4233
+
4234
+ s *= R
4235
+ h *= R*T
4236
+
4237
+ conv = pm.units.energy(1.,from_units='J')
4238
+ conv = pm.units.matter(conv, self.data['mw'], from_units='kg')
4239
+ h*=conv
4240
+ conv = pm.units.temperature(conv, from_units='K')
4241
+ s*=conv
4242
+ pm.units.matter(d1, self.data['mw'],from_units='kg',inplace=True)
4243
+ pm.units.volume(d1, from_units='m3', exponent=-1, inplace=True)
4244
+
4245
+ if quality:
4246
+ return h,s,d1,x
4247
+ return h,s,d1
4248
+
4249
+
4250
+ def cp(self, *varg, quality=False, **kwarg):
4251
+ """Constant-pressure specific heat
4252
+ cp(...)
4253
+
4254
+ All properties accept two other properties as flexible inputs.
4255
+ Below are the recognized keywords, their meaning, and the config entries
4256
+ that determine their units.
4257
+ T temperature unit_temperature
4258
+ p pressure unit_pressure
4259
+ d density unit_matter / unit_volume
4260
+ v specific volume unit_volume / unit_matter
4261
+ x quality dimensionless
4262
+ e internal energy unit_energy / unit_matter
4263
+ h enthalpy unit_energy / unit_matter
4264
+ s entropy unit_energy / unit_matter / unit_temperature
4265
+
4266
+ If no keywords are specified, the positional arguments are interpreted
4267
+ as (T,p). To configure their defaults, use the def_T and def_p config
4268
+ entries.
4269
+
4270
+ Additionally, if the optional keyword, "quality" is set to True, the
4271
+ quality of the liquid/vapor mixture is also returned
4272
+ cp,x = cp(..., quality=True)
4273
+
4274
+ Note that constant-pressure specific heat is theoretically infinite for
4275
+ saturated liquid-vapor mixtures. cp() returns +Inf for any states that
4276
+ are under the dome.
4277
+
4278
+ Returns specific heat in unit_energy / unit_matter / unit_temperature
4279
+ """
4280
+
4281
+ T,d1,d2,x,I = self._argparse(*varg, **kwarg)
4282
+ cp = self._cp(T,d1)
4283
+ if I.any():
4284
+ cp[I] = np.inf
4285
+ # Convert the units back to user space
4286
+ pm.units.energy(cp, from_units='J', inplace=True)
4287
+ pm.units.matter(cp, self.data['mw'],
4288
+ from_units='kg', exponent=-1, inplace=True)
4289
+ pm.units.temperature(cp, from_units='K',
4290
+ exponent=-1, inplace=True)
4291
+ if quality:
4292
+ return cp, x
4293
+ return cp
4294
+
4295
+
4296
+ def cv(self, *varg, quality=False, **kwarg):
4297
+ """Constant-volume specific heat
4298
+ cv(...)
4299
+
4300
+ All properties accept two other properties as flexible inputs.
4301
+ Below are the recognized keywords, their meaning, and the config entries
4302
+ that determine their units.
4303
+ T temperature unit_temperature
4304
+ p pressure unit_pressure
4305
+ d density unit_matter / unit_volume
4306
+ v specific volume unit_volume / unit_matter
4307
+ x quality dimensionless
4308
+ e internal energy unit_energy / unit_matter
4309
+ h enthalpy unit_energy / unit_matter
4310
+ s entropy unit_energy / unit_matter / unit_temperature
4311
+
4312
+ If no keywords are specified, the positional arguments are interpreted
4313
+ as (T,p). To configure their defaults, use the def_T and def_p config
4314
+ entries.
4315
+
4316
+ Additionally, if the optional keyword, "quality" is set to True, the
4317
+ quality of the liquid/vapor mixture is also returned
4318
+ cv,x = cv(..., quality=True)
4319
+
4320
+ The cv() method is unique in that it provides slightly different
4321
+ behaviors from its corresponding value returned by the state() method.
4322
+ The state() method does not calculate specific heats of any kind for
4323
+ saturated conditions. Meanwhile, cv() uses the derivatives saturation
4324
+ density and internal energy to calculate the total mixture specific
4325
+ heat. Applications that require this behavior should use cv()
4326
+ explicitly instead of depending on state().
4327
+
4328
+ Returns specific heat in unit_energy / unit_matter / unit_temperature
4329
+ """
4330
+
4331
+ T,d1,d2,x,I = self._argparse(*varg, **kwarg)
4332
+ cv = self._cv(T,d1)
4333
+ if I.any():
4334
+ # How do the saturation densities change with temperature?
4335
+ _,dVT,_ = self._dsv(T[I], diff=1)
4336
+ _,dLT,_ = self._dsl(T[I], diff=1)
4337
+ # How does x change with temperature
4338
+ temp = d1[I]/d2[I]
4339
+ xT = (dLT/d1[I]*(1-x[I]) + temp*dVT/d2[I]*x) / (temp-1)
4340
+ # Grab the saturation sensitivities
4341
+ eL,eLT,eLd = self._e(T[I],d1[I],diff=1)
4342
+ eV,eVT,eVd = self._e(T[I],d2[I],diff=1)
4343
+ # Calculate the true isochoric specific heat for the
4344
+ # two-phase mixture
4345
+ cv[I] = (eLT+eLd*dLT)*(1-x) + (eVT+eVd*dVT)*x + (eV-eL)*xT
4346
+
4347
+ # Convert the units back to user space
4348
+ pm.units.energy(cv, from_units='J', inplace=True)
4349
+ pm.units.matter(cv, self.data['mw'],
4350
+ from_units='kg', exponent=-1, inplace=True)
4351
+ pm.units.temperature(cv, from_units='K',
4352
+ exponent=-1, inplace=True)
4353
+ if quality:
4354
+ return cv, x
4355
+ return cv
4356
+
4357
+
4358
+ def gam(self, *varg, quality=False, **kwarg):
4359
+ """Specific heat ratio
4360
+ gam(...)
4361
+
4362
+ All properties accept two other properties as flexible inputs.
4363
+ Below are the recognized keywords, their meaning, and the config entries
4364
+ that determine their units.
4365
+ T temperature unit_temperature
4366
+ p pressure unit_pressure
4367
+ d density unit_matter / unit_volume
4368
+ v specific volume unit_volume / unit_matter
4369
+ x quality dimensionless
4370
+ e internal energy unit_energy / unit_matter
4371
+ h enthalpy unit_energy / unit_matter
4372
+ s entropy unit_energy / unit_matter / unit_temperature
4373
+
4374
+ If no keywords are specified, the positional arguments are interpreted
4375
+ as (T,p). To configure their defaults, use the def_T and def_p config
4376
+ entries.
4377
+
4378
+ Additionally, if the optional keyword, "quality" is set to True, the
4379
+ quality of the liquid/vapor mixture is also returned
4380
+ gam,x = gam(..., quality=True)
4381
+
4382
+ Returns specific heat ratio, which is dimensionless
4383
+ """
4384
+
4385
+ T,d1,d2,x,I = self._argparse(*varg, **kwarg)
4386
+ cv = self._cv(T,d1)
4387
+ cp = self._cp(T,d1)
4388
+ if I.any():
4389
+ cp[I] = np.inf
4390
+
4391
+ if quality:
4392
+ return cp/cv, x
4393
+ return cp/cv
4394
+
4395
+
4396
+ def T_s(self, s, p=None, d=None, quality=False, debug=False):
4397
+ """Temperature from entropy
4398
+ ** Deprecated - use T() **
4399
+
4400
+ T = T_s(s, p=p)
4401
+ OR
4402
+ T = T_s(s, d=d)
4403
+
4404
+ If neither pressure nor density is specified, the default pressure will be
4405
+ used (config['def_p']).
4406
+
4407
+ The optional keyword flag, quality, will cause quality to be returned
4408
+ along with temperature.
4409
+
4410
+ T,x = T_s(s, p=p, quality=True)
4411
+ """
4412
+ if p is not None:
4413
+ return self.T(s=s,p=p,quality=quality)
4414
+ elif d is not None:
4415
+ return self.T(s=s,d=d,quality=quality)
4416
+ p = pm.config['def_p']
4417
+ return self.T(s=s, p=p)
4418
+
4419
+
4420
+ def d_s(self, s, T=None, quality=False, debug=False):
4421
+ """Density from entropy
4422
+ ** Deprecated - use d() **
4423
+
4424
+ d = d_s(s,T=T)
4425
+
4426
+ If temperature is not specified, the default temperature will be used
4427
+ (config['def_T']).
4428
+
4429
+ The optional keyword flag, quality, will cause quality to be returned along
4430
+ with pressure.
4431
+ """
4432
+ if T is not None:
4433
+ return self.d(s=s, T=T, quality=quality)
4434
+ return self.d(s=s, quality=quality)
4435
+
4436
+
4437
+
4438
+
4439
+ def T_h(self, h, p=None, d=None, quality=False, debug=False):
4440
+ """Temperature from entropy
4441
+ ** Deprecated - use T() **
4442
+
4443
+ T = T_s(s, p=p)
4444
+ OR
4445
+ T = T_s(s, d=d)
4446
+
4447
+ If neither pressure nor density is specified, the default pressure will be
4448
+ used (config['def_p']).
4449
+
4450
+ The optional keyword flag, quality, will cause quality to be returned
4451
+ along with temperature.
4452
+
4453
+ T,x = T_s(s, p=p, quality=True)
4454
+ """
4455
+ if p is not None:
4456
+ return self.T(h=h,p=p,quality=quality)
4457
+ elif d is not None:
4458
+ return self.T(h=h,d=d,quality=quality)
4459
+ p = pm.config['def_p']
4460
+ return self.T(h=h, p=p)