如何反转 CANTERA Python 模块中的程序 adiabetic.py 使其输入绝热温度并给出输出入口温度?
Posted
技术标签:
【中文标题】如何反转 CANTERA Python 模块中的程序 adiabetic.py 使其输入绝热温度并给出输出入口温度?【英文标题】:How can I reverse the program adiabetic.py in CANTERA Python module such that it inputs the adiabetic temperature and gives output inlet temperature? 【发布时间】:2016-06-16 06:28:45 【问题描述】:我正在做一个项目,对不同复杂程度的层流预混火焰进行数值分析。我非常需要帮助,因为我是 Python 和 Cantera 的新手。我有以下疑问:
-
我是否可以修改 adiabetic.py 模块,该模块主要将混合物的绝热温度从入口温度转换为可以将绝热温度作为输入的入口温度?
以下是程序:
"""
Adiabatic flame temperature and equilibrium composition for a fuel/air mixture
as a function of equivalence ratio, including formation of solid carbon.
"""
import cantera as ct
import numpy as np
import sys
import csv
##############################################################################
# Edit these parameters to change the initial temperature, the pressure, and
# the phases in the mixture.
T = 300.0
P = 101325.0
# phases
gas = ct.Solution('gri30.xml')
carbon = ct.Solution('graphite.xml')
# the phases that will be included in the calculation, and their initial moles
mix_phases = [(gas, 1.0), (carbon, 0.0)]
# gaseous fuel species
fuel_species = 'CH4'
# equivalence ratio range
npoints = 50
phi = np.linspace(0.3, 3.5, npoints)
##############################################################################
mix = ct.Mixture(mix_phases)
# create some arrays to hold the data
tad = np.zeros(npoints)
xeq = np.zeros((mix.n_species,npoints))
for i in range(npoints):
# set the gas state
gas.set_equivalence_ratio(phi[i], fuel_species, 'O2:1.0, N2:3.76')
# create a mixture of 1 mole of gas, and 0 moles of solid carbon.
mix = ct.Mixture(mix_phases)
mix.T = T
mix.P = P
# equilibrate the mixture adiabatically at constant P
mix.equilibrate('HP', solver='gibbs', max_steps=1000)
tad[i] = mix.T
print('At phi = 0:12.4g, Tad = 1:12.4g'.format(phi[i], tad[i]))
xeq[:,i] = mix.species_moles
# write output CSV file for importing into Excel
csv_file = 'adiabatic.csv'
with open(csv_file, 'w') as outfile:
writer = csv.writer(outfile)
writer.writerow(['phi','T (K)'] + mix.species_names)
for i in range(npoints):
writer.writerow([phi[i], tad[i]] + list(xeq[:,i]))
print('Output written to 0'.format(csv_file))
if '--plot' in sys.argv:
import matplotlib.pyplot as plt
plt.plot(phi, tad)
plt.xlabel('Equivalence ratio')
plt.ylabel('Adiabatic flame temperature [K]')
plt.show()
取自:http://www.cantera.org/docs/sphinx/html/cython/examples/multiphase_adiabatic.html
请问我具体的问题,因为即使我不知道具体要问什么。但我知道我想做什么。
【问题讨论】:
【参考方案1】:这是一个有趣的问题。
原则上应该不会太难。假设您已经给出了入口燃料成分、当量比和绝热火焰温度,那么步骤将是:
-
将温度设置为绝热火焰温度并平衡燃料-空气混合物以达到设定的 T 和 P。
计算(并保存)混合平均焓。
将成分设置回入口的成分,并拟合温度,直到混合物平均焓与步骤 2 中的值匹配。
【讨论】:
以上是关于如何反转 CANTERA Python 模块中的程序 adiabetic.py 使其输入绝热温度并给出输出入口温度?的主要内容,如果未能解决你的问题,请参考以下文章