[Python/1D] Generalize initial profile generation for diffusion flames
The calculation of the stoichiometric mixture composition now works for arbitrary fuel and oxidizer mixtures, including multi-component fuels and fuels containing oxygen. In addition, it is not necessary to specify any additional arguments when generating the initial profile.
This commit is contained in:
parent
28156cc511
commit
51e0c9158a
5 changed files with 30 additions and 46 deletions
|
|
@ -49,12 +49,6 @@ f.oxidizer_inlet.T = tin_o
|
|||
f.flame.set_steady_tolerances(default=tol_ss)
|
||||
f.flame.set_transient_tolerances(default=tol_ts)
|
||||
|
||||
# construct the initial solution estimate. To do so, it is necessary
|
||||
# to specify the fuel species. If a fuel mixture is being used,
|
||||
# specify a representative species here for the purpose of
|
||||
# constructing an initial guess.
|
||||
f.set_initial_guess(fuel='C2H6')
|
||||
|
||||
# Set the boundary emissivities
|
||||
f.set_boundary_emissivities(0.0, 0.0)
|
||||
# Turn radiation off
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ def interrupt_extinction(t):
|
|||
f.set_interrupt(interrupt_extinction)
|
||||
|
||||
# Initialize and solve
|
||||
f.set_initial_guess(fuel='H2')
|
||||
print('Creating the initial solution')
|
||||
f.solve(loglevel=0, refine_grid=refine)
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ f.set_grid_min(1e-20)
|
|||
temperature_limit_extinction = 500 # K
|
||||
|
||||
# Initialize and solve
|
||||
f.set_initial_guess(fuel='H2')
|
||||
print('Creating the initial solution')
|
||||
f.solve(loglevel=0, refine_grid=refine)
|
||||
|
||||
|
|
|
|||
|
|
@ -494,59 +494,49 @@ class CounterflowDiffusionFlame(FlameBase):
|
|||
super(CounterflowDiffusionFlame, self).__init__(
|
||||
(self.fuel_inlet, self.flame, self.oxidizer_inlet), gas, grid)
|
||||
|
||||
def set_initial_guess(self, fuel, oxidizer=None, stoich=None):
|
||||
def set_initial_guess(self, fuel=None, oxidizer=None, stoich=None):
|
||||
"""
|
||||
Set the initial guess for the solution. The fuel species must be
|
||||
specified:
|
||||
|
||||
>>> f.set_initial_guess(fuel='CH4')
|
||||
|
||||
The oxidizer and corresponding stoichiometry must be specified if it
|
||||
is not 'O2'. The initial guess is generated by assuming infinitely-
|
||||
fast chemistry.
|
||||
Set the initial guess for the solution. The initial guess is generated
|
||||
by assuming infinitely-fast chemistry.
|
||||
"""
|
||||
if fuel is not None or oxidizer is not None or stoich is not None:
|
||||
warnings.warn(
|
||||
'Arguments to CounterflowDiffusionFlame.set_initial_guess are '
|
||||
'unused and deprecated and will be removed after Cantera 2.3.')
|
||||
|
||||
super(CounterflowDiffusionFlame, self).set_initial_guess()
|
||||
|
||||
if stoich is None:
|
||||
if oxidizer is None:
|
||||
if 'O2' in self.gas.species_names:
|
||||
oxidizer = 'O2'
|
||||
elif 'o2' in self.gas.species_names:
|
||||
oxidizer = 'o2'
|
||||
else:
|
||||
raise Exception("Can't identify default oxidizer species.")
|
||||
if oxidizer.upper() == 'O2':
|
||||
stoich = 0.0
|
||||
if 'H' in self.gas.element_names:
|
||||
stoich += 0.25 * self.gas.n_atoms(fuel, 'H')
|
||||
if 'C' in self.gas.element_names:
|
||||
stoich += self.gas.n_atoms(fuel, 'C')
|
||||
else:
|
||||
raise Exception('oxidizer/fuel stoichiometric ratio must be '
|
||||
'specified since the oxidizer is not O2')
|
||||
|
||||
kFuel = self.gas.species_index(fuel)
|
||||
kOx = self.gas.species_index(oxidizer)
|
||||
|
||||
s = stoich * self.gas.molecular_weights[kOx] / self.gas.molecular_weights[kFuel]
|
||||
phi = s * self.fuel_inlet.Y[kFuel] / self.oxidizer_inlet.Y[kOx]
|
||||
zst = 1.0 / (1.0 + phi)
|
||||
moles = lambda el: (self.gas.elemental_mass_fraction(el) /
|
||||
self.gas.atomic_weight(el))
|
||||
|
||||
# Compute stoichiometric mixture composition
|
||||
Yin_f = self.fuel_inlet.Y
|
||||
Yin_o = self.oxidizer_inlet.Y
|
||||
Yst = zst * Yin_f + (1.0 - zst) * Yin_o
|
||||
|
||||
self.gas.TPY = self.fuel_inlet.T, self.P, Yin_f
|
||||
mdotf = self.fuel_inlet.mdot
|
||||
u0f = mdotf / self.gas.density
|
||||
T0f = self.fuel_inlet.T
|
||||
|
||||
sFuel = moles('O')
|
||||
if 'C' in self.gas.element_names:
|
||||
sFuel -= 2 * moles('C')
|
||||
if 'H' in self.gas.element_names:
|
||||
sFuel -= 0.5 * moles('H')
|
||||
|
||||
Yin_o = self.oxidizer_inlet.Y
|
||||
self.gas.TPY = self.oxidizer_inlet.T, self.P, Yin_o
|
||||
mdoto = self.oxidizer_inlet.mdot
|
||||
u0o = mdoto/self.gas.density
|
||||
u0o = mdoto / self.gas.density
|
||||
T0o = self.oxidizer_inlet.T
|
||||
|
||||
sOx = moles('O')
|
||||
if 'C' in self.gas.element_names:
|
||||
sOx -= 2 * moles('C')
|
||||
if 'H' in self.gas.element_names:
|
||||
sOx -= 0.5 * moles('H')
|
||||
|
||||
zst = 1.0 / (1 - sFuel / sOx)
|
||||
Yst = zst * Yin_f + (1.0 - zst) * Yin_o
|
||||
|
||||
# get adiabatic flame temperature and composition
|
||||
Tbar = 0.5 * (T0f + T0o)
|
||||
self.gas.TPY = Tbar, self.P, Yst
|
||||
|
|
@ -558,6 +548,8 @@ class CounterflowDiffusionFlame(FlameBase):
|
|||
zz = self.flame.grid
|
||||
dz = zz[-1] - zz[0]
|
||||
a = (u0o + u0f)/dz
|
||||
kOx = (self.gas.species_index('O2') if 'O2' in self.gas.species_names else
|
||||
self.gas.species_index('o2'))
|
||||
f = np.sqrt(a / (2.0 * self.gas.mix_diff_coeffs[kOx]))
|
||||
|
||||
x0 = mdotf * dz / (mdotf + mdoto)
|
||||
|
|
|
|||
|
|
@ -412,7 +412,7 @@ class TestDiffusionFlame(utilities.CanteraTest):
|
|||
self.sim.oxidizer_inlet.X = oxidizer
|
||||
self.sim.oxidizer_inlet.T = T_ox
|
||||
|
||||
self.sim.set_initial_guess(fuel='H2')
|
||||
self.sim.set_initial_guess()
|
||||
|
||||
def solve_fixed_T(self):
|
||||
# Solve with the energy equation disabled
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue