首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在CANTERA模块中反转程序adiabetic.py,使其输入绝热温度并给出输出入口温度?

如何在CANTERA模块中反转程序adiabetic.py,使其输入绝热温度并给出输出入口温度?
EN

Stack Overflow用户
提问于 2016-06-16 06:28:45
回答 1查看 203关注 0票数 2

我正在做一个关于层流预混火焰在不同复杂程度上的数值分析的项目。我非常需要帮助,因为我是Python和Cantera的新手。我有以下问题:

  1. 我是否可以修改adiabetic.py模块,该模块主要将混合物的绝热温度从入口温度改为从绝热温度输入的入口温度?

以下是节目内容:

代码语言:javascript
复制
"""
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()

摘自:adiabatic.html

请问我一些具体的问题,因为我也不知道具体该问些什么。但我知道我想做什么。

EN

回答 1

Stack Overflow用户

发布于 2018-03-08 22:52:20

这是一个有趣的问题。

原则上,这不应太困难。假设您已经给出了进气燃料组成、当量比和绝热火焰温度,则步骤如下:

  1. 设定温度至绝热火焰温度,并平衡燃料-空气混合物的设定T和P。
  2. 计算(并保存)混合物平均焓。
  3. 设定组成回到进气道,并适应温度,直到混合物平均焓匹配,从第二步。
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37851443

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档