Как я могу повернуть программу adiabetic.py в модуле CANTERA Python таким образом, чтобы она вводила адиабетическую температуру и давала выходную температуру на входе?
Я делаю проект по численному анализу ламинарного предварительно смешанного пламени на разных уровнях сложности. Я остро нуждаюсь в помощи, поскольку я новичок в 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