coolprop调用refprop计算流体的热力学性质和传输特性
coolprop调用refprop计算流体的物性环境:Windows64位
Python3.6.8
CoolProp6.3.0
refprop9.1
安装:
pip install coolprop
refprop9.1
1、纯流体
例子:
from CoolProp.CoolProp import PropsSI
pressure = 101325 # 压力 Pa
temperature = 373.15 # 温度 K
# fld为纯流体计算文件,可在refprop安装目录下C:\Program Files (x86)\REFPROP\fluids(默认安装路径)找到
fld = ['acetone.fld', 'ammonia.fld', 'argon.fld', 'benzene.fld', 'butane.fld', '1butene.fld', 'co2.fld', 'co.fld', 'cos.fld']
# 根据压力和温度计算比焓
H = PropsSI('H', "P", pressure, "T", temperature, "REFPROP::"+fld)
# 根据压力和比焓计算比熵
S = PropsSI('S', "P", pressure, "H", H, "REFPROP::"+fld)
# ...
完整的代码,已部署在服务器,功能由微信小程序物性计算实现
import json
from CoolProp.CoolProp import PropsSI
paras = [
{'name': '压力', 'mark': 'P', 'unit': 'Pa', 'id': 1},
{'name': '温度', 'mark': 'T', 'unit': 'K', 'id': 2},
{'name': '比焓', 'mark': 'H', 'unit': 'J/kg', 'id': 3},
{'name': '比熵', 'mark': 'S', 'unit': 'J/kg/K', 'id': 4},
{'name': '恒压比热', 'mark': 'C', 'unit': 'J/kg/K', 'id': 5},
{'name': '恒容比热', 'mark': 'CVMASS', 'unit': 'J/kg/K', 'id': 6},
{'name': '密度', 'mark': 'D', 'unit': 'kg/m^3', 'id': 7},
{'name': '比内能', 'mark': 'U', 'unit': 'J/kg', 'id': 8},
{'name': '黏度', 'mark': 'V', 'unit': 'Pa s', 'id': 9},
{'name': '干度', 'mark': 'Q', 'unit': 'mol/mol', 'id': 10},
{'name': '声速', 'mark': 'A', 'unit': 'm/s', 'id': 11},
{'name': '导热系数', 'mark': 'L', 'unit': 'W/m/K', 'id': 12},
{'name': '热膨胀系数', 'mark': 'ISOBARIC_EXPANSION_COEFFICIENT', 'unit': '1/K', 'id': 13},
{'name': '普朗特数', 'mark': 'PRANDTL', 'unit': '[-]', 'id': 14},
{'name': '压缩系数', 'mark': 'Z', 'unit': '[-]', 'id': 15},
{'name': '摩尔密度', 'mark': 'DMOLAR', 'unit': 'mol/m^3', 'id': 16},
{'name': '摩尔比焓', 'mark': 'HMOLAR', 'unit': 'J/mol', 'id': 17},
{'name': '摩尔比熵', 'mark': 'SMOLAR', 'unit': 'J/mol/K', 'id': 18},
{'name': '摩尔比内能', 'mark': 'UMOLAR', 'unit': 'J/mol', 'id': 19},
{'name': '摩尔比恒压比热', 'mark': 'CPMOLAR', 'unit': 'J/mol/K', 'id': 20},
{'name': '摩尔比恒容比热', 'mark': 'CVMOLAR', 'unit': 'J/mol/K', 'id': 21},
{'name': '等压膨胀系数', 'mark': 'ISOBARIC_EXPANSION_COEFFICIENT', 'unit': '1/K', 'id': 22},
{'name': '等温压缩率', 'mark': 'ISOTHERMAL_COMPRESSIBILITY', 'unit': '1/Pa', 'id': 23},
{'name': '表面张力', 'mark': 'I', 'unit': 'N/m', 'id': 24},
{'name': '第二维里系数', 'mark': 'BVIRIAL', 'unit': '[-]', 'id': 25},
{'name': '第三维里系数', 'mark': 'CVIRIAL', 'unit': '[-]', 'id': 26},
{'name': '吉布斯能量', 'mark': 'GMOLAR', 'unit': 'J/mol', 'id': 27},
{'name': '亥姆霍兹能量', 'mark': 'HELMHOLTZMOLAR', 'unit': 'J/mol', 'id': 28},
]
def fluid_PT(pressure, temperature, fld):
article_info = {}
data = json.loads(json.dumps(article_info))
for str in paras:
try:
result = PropsSI(str["mark"], "P", pressure, "T", temperature, "REFPROP::"+fld)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_Ph(pressure, enthalpy, fld):
article_info = {}
data = json.loads(json.dumps(article_info))
for str in paras:
try:
result = PropsSI(str["mark"], "P", pressure, "H", enthalpy, "REFPROP::"+fld)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_Ps(pressure, entropy, fld):
article_info = {}
data = json.loads(json.dumps(article_info))
for str in paras:
try:
result = PropsSI(str["mark"], "P", pressure, "S", entropy, "REFPROP::"+fld)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_Px(pressure, dryness, fld):
article_info = {}
data = json.loads(json.dumps(article_info))
for str in paras:
try:
result = PropsSI(str["mark"], "P", pressure, "Q", dryness, "REFPROP::"+fld)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_Th(temperature, enthalpy, fld):
article_info = {}
data = json.loads(json.dumps(article_info))
for str in paras:
try:
result = PropsSI(str["mark"], "T", temperature, "H", enthalpy, "REFPROP::"+fld)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_Ts(temperature, entropy, fld):
article_info = {}
data = json.loads(json.dumps(article_info))
for str in paras:
try:
result = PropsSI(str["mark"], "T", temperature, "S", entropy, "REFPROP::"+fld)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_Tx(temperature, dryness, fld):
article_info = {}
data = json.loads(json.dumps(article_info))
for str in paras:
try:
result = PropsSI(str["mark"], "T", temperature, "Q", dryness, "REFPROP::"+fld)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_hs(enthalpy, entropy, fld):
article_info = {}
data = json.loads(json.dumps(article_info))
for str in paras:
try:
result = PropsSI(str["mark"], "H", enthalpy, "S", entropy, "REFPROP::"+fld)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_hx(enthalpy, dryness, fld):
article_info = {}
data = json.loads(json.dumps(article_info))
for str in paras:
try:
result = PropsSI(str["mark"], "H", enthalpy, "Q", dryness, "REFPROP::"+fld)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_sx(entropy, dryness, fld):
article_info = {}
data = json.loads(json.dumps(article_info))
for str in paras:
try:
result = PropsSI(str["mark"], "S", entropy, "Q", dryness, "REFPROP::"+fld)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
2、混合物
例子
from CoolProp.CoolProp import PropsSI
# 空气
refprop = 'REFPROP::nitrogen&argon&oxygen'
pressure = 101325 # 压力 Pa
temperature = 373.15 # 温度 K
# 根据压力和温度计算比焓
H = PropsSI('H', "P", pressure, "T", temperature, refprop)
# 根据压力和比焓计算比熵
S = PropsSI('S', "P", pressure, "H", H, refprop)
# ...
服务器代码
import json
import CoolProp.CoolProp as CP
refprop = ['REFPROP::nitrogen&argon&oxygen', 'REFPROP::R22&R152a&R124', 'REFPROP::R22&R152a&R124', 'REFPROP::R22&R152a&R124', 'REFPROP::R125&Propane&R22', 'REFPROP::R125&Propane&R22', 'REFPROP::Propane&R22&R218', 'REFPROP::Propane&R22&R218', 'REFPROP::R125&R134a&R143a', 'REFPROP::R22&R152a&R142b&RC318', 'REFPROP::R22&Isobutan&R142b', 'REFPROP::R32&R125&R134a', 'REFPROP::R32&R125&R134a', 'REFPROP::R32&R125&R134a', 'REFPROP::R32&R125&R134a', 'REFPROP::R32&R125&R134a', 'REFPROP::R32&R125&R134A', 'REFPROP::R125&R143a&R22', 'REFPROP::R22&R124&R142b', 'REFPROP::R22&R124&R142b', 'REFPROP::R32&R125', 'REFPROP::R32&R125', 'REFPROP::propylen&R22&R152a', 'REFPROP::propylen&R22&R152a', 'REFPROP::R22&R218&R142b', 'REFPROP::R218&R134a&Isobutan', 'REFPROP::R22&R124&Isobutan&R142b', 'REFPROP::R22&R124&Isobutan&R142b', 'REFPROP::R22&R152a', 'REFPROP::R22&R152a', 'REFPROP::R134a&R124&Butane', 'REFPROP::R125&R134a&Butane', 'REFPROP::Propane&R22&R152a', 'REFPROP::R125&R134a&DME', 'REFPROP::R134a&R142b', 'REFPROP::R125&R134a', 'REFPROP::R125&R134a', 'REFPROP::R125&R134a&Isobutan', 'REFPROP::R125&R134a&Isobutan', 'REFPROP::R125&R134a&Isobutan', 'REFPROP::R125&R134a&Isobutan', 'REFPROP::R134a&R227ea', 'REFPROP::R125&R134a&Isobutan&Butane', 'REFPROP::R32&R134a&R227ea', 'REFPROP::R125&R134a&Butane&ipentane', 'REFPROP::R32&R125&R143a&R134a', 'REFPROP::R125&R143a&Propane&Isobutan', 'REFPROP::dme&R152a&Isobutan', 'REFPROP::R152a&Isobutan', 'REFPROP::Propane&R152a', 'REFPROP::propylen&dme', 'REFPROP::propylen&Propane', 'REFPROP::R125&R143a&R134a&Isobutan', 'REFPROP::dme&R152a', 'REFPROP::Propane&Isobutan', 'REFPROP::Propane&Isobutan', 'REFPROP::R125&R134a&Butane&Pentane', 'REFPROP::R32&R125&R134a&Butane&ipentane', 'REFPROP::Ethane&Propane&Isobutan&Butane', 'REFPROP::R32&R125&R134a&R152a&R227ea', 'REFPROP::propylen&Propane&Isobutan', 'REFPROP::R32&R152a&R1234ze', 'REFPROP::R12&R152a', 'REFPROP::R22&R12', 'REFPROP::R22&R115', 'REFPROP::R23&R13', 'REFPROP::R32&R115', 'REFPROP::R125&R143a', 'REFPROP::R23&R116', 'REFPROP::R23&R116', 'REFPROP::R22&R218', 'REFPROP::dme&Isobutan', 'REFPROP::R134a&R152a']
fluid = ['air',
'R401A',
'R401B',
'R401C',
'R402A',
'R402B',
'R403A',
'R403B',
'R404A',
'R405A',
'R406A',
'R407A',
'R407B',
'R407C',
'R407D',
'R407E',
'R407F',
'R408A',
'R409A',
'R409B',
'R410A',
'R410B',
'R411A',
'R411B',
'R412A',
'R413A',
'R414A',
'R414B',
'R415A',
'R415B',
'R416A',
'R417A',
'R418A',
'R419A',
'R420A',
'R421A',
'R421B',
'R422A',
'R422B',
'R422C',
'R422D',
'R423A',
'R424A',
'R425A',
'R426A',
'R427A',
'R428A',
'R429A',
'R430A',
'R431A',
'R432A',
'R433A',
'R434A',
'R435A',
'R436A',
'R436B',
'R437A',
'R438A',
'R441A',
'R442A',
'R443A',
'R444A',
'R500',
'R501',
'R502',
'R503',
'R504',
'R507A',
'R508A',
'R508B',
'R509A',
'R510A',
'R512A'
]
paras = [
{'name': '压力', 'mark': 'P', 'unit': 'Pa', 'id': 1},
{'name': '温度', 'mark': 'T', 'unit': 'K', 'id': 2},
{'name': '比焓', 'mark': 'H', 'unit': 'J/kg', 'id': 3},
{'name': '比熵', 'mark': 'S', 'unit': 'J/kg/K', 'id': 4},
{'name': '恒压比热', 'mark': 'C', 'unit': 'J/kg/K', 'id': 5},
{'name': '恒容比热', 'mark': 'CVMASS', 'unit': 'J/kg/K', 'id': 6},
{'name': '密度', 'mark': 'D', 'unit': 'kg/m^3', 'id': 7},
{'name': '比内能', 'mark': 'U', 'unit': 'J/kg', 'id': 8},
{'name': '黏度', 'mark': 'V', 'unit': 'Pa s', 'id': 9},
{'name': '干度', 'mark': 'Q', 'unit': 'mol/mol', 'id': 10},
{'name': '声速', 'mark': 'A', 'unit': 'm/s', 'id': 11},
{'name': '导热系数', 'mark': 'L', 'unit': 'W/m/K', 'id': 12},
{'name': '热膨胀系数', 'mark': 'ISOBARIC_EXPANSION_COEFFICIENT', 'unit': '1/K', 'id': 13},
{'name': '普朗特数', 'mark': 'PRANDTL', 'unit': '[-]', 'id': 14},
{'name': '压缩系数', 'mark': 'Z', 'unit': '[-]', 'id': 15},
{'name': '摩尔密度', 'mark': 'DMOLAR', 'unit': 'mol/m^3', 'id': 16},
{'name': '摩尔比焓', 'mark': 'HMOLAR', 'unit': 'J/mol', 'id': 17},
{'name': '摩尔比熵', 'mark': 'SMOLAR', 'unit': 'J/mol/K', 'id': 18},
{'name': '摩尔比内能', 'mark': 'UMOLAR', 'unit': 'J/mol', 'id': 19},
{'name': '摩尔比恒压比热', 'mark': 'CPMOLAR', 'unit': 'J/mol/K', 'id': 20},
{'name': '摩尔比恒容比热', 'mark': 'CVMOLAR', 'unit': 'J/mol/K', 'id': 21},
{'name': '等压膨胀系数', 'mark': 'ISOBARIC_EXPANSION_COEFFICIENT', 'unit': '1/K', 'id': 22},
{'name': '等温压缩率', 'mark': 'ISOTHERMAL_COMPRESSIBILITY', 'unit': '1/Pa', 'id': 23},
{'name': '表面张力', 'mark': 'I', 'unit': 'N/m', 'id': 24},
{'name': '第二维里系数', 'mark': 'BVIRIAL', 'unit': '[-]', 'id': 25},
{'name': '第三维里系数', 'mark': 'CVIRIAL', 'unit': '[-]', 'id': 26},
{'name': '吉布斯能量', 'mark': 'GMOLAR', 'unit': 'J/mol', 'id': 27},
{'name': '亥姆霍兹能量', 'mark': 'HELMHOLTZMOLAR', 'unit': 'J/mol', 'id': 28},
]
def fluid_PT(pressure, temperature, name):
article_info = {}
data = json.loads(json.dumps(article_info))
i = fluid.index(name)
re = refprop
for str in paras:
try:
result = CP.PropsSI(str['mark'], 'P', pressure, 'T', temperature, re)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_Ph(pressure, enthalpy, name):
article_info = {}
data = json.loads(json.dumps(article_info))
i = fluid.index(name)
re = refprop
for str in paras:
try:
result = CP.PropsSI(str['mark'], 'P', pressure, 'H', enthalpy, re)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_Ps(pressure, entropy, name):
article_info = {}
data = json.loads(json.dumps(article_info))
i = fluid.index(name)
re = refprop
for str in paras:
try:
result = CP.PropsSI(str['mark'], 'P', pressure, 'S', entropy, re)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_Px(pressure, dryness, name):
article_info = {}
data = json.loads(json.dumps(article_info))
i = fluid.index(name)
re = refprop
for str in paras:
try:
result = CP.PropsSI(str['mark'], 'P', pressure, 'Q', dryness, re)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_Th(temperature, enthalpy, name):
article_info = {}
data = json.loads(json.dumps(article_info))
i = fluid.index(name)
re = refprop
for str in paras:
try:
result = CP.PropsSI(str['mark'], 'T', temperature, 'H', enthalpy, re)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_Ts(temperature, entropy, name):
article_info = {}
data = json.loads(json.dumps(article_info))
i = fluid.index(name)
re = refprop
for str in paras:
try:
result = CP.PropsSI(str['mark'], 'T', temperature, 'S', entropy, re)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_Tx(temperature, dryness, name):
article_info = {}
data = json.loads(json.dumps(article_info))
i = fluid.index(name)
re = refprop
for str in paras:
try:
result = CP.PropsSI(str['mark'], 'T', temperature, 'Q', dryness, re)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_hs(enthalpy, entropy, name):
article_info = {}
data = json.loads(json.dumps(article_info))
i = fluid.index(name)
re = refprop
for str in paras:
try:
result = CP.PropsSI(str['mark'], 'H', enthalpy, 'S', entropy, re)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_hx(enthalpy, dryness, name):
article_info = {}
data = json.loads(json.dumps(article_info))
i = fluid.index(name)
re = refprop
for str in paras:
try:
result = CP.PropsSI(str['mark'], 'H', enthalpy, 'Q', dryness, re)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
def fluid_sx(entropy, dryness, name):
article_info = {}
data = json.loads(json.dumps(article_info))
i = fluid.index(name)
re = refprop
for str in paras:
try:
result = CP.PropsSI(str['mark'], 'S', entropy, 'Q', dryness, re)
if len(str['mark']) > 10:
x = {'name': str['name'], 'mark': '...', 'value': round(result, 6), 'unit': str['unit']}
else:
x = {'name': str['name'], 'mark': str['mark'], 'value': round(result, 6), 'unit': str['unit']}
data] = x
except:
pass
return json.dumps(data, ensure_ascii=False)
print(fluid_PT(101325,100, 'Air')) 整个就是专业领域的
致敬 楼主,分享个refprop吧~{:1_919:} 感谢分享 求分享一个refprop9.1 kankanzuoyou 发表于 2021-4-15 10:32
求分享一个refprop9.1
怎么给你 liyewudi 发表于 2021-4-18 20:24
怎么给你
我也需要 460856348@qq.com liyewudi 发表于 2021-4-18 20:24
怎么给你
876042121@qq.com 谢谢
页:
[1]