Counterflow Diffusion FlameΒΆ
This example shows how to simulate an opposed flow diffusion flame.
example_diffusion.py
:
#!/usr/bin/python
"""
Hot methane diluted by nitrogen opposing hot air in the planar opposed jet geometry
for a low strain rate. The converged axial velocity profile is plotted.
"""
from ember import *
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
output = 'run/ex_diffusion'
conf = Config(
Paths(outputDir=output,
# logFile='ex_diffusion.log'
),
InitialCondition(flameType='diffusion',
fuel='CH4:1.0, N2:2.0',
oxidizer='N2:3.76, O2:1.0',
Tfuel=600,
Toxidizer=600,
xLeft=-0.004,
xRight=0.004,
centerWidth=0.002,
slopeWidth=0.001),
StrainParameters(initial=100,
final=100),
General(nThreads=2),
Times(globalTimestep=1e-5,
profileStepInterval=20),
TerminationCondition(tEnd=0.010))
if __name__ == '__main__':
conf.run()
struct = utils.load(output + '/profNow.h5')
f, ax = plt.subplots()
ax.plot(struct.x, struct.V / struct.rho)
ax.set_xlabel('Position [m]')
ax.set_ylabel('Axial Velocity [m/s]')
f.savefig(output+'/FinalAxialVelocity.png')
The given configuration parameters override default values. The full set of configuration parameters is described in Configuration Options.
Paths
outputDir
is the directory where periodic periodic output profiles (prof000000.h5
,prof0000001.h5
, etc.) and time series output files (out.h5
) will be saved. If a relative path is given (as in this example), the path is relative to the directory from which the script is run.logFile
is used to write information about the progress of the solver. The path is relative to the directory from which the script is run, i.e. it is not necessarily placed inoutputDir
. If no value is specified for this option, the log output is written to the screen viastdout
.
InitialCondition
- For the diffusion flame, properties need to be for the separate fuel and oxidizer streams.flameType='diffusion'
specifies that this is a diffusion flame and that independent properties for the fuel and oxidizer mixture should be used.fuel
andoxidizer
define the composition of the fuel and oxidizer streams, respectively.Tfuel
andToxidizer
define the temperature of the fuel and oxidizer streams, respectively.xLeft
andxRight
define the extent of the initial domain. Depending on the grid adaptation parameters, the extent of the domain may change as the flame evolves in time.centerWidth
defines the width in the initial profile of the fully-mixed region between the two inlet streams. If this region is not wide enough, the flame may extinguish unexpectedly. Otherwise, the steady-state solution will be independent of this value.slopeWidth
defines the initial width of the transition between the inlet streams and the center zone. Making this too narrow wide will increase the time it takes to reach a steady-state flame. Making this too wide may result in integration difficulties.
StrainParameters
specifies how the strain rate imposed on the flame varies as a function of time. In this case we specify a constant strain rate.General
nThreads
- Set the number of parallel threads to use when solving. This can be set to any value up to the number of processors in the computer.
Times
globalTimestep
- sets the timestep size used by the operator-split integrator. Decreasing this value may help in cases where numerical oscillations are observed. Typically, a value of2e-5
can be used without trouble.profileStepInterval
- specifies that the output profiles (prof000001.h5
etc.) should be produced every 20 global timesteps.
TerminationCondition
specifies the conditions under which the time integration will be terminated. Here, we specify integration until a specific time. Another option is to integrate until a steady-state solution is reached.
To try this example, run the following command:
$ python -m ember.examples.example_diffusion
Or copy the example_diffusion.py
file to another directory, make any
modifications you desire, then run:
$ python example_diffusion.py