This commit is contained in:
Ian Bell
2014-12-02 18:13:31 +01:00
4 changed files with 113 additions and 89 deletions

View File

@@ -6,8 +6,8 @@ FORTRAN Wrapper
For FORTRAN, there are two fundamental choices. Choose one option:
* [Recommended] For FORTRAN 95 and newer, compile a static library of CoolProp and link it with FORTRAN code following the instructions here: :ref:`F95 and newer <FORTRAN95>`
* For FORTRAN 77 and newer, call a shared library of CoolProp using the instructions here: :ref:`F77 and newer <FORTRAN77>`
* For FORTRAN 95 and newer, compile a static library of CoolProp and link it with FORTRAN code following the instructions here: :ref:`F95 and newer <FORTRAN95>`
Common Requirements
===================
@@ -40,7 +40,7 @@ The most reliable mixed compilation on linux seems to be with the true-gcc/g++ t
brew install gcc-4.9
where you can change ``4.9`` to the most up to date version. Search `http://braumeister.org/formula/gcc`_ for the most recipe for gcc. Looks like ``gcc`` also works.
where you can change ``4.9`` to the most up to date version. Search `braumeister <http://braumeister.org/formula/gcc>`_ for the most recipe for gcc. Looks like ``gcc`` also works.
.. _FORTRAN95:
@@ -191,5 +191,3 @@ On windows, the current folder is always searched for DLL, so you can just do::
gfortran -g -o example example.for -L. -lCoolProp
example
On OSX

View File

