From 69bbdc693be1baeb0e67f8f3fae3f666cad9a46f Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Fri, 22 Aug 2014 22:14:48 +0200 Subject: [PATCH] Reimplemented critical region splines all the way from scripts to build to C++ code Closes https://github.com/CoolProp/CoolProp/issues/94 Signed-off-by: Ian Bell --- dev/clean_up_json.py | 14 + dev/fluids/Acetone.json | 19 + dev/fluids/Argon.json | 19 + dev/fluids/Benzene.json | 19 + dev/fluids/CarbonMonoxide.json | 19 + dev/fluids/CycloHexane.json | 35 +- dev/fluids/Cyclopentane.json | 19 + dev/fluids/D4.json | 19 + dev/fluids/D6.json | 19 + dev/fluids/Deuterium.json | 19 + dev/fluids/DimethylCarbonate.json | 19 + dev/fluids/DimethylEther.json | 19 + dev/fluids/Ethanol.json | 19 + dev/fluids/EthylBenzene.json | 19 + dev/fluids/Ethylene.json | 19 + dev/fluids/HFE143m.json | 19 + dev/fluids/Helium.json | 19 + dev/fluids/Hydrogen.json | 19 + dev/fluids/IsoButane.json | 19 + dev/fluids/IsoButene.json | 19 + dev/fluids/Isopentane.json | 19 + dev/fluids/Krypton.json | 19 + dev/fluids/MD3M.json | 19 + dev/fluids/Methane.json | 19 + dev/fluids/MethylLinolenate.json | 19 + dev/fluids/MethylPalmitate.json | 19 + dev/fluids/MethylStearate.json | 19 + dev/fluids/Neon.json | 19 + dev/fluids/Neopentane.json | 19 + dev/fluids/Nitrogen.json | 19 + dev/fluids/OrthoDeuterium.json | 19 + dev/fluids/OrthoHydrogen.json | 19 + dev/fluids/ParaDeuterium.json | 19 + dev/fluids/ParaHydrogen.json | 19 + dev/fluids/Propylene.json | 19 + dev/fluids/R113.json | 19 + dev/fluids/R116.json | 19 + dev/fluids/R12.json | 19 + dev/fluids/R123.json | 19 + dev/fluids/R1234yf.json | 19 + dev/fluids/R1234ze(E).json | 19 + dev/fluids/R1234ze(Z).json | 19 + dev/fluids/R134a.json | 19 + dev/fluids/R14.json | 19 + dev/fluids/R143a.json | 19 + dev/fluids/R152A.json | 19 + dev/fluids/R161.json | 19 + dev/fluids/R218.json | 19 + dev/fluids/R22.json | 19 + dev/fluids/R227EA.json | 19 + dev/fluids/R236EA.json | 19 + dev/fluids/R245fa.json | 19 + dev/fluids/R32.json | 19 + dev/fluids/R41.json | 19 + dev/fluids/RC318.json | 19 + dev/fluids/Toluene.json | 19 + dev/fluids/Water.json | 19 + dev/fluids/Xenon.json | 19 + dev/fluids/m-Xylene.json | 19 + dev/fluids/n-Butane.json | 19 + dev/fluids/n-Decane.json | 19 + dev/fluids/n-Dodecane.json | 19 + dev/fluids/n-Hexane.json | 19 + dev/fluids/n-Nonane.json | 19 + dev/fluids/n-Pentane.json | 19 + dev/fluids/n-Propane.json | 19 + dev/fluids/p-Xylene.json | 19 + .../fit_saturation_critical_splines.py | 395 ++++++++++++++++++ include/CoolPropFluid.h | 32 ++ include/CoolPropTools.h | 5 + include/Helmholtz.h | 2 +- src/Backends/Helmholtz/FlashRoutines.cpp | 34 +- src/Backends/Helmholtz/Fluids/FluidLibrary.h | 10 + 73 files changed, 1747 insertions(+), 15 deletions(-) create mode 100644 dev/clean_up_json.py create mode 100644 dev/scripts/fit_saturation_critical_splines.py diff --git a/dev/clean_up_json.py b/dev/clean_up_json.py new file mode 100644 index 00000000..3ed1821c --- /dev/null +++ b/dev/clean_up_json.py @@ -0,0 +1,14 @@ +import json, sys, glob +sys.path.append('..') +from package_json import json_options + +for fluid in glob.glob('fluids/*.json'): + + print fluid + j = json.load(open(fluid,'r')) + + fp = open(fluid,'w') + fp.write(json.dumps(j,**json_options)) + fp.close() + + \ No newline at end of file diff --git a/dev/fluids/Acetone.json b/dev/fluids/Acetone.json index 3ceca17d..f3812c10 100644 --- a/dev/fluids/Acetone.json +++ b/dev/fluids/Acetone.json @@ -351,6 +351,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 508.1, + "T_min": 508.09697325761744, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -1.5123933548972854e-11, + -1.7185082712306687e-08, + 0.0011638028537861549, + 504.579957217175 + ], + "cV": [ + 1.9536072269032177e-10, + -2.983480058312324e-06, + 0.015098157455448244, + 482.76079813563524 + ], + "rhomolar_max": 4814.181193727979, + "rhomolar_min": 4590.050467927069 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.05807914, diff --git a/dev/fluids/Argon.json b/dev/fluids/Argon.json index a8cd9918..ef68f78d 100644 --- a/dev/fluids/Argon.json +++ b/dev/fluids/Argon.json @@ -504,6 +504,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 150.687, + "T_min": 150.68697834063298, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -6.171554333557227e-07, + 150.69527446806111 + ], + "cV": [ + 0.0, + 0.0, + 6.072607995401675e-07, + 150.67885819354578 + ], + "rhomolar_max": 13442.525139946354, + "rhomolar_min": 13371.76233564158 + }, "gas_constant": 8.31451, "gas_constant_units": "J/mol/K", "molar_mass": 0.039948, diff --git a/dev/fluids/Benzene.json b/dev/fluids/Benzene.json index 4e47bb23..a2297176 100644 --- a/dev/fluids/Benzene.json +++ b/dev/fluids/Benzene.json @@ -392,6 +392,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 562.02, + "T_min": 562.0154317177073, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 1.520711526285315e-09, + -1.882771712992933e-05, + 0.07747024998960111, + 456.0485114418244 + ], + "cV": [ + -1.4493190976253649e-09, + 1.594228162718946e-05, + -0.05821328986834306, + 632.5418824068289 + ], + "rhomolar_max": 3972.502745702652, + "rhomolar_min": 3831.5869548914043 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.07811180000000001, diff --git a/dev/fluids/CarbonMonoxide.json b/dev/fluids/CarbonMonoxide.json index 906149d8..98d78628 100644 --- a/dev/fluids/CarbonMonoxide.json +++ b/dev/fluids/CarbonMonoxide.json @@ -365,6 +365,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 132.86, + "T_min": 132.85867131966137, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 3.1174266374072594e-11, + -1.0578676813227408e-06, + 0.011945990965038183, + 87.96227472439597 + ], + "cV": [ + -2.7988602187391993e-11, + 8.673443114829891e-07, + -0.008936706896165105, + 163.4668663127422 + ], + "rhomolar_max": 11038.842068491349, + "rhomolar_min": 10664.189840198747 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.0280101, diff --git a/dev/fluids/CycloHexane.json b/dev/fluids/CycloHexane.json index 3b33be02..bba3f450 100644 --- a/dev/fluids/CycloHexane.json +++ b/dev/fluids/CycloHexane.json @@ -447,6 +447,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 553.6, + "T_min": 553.5979946139788, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 1.56104739484658e-08, + -0.00015385588557227471, + 0.5052887091787223, + 0.6345188298942561 + ], + "cV": [ + -1.5338245208003638e-08, + 0.0001454870563719106, + -0.45981527881664047, + 1037.8236160527126 + ], + "rhomolar_max": 3252.773506033089, + "rhomolar_min": 3195.2323910542696 + }, "gas_constant": 8.3144621, "gas_constant_units": "J/mol/K", "molar_mass": 0.08415948000000001, @@ -550,10 +569,10 @@ 0, 0, 0, - 0, - 0, - 0, - 0, + 0, + 0, + 0, + 0, 0 ], "h": [ @@ -571,10 +590,10 @@ 1, 1, 1, - 1, - 1, - 1, - 1, + 1, + 1, + 1, + 1, 1 ], "p": [ diff --git a/dev/fluids/Cyclopentane.json b/dev/fluids/Cyclopentane.json index ae9b299f..31977cf2 100644 --- a/dev/fluids/Cyclopentane.json +++ b/dev/fluids/Cyclopentane.json @@ -385,6 +385,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 511.72, + "T_min": 511.7095934234679, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -4.880588052926918e-09, + 5.252717316693226e-05, + -0.18764912368477027, + 734.1005944101676 + ], + "cV": [ + 5.250582737174832e-09, + -6.357124543112242e-05, + 0.2558285044919253, + 169.4290891702673 + ], + "rhomolar_max": 3873.2904355172786, + "rhomolar_min": 3766.813756733369 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.07013290000000001, diff --git a/dev/fluids/D4.json b/dev/fluids/D4.json index a5a463a9..22ccd2f2 100644 --- a/dev/fluids/D4.json +++ b/dev/fluids/D4.json @@ -359,6 +359,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 586.5, + "T_min": 583.1872205036263, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + -1.667552305553379e-05, + 0.034382527265190706, + 568.7770449657756 + ], + "cV": [ + 6.813459579816792e-08, + -0.00021263235123370055, + 0.22117438047692597, + 509.81953537332856 + ], + "rhomolar_max": 1476.6422633230486, + "rhomolar_min": 675.0371135400856 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.29661576, diff --git a/dev/fluids/D6.json b/dev/fluids/D6.json index bf8be280..1750f567 100644 --- a/dev/fluids/D6.json +++ b/dev/fluids/D6.json @@ -350,6 +350,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 645.78, + "T_min": 645.4997615767367, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -1.554702914197144e-07, + 0.00027871311312902783, + -0.16613864293822964, + 678.7008854032358 + ], + "cV": [ + 2.1732433324774884e-07, + -0.00042927603672073575, + 0.28201442644063596, + 584.1491278422845 + ], + "rhomolar_max": 725.3981107757561, + "rhomolar_min": 542.276230072255 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.444924, diff --git a/dev/fluids/Deuterium.json b/dev/fluids/Deuterium.json index e01cb0a5..74a443b4 100644 --- a/dev/fluids/Deuterium.json +++ b/dev/fluids/Deuterium.json @@ -438,6 +438,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 38.34, + "T_min": 38.3399506598222, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -8.339819490855398e-07, + 38.35436950898275 + ], + "cV": [ + 0.0, + 0.0, + 8.380089288669903e-07, + 38.325561106155625 + ], + "rhomolar_max": 17289.162165151512, + "rhomolar_min": 17171.122133543762 + }, "gas_constant": 8.3144621, "gas_constant_units": "J/mol/K", "molar_mass": 0.0040282, diff --git a/dev/fluids/DimethylCarbonate.json b/dev/fluids/DimethylCarbonate.json index 87ad27c3..fe5efbfc 100644 --- a/dev/fluids/DimethylCarbonate.json +++ b/dev/fluids/DimethylCarbonate.json @@ -407,6 +407,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 557.0, + "T_min": 556.9999904919641, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -2.1173490191325178e-07, + 557.0008469396076 + ], + "cV": [ + 0.0, + 0.0, + 2.0050706260121842e-07, + 556.9991979717496 + ], + "rhomolar_max": 4044.9053782587557, + "rhomolar_min": 3952.580044972171 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.0900779, diff --git a/dev/fluids/DimethylEther.json b/dev/fluids/DimethylEther.json index 522aaffd..79ee8b64 100644 --- a/dev/fluids/DimethylEther.json +++ b/dev/fluids/DimethylEther.json @@ -387,6 +387,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 400.378, + "T_min": 400.3774167354802, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -1.846177917829548e-05, + 400.48766296831906 + ], + "cV": [ + 0.0, + 0.0, + 1.8536722158567707e-05, + 400.2678918703781 + ], + "rhomolar_max": 5971.593082884313, + "rhomolar_min": 5908.534646267459 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.04606844, diff --git a/dev/fluids/Ethanol.json b/dev/fluids/Ethanol.json index 91f8ced8..4bc57127 100644 --- a/dev/fluids/Ethanol.json +++ b/dev/fluids/Ethanol.json @@ -465,6 +465,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 514.71, + "T_min": 513.7464813947397, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 1.0321929712568178e-10, + -2.8791135673288862e-06, + 0.023257198124035903, + 456.514456977566 + ], + "cV": [ + -2.567634017795019e-10, + 3.6513286874767864e-06, + -0.016217580191766636, + 536.0239643040333 + ], + "rhomolar_max": 6943.380770596912, + "rhomolar_min": 4649.622177033432 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.04606844, diff --git a/dev/fluids/EthylBenzene.json b/dev/fluids/EthylBenzene.json index fe490e4a..61a5cb98 100644 --- a/dev/fluids/EthylBenzene.json +++ b/dev/fluids/EthylBenzene.json @@ -379,6 +379,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 617.12, + "T_min": 617.1197439583547, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -2.3245131740117315e-05, + 617.1837152780217 + ], + "cV": [ + 0.0, + 0.0, + 2.3091817015124984e-05, + 617.0567049600925 + ], + "rhomolar_max": 2752.0308502563307, + "rhomolar_min": 2729.928018264121 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.106165, diff --git a/dev/fluids/Ethylene.json b/dev/fluids/Ethylene.json index 257cbf1d..426a0c01 100644 --- a/dev/fluids/Ethylene.json +++ b/dev/fluids/Ethylene.json @@ -508,6 +508,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 282.35, + "T_min": 282.3497439583547, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -3.634935446259431e-06, + 282.37775915135825 + ], + "cV": [ + 0.0, + 0.0, + 3.6437107681563877e-06, + 282.3221738335621 + ], + "rhomolar_max": 7707.205098345808, + "rhomolar_min": 7566.496505023215 + }, "gas_constant": 8.31451, "gas_constant_units": "J/mol/K", "molar_mass": 0.02805376, diff --git a/dev/fluids/HFE143m.json b/dev/fluids/HFE143m.json index fe6e8a25..c92162af 100644 --- a/dev/fluids/HFE143m.json +++ b/dev/fluids/HFE143m.json @@ -360,6 +360,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 377.921, + "T_min": 377.88522000242136, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 4.9355266611563965e-11, + -1.1363349519029853e-06, + 0.00736469652648742, + 363.2831553274167 + ], + "cV": [ + -1.6224665103344288e-10, + 1.8467354481248633e-06, + -0.0066516525010036605, + 385.2331741502011 + ], + "rhomolar_max": 4935.29110614525, + "rhomolar_min": 4335.002308503029 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.10004, diff --git a/dev/fluids/Helium.json b/dev/fluids/Helium.json index 23733b01..952666a3 100644 --- a/dev/fluids/Helium.json +++ b/dev/fluids/Helium.json @@ -438,6 +438,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 5.1953000000000005, + "T_min": 5.19073171770731, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -3.0333435224167437e-13, + 1.5607506016709e-08, + -0.00026681298442982895, + 6.710133323667334 + ], + "cV": [ + 0.0, + -4.479989405503328e-10, + 1.624444158435496e-05, + 5.048044137037824 + ], + "rhomolar_max": 19915.76431162559, + "rhomolar_min": 14936.712852945791 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.004002602, diff --git a/dev/fluids/Hydrogen.json b/dev/fluids/Hydrogen.json index e19d1266..4a64f600 100644 --- a/dev/fluids/Hydrogen.json +++ b/dev/fluids/Hydrogen.json @@ -410,6 +410,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 33.145, + "T_min": 33.13810506132737, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 3.1007578284721566e-12, + -1.5869880447859634e-07, + 0.0026850233556669507, + 18.107690278950276 + ], + "cV": [ + -2.3396699485553584e-12, + 9.516798742074658e-08, + -0.0012636720187622463, + 38.58044486815464 + ], + "rhomolar_max": 16262.923237049079, + "rhomolar_min": 14746.877675758724 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.00201588, diff --git a/dev/fluids/IsoButane.json b/dev/fluids/IsoButane.json index 6ef90b6a..b6e92b99 100644 --- a/dev/fluids/IsoButane.json +++ b/dev/fluids/IsoButane.json @@ -452,6 +452,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 407.817, + "T_min": 407.73549293470376, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -5.728389280296945e-10, + 6.296755366265217e-06, + -0.022991762972926447, + 435.69130219666266 + ], + "cV": [ + 5.562666408422913e-10, + -6.761233991678565e-06, + 0.027344254864717768, + 371.015481302833 + ], + "rhomolar_max": 4253.160501655689, + "rhomolar_min": 3479.687062549918 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.0581222, diff --git a/dev/fluids/IsoButene.json b/dev/fluids/IsoButene.json index f9f67ba0..3d251512 100644 --- a/dev/fluids/IsoButene.json +++ b/dev/fluids/IsoButene.json @@ -347,6 +347,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 418.09000000000003, + "T_min": 418.08543171770737, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 1.0856405178489673e-09, + -1.4451084442137125e-05, + 0.06388776104495195, + 324.24484504699296 + ], + "cV": [ + -6.230035048466998e-10, + 6.9227418610441575e-06, + -0.02523563018482191, + 448.11876326463465 + ], + "rhomolar_max": 4246.188019158735, + "rhomolar_min": 4095.5716752458243 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.05610631999999999, diff --git a/dev/fluids/Isopentane.json b/dev/fluids/Isopentane.json index fc084120..6a8a1a95 100644 --- a/dev/fluids/Isopentane.json +++ b/dev/fluids/Isopentane.json @@ -363,6 +363,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 460.35, + "T_min": 460.34697325761744, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 8.005022701910341e-10, + -8.44526357152168e-06, + 0.029554133854069683, + 426.02215187987395 + ], + "cV": [ + -5.384468503556533e-10, + 4.689391032778603e-06, + -0.013394755215389163, + 472.83487531264404 + ], + "rhomolar_max": 3346.612383148717, + "rhomolar_min": 3197.125647678554 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.07214878, diff --git a/dev/fluids/Krypton.json b/dev/fluids/Krypton.json index bdb1b786..3144b63d 100644 --- a/dev/fluids/Krypton.json +++ b/dev/fluids/Krypton.json @@ -347,6 +347,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 209.48000000000002, + "T_min": 209.47310506132737, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 6.390300964893231e-11, + -2.199509680360674e-06, + 0.02516089390363733, + 113.79346021244321 + ], + "cV": [ + -3.436623953002642e-11, + 1.0066209446840255e-06, + -0.009706635600422744, + 240.19068612286947 + ], + "rhomolar_max": 11108.82129459245, + "rhomolar_min": 10591.412518037536 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.083798, diff --git a/dev/fluids/MD3M.json b/dev/fluids/MD3M.json index 9d856d8f..bf146615 100644 --- a/dev/fluids/MD3M.json +++ b/dev/fluids/MD3M.json @@ -350,6 +350,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 628.36, + "T_min": 628.3495934234678, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 7.278401833841499e-08, + -0.00016564557063869183, + 0.12450370964999923, + 597.405816117967 + ], + "cV": [ + 4.6976897100679125e-08, + -0.00011341900983330957, + 0.08928269840896542, + 605.3211026107697 + ], + "rhomolar_max": 713.1509447889869, + "rhomolar_min": 661.6875900836687 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.384839, diff --git a/dev/fluids/Methane.json b/dev/fluids/Methane.json index 27e236da..3547ef04 100644 --- a/dev/fluids/Methane.json +++ b/dev/fluids/Methane.json @@ -516,6 +516,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 190.564, + "T_min": 190.5639673093741, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -8.298041773773189e-07, + 190.57241349076935 + ], + "cV": [ + 0.0, + 0.0, + 8.001489626516288e-07, + 190.5558871872486 + ], + "rhomolar_max": 10178.523590876614, + "rhomolar_min": 10098.272325109083 + }, "gas_constant": 8.31451, "gas_constant_units": "J/mol/K", "molar_mass": 0.0160428, diff --git a/dev/fluids/MethylLinolenate.json b/dev/fluids/MethylLinolenate.json index a6076b0f..1ffe037e 100644 --- a/dev/fluids/MethylLinolenate.json +++ b/dev/fluids/MethylLinolenate.json @@ -380,6 +380,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 772.0, + "T_min": 771.9954317177073, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -7.06979551641186e-10, + -5.571201614845291e-05, + 0.0959322410965671, + 731.1432812971636 + ], + "cV": [ + 2.442004237931142e-08, + -0.0001196088172901947, + 0.15009438984004297, + 715.8397616487149 + ], + "rhomolar_max": 856.2121900411788, + "rhomolar_min": 838.4061393625097 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.29245618, diff --git a/dev/fluids/MethylPalmitate.json b/dev/fluids/MethylPalmitate.json index 845ea715..b270d495 100644 --- a/dev/fluids/MethylPalmitate.json +++ b/dev/fluids/MethylPalmitate.json @@ -393,6 +393,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 755.0, + "T_min": 754.9979946139788, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -8.453804974988888e-07, + 0.0022314430347624794, + -1.9626065342276378, + 1330.1589912157262 + ], + "cV": [ + 8.346377269227008e-07, + -0.002289692013105165, + 2.0930363910460232, + 117.46650514532276 + ], + "rhomolar_max": 903.4045446436754, + "rhomolar_min": 890.603960171529 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.27045066, diff --git a/dev/fluids/MethylStearate.json b/dev/fluids/MethylStearate.json index e916e4ed..975d8c82 100644 --- a/dev/fluids/MethylStearate.json +++ b/dev/fluids/MethylStearate.json @@ -393,6 +393,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 775.0, + "T_min": 774.9931050613274, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 3.695594514041921e-08, + -0.00015314359180175198, + 0.1733360078297273, + 715.4195409309607 + ], + "cV": [ + -8.410775169091402e-09, + -4.503043200679788e-05, + 0.08745473360028402, + 738.1598907285911 + ], + "rhomolar_max": 804.623188217212, + "rhomolar_min": 783.9995580899517 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.29850382, diff --git a/dev/fluids/Neon.json b/dev/fluids/Neon.json index 26f0f0a6..d1d3803e 100644 --- a/dev/fluids/Neon.json +++ b/dev/fluids/Neon.json @@ -425,6 +425,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 44.491800000000005, + "T_min": 44.49141355465158, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -1.5811616648711508e-06, + 44.52956130288046 + ], + "cV": [ + 0.0, + 0.0, + 1.5834258838542428e-06, + 44.4539846230418 + ], + "rhomolar_max": 24126.40596873362, + "rhomolar_min": 23637.943519451463 + }, "gas_constant": 8.31434, "gas_constant_units": "J/mol/K", "molar_mass": 0.020179, diff --git a/dev/fluids/Neopentane.json b/dev/fluids/Neopentane.json index d65199d2..b78efdeb 100644 --- a/dev/fluids/Neopentane.json +++ b/dev/fluids/Neopentane.json @@ -347,6 +347,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 433.74, + "T_min": 433.73543171770734, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 1.8157110662036835e-09, + -1.8874192929720874e-05, + 0.0651915711809464, + 358.895660684941 + ], + "cV": [ + -2.2365486585331262e-09, + 2.089693784319932e-05, + -0.06492040004203695, + 500.7835165371252 + ], + "rhomolar_max": 3339.892894257803, + "rhomolar_min": 3198.06041887194 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.07214878, diff --git a/dev/fluids/Nitrogen.json b/dev/fluids/Nitrogen.json index 4c5ea4f3..8d20ec44 100644 --- a/dev/fluids/Nitrogen.json +++ b/dev/fluids/Nitrogen.json @@ -499,6 +499,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 126.19200000000001, + "T_min": 126.19199998688855, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -1.547800694886972e-07, + 126.19373104504585 + ], + "cV": [ + 0.0, + 0.0, + 9.95463660457675e-10, + 126.19198886683252 + ], + "rhomolar_max": 11183.986174852074, + "rhomolar_min": 11170.73026187868 + }, "gas_constant": 8.31451, "gas_constant_units": "J/mol/K", "molar_mass": 0.02801348, diff --git a/dev/fluids/OrthoDeuterium.json b/dev/fluids/OrthoDeuterium.json index ae2103cd..32f25165 100644 --- a/dev/fluids/OrthoDeuterium.json +++ b/dev/fluids/OrthoDeuterium.json @@ -415,6 +415,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 38.34, + "T_min": 38.33996730937413, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -6.850188755192064e-07, + 38.3518028752252 + ], + "cV": [ + 0.0, + 0.0, + 6.843466890793785e-07, + 38.328208706547166 + ], + "rhomolar_max": 17277.722226405003, + "rhomolar_min": 17182.23089934681 + }, "gas_constant": 8.3144621, "gas_constant_units": "J/mol/K", "molar_mass": 0.0040282, diff --git a/dev/fluids/OrthoHydrogen.json b/dev/fluids/OrthoHydrogen.json index 346cf66f..673941aa 100644 --- a/dev/fluids/OrthoHydrogen.json +++ b/dev/fluids/OrthoHydrogen.json @@ -377,6 +377,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 33.22, + "T_min": 33.216973257617425, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 4.066468806855226e-12, + -2.0485786362827496e-07, + 0.003417899984425546, + 14.316580566669387 + ], + "cV": [ + -3.379814959674437e-12, + 1.404217131242082e-07, + -0.0019188970430762365, + 41.812545688089735 + ], + "rhomolar_max": 15899.98591137461, + "rhomolar_min": 14989.857909343546 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.00201594, diff --git a/dev/fluids/ParaDeuterium.json b/dev/fluids/ParaDeuterium.json index b243ee7f..d8777e9b 100644 --- a/dev/fluids/ParaDeuterium.json +++ b/dev/fluids/ParaDeuterium.json @@ -413,6 +413,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 38.34, + "T_min": 38.33996730937413, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -6.849502299785245e-07, + 38.35180169246253 + ], + "cV": [ + 0.0, + 0.0, + 6.848389037037868e-07, + 38.32820022568919 + ], + "rhomolar_max": 17277.727009113827, + "rhomolar_min": 17182.26523245882 + }, "gas_constant": 8.3144621, "gas_constant_units": "J/mol/K", "molar_mass": 0.0040282, diff --git a/dev/fluids/ParaHydrogen.json b/dev/fluids/ParaHydrogen.json index c3ac9c1c..0d787c36 100644 --- a/dev/fluids/ParaHydrogen.json +++ b/dev/fluids/ParaHydrogen.json @@ -417,6 +417,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 32.938, + "T_min": 32.93599461397884, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 4.253205081213295e-12, + -2.116493776473347e-07, + 0.0034966692458426726, + 13.749966028178376 + ], + "cV": [ + -3.141534424322369e-12, + 1.338646257848717e-07, + -0.0018846003827776433, + 41.68699310689614 + ], + "rhomolar_max": 15953.359013823481, + "rhomolar_min": 15115.765516662266 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.00201588, diff --git a/dev/fluids/Propylene.json b/dev/fluids/Propylene.json index be26dabb..0f958d48 100644 --- a/dev/fluids/Propylene.json +++ b/dev/fluids/Propylene.json @@ -456,6 +456,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 364.211, + "T_min": 364.21041673548024, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -6.505035916897591e-06, + 364.2464979809985 + ], + "cV": [ + 0.0, + 0.0, + 6.4811926293276935e-06, + 364.17563213182177 + ], + "rhomolar_max": 5546.663535640788, + "rhomolar_min": 5367.006606323258 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.04207974, diff --git a/dev/fluids/R113.json b/dev/fluids/R113.json index 0e7114cc..27fe1446 100644 --- a/dev/fluids/R113.json +++ b/dev/fluids/R113.json @@ -374,6 +374,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 487.21000000000004, + "T_min": 487.20941673548026, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -2.1155772356204888e-05, + 487.27322739169836 + ], + "cV": [ + 0.0, + 0.0, + 2.1763182218616364e-05, + 487.1449572672853 + ], + "rhomolar_max": 3016.2291002048787, + "rhomolar_min": 2961.858589771953 + }, "gas_constant": 8.314471, "gas_constant_units": "J/mol/K", "molar_mass": 0.187375, diff --git a/dev/fluids/R116.json b/dev/fluids/R116.json index 1b7b355f..4319a639 100644 --- a/dev/fluids/R116.json +++ b/dev/fluids/R116.json @@ -344,6 +344,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 293.03000000000003, + "T_min": 293.02697325761744, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 5.973701413916427e-10, + -8.378309573561642e-06, + 0.039073782995767505, + 232.42219731732985 + ], + "cV": [ + -4.2587664193266785e-10, + 5.257573775768188e-06, + -0.02149722855677295, + 322.1082759616395 + ], + "rhomolar_max": 4535.77641861197, + "rhomolar_min": 4355.023810307573 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.13801182, diff --git a/dev/fluids/R12.json b/dev/fluids/R12.json index 62242f4b..3541380c 100644 --- a/dev/fluids/R12.json +++ b/dev/fluids/R12.json @@ -392,6 +392,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 385.12, + "T_min": 385.11941673548023, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -1.583911139375003e-05, + 385.1940127028315 + ], + "cV": [ + 0.0, + 0.0, + 1.5981068543804365e-05, + 385.04532396245855 + ], + "rhomolar_max": 4709.605576782584, + "rhomolar_min": 4636.284039366143 + }, "gas_constant": 8.314471, "gas_constant_units": "J/mol/K", "molar_mass": 0.120913, diff --git a/dev/fluids/R123.json b/dev/fluids/R123.json index fcc4bd61..4b9fd82c 100644 --- a/dev/fluids/R123.json +++ b/dev/fluids/R123.json @@ -468,6 +468,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 456.831, + "T_min": 456.7079808473738, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -5.2516982254248e-10, + 4.95822393582125e-06, + -0.015285703141563677, + 472.1032632289936 + ], + "cV": [ + 5.019316578137991e-10, + -6.104407328102757e-06, + 0.024431712288804266, + 424.57182248409964 + ], + "rhomolar_max": 3965.7364882421543, + "rhomolar_min": 3221.873367889577 + }, "gas_constant": 8.31451, "gas_constant_units": "J/mol/K", "molar_mass": 0.152931, diff --git a/dev/fluids/R1234yf.json b/dev/fluids/R1234yf.json index d0502c35..a7935a55 100644 --- a/dev/fluids/R1234yf.json +++ b/dev/fluids/R1234yf.json @@ -390,6 +390,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 367.85, + "T_min": 367.84983035809745, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -7.28092281910778e-06, + 367.8803614481557 + ], + "cV": [ + 0.0, + 0.0, + 7.273842039048367e-06, + 367.8196680786972 + ], + "rhomolar_max": 4193.299505682264, + "rhomolar_min": 4146.67781322612 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.1140415928, diff --git a/dev/fluids/R1234ze(E).json b/dev/fluids/R1234ze(E).json index cb2de646..bac6b8ef 100644 --- a/dev/fluids/R1234ze(E).json +++ b/dev/fluids/R1234ze(E).json @@ -403,6 +403,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 382.52, + "T_min": 382.5199506598222, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -7.9305911732753e-07, + 382.5234022236133 + ], + "cV": [ + 0.0, + 0.0, + 6.090875342473237e-07, + 382.51738701447806 + ], + "rhomolar_max": 4352.215006013345, + "rhomolar_min": 4208.993289113025 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.1140415928, diff --git a/dev/fluids/R1234ze(Z).json b/dev/fluids/R1234ze(Z).json index 3add47b1..39aab603 100644 --- a/dev/fluids/R1234ze(Z).json +++ b/dev/fluids/R1234ze(Z).json @@ -346,6 +346,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 423.27, + "T_min": 423.26310506132734, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -1.0661006391670194e-09, + 1.2653370461499062e-05, + -0.04997314613163001, + 488.933234607043 + ], + "cV": [ + -8.160851613585538e-10, + 9.267609720003654e-06, + -0.03480529660648677, + 466.4282367596696 + ], + "rhomolar_max": 4225.213370352157, + "rhomolar_min": 4025.0245673273625 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.1140415928, diff --git a/dev/fluids/R134a.json b/dev/fluids/R134a.json index 01004a25..ac3f4df6 100644 --- a/dev/fluids/R134a.json +++ b/dev/fluids/R134a.json @@ -378,6 +378,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 374.21, + "T_min": 374.15599701305536, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -2.358891970526994e-10, + 3.35250579170572e-06, + -0.015826824353177796, + 399.0175702243528 + ], + "cV": [ + 2.033032586375043e-10, + -3.2541387283179285e-06, + 0.017300443262052236, + 343.6482870886872 + ], + "rhomolar_max": 5442.556273932187, + "rhomolar_min": 4580.218882520725 + }, "gas_constant": 8.314471, "gas_constant_units": "J/mol/K", "molar_mass": 0.102032, diff --git a/dev/fluids/R14.json b/dev/fluids/R14.json index df48a2d2..58dc3551 100644 --- a/dev/fluids/R14.json +++ b/dev/fluids/R14.json @@ -413,6 +413,25 @@ "type": "ResidualHelmholtzExponential" } ], + "critical_region_splines": { + "T_max": 227.51, + "T_min": 226.05575499770643, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -4.497162085380202e-11, + 7.584188775966138e-07, + -0.003964719969167488, + 233.5234361790954 + ], + "cV": [ + 5.850937467308107e-11, + -1.409814381412894e-06, + 0.011174057273190223, + 198.30177311425936 + ], + "rhomolar_max": 9311.871085841536, + "rhomolar_min": 4879.2736322840055 + }, "gas_constant": 8.31451, "gas_constant_units": "J/mol/K", "molar_mass": 0.0880046, diff --git a/dev/fluids/R143a.json b/dev/fluids/R143a.json index ab32f3c0..950e1464 100644 --- a/dev/fluids/R143a.json +++ b/dev/fluids/R143a.json @@ -379,6 +379,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 345.857, + "T_min": 345.85688760275673, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -5.242214594297355e-06, + 345.88388443543613 + ], + "cV": [ + 0.0, + 0.0, + 5.221395136669298e-06, + 345.8302223361114 + ], + "rhomolar_max": 5149.890794010884, + "rhomolar_min": 5106.923714331294 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.08404099999999999, diff --git a/dev/fluids/R152A.json b/dev/fluids/R152A.json index 181d6bf5..b6e727e5 100644 --- a/dev/fluids/R152A.json +++ b/dev/fluids/R152A.json @@ -466,6 +466,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 386.411, + "T_min": 386.2879808473738, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -1.1446811820239007e-10, + 1.646295645058246e-06, + -0.007684872988074046, + 397.9206701191548 + ], + "cV": [ + 1.0521854870590392e-10, + -2.0174071540863595e-06, + 0.012681483095329345, + 360.1823139464937 + ], + "rhomolar_max": 6176.35151183272, + "rhomolar_min": 4954.90121849081 + }, "gas_constant": 8.314471, "gas_constant_units": "J/mol/K", "molar_mass": 0.066051, diff --git a/dev/fluids/R161.json b/dev/fluids/R161.json index c3199cc6..83708b5d 100644 --- a/dev/fluids/R161.json +++ b/dev/fluids/R161.json @@ -395,6 +395,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 375.25, + "T_min": 375.2498876027567, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -1.0274211653082636e-06, + 375.25645220491816 + ], + "cV": [ + 0.0, + 0.0, + 6.800670480519312e-07, + 375.24572917893823 + ], + "rhomolar_max": 6389.397438091061, + "rhomolar_min": 6114.726232371929 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.0480595, diff --git a/dev/fluids/R218.json b/dev/fluids/R218.json index 29e533fe..905637fc 100644 --- a/dev/fluids/R218.json +++ b/dev/fluids/R218.json @@ -342,6 +342,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 345.02, + "T_min": 345.01867131966134, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 2.115849844779737e-09, + -2.2622652824384362e-05, + 0.08030859728161308, + 250.32261200217556 + ], + "cV": [ + -1.5113366978895236e-09, + 1.3734866737761167e-05, + -0.04116930680731554, + 385.6167633643665 + ], + "rhomolar_max": 3371.3072650243957, + "rhomolar_min": 3308.7608519066903 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.18801933, diff --git a/dev/fluids/R22.json b/dev/fluids/R22.json index 03c23f80..76f4d552 100644 --- a/dev/fluids/R22.json +++ b/dev/fluids/R22.json @@ -471,6 +471,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 369.295, + "T_min": 369.29299461397886, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -6.068711638786403e-11, + 9.60793099642547e-07, + -0.004959370923967982, + 377.5706211619357 + ], + "cV": [ + 2.0197560844726486e-11, + -5.076049994717274e-07, + 0.003926491093801074, + 359.64667998370135 + ], + "rhomolar_max": 6174.151068396738, + "rhomolar_min": 5939.762656878844 + }, "gas_constant": 8.31451, "gas_constant_units": "J/mol/K", "molar_mass": 0.086468, diff --git a/dev/fluids/R227EA.json b/dev/fluids/R227EA.json index 7b170d32..d35dd1c9 100644 --- a/dev/fluids/R227EA.json +++ b/dev/fluids/R227EA.json @@ -414,6 +414,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 374.90000000000003, + "T_min": 374.8931050613274, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -5.875126621910152e-10, + 5.780632973589872e-06, + -0.01887717891595377, + 395.3469681114307 + ], + "cV": [ + 1.1730303150524067e-10, + -1.607222079285808e-06, + 0.006935903946970884, + 365.2834297632339 + ], + "rhomolar_max": 3618.508261092158, + "rhomolar_min": 3362.517912603551 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.17002886, diff --git a/dev/fluids/R236EA.json b/dev/fluids/R236EA.json index 56891551..e6677c50 100644 --- a/dev/fluids/R236EA.json +++ b/dev/fluids/R236EA.json @@ -392,6 +392,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 412.44, + "T_min": 412.01703429466085, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -9.065638596766866e-10, + 9.956613016634915e-06, + -0.036442262498707786, + 456.8904836061875 + ], + "cV": [ + 8.719771420305249e-10, + -9.978606681376363e-06, + 0.03803850767350116, + 364.13631933098907 + ], + "rhomolar_max": 4440.255966785143, + "rhomolar_min": 3017.4925122772956 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.1520384, diff --git a/dev/fluids/R245fa.json b/dev/fluids/R245fa.json index 6a315054..09262ad4 100644 --- a/dev/fluids/R245fa.json +++ b/dev/fluids/R245fa.json @@ -385,6 +385,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 427.01, + "T_min": 427.0098876027567, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -1.084584597428029e-06, + 427.014202765315 + ], + "cV": [ + 0.0, + 0.0, + 1.2920303634458716e-06, + 427.00499338234164 + ], + "rhomolar_max": 3978.6316056494643, + "rhomolar_min": 3788.0072740848295 + }, "gas_constant": 8.3144621, "gas_constant_units": "J/mol/K", "molar_mass": 0.13404794, diff --git a/dev/fluids/R32.json b/dev/fluids/R32.json index 4ce8eb23..0c9a5923 100644 --- a/dev/fluids/R32.json +++ b/dev/fluids/R32.json @@ -372,6 +372,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 351.255, + "T_min": 351.25499816776613, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -4.041924265889875e-07, + 351.25829420247135 + ], + "cV": [ + 0.0, + 0.0, + 1.4328717651880036e-07, + 351.2538321973893 + ], + "rhomolar_max": 8154.617673148497, + "rhomolar_min": 8137.297455089546 + }, "gas_constant": 8.314471, "gas_constant_units": "J/mol/K", "molar_mass": 0.052024, diff --git a/dev/fluids/R41.json b/dev/fluids/R41.json index 32e4897b..35774465 100644 --- a/dev/fluids/R41.json +++ b/dev/fluids/R41.json @@ -355,6 +355,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 317.28000000000003, + "T_min": 317.2695934234679, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 8.947784934150927e-11, + -2.661886245206215e-06, + 0.0262942665921942, + 230.99772757769114 + ], + "cV": [ + -8.480951160041928e-11, + 2.20398173327229e-06, + -0.018988536263903795, + 371.46813146596344 + ], + "rhomolar_max": 9571.518280811737, + "rhomolar_min": 9026.378810480832 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.03403291999999999, diff --git a/dev/fluids/RC318.json b/dev/fluids/RC318.json index e8948e99..96b83c2e 100644 --- a/dev/fluids/RC318.json +++ b/dev/fluids/RC318.json @@ -411,6 +411,25 @@ "type": "ResidualHelmholtzExponential" } ], + "critical_region_splines": { + "T_max": 388.38, + "T_min": 388.25698084737377, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 5.161678249152199e-10, + -6.54174243254277e-06, + 0.0256755247809552, + 356.27486161409246 + ], + "cV": [ + -4.001990439211164e-10, + 1.9669817951712655e-06, + -0.0006597242702549873, + 383.44477922926757 + ], + "rhomolar_max": 3376.736130176733, + "rhomolar_min": 2825.886785898815 + }, "gas_constant": 8.31451, "gas_constant_units": "J/mol/K", "molar_mass": 0.2000312, diff --git a/dev/fluids/Toluene.json b/dev/fluids/Toluene.json index 74c59926..f077e5dd 100644 --- a/dev/fluids/Toluene.json +++ b/dev/fluids/Toluene.json @@ -349,6 +349,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 591.75, + "T_min": 591.7342932852254, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 3.3834089871987155e-09, + -3.464558495481263e-05, + 0.11764944401792847, + 459.1727413679192 + ], + "cV": [ + -2.3379515587297088e-09, + 1.972502928601055e-05, + -0.05458017218397031, + 641.0297738234855 + ], + "rhomolar_max": 3253.6261257770193, + "rhomolar_min": 3086.5243371577894 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.09213842, diff --git a/dev/fluids/Water.json b/dev/fluids/Water.json index f870f223..a744b9c1 100644 --- a/dev/fluids/Water.json +++ b/dev/fluids/Water.json @@ -641,6 +641,25 @@ "type": "ResidualHelmholtzNonAnalytic" } ], + "critical_region_splines": { + "T_max": 647.096, + "T_min": 647.0954167354802, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -2.6319631259532804e-06, + 647.1430429930077 + ], + "cV": [ + 0.0, + 0.0, + 2.6053577217441603e-06, + 647.0494325447503 + ], + "rhomolar_max": 18095.336161027783, + "rhomolar_min": 17649.856810851063 + }, "gas_constant": 8.314371357587, "gas_constant_units": "J/mol/K", "molar_mass": 0.018015268, diff --git a/dev/fluids/Xenon.json b/dev/fluids/Xenon.json index a6148289..0995f78a 100644 --- a/dev/fluids/Xenon.json +++ b/dev/fluids/Xenon.json @@ -350,6 +350,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 289.733, + "T_min": 289.72843171770734, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 2.4311831644858725e-10, + -6.354625581839551e-06, + 0.05529442454906748, + 129.54501621008842 + ], + "cV": [ + -2.2130895526715094e-10, + 5.34493631486394e-06, + -0.04294825043876369, + 404.53030033147684 + ], + "rhomolar_max": 8554.90344650679, + "rhomolar_min": 8248.286253998665 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.131293, diff --git a/dev/fluids/m-Xylene.json b/dev/fluids/m-Xylene.json index cdb51262..98b9b7c7 100644 --- a/dev/fluids/m-Xylene.json +++ b/dev/fluids/m-Xylene.json @@ -384,6 +384,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 616.89, + "T_min": 616.8899937003947, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -2.3188404050194553e-07, + 616.8906179709679 + ], + "cV": [ + 0.0, + 0.0, + 2.1811620743863226e-07, + 616.8894187203072 + ], + "rhomolar_max": 2692.1670497921914, + "rhomolar_min": 2636.1181240342576 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.106165, diff --git a/dev/fluids/n-Butane.json b/dev/fluids/n-Butane.json index afab88b2..0b2c67c0 100644 --- a/dev/fluids/n-Butane.json +++ b/dev/fluids/n-Butane.json @@ -449,6 +449,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 425.125, + "T_min": 425.1219732576174, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -1.6020493306008252e-10, + 1.133822562422527e-06, + -0.0014996904947787396, + 423.23116044183894 + ], + "cV": [ + 5.058796197557434e-11, + -1.3472509771444817e-06, + 0.008234549282093268, + 410.50072741365295 + ], + "rhomolar_max": 3985.810039412961, + "rhomolar_min": 3859.458487995192 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.0581222, diff --git a/dev/fluids/n-Decane.json b/dev/fluids/n-Decane.json index 2e5f6fd2..78fe3abc 100644 --- a/dev/fluids/n-Decane.json +++ b/dev/fluids/n-Decane.json @@ -349,6 +349,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 617.7, + "T_min": 617.6842932852254, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 3.811704985816065e-08, + -0.00019945721156220926, + 0.3466608020285197, + 417.5042285213912 + ], + "cV": [ + -3.8653700756418197e-08, + 0.00017824366286806788, + -0.2727502335438755, + 756.1055367913187 + ], + "rhomolar_max": 1678.7818428517664, + "rhomolar_min": 1601.198950562281 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.14228168, diff --git a/dev/fluids/n-Dodecane.json b/dev/fluids/n-Dodecane.json index 62cbfb64..d1f5bc97 100644 --- a/dev/fluids/n-Dodecane.json +++ b/dev/fluids/n-Dodecane.json @@ -357,6 +357,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 658.1, + "T_min": 658.0986713196614, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + -2.1192739463715689e-07, + 0.0005637268697348361, + 657.7251216316264 + ], + "cV": [ + 1.345410821444352e-08, + -5.389362597299564e-05, + 0.07196012902658075, + 626.0728305909759 + ], + "rhomolar_max": 1409.180220111776, + "rhomolar_min": 1288.4723365719328 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.17033484, diff --git a/dev/fluids/n-Hexane.json b/dev/fluids/n-Hexane.json index a36a27fb..27014dc1 100644 --- a/dev/fluids/n-Hexane.json +++ b/dev/fluids/n-Hexane.json @@ -366,6 +366,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 507.82, + "T_min": 506.8564813947396, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 8.758829336463305e-09, + -8.028744783668493e-05, + 0.24210552253394685, + 267.0302268919283 + ], + "cV": [ + 3.991905207393978e-09, + -3.342318035828356e-05, + 0.09319459234659805, + 421.2768792846532 + ], + "rhomolar_max": 3123.268752501498, + "rhomolar_min": 2157.714974917123 + }, "gas_constant": 8.31451, "gas_constant_units": "J/mol/K", "molar_mass": 0.08617535999999999, diff --git a/dev/fluids/n-Nonane.json b/dev/fluids/n-Nonane.json index 60abaeaf..6a749f91 100644 --- a/dev/fluids/n-Nonane.json +++ b/dev/fluids/n-Nonane.json @@ -348,6 +348,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 594.5500000000001, + "T_min": 594.5262937515283, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 2.6268572567217745e-08, + -0.00015162277736042532, + 0.2906990422823534, + 409.3502826161235 + ], + "cV": [ + -2.3832710380126962e-08, + 0.00012016817674452382, + -0.2007737723861744, + 705.5893640684056 + ], + "rhomolar_max": 1866.189822592916, + "rhomolar_min": 1755.3631417347385 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.1282551, diff --git a/dev/fluids/n-Pentane.json b/dev/fluids/n-Pentane.json index fdfdf0ea..f6909600 100644 --- a/dev/fluids/n-Pentane.json +++ b/dev/fluids/n-Pentane.json @@ -384,6 +384,25 @@ "type": "ResidualHelmholtzPower" } ], + "critical_region_splines": { + "T_max": 469.70000000000005, + "T_min": 469.06161506402384, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -1.5350222378894414e-09, + 1.4495090265584156e-05, + -0.04560406484397615, + 517.5028217560338 + ], + "cV": [ + 1.3419945158856869e-09, + -1.3857242599790237e-05, + 0.047489652270097, + 415.6565744315043 + ], + "rhomolar_max": 3899.8810879232615, + "rhomolar_min": 2607.6316735875685 + }, "gas_constant": 8.31451, "gas_constant_units": "J/mol/K", "molar_mass": 0.07214878, diff --git a/dev/fluids/n-Propane.json b/dev/fluids/n-Propane.json index 4f026bba..a6566873 100644 --- a/dev/fluids/n-Propane.json +++ b/dev/fluids/n-Propane.json @@ -430,6 +430,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 369.89, + "T_min": 369.88310506132734, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + -1.2699463565482216e-10, + 1.6385267569449435e-06, + -0.0068606698953377855, + 379.1045100099181 + ], + "cV": [ + 1.3753113621718563e-10, + -2.32949579930026e-06, + 0.012980122776713688, + 346.03538907178984 + ], + "rhomolar_max": 5155.238965206609, + "rhomolar_min": 4845.222396586998 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.04409562, diff --git a/dev/fluids/p-Xylene.json b/dev/fluids/p-Xylene.json index 2166351e..bf72fa97 100644 --- a/dev/fluids/p-Xylene.json +++ b/dev/fluids/p-Xylene.json @@ -382,6 +382,25 @@ "type": "ResidualHelmholtzGaussian" } ], + "critical_region_splines": { + "T_max": 616.168, + "T_min": 616.1676135546516, + "_note": "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + "cL": [ + 0.0, + 0.0, + -1.1132572209863086e-05, + 616.1979902589276 + ], + "cV": [ + 0.0, + 0.0, + 8.534367674093475e-06, + 616.1450090962354 + ], + "rhomolar_max": 2728.633033173596, + "rhomolar_min": 2648.6389243240715 + }, "gas_constant": 8.314472, "gas_constant_units": "J/mol/K", "molar_mass": 0.106165, diff --git a/dev/scripts/fit_saturation_critical_splines.py b/dev/scripts/fit_saturation_critical_splines.py new file mode 100644 index 00000000..79388d23 --- /dev/null +++ b/dev/scripts/fit_saturation_critical_splines.py @@ -0,0 +1,395 @@ +import CoolProp as CoolProp +import matplotlib.pyplot as plt +import numpy as np, os, json + + + +class LinearFitter(object): + def __init__(self): + self.Nconstraints = 0 + self.A = np.zeros((2,2)) + self.B = np.zeros((2,1)) + + def build(self): + if (self.Nconstraints == 2): + self.a = np.linalg.solve(self.A, self.B).squeeze(); + else: + raise ValueError("Number of constraints[%d] is not equal to 2" % Nconstraints); + + self.c = list(np.r_[0, 0, self.a]) + + def add_value_constraint(self, x, y): + i = self.Nconstraints; + if (i == 2): + return false; + self.A[i,0] = x; + self.A[i,1] = 1; + self.B[i] = y; + self.Nconstraints += 1; + + def add_derivative_constraint(self, x, dydx): + i = self.Nconstraints; + if (i == 2): + return false; + self.A[i,0] = 1; + self.A[i,1] = 0; + self.B[i] = dydx; + self.Nconstraints += 1; + + def evaluate(self, x): + return np.polyval(self.a, x) + +class QuadraticFitter(object): + def __init__(self): + self.Nconstraints = 0 + self.A = np.zeros((3,3)) + self.B = np.zeros((3,1)) + + def build(self): + if (self.Nconstraints == 3): + self.a = np.linalg.solve(self.A, self.B).squeeze(); + else: + raise ValueError("Number of constraints[%d] is not equal to 3" % Nconstraints); + + self.c = list(np.r_[0, self.a]) + + def add_value_constraint(self, x, y): + i = self.Nconstraints; + if (i == 4): + return false; + self.A[i,0] = x*x; + self.A[i,1] = x; + self.A[i,2] = 1; + self.B[i] = y; + self.Nconstraints += 1; + + def add_derivative_constraint(self, x, dydx): + i = self.Nconstraints; + if (i == 4): + return false; + self.A[i,0] = 2*x; + self.A[i,1] = 1; + self.A[i,2] = 0; + self.B[i] = dydx; + self.Nconstraints += 1; + + def add_second_derivative_constraint(self, x, d2ydx2): + i = self.Nconstraints; + if (i == 3): + return false; + self.A[i,0] = 2; + self.A[i,1] = 0; + self.A[i,2] = 0; + self.B[i] = d2ydx2; + self.Nconstraints += 1; + + def evaluate(self, x): + return np.polyval(self.a, x) + +class CubicFitter(object): + def __init__(self): + self.Nconstraints = 0 + self.A = np.zeros((4,4)) + self.B = np.zeros((4,1)) + + def build(self): + if (self.Nconstraints == 4): + self.a = np.linalg.solve(self.A, self.B).squeeze(); + else: + raise ValueError("Number of constraints[%d] is not equal to 4" % Nconstraints); + + self.c = list(self.a) + + def add_value_constraint(self, x, y): + i = self.Nconstraints; + if (i == 4): + return false; + self.A[i,0] = x*x*x; + self.A[i,1] = x*x; + self.A[i,2] = x; + self.A[i,3] = 1; + self.B[i] = y; + self.Nconstraints += 1; + + def add_derivative_constraint(self, x, dydx): + i = self.Nconstraints; + if (i == 4): + return false; + self.A[i,0] = 3*x*x; + self.A[i,1] = 2*x; + self.A[i,2] = 1; + self.A[i,3] = 0; + self.B[i] = dydx; + self.Nconstraints += 1; + + def add_second_derivative_constraint(self, x, d2ydx2): + i = self.Nconstraints; + if (i == 4): + return false; + self.A[i,0] = 6*x; + self.A[i,1] = 2; + self.A[i,2] = 0; + self.A[i,3] = 0; + self.B[i] = d2ydx2; + self.Nconstraints += 1; + + def evaluate(self, x): + return np.polyval(self.a, x) + +class QuarticFitter(object): + def __init__(self): + self.Nconstraints = 0 + self.A = np.zeros((5, 5)) + self.B = np.zeros((5, 1)) + + def build(self): + if (self.Nconstraints == 5): + self.a = np.linalg.solve(self.A, self.B); + else: + raise ValueError("Number of constraints[%d] is not equal to 4" % Nconstraints); + + def add_value_constraint(self, x, y): + i = self.Nconstraints; + if (i == 5): + return false; + self.A[i,0] = x*x*x*x; + self.A[i,1] = x*x*x; + self.A[i,2] = x*x; + self.A[i,3] = x; + self.A[i,4] = 1; + self.B[i] = y; + self.Nconstraints += 1; + + def add_derivative_constraint(self, x, dydx): + i = self.Nconstraints; + if (i == 5): + return false; + self.A[i,0] = 4*x*x*x; + self.A[i,1] = 3*x*x; + self.A[i,2] = 2*x; + self.A[i,3] = 1; + self.A[i,4] = 0; + self.B[i] = dydx; + self.Nconstraints += 1; + + def add_second_derivative_constraint(self, x, d2ydx2): + i = self.Nconstraints; + if (i == 5): + return false; + self.A[i,0] = 12*x*x; + self.A[i,1] = 6*x; + self.A[i,2] = x; + self.A[i,3] = 0; + self.A[i,4] = 0; + self.B[i] = d2ydx2; + self.Nconstraints += 1; + + def evaluate(self, x): + return np.polyval(self.a,x) + +CoolProp.CoolProp.set_debug_level(0) + +if not os.path.exists('sat_spline_json.json'): + + from matplotlib.backends.backend_pdf import PdfPages + sat_crit_spline = PdfPages('sat_crit_spline.pdf') + + V = '' + e = {} + e['Tc'] = [] + e['Tt'] = [] + e['dT'] = [] + + JSON = {} + + for fluid in CoolProp.__fluids__: + perfect = False + cL = None, + cV = None, + if fluid in ['R410A','R404A','R507A','R407C','SES36','Air','R407F']: continue + dT = 3 + plt.close('all') + fig, (ax1, ax2) = plt.subplots(1,2) + pc = CoolProp.CoolProp.PropsSI('pcrit',fluid) + Tc = CoolProp.CoolProp.PropsSI('Tcrit',fluid) + Tt = CoolProp.CoolProp.PropsSI('Ttriple',fluid) + try: + + good_T = Tc-dT + rhomolar_crit = CoolProp.CoolProp.PropsSI('rhomolar_critical',fluid) + ok = False # Start assuming not ok + for i in np.linspace(np.log10(2), 18, 100): + dT = 10**(-i) + bad_T = Tc-dT + + p = CoolProp.CoolProp.PropsSI('P', 'T', Tc - dT, 'Q', 0, fluid) + + # If this run worked, good_T and good_dT are set to the working values + good_dT = 10**(-(i-1)) + good_T = Tc-good_dT + + # Set the flag saying this temperature was OK + ok = True + + good_dT = 10**(-17) + good_T = Tc-good_dT + + except ValueError as V: + pass + + if ok: + + rhomolar_endL = CoolProp.CoolProp.PropsSI('Dmolar', 'T', good_T, 'Q', 0, fluid) + rhomolar_endV = CoolProp.CoolProp.PropsSI('Dmolar', 'T', good_T, 'Q', 1, fluid) + + if good_dT > 1e-3: + # Cubic or quadratic fit + DELTAT = 1e-5 + + dT_drhoL = DELTAT/(rhomolar_endL - CoolProp.CoolProp.PropsSI('Dmolar', 'T', good_T - DELTAT, 'Q', 0, fluid)) + dT_drhoV = DELTAT/(rhomolar_endV - CoolProp.CoolProp.PropsSI('Dmolar', 'T', good_T - DELTAT, 'Q', 1, fluid)) + + CFL = CubicFitter() + CFL.add_value_constraint(rhomolar_crit, Tc) + CFL.add_derivative_constraint(rhomolar_crit, 0) + CFL.add_value_constraint(rhomolar_endL, good_T) + CFL.add_derivative_constraint(rhomolar_endL, dT_drhoL) + CFL.build() + + zeros = np.roots(np.polyder(CFL.a)) + print zeros + monotonic_liq = not np.any(np.logical_and(zeros > 1.000000001*rhomolar_crit, zeros < 0.999999999*rhomolar_endL)) + + if not monotonic_liq: + + CFL = QuadraticFitter() + CFL.add_value_constraint(rhomolar_crit, Tc) + CFL.add_derivative_constraint(rhomolar_crit, 0) + CFL.add_value_constraint(rhomolar_endL, good_T) + ##CFL.add_second_derivative_constraint(rhomolar_endL, dT_drhoL) + CFL.build() + + CFV = CubicFitter() + CFV.add_value_constraint(rhomolar_crit, Tc) + CFV.add_derivative_constraint(rhomolar_crit, 0) + CFV.add_value_constraint(rhomolar_endV, good_T) + CFV.add_derivative_constraint(rhomolar_endV, dT_drhoV) + CFV.build() + + zeros = np.roots(np.polyder(CFV.a)) + print zeros, rhomolar_crit, rhomolar_endV + monotonic_vap = not np.any(np.logical_and(zeros < 0.999999999*rhomolar_crit, zeros > 1.000000001*rhomolar_endV)) + + if not monotonic_vap: + + CFV = QuadraticFitter() + CFV.add_value_constraint(rhomolar_crit, Tc) + CFV.add_derivative_constraint(rhomolar_crit, 0) + CFV.add_value_constraint(rhomolar_endV, good_T) + ##CFV.add_second_derivative_constraint(rhomolar_endV, dT_drhoV) + CFV.build() + + # Plot the cubic part on small axis + ax1.plot(np.linspace(rhomolar_endL, rhomolar_crit), CFL.evaluate(np.linspace(rhomolar_endL, rhomolar_crit)),'r') + ax1.plot(np.linspace(rhomolar_endV, rhomolar_crit), CFV.evaluate(np.linspace(rhomolar_endV, rhomolar_crit)),'r') + # Plot the cubic part on big ais + ax2.plot(np.linspace(rhomolar_endL, rhomolar_crit), CFL.evaluate(np.linspace(rhomolar_endL, rhomolar_crit)),'r') + ax2.plot(np.linspace(rhomolar_endV, rhomolar_crit), CFV.evaluate(np.linspace(rhomolar_endV, rhomolar_crit)),'r') + + # Evaluated from EOS + TsL = np.linspace(good_T, good_T-good_dT, 100) + ax1.plot(CoolProp.CoolProp.PropsSI('Dmolar', 'T', TsL, 'Q', [0]*len(TsL), fluid), TsL,'g') + ax1.plot(CoolProp.CoolProp.PropsSI('Dmolar', 'T', TsL, 'Q', [1]*len(TsL), fluid), TsL,'g') + + ax1.plot(rhomolar_endL, good_T, 'o') + ax1.plot(rhomolar_endV, good_T, 'o') + ax1.text(rhomolar_crit, good_T, '{T:0.2f} K'.format(T=good_T), va='top',ha='center') + + print fluid, ':::', dT, good_T, bad_T, CoolProp.CoolProp.PropsSI('P', 'T', good_T, 'Q', 0, fluid) + + cL = CFL.c + cV = CFV.c + + elif dT < 1e-3 and dT > 1e-15: + # Linear fit + LFV = LinearFitter() + LFV.add_value_constraint(rhomolar_crit, Tc) + LFV.add_value_constraint(rhomolar_endV, good_T) + LFV.build() + + LFL = LinearFitter() + LFL.add_value_constraint(rhomolar_crit, Tc) + LFL.add_value_constraint(rhomolar_endL, good_T) + LFL.build() + + ax1.plot(np.linspace(rhomolar_endL, rhomolar_crit), LFL.evaluate(np.linspace(rhomolar_endL, rhomolar_crit)),'r') + ax1.plot(np.linspace(rhomolar_endV, rhomolar_crit), LFV.evaluate(np.linspace(rhomolar_endV, rhomolar_crit)),'r') + + e['Tc'].append(Tc) + e['Tt'].append(Tt) + e['dT'].append(dT) + + cL = LFL.c + cV = LFV.c + else: + # Evaluated from EOS + TsL = np.linspace(0.999*Tc, Tc-1e-15, 100) + ax1.plot(CoolProp.CoolProp.PropsSI('Dmolar', 'T', TsL, 'Q', [0]*len(TsL), fluid), TsL,'g') + ax1.plot(CoolProp.CoolProp.PropsSI('Dmolar', 'T', TsL, 'Q', [1]*len(TsL), fluid), TsL,'g') + ax1.text(rhomolar_crit, Tc, 'PERFECT', ha='center', va='bottom') + perfect = True + + ax1.plot(rhomolar_crit, Tc, 'o') + ax2.plot(rhomolar_crit, Tc, 'o', ms = 2) + + TsL = np.linspace(Tt+1, good_T, 1000) + ax2.plot(CoolProp.CoolProp.PropsSI('Dmolar', 'T', TsL, 'Q', [0]*len(TsL), fluid), TsL,'g') + ax2.plot(CoolProp.CoolProp.PropsSI('Dmolar', 'T', TsL, 'Q', [1]*len(TsL), fluid), TsL,'g') + + plt.title(fluid) + plt.xlabel(r'$\rho$ [mol/m$^3$]') + plt.ylabel(r'T [K]') + sat_crit_spline.savefig() + plt.close() + + if not perfect: + JSON[fluid] = dict(cL = cL, + cV = cV, + _note = "Coefficients for the critical cubic spline. T = c[0]*rho^3 + c[1]*rho^2 + c[2]*rho + c[3] with rho in mol/m^3 and T in K", + T_min = good_T, + T_max = Tc, + rhomolar_min = rhomolar_endV, + rhomolar_max = rhomolar_endL + ) + + else: + print fluid, 'FAIL', V + + sat_crit_spline.close() + + plt.semilogy(np.array(e['Tc'])/np.array(e['Tt']), e['dT'],'o',mfc='none') + plt.close() + + fp = open('sat_spline_json.json','w') + json.dump(JSON, fp) + fp.close() + +else: + # Load the generated JSON file + jj = json.load(open('sat_spline_json.json','r')) + + # Iterate over the list of fluids and inject into the fluid JSON files + for fluid, v in jj.iteritems(): + fp = open(os.path.join('..', 'fluids', fluid + '.json'),'r') + fluid_json = json.load(fp) + if 'critical_region_spline' in fluid_json['EOS'][0]: + del fluid_json['EOS'][0]['critical_region_spline'] + fluid_json['EOS'][0]['critical_region_splines'] = v + fp.close() + fp = open(os.path.join('..', 'fluids', fluid + '.json'),'w') + json.dump(fluid_json, fp) + fp.close() + + + + diff --git a/include/CoolPropFluid.h b/include/CoolPropFluid.h index 1a02f53a..0a4f5d6d 100644 --- a/include/CoolPropFluid.h +++ b/include/CoolPropFluid.h @@ -40,6 +40,37 @@ struct EnvironmentalFactorsStruct double GWP20, GWP100, GWP500, ODP, HH, PH, FH; std::string ASHRAE34; }; +struct CriticalRegionSplines{ + double T_min, T_max, rhomolar_min, rhomolar_max; + std::vector cL, cV; + bool enabled; + CriticalRegionSplines(){enabled = false;}; + void get_densities(double T, double rho_min, double rho_crit, double rho_max, double &rhoL, double &rhoV){ + bool ok1 = false, ok2 = false, ok3 = false; + int Nsoln = -1, Ngood = 0; + double rho1, rho2, rho3; + + // ----------- + // Liquid part + // ----------- + Ngood = 0; + solve_cubic(cL[0], cL[1], cL[2], cL[3]-T, Nsoln, rho1, rho2, rho3); + if (rho1 < rho_max && rho1 > rho_crit){ ok1 = true; Ngood++; rhoL = rho1; } + if (rho2 < rho_max && rho2 > rho_crit){ ok2 = true; Ngood++; rhoL = rho2; } + if (rho3 < rho_max && rho3 > rho_crit){ ok3 = true; Ngood++; rhoL = rho3; } + if (Ngood != 1){ throw ValueError(format("more than one liquid solution found for critical spline for T=%g",T));}; + + // ---------- + // Vapor part + // ---------- + Ngood = 0; + solve_cubic(cV[0], cV[1], cV[2], cV[3]-T, Nsoln, rho1, rho2, rho3); + if (rho1 > rho_min && rho1 < rho_crit){ ok1 = true; Ngood++; rhoV = rho1; } + if (rho2 > rho_min && rho2 < rho_crit){ ok2 = true; Ngood++; rhoV = rho2; } + if (rho3 > rho_min && rho3 < rho_crit){ ok3 = true; Ngood++; rhoV = rho3; } + if (Ngood != 1){ throw ValueError(format("more than one vapor solution found for critical spline for T=%g",T));}; + }; +}; /// A set of limits for the eos parameters struct EOSLimits @@ -296,6 +327,7 @@ public: IdealHelmholtzContainer alpha0; ///< The ideal Helmholtz energy std::string BibTeX_EOS, ///< The bibtex key for the equation of state BibTeX_CP0; ///< The bibtex key for the ideal gas specific heat correlation + CriticalRegionSplines critical_region_splines; ///< A cubic spline in the form T = f(rho) for saturated liquid and saturated vapor curves in the near-critical region /// Validate the EOS that was just constructed void validate() diff --git a/include/CoolPropTools.h b/include/CoolPropTools.h index bbae44f8..055e2407 100644 --- a/include/CoolPropTools.h +++ b/include/CoolPropTools.h @@ -192,6 +192,11 @@ return (x >= std::min(x1,x2) && x <= std::max(x1,x2)); }; + /** + * Solve a cubic with coefficients in decreasing order + * + * 0 = ax^3 + b*x^2 + c*x + d + */ void solve_cubic(double a, double b, double c, double d, int &N, double &x0, double &x1, double &x2); inline double min3(double x1, double x2, double x3){return std::min(std::min(x1, x2), x3);}; diff --git a/include/Helmholtz.h b/include/Helmholtz.h index ac3c78f2..a09b0c4d 100644 --- a/include/Helmholtz.h +++ b/include/Helmholtz.h @@ -311,7 +311,7 @@ public: long double dTau3(const long double &tau, const long double &delta) throw(){return 0;}; void all(const long double &tau, const long double &delta, HelmholtzDerivatives &derivs) throw(); - void allEigen(const long double &tau, const long double &delta, HelmholtzDerivatives &derivs) throw(); + //void allEigen(const long double &tau, const long double &delta, HelmholtzDerivatives &derivs) throw(); }; struct ResidualHelmholtzNonAnalyticElement diff --git a/src/Backends/Helmholtz/FlashRoutines.cpp b/src/Backends/Helmholtz/FlashRoutines.cpp index 89db0818..f3758b48 100644 --- a/src/Backends/Helmholtz/FlashRoutines.cpp +++ b/src/Backends/Helmholtz/FlashRoutines.cpp @@ -37,12 +37,33 @@ void FlashRoutines::QT_flash(HelmholtzEOSMixtureBackend &HEOS) HEOS.calc_Tmin_sat(Tmin_satL, Tmin_satV); Tmin_sat = std::max(Tmin_satL, Tmin_satV); + // Get a reference to keep the code a bit cleaner + CriticalRegionSplines &splines = HEOS.components[0]->pEOS->critical_region_splines; + // Check limits if (!is_in_closed_range(Tmin_sat, Tmax_sat, static_cast(HEOS._T))){ throw ValueError(format("Temperature to QT_flash [%6g K] must be in range [%8g K, %8g K]",HEOS._T, Tmin_sat, Tmax_sat)); } - if (!(HEOS.components[0]->pEOS->pseudo_pure)) + //splines.enabled = false; + + // If exactly at the critical temperature, liquid and vapor have the critial density + if (std::abs(T-HEOS.T_critical())< 1e-14){ + HEOS.SatL->update(DmolarT_INPUTS, HEOS.rhomolar_critical(), HEOS._T); + HEOS.SatV->update(DmolarT_INPUTS, HEOS.rhomolar_critical(), HEOS._T); + HEOS._rhomolar = HEOS.rhomolar_critical(); + HEOS._p = HEOS.SatL->p(); + } + else if (splines.enabled && HEOS._T > splines.T_min){ + double rhoL, rhoV; + // Use critical region spline if it has it and temperature is in its range + splines.get_densities(T, splines.rhomolar_min, HEOS.rhomolar_critical(), splines.rhomolar_max, rhoL, rhoV); + HEOS.SatL->update(DmolarT_INPUTS, rhoL, HEOS._T); + HEOS.SatV->update(DmolarT_INPUTS, rhoV, HEOS._T); + HEOS._p = HEOS._Q*HEOS.SatV->p() + (1- HEOS._Q)*HEOS.SatL->p(); + HEOS._rhomolar = 1/(HEOS._Q/HEOS.SatV->rhomolar() + (1 - HEOS._Q)/HEOS.SatL->rhomolar()); + } + else if (!(HEOS.components[0]->pEOS->pseudo_pure)) { // Set some imput options SaturationSolvers::saturation_T_pure_options options; @@ -73,11 +94,11 @@ void FlashRoutines::QT_flash(HelmholtzEOSMixtureBackend &HEOS) SaturationSolvers::saturation_T_pure_1D_P(&HEOS, T, options); } catch(std::exception &){ - SaturationSolvers::saturation_critical(&HEOS, iT, T); + throw; + //SaturationSolvers::saturation_critical(&HEOS, iT, T); } } - // Load the outputs - HEOS._phase = iphase_twophase; + HEOS._p = HEOS._Q*HEOS.SatV->p() + (1- HEOS._Q)*HEOS.SatL->p(); HEOS._rhomolar = 1/(HEOS._Q/HEOS.SatV->rhomolar() + (1 - HEOS._Q)/HEOS.SatL->rhomolar()); } @@ -108,12 +129,13 @@ void FlashRoutines::QT_flash(HelmholtzEOSMixtureBackend &HEOS) rhoLsat = rhoLanc; rhoVsat = rhoVanc; } - HEOS._phase = iphase_twophase; HEOS._p = HEOS._Q*psatVanc + (1-HEOS._Q)*psatLanc; HEOS._rhomolar = 1/(HEOS._Q/rhoVsat + (1-HEOS._Q)/rhoLsat); HEOS.SatL->update(DmolarT_INPUTS, rhoLsat, HEOS._T); HEOS.SatV->update(DmolarT_INPUTS, rhoVsat, HEOS._T); } + // Load the outputs + HEOS._phase = iphase_twophase; } else { @@ -221,7 +243,7 @@ void FlashRoutines::PQ_flash(HelmholtzEOSMixtureBackend &HEOS) double Tc = HEOS.components[0]->pEOS->reduce.T; double Tt = HEOS.components[0]->pEOS->Ttriple; double pt = HEOS.components[0]->pEOS->ptriple; - double Tsat_guess = 1/(1/Tc-(1/Tt-1/Tc)/log(pc/pt)*log(HEOS._p/pc)); + //double Tsat_guess = 1/(1/Tc-(1/Tt-1/Tc)/log(pc/pt)*log(HEOS._p/pc)); // Set some imput options SaturationSolvers::mixture_VLE_IO io; diff --git a/src/Backends/Helmholtz/Fluids/FluidLibrary.h b/src/Backends/Helmholtz/Fluids/FluidLibrary.h index 5dca7b6c..adf457f0 100644 --- a/src/Backends/Helmholtz/Fluids/FluidLibrary.h +++ b/src/Backends/Helmholtz/Fluids/FluidLibrary.h @@ -352,6 +352,16 @@ protected: EOS.max_sat_p.rhomolar = cpjson::get_double(s, "rhomolar"); } + if (EOS_json.HasMember("critical_region_splines")){ + rapidjson::Value &spline = EOS_json["critical_region_splines"]; + EOS.critical_region_splines.T_min = cpjson::get_double(spline, "T_min"); + EOS.critical_region_splines.T_max = cpjson::get_double(spline, "T_max"); + EOS.critical_region_splines.rhomolar_min = cpjson::get_double(spline, "rhomolar_min"); + EOS.critical_region_splines.rhomolar_max = cpjson::get_double(spline, "rhomolar_max"); + EOS.critical_region_splines.cL = cpjson::get_double_array(spline["cL"]); + EOS.critical_region_splines.cV = cpjson::get_double_array(spline["cV"]); + EOS.critical_region_splines.enabled = true; + } // Validate the equation of state that was just created EOS.validate();