mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Added necessary functions to Python in order to generate parameter table
Built table in RST using python script Web/coolprop/build_parametric_table.py for High-Level API Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
@@ -11,4 +11,7 @@ Code
|
||||
|
||||
Output
|
||||
------
|
||||
.. literalinclude:: snippets/propssi.cxx.output
|
||||
.. literalinclude:: snippets/propssi.cxx.output
|
||||
|
||||
|
||||
.. include:: parameter_table.rst.in
|
||||
49
Web/coolprop/build_parametric_table.py
Normal file
49
Web/coolprop/build_parametric_table.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import CoolProp5
|
||||
import pandas
|
||||
grouping = dict()
|
||||
grouping2 = []
|
||||
# Group aliases
|
||||
for parameter in CoolProp5.get('parameter_list').split(','):
|
||||
|
||||
index = CoolProp5.CoolProp.get_parameter_index(parameter)
|
||||
units = CoolProp5.CoolProp.get_parameter_information(index, 'units').replace('-',' ')
|
||||
IO = CoolProp5.CoolProp.get_parameter_information(index, 'IO')
|
||||
long = CoolProp5.CoolProp.get_parameter_information(index, 'long')
|
||||
short = CoolProp5.CoolProp.get_parameter_information(index, 'short')
|
||||
|
||||
RHS = (units, IO, long)
|
||||
if RHS not in grouping:
|
||||
grouping[RHS] = [parameter]
|
||||
else:
|
||||
grouping[RHS].append(parameter)
|
||||
|
||||
for k, v in grouping.iteritems():
|
||||
grouping2.append([', '.join(['``'+_+'``' for _ in v])] + list(k))
|
||||
|
||||
headers = ['Parameter','Units','Input/Output','Description']
|
||||
|
||||
df3 = pandas.DataFrame(grouping2, columns = headers)
|
||||
df4 = df3.sort_index(by = ['Input/Output', 'Parameter'])
|
||||
grouping2 = [row for row in df4.values]
|
||||
|
||||
N = []
|
||||
for i in range(len(grouping2[0])):
|
||||
N.append(max([len(el[i]) for el in grouping2]))
|
||||
|
||||
for i in range(len(N)):
|
||||
if N[i] < len(headers[i]):
|
||||
N[i] = len(headers[i])
|
||||
|
||||
top_line = '='*N[0] + ' ' + '='*N[1] + ' ' + '='*N[2] + ' ' + '='*N[3]
|
||||
header = ' '.join([h.ljust(n) for h,n in zip(headers,N)])
|
||||
|
||||
fp = open('parameter_table.rst.in', 'w')
|
||||
fp.write('.. constructed with the build_parameter_table.py script in this folder \n\n')
|
||||
fp.write(top_line + '\n')
|
||||
fp.write(header + '\n')
|
||||
fp.write(top_line + '\n')
|
||||
for line in grouping2:
|
||||
fp.write(' '.join([h.ljust(n) for h,n in zip(line,N)]) + '\n')
|
||||
fp.write(top_line + '\n')
|
||||
fp.close()
|
||||
|
||||
48
Web/coolprop/parameter_table.rst.in
Normal file
48
Web/coolprop/parameter_table.rst.in
Normal file
@@ -0,0 +1,48 @@
|
||||
.. constructed with the build_parameter_table.py script in this folder
|
||||
|
||||
================================= ======= ============ =========================================================
|
||||
Parameter Units Input/Output Description
|
||||
================================= ======= ============ =========================================================
|
||||
``D``, ``Dmass`` kg/m^3 IO Mass density
|
||||
``Delta`` IO Reduced density (rho/rhoc)
|
||||
``Dmolar`` mol/m^3 IO Molar density
|
||||
``H``, ``Hmass`` J/kg IO Mass specific enthalpy
|
||||
``Hmolar`` J/mol IO Molar specific enthalpy
|
||||
``P`` Pa IO Pressure
|
||||
``Q`` mol/mol IO Mass vapor quality
|
||||
``S``, ``Smass`` J/kg/K IO Mass specific entropy
|
||||
``Smolar`` J/mol/K IO Molar specific entropy
|
||||
``T`` K IO Temperature
|
||||
``Tau`` IO Reciprocal reduced temperature (Tc/T)
|
||||
``U``, ``Umass`` J/kg IO Mass specific internal energy
|
||||
``Umolar`` J/mol IO Molar specific internal energy
|
||||
``Bvirial`` O Second virial coefficient
|
||||
``C``, ``Cpmass`` J/kg/K O Mass specific constant presssure specific heat
|
||||
``Cpmolar`` J/mol/K O Molar specific constant presssure specific heat
|
||||
``Cvirial`` O Third virial coefficient
|
||||
``Cvmass``, ``O`` J/kg/K O Mass specific constant volume specific heat
|
||||
``Cvmolar`` J/mol/K O Molar specific constant volume specific heat
|
||||
``FH`` O Flammability hazard
|
||||
``GWP100`` O 100-year gobal warming potential
|
||||
``GWP20`` O 20-year gobal warming potential
|
||||
``GWP500`` O 500-year gobal warming potential
|
||||
``HH`` O Health hazard
|
||||
``L``, ``conductivity`` W/m/K O Thermal conductivity
|
||||
``ODP`` O Ozone depletion potential
|
||||
``PH`` O Physical hazard
|
||||
``T_critical``, ``Tcrit`` K O Temperature at the critical point
|
||||
``T_max`` K O Maximum temperature limit
|
||||
``T_min`` K O Minimum temperature limit
|
||||
``T_reducing`` K O Temperature at the reducing point
|
||||
``T_triple``, ``Ttriple`` K O Temperature at the triple point
|
||||
``V``, ``viscosity`` Pa s O Viscosity
|
||||
``dBvirial_dT`` O Derivative of second virial coefficient with respect to T
|
||||
``dCvirial_dT`` O Derivative of third virial coefficient with respect to T
|
||||
``isothermal_compressibility`` 1/Pa O Isothermal compressibility
|
||||
``molar_mass`` kg/mol O Molar mass
|
||||
``p_critical``, ``pcrit`` Pa O Pressure at the critical point
|
||||
``rhocrit``, ``rhomass_critical`` kg/m^3 O Mass density at critical point
|
||||
``rhomolar_critical`` mol/m^3 O Molar density at critical point
|
||||
``rhomolar_reducing`` mol/m^3 O Molar density at reducing point
|
||||
``speed_of_sound`` m/s O Speed of sound
|
||||
================================= ======= ============ =========================================================
|
||||
@@ -58,7 +58,8 @@ struct element
|
||||
|
||||
int main()
|
||||
{
|
||||
#if 0
|
||||
#if 1
|
||||
std::cout << get_global_param_string("parameter_list") << std::endl;
|
||||
double T = PropsSI("P","T",5.9020000000000005e+02,"Q",0.0000000000000000e+00,"AceticAcid");
|
||||
std::cout << get_global_param_string("errstring");
|
||||
double Tc = Props1SI("Water","T_triple");
|
||||
|
||||
@@ -15,19 +15,18 @@ include "AbstractState.pxd"
|
||||
ctypedef fused string_like:
|
||||
cython.bytes
|
||||
cython.unicode
|
||||
|
||||
# cdef extern from "CoolPropDLL.h":
|
||||
# int _set_reference_stateS "set_reference_stateS"(char *, char *)
|
||||
# int _set_reference_stateD "set_reference_stateD"(char *, double T, double rho, double h0, double s0)
|
||||
# int _get_standard_unit_system "get_standard_unit_system"()
|
||||
|
||||
cdef extern from "CoolPropTools.h" namespace "CoolProp":
|
||||
bint _ValidNumber "ValidNumber"(double)
|
||||
|
||||
cdef extern from "DataStructures.h" namespace "CoolProp":
|
||||
string _get_parameter_information "CoolProp::get_parameter_information"(int, string) except +
|
||||
int _get_parameter_index "CoolProp::get_parameter_index"(string) except +
|
||||
|
||||
cdef extern from "CoolProp.h" namespace "CoolProp":
|
||||
double _PropsSI "CoolProp::PropsSI"(string Output, string Name1, double Prop1, string Name2, double Prop2, string FluidName)
|
||||
vector[double] _PropsSI "CoolProp::PropsSI"(string Output, string Name1, vector[double] Prop1, string Name2, vector[double] Prop2, string FluidName, vector[double] fractions)
|
||||
string _get_global_param_string "CoolProp::get_global_param_string"(string ParamName)
|
||||
string _get_global_param_string "CoolProp::get_global_param_string"(string ParamName) except +
|
||||
|
||||
# double _Props1SI "CoolProp::Props1SI"(string Ref, string Output)
|
||||
|
||||
@@ -39,10 +38,9 @@ cdef extern from "CoolProp.h" namespace "CoolProp":
|
||||
# string _get_fluid_param_string "CoolProp::get_fluid_param_string"(string ParamName, string FluidName)
|
||||
|
||||
# long _get_Fluid_index "CoolProp::get_Fluid_index" (string Fluid)
|
||||
long _get_parameter_index "CoolProp::get_parameter_index" (string param)
|
||||
#long _get_parameter_index "CoolProp::get_parameter_index" (string param)
|
||||
int _get_debug_level "CoolProp::get_debug_level"()
|
||||
void _set_debug_level "CoolProp::set_debug_level"(int level)
|
||||
#
|
||||
# string _get_BibTeXKey "CoolProp::get_BibTeXKey"(string Ref, string key)
|
||||
|
||||
# Convenience functions
|
||||
|
||||
@@ -111,6 +111,12 @@ include "AbstractState.pyx"
|
||||
# else:
|
||||
# return val
|
||||
|
||||
cpdef int get_parameter_index(string key):
|
||||
return _get_parameter_index(key)
|
||||
|
||||
cpdef string get_parameter_information(int key, string info):
|
||||
return _get_parameter_information(key, info)
|
||||
|
||||
cpdef get_global_param_string(string param):
|
||||
return _get_global_param_string(param)
|
||||
|
||||
@@ -145,7 +151,7 @@ cpdef PropsSI(in1, in2, in3, in4, in5, in6, in7 = None):
|
||||
cdef double val
|
||||
if in7 is None:
|
||||
val = _PropsSI(in1, in2, in3, in4, in5, in6)
|
||||
if not _ValidNumber(val):
|
||||
if not iterable(val) and not _ValidNumber(val):
|
||||
__Props_err2(in1, in2, in3, in4, in5, in6)
|
||||
else:
|
||||
return val
|
||||
|
||||
@@ -128,7 +128,6 @@ if __name__=='__main__':
|
||||
[os.path.join('CoolProp5','constants.' + cy_ext)],
|
||||
**common_args)
|
||||
|
||||
|
||||
if not pypi:
|
||||
copy_files()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user