@@ -46,16 +46,28 @@ The red curve is the maximum temperature curve, and the blue curve is the meltin
"""
table_template = """ Parameter, Value
**General**,
Molar mass [kg/mol],{mm:s}
CAS, {CAS:s}
ASHRAE, {ASHRAE:s}
CAS number, {CAS:s}
ASHRAE class, {ASHRAE:s}
**Limits**,
Maximum temperature [K],{Tmax:s}
Maximum pressure [Pa],{pmax:s}
**Triple point**,
Triple point temperature [K],{Tt:s}
Triple point pressure [Pa], {pt:s}
**Critical point**,
Critical point temperature [K], {Tc:s}
Critical point pressure [Pa], {pc:s}
Critical point density [kg/m3], {rhoc_mass:s}
Critical point density [mol/m3], {rhoc_molar:s}
{reducing_string:s}
"""
reducing_template = """**Reducing point**,
Reducing point temperature [K], {Tr:s}
Reducing point density [mol/m3], {rhor_molar:s}
"""
class FluidInfoTableGenerator(object):
def __init__(self, name):
@@ -74,12 +86,23 @@ class FluidInfoTableGenerator(object):
molar_mass = CoolProp.CoolProp.PropsSI(self.name,'molemass')
Tt = CoolProp.CoolProp.PropsSI(self.name,'Ttriple')
Tc = CoolProp.CoolProp.PropsSI(self.name,'Tcrit')
Tr = CoolProp.CoolProp.PropsSI(self.name,'T_reducing')
pc = CoolProp.CoolProp.PropsSI(self.name,'pcrit')
pt = CoolProp.CoolProp.PropsSI(self.name,'ptriple')
Tmax = CoolProp.CoolProp.PropsSI(self.name,'Tmax')
pmax = CoolProp.CoolProp.PropsSI(self.name,'pmax')
rhoc_mass = CoolProp.CoolProp.PropsSI(self.name,'rhomass_critical')
rhoc_molar = CoolProp.CoolProp.PropsSI(self.name,'rhomolar_critical')
rhor_molar = CoolProp.CoolProp.PropsSI(self.name,'rhomolar_reducing')
CAS = CoolProp.CoolProp.get_fluid_param_string(self.name, "CAS")
ASHRAE = CoolProp.CoolProp.get_fluid_param_string(self.name, "ASHRAE34")
# Generate (or not) the reducing data
reducing_data = ''
if abs(Tr - Tc) > 1e-3:
reducing_data = reducing_template.format(Tr = tos(Tr),
rhor_molar = tos(rhor_molar))
args = dict(mm = tos(molar_mass),
Tt = tos(Tt),
@@ -89,7 +112,10 @@ class FluidInfoTableGenerator(object):
rhoc_molar = tos(rhoc_molar),
pc = tos(pc),
CAS = tos(CAS),
ASHRAE = tos(ASHRAE))
ASHRAE = tos(ASHRAE),
Tmax = tos(Tmax),
pmax = tos(pmax),
reducing_string = reducing_data)
out = table_template.format(**args)
with open(os.path.join(path, self.name+'-info.csv'),'w') as fp:

View File

@@ -45,74 +45,12 @@
"max_abs_error_units": "J/mol",
"type": "rational_polynomial"
},
"pV": {
"Tmin": 200.0,
"description": "p'' = pc*exp(Tc/T*sum(n_i*theta^t_i))",
"Tmax": 450.69000000000005,
"using_tau_r": true,
"max_abserror_percentage": 0.010851665467770388,
"t": [
0.383,
1.0,
1.1666666666666667,
3.0,
4.333333333333333,
18.5
],
"reducing_value": 2849000.0,
"T_r": 450.70000000000005,
"n": [
0.0074229398001144425,
-8.947924311081916,
2.4455850233209473,
-6.449704516156368,
13.607518741300712,
-27.19167556046972
],
"type": "pV"
},
"rhoV": {
"Tmin": 200.0,
"description": "rho'' = rhoc*exp(Tc/T*sum(n_i*theta^t_i))",
"Tmax": 450.69000000000005,
"using_tau_r": true,
"max_abserror_percentage": 0.022432295783458844,
"t": [
0.08,
0.124,
0.3685,
1.1666666666666667,
1.5,
5.5
],
"reducing_value": 2800.0,
"T_r": 450.70000000000005,
"n": [
-4.086903656826663,
6.180725737220783,
-6.241598036559721,
1.036017562604198,
-4.093270917666299,
9.117098066697686
],
"type": "rhoV"
},
"pL": {
"T_r": 450.70000000000005,
"Tmax": 450.69000000000005,
"Tmin": 200.0,
"description": "p' = pc*exp(Tc/T*sum(n_i*theta^t_i))",
"Tmax": 450.69000000000005,
"using_tau_r": true,
"max_abserror_percentage": 0.022411189649551577,
"t": [
0.359,
0.375,
0.3765,
0.8333333333333334,
2.5,
4.5
],
"reducing_value": 2849000.0,
"T_r": 450.70000000000005,
"n": [
94.87532704021716,
-1299.2634694546925,
@@ -121,24 +59,50 @@
-4.414966788345308,
11.055551606406958
],
"type": "pL"
"reducing_value": 2849000.0,
"t": [
0.359,
0.375,
0.3765,
0.8333333333333334,
2.5,
4.5
],
"type": "pL",
"using_tau_r": true
},
"pV": {
"T_r": 450.70000000000005,
"Tmax": 450.69000000000005,
"Tmin": 200.0,
"description": "p'' = pc*exp(Tc/T*sum(n_i*theta^t_i))",
"max_abserror_percentage": 0.010851665467770388,
"n": [
0.0074229398001144425,
-8.947924311081916,
2.4455850233209473,
-6.449704516156368,
13.607518741300712,
-27.19167556046972
],
"reducing_value": 2849000.0,
"t": [
0.383,
1.0,
1.1666666666666667,
3.0,
4.333333333333333,
18.5
],
"type": "pV",
"using_tau_r": true
},
"rhoL": {
"T_r": 450.70000000000005,
"Tmax": 450.69000000000005,
"Tmin": 200.0,
"description": "rho' = rhoc*(1+sum(n_i*theta^t_i))",
"Tmax": 450.69000000000005,
"using_tau_r": false,
"max_abserror_percentage": 0.017899439685187257,
"t": [
0.059000000000000004,
0.062,
0.083,
0.3605,
1.5,
2.0
],
"reducing_value": 2800.0,
"T_r": 450.70000000000005,
"n": [
-241.2370611920301,
279.06782469843284,
@@ -147,7 +111,43 @@
1.2945715078736757,
-0.7959298395742012
],
"type": "rhoLnoexp"
"reducing_value": 2800.0,
"t": [
0.059000000000000004,
0.062,
0.083,
0.3605,
1.5,
2.0
],
"type": "rhoLnoexp",
"using_tau_r": false
},
"rhoV": {
"T_r": 450.70000000000005,
"Tmax": 450.69000000000005,
"Tmin": 200.0,
"description": "rho'' = rhoc*exp(Tc/T*sum(n_i*theta^t_i))",
"max_abserror_percentage": 0.022432295783458844,
"n": [
-4.086903656826663,
6.180725737220783,
-6.241598036559721,
1.036017562604198,
-4.093270917666299,
9.117098066697686
],
"reducing_value": 2800.0,
"t": [
0.08,
0.124,
0.3685,
1.1666666666666667,
1.5,
5.5
],
"type": "rhoV",
"using_tau_r": true
},
"sL": {
"A": [

View File

@@ -1368,14 +1368,14 @@ void HelmholtzEOSMixtureBackend::T_phase_determination_pure_or_pseudopure(int ot
if (other == iP)
{
if (value > HEOS.SatL->p()*(1e-6 + 1)){
if (value > HEOS.SatL->p()*(1e-10 + 1)){
this->_phase = iphase_liquid; _Q = -1000; return;
}
else if (value < HEOS.SatV->p()*(1 - 1e-6)){
else if (value < HEOS.SatV->p()*(1 - 1e-10)){
this->_phase = iphase_gas; _Q = 1000; return;
}
else{
throw ValueError(format("Saturation pressure [%g Pa] corresponding to T [%g K] is within 1e-4 %% of given p [%Lg Pa]", HEOS.SatL->p(), _T, value));
throw ValueError(format("Saturation pressure [%g Pa] corresponding to T [%g K] is within 1e-8 %% of given p [%Lg Pa]", HEOS.SatL->p(), _T, value));
}
}