Cantera

Table Of Contents

Previous topic

Zero-Dimensional Reactors

Next topic

Func Module

This Page

Warning

This documentation is for an old version of Cantera. You can find docs for newer versions here.

One-Dimensional Reacting Flows

The classes in this package implement one-dimensional reacting flow problems.

class Cantera.OneD.onedim.Domain1D

Base class for one-dimensional domains.

bounds(component)

Return the (lower, upper) bounds for a solution component.

>>> d.bounds('T')
(200.0, 5000.0)
componentIndex(name)

Index of the component with name ‘name’

componentName(n)

Name of the nth component.

componentNames()

List of the names of all components of this domain.

domain_hndl()

Integer used to reference the kernel object.

grid(n=-1)

If n >= 0, return the value of the nth grid point from the left in this domain. If n is not supplied, return the entire grid.

>>> z4 = d.grid(4)
>>> z_array = d.grid()
index()

Index of this domain in a stack. Returns -1 if this domain is not part of a stack.

nComponents()

Number of solution components at each grid point.

nPoints()

Number of grid points belonging to this domain.

set(**options)

convenient function to invoke other methods. Parameters that can be set:

grid, name, desc

>>> d.set(name='flame', grid=z)
setBounds(**bounds)

Set the lower and upper bounds on the solution.

The argument list should consist of keyword/value pairs, with component names as keywords and (lower_bound, upper_bound) tuples as the values. The keyword default may be used to specify default bounds for all unspecified components. The keyword Y can be used to stand for all species mass fractions in flow domains.

>>> d.setBounds(default=(0, 1),
...             Y=(-1.0e-5, 2.0))
setDesc(desc)

Set the description of this domain.

setID(id)
setTolerances(**tol)

Set the error tolerances. If time is present and non-zero, then the values entered will apply to the transient problem. Otherwise, they will apply to the steady-state problem.

The argument list should consist of keyword/value pairs, with component names as keywords and (rtol, atol) tuples as the values. The keyword default may be used to specify default bounds for all unspecified components. The keyword Y can be used to stand for all species mass fractions in flow domains.

>>> d.setTolerances(Y=(1.0e-5, 1.0e-9),
...                 default=(1.0e-7, 1.0e-12),
...                 time=1)
setupGrid(grid)

Specify the grid.

>>> d.setupGrid([0.0, 0.1, 0.2])
tolerances(component)

Return the (relative, absolute) error tolerances for a solution component.

>>> (r, a) = d.tolerances('u')
type()

Domain type. Integer.

Cantera.OneD.onedim.clearDomains()

Clear all domains.

Cantera.OneD.onedim.clearSim1D()

Clear all stacks.

Flow Domains

class Cantera.OneD.onedim.AxisymmetricFlow(id='axisymmetric_flow', gas=None, type=1)

Bases: Cantera.OneD.onedim.Domain1D

An axisymmetric flow domain.

In an axisymmetric flow domain, the equations solved are the similarity equations for the flow in a finite-height gap of infinite radial extent. The solution variables are

u
axial velocity
V
radial velocity divided by radius
T
temperature
lambda
(1/r)(dP/dr)
Y_k
species mass fractions

It may be shown that if the boundary conditions on these variables are independent of radius, then a similarity solution to the exact governing equations exists in which these variables are all independent of radius. This solution holds only in in low-Mach-number limit, in which case (dP/dz) = 0, and lambda is a constant. (Lambda is treated as a spatially-varying solution variable for numerical reasons, but in the final solution it is always independent of z.) As implemented here, the governing equations assume an ideal gas mixture. Arbitrary chemistry is allowed, as well as arbitrary variation of the transport properties.

enableSoret(withSoret=1)

Include or exclude thermal diffusion (Soret effect) when computing diffusion velocities. If withSoret is not supplied or is positive, thermal diffusion is enabled; otherwise it is disabled.

pressure()

Pressure [Pa].

set(**opt)

Set parameters. In addition to the parameters that may be set by Domain1D.set, this method can be used to set the pressure and energy flag

>>> d.set(pressure=OneAtm, energy='on')
setFixedTempProfile(pos, temp)

Set the fixed temperature profile. This profile is used whenever the energy equation is disabled.

Parameters:
  • pos – arrray of relative positions from 0 to 1
  • temp – array of temperature values
>>> d.setFixedTempProfile(array([0.0, 0.5, 1.0]),
...                       array([500.0, 1500.0, 2000.0])
setPressure(p)

Set the pressure [Pa]. The pressure is a constant, since the governing equations are those for the low-Mach-number limit.

setTransportModel(transp, withSoret=0)

Set the transport model. The argument must be a transport manager for the ‘gas’ object.

solveEnergyEqn(flag=1)

Enable or disable solving the energy equation. If invoked with no arguments or with a non-zero argument, the energy equations will be solved. If invoked with a zero argument, it will not be, and instead the temperature profiles will be held to the one specified by the call to setFixedTempProfile(). Default: energy equation enabled.

solveSpeciesEqs(flag=1)

Enable or disable solving the species equations. If invoked with no arguments or with a non-zero argument, the species equations will be solved. If invoked with a zero argument, they will not be, and instead the species profiles will be held at their initial values. Default: species equations enabled.

class Cantera.OneD.StagnationFlow.StagnationFlow(gas=None, surfchem=None, grid=None)

Bases: Cantera.OneD.onedim.Stack

An axisymmetric flow impinging on a surface at normal incidence.

Parameters:
  • gas – object to use to evaluate all gas properties and reaction rates. Required.
  • surfchem – object used to evaluate surface reaction rates. If omitted, surface will be treated as inert.
  • grid – array of initial grid points

A domain of type AxisymmetricFlow named flow will be created to represent the flow, and one of type Surface named surface will be created to represent the surface. The three domains comprising the stack are stored as self.inlet, self.flow, and self.surface.

T(point=-1)

The temperature [K]

V(point=-1)

The radial velocity divided by radius [s^-1]

coverages()

The coverages of the surface species.

init(products='inlet')

Set the initial guess for the solution. If products = ‘equil’, then the equilibrium composition at the adiabatic flame temperature will be used to form the initial guess. Otherwise the inlet composition will be used.

set(tol=None, energy='', tol_time=None)

Set parameters.

Parameters:
  • tol – (rtol, atol) for steady-state
  • tol_time – (rtol, atol) for time stepping
  • energy – ‘on’ or ‘off’ to enable or disable the energy equation
setGasState(j)

Set the state of the object representing the gas to the current solution at grid point j.

setGridMin(gridmin)

Set the minimum allowable grid spacing in a domain.

Parameters:
  • domain – domain object
  • gridmin – The minimum allowable grid spacing [m] for this domain
setProfile(component, locs, vals)

Set an initial estimate for a profile of one component in one domain.

Parameters:
  • dom – domain object
  • comp – component name
  • pos – sequence of relative positions, from 0 on the left to 1 on the right
  • v – sequence of values at the relative positions specified in ‘pos’
>>> s.setProfile(d, 'T', [0.0, 0.2, 1.0], [400.0, 800.0, 1500.0])
setRefineCriteria(ratio=10.0, slope=0.8, curve=0.8, prune=0.0)

Set the criteria used to refine one domain.

Parameters:
  • domain – domain object
  • ratio – additional points will be added if the ratio of the spacing on either side of a grid point exceeds this value
  • slope – maximum difference in value between two adjacent points, scaled by the maximum difference in the profile (0.0 < slope < 1.0). Adds points in regions of high slope.
  • curve – maximum difference in slope between two adjacent intervals, scaled by the maximum difference in the profile (0.0 < curve < 1.0). Adds points in regions of high curvature.
  • prune – if the slope or curve criteria are satisfied to the level of ‘prune’, the grid point is assumed not to be needed and is removed. Set prune significantly smaller than ‘slope’ and ‘curve’. Set to zero to disable pruning the grid.
>>> s.setRefineCriteria(d, ratio=5.0, slope=0.2, curve=0.3,
...                     prune=0.03)
solution(component='', point=-1)

The solution for one specified component. If a point number is given, return the value of component component at this point. Otherwise, return the entire profile for this component.

solve(loglevel=1, refine_grid=1)

Solve the problem.

Parameters:
  • loglevel – integer flag controlling the amount of diagnostic output. Zero suppresses all output, and 5 produces very verbose output. Default: 1
  • refine_grid – if non-zero, enable grid refinement.
u(point=-1)

The axial velocity [m/s]

Boundaries

class Cantera.OneD.onedim.Bdry1D

Bases: Cantera.OneD.onedim.Domain1D

Base class for boundary domains.

massFraction(k)

The mass fraction of species k.

mdot()

The mass flow rate per unit area [kg/m2/s

set(**options)

Set parameters: mdot or massflux temperature or T mole_fractions or X

setMdot(mdot)

Set the mass flow rate per unit area [kg/m2].

setMoleFractions(x)

set the mole fraction values.

setTemperature(t)

Set the temperature [K]

temperature()

Set the temperature [K].

class Cantera.OneD.onedim.Inlet(id='inlet')

Bases: Cantera.OneD.onedim.Bdry1D

A one-dimensional inlet. Note that an inlet can only be a terminal domain - it must be either the leftmost or rightmost domain in a stack.

setSpreadRate(V0=0.0)

Set the spead rate, defined as the value of V = v/r at the inlet.

class Cantera.OneD.onedim.Outlet(id='outlet')

Bases: Cantera.OneD.onedim.Bdry1D

A one-dimensional outlet. An outlet imposes a zero-gradient boundary condition on the flow.

class Cantera.OneD.onedim.OutletRes(id='outletres')

Bases: Cantera.OneD.onedim.Bdry1D

A one-dimensional outlet into a reservoir.

class Cantera.OneD.onedim.SymmPlane(id='symmetry_plane')

Bases: Cantera.OneD.onedim.Bdry1D

A symmetry plane.

Composite Domains

class Cantera.OneD.onedim.Stack(domains=None)

Class Stack is a container for one-dimensional domains. It also holds the multi-domain solution vector, and controls the process of finding the solution.

Domains are ordered left-to-right, with domain number 0 at the left.

This class is largely a shadow class for C++ kernel class Sim1D.

domainIndex(name)

Integer index of the domain with name ‘name’

eval(rdt, count=1)

Evaluate the residual function. If count = 0, do is ‘silently’, without adding to the function evaluation counter

getInitialSoln()

Load the initial solution from each domain into the global solution vector.

profile(domain, component)

Spatial profile of one component in one domain.

>>> print s.profile(flow, 'T')
refine(loglevel=1)

Refine the grid, adding points where solution is not adequately resolved.

restore(file='soln.xml', id='solution')

Set the solution vector to a previously-saved solution.

Parameters:
  • file – solution file
  • id – solution name within the file
>>> s.restore(file = 'save.xml', id = 'energy_off')
save(file='soln.xml', id='solution', desc='none')

Save the solution in XML format.

>>> s.save(file='save.xml', id='energy_off',
...        desc='solution with energy eqn. disabled')
setFixedTemperature(temp)

This is a temporary fix.

setFlatProfile(dom, comp, v)

Set a flat profile for one component in one domain.

Parameters:
  • dom – domain object
  • comp – component name
  • v – value
>>> s.setFlatProfile(d, 'u', -3.0)
setGridMin(domain, gridmin)

Set the minimum allowable grid spacing in a domain.

Parameters:
  • domain – domain object
  • gridmin – The minimum allowable grid spacing [m] for this domain
setMaxJacAge(ss_age, ts_age)

Set the maximum number of times the Jacobian will be used before it must be re-evaluated.

Parameters:
  • ss_age – age criterion during steady-state mode
  • ts_age – age criterion during time-stepping mode
setProfile(dom, comp, pos, v)

Set an initial estimate for a profile of one component in one domain.

Parameters:
  • dom – domain object
  • comp – component name
  • pos – sequence of relative positions, from 0 on the left to 1 on the right
  • v – sequence of values at the relative positions specified in ‘pos’
>>> s.setProfile(d, 'T', [0.0, 0.2, 1.0], [400.0, 800.0, 1500.0])
setRefineCriteria(domain=None, ratio=10.0, slope=0.8, curve=0.8, prune=0.05)

Set the criteria used to refine one domain.

Parameters:
  • domain – domain object
  • ratio – additional points will be added if the ratio of the spacing on either side of a grid point exceeds this value
  • slope – maximum difference in value between two adjacent points, scaled by the maximum difference in the profile (0.0 < slope < 1.0). Adds points in regions of high slope.
  • curve – maximum difference in slope between two adjacent intervals, scaled by the maximum difference in the profile (0.0 < curve < 1.0). Adds points in regions of high curvature.
  • prune – if the slope or curve criteria are satisfied to the level of ‘prune’, the grid point is assumed not to be needed and is removed. Set prune significantly smaller than ‘slope’ and ‘curve’. Set to zero to disable pruning the grid.
>>> s.setRefineCriteria(d, ratio=5.0, slope=0.2, curve=0.3,
...                     prune=0.03)
setTimeStep(stepsize, nsteps)

Set the sequence of time steps to try when Newton fails.

Parameters:
  • stepsize – initial time step size [s]
  • nsteps – sequence of integer step numbers
>>> s.setTimeStep(1.0e-5, [1, 2, 5, 10])
setTimeStepLimits(tsmin, tsmax)

Set the maximum and minimum time steps.

setValue(dom, comp, localPoint, value)

Set the value of one component in one domain at one point to ‘value’.

Parameters:
  • dom – domain object
  • comp – component number
  • localPoint – grid point number within domain dom starting with zero on the left
  • value – numerical value
>>> s.set(d, 3, 5, 6.7)
showSolution(fname='-')

Show the current solution. If called with no argument, the solution is printed to the screen. If a filename is supplied, it is written to the file.

>>> s.showSolution()
>>> s.showSolution('soln.txt')
showStats(printTime=1)

Show the statistics for the last solution. If invoked with no arguments or with a non-zero argument, the timing statistics will be printed. If invoked with a zero argument, the timing will not be printed. Default: print timing enabled.

solve(loglevel=1, refine_grid=1)

Solve the problem.

Parameters:
  • loglevel – integer flag controlling the amount of diagnostic output. Zero suppresses all output, and 5 produces very verbose output. Default: 1
  • refine_grid – if non-zero, enable grid refinement.
timeStepFactor(tfactor)

Set the factor by which the time step will be increased after a successful step, or decreased after an unsuccessful one.

>>> s.timeStepFactor(3.0)
value(domain, component, localPoint)

Solution value at one point.

Parameters:
  • domain – domain object
  • component – component name
  • localPoint – grid point number in the domain, starting with zero at the left
>>> t = s.value(flow, 'T', 6)
workValue(dom, icomp, localPoint)

Internal work array value at one point. After calling eval, this array contains the values of the residual function.

Parameters:
  • domain – domain object
  • component – component name
  • localPoint – grid point number in the domain, starting with zero at the left
>>> t = s.value(flow, 'T', 6)
class Cantera.OneD.BurnerDiffFlame.BurnerDiffFlame(gas=None, burner=None, outlet=None, grid=None)

Bases: Cantera.OneD.onedim.Stack

A burner-stabilized flat flame.

Parameters:
  • gas – object to use to evaluate all gas properties and reaction rates. Required
  • burner – Inlet object representing the burner. Optional; if not supplied, one will be created with name ‘burner’
  • outlet – Outlet object representing the outlet. Optional; if not supplied, one will be created with name ‘outlet’
  • grid – array of initial grid points

A domain of type AxisymmetricFlow named ‘flame’ will be created to represent the flame. The three domains comprising the stack are stored as self.burner, self.flame, and self.outlet.

T(point=-1)

Temperature profile or value at one point.

V(point=-1)

Radial velocity profile or value at one point.

init()

Set the initial guess for the solution. The adiabatic flame temperature and equilibrium composition are computed for the burner gas composition. The temperature profile rises linearly in the first 20% of the flame to Tad, then is flat. The mass fraction profiles are set similarly.

set(tol=None, energy='', tol_time=None)

Set parameters.

Parameters:
  • tol – (rtol, atol) for steady-state
  • tol_time – (rtol, atol) for time stepping
  • energy'on' or 'off' to enable or disable the energy equation
setGasState(j)

Set the state of the object representing the gas to the current solution at grid point j.

setGridMin(gridmin)

Set the minimum allowable grid spacing in a domain.

Parameters:
  • domain – domain object
  • gridmin – The minimum allowable grid spacing [m] for this domain
setProfile(component, locs, vals)

Set an initial estimate for a profile of one component in one domain.

Parameters:
  • dom – domain object
  • comp – component name
  • pos – sequence of relative positions, from 0 on the left to 1 on the right
  • v – sequence of values at the relative positions specified in ‘pos’
>>> s.setProfile(d, 'T', [0.0, 0.2, 1.0], [400.0, 800.0, 1500.0])
setRefineCriteria(ratio=10.0, slope=0.8, curve=0.8, prune=0.0)

Set the criteria used to refine one domain.

Parameters:
  • domain – domain object
  • ratio – additional points will be added if the ratio of the spacing on either side of a grid point exceeds this value
  • slope – maximum difference in value between two adjacent points, scaled by the maximum difference in the profile (0.0 < slope < 1.0). Adds points in regions of high slope.
  • curve – maximum difference in slope between two adjacent intervals, scaled by the maximum difference in the profile (0.0 < curve < 1.0). Adds points in regions of high curvature.
  • prune – if the slope or curve criteria are satisfied to the level of ‘prune’, the grid point is assumed not to be needed and is removed. Set prune significantly smaller than ‘slope’ and ‘curve’. Set to zero to disable pruning the grid.
>>> s.setRefineCriteria(d, ratio=5.0, slope=0.2, curve=0.3,
...                     prune=0.03)
solution(component='', point=-1)

Solution component at one point, or full profile if no point specified.

solve(loglevel=1, refine_grid=1)

Solve the problem.

Parameters:
  • loglevel – integer flag controlling the amount of diagnostic output. Zero suppresses all output, and 5 produces very verbose output. Default: 1
  • refine_grid – if non-zero, enable grid refinement.
u(point=-1)

Axial velocity profile or value at one point.

class Cantera.OneD.BurnerFlame.BurnerFlame(gas=None, burner=None, outlet=None, grid=None)

Bases: Cantera.OneD.onedim.Stack

A burner-stabilized flat flame.

Parameters:
  • gas – object to use to evaluate all gas properties and reaction rates. Required
  • burner – Inlet object representing the burner. Optional; if not supplied, one will be created with name burner
  • outlet – Outlet object representing the outlet. Optional; if not supplied, one will be created with name outlet
  • grid – array of initial grid points

A domain of type AxisymmetricFlow named flame will be created to represent the flame. The three domains comprising the stack are stored as self.burner, self.flame, and self.outlet.

T(point=-1)

Temperature profile or value at one point.

V(point=-1)

Radial velocity profile or value at one point.

init()

Set the initial guess for the solution. The adiabatic flame temperature and equilibrium composition are computed for the burner gas composition. The temperature profile rises linearly in the first 20% of the flame to Tad, then is flat. The mass fraction profiles are set similarly.

set(tol=None, energy='', tol_time=None)

Set parameters.

Parameters:
  • tol – (rtol, atol) for steady-state
  • tol_time – (rtol, atol) for time stepping
  • energy'on' or 'off' to enable or disable the energy equation
setGasState(j)

Set the state of the object representing the gas to the current solution at grid point j.

setGridMin(gridmin)

Set the minimum allowable grid spacing in a domain.

Parameters:
  • domain – domain object
  • gridmin – The minimum allowable grid spacing [m] for this domain
setProfile(component, locs, vals)

Set an initial estimate for a profile of one component in one domain.

Parameters:
  • dom – domain object
  • comp – component name
  • pos – sequence of relative positions, from 0 on the left to 1 on the right
  • v – sequence of values at the relative positions specified in ‘pos’
>>> s.setProfile(d, 'T', [0.0, 0.2, 1.0], [400.0, 800.0, 1500.0])
setRefineCriteria(ratio=10.0, slope=0.8, curve=0.8, prune=0.0)

Set the criteria used to refine one domain.

Parameters:
  • domain – domain object
  • ratio – additional points will be added if the ratio of the spacing on either side of a grid point exceeds this value
  • slope – maximum difference in value between two adjacent points, scaled by the maximum difference in the profile (0.0 < slope < 1.0). Adds points in regions of high slope.
  • curve – maximum difference in slope between two adjacent intervals, scaled by the maximum difference in the profile (0.0 < curve < 1.0). Adds points in regions of high curvature.
  • prune – if the slope or curve criteria are satisfied to the level of ‘prune’, the grid point is assumed not to be needed and is removed. Set prune significantly smaller than ‘slope’ and ‘curve’. Set to zero to disable pruning the grid.
>>> s.setRefineCriteria(d, ratio=5.0, slope=0.2, curve=0.3,
...                     prune=0.03)
solution(component='', point=-1)

Solution component at one point, or full profile if no point specified.

solve(loglevel=1, refine_grid=1)

Solve the problem.

Parameters:
  • loglevel – integer flag controlling the amount of diagnostic output. Zero suppresses all output, and 5 produces very verbose output. Default: 1
  • refine_grid – if non-zero, enable grid refinement.
u(point=-1)

Axial velocity profile or value at one point.

class Cantera.OneD.CounterFlame.CounterFlame(gas=None, grid=None)

Bases: Cantera.OneD.onedim.Stack

A non-premixed counterflow flame.

The domains are:

[self.fuel_inlet,      # class Inlet,
self.flame, # class AxisymmetricFlow, self.oxidizer_inlet] # class Inlet
T(point=-1)

The temperature [K]

V(point=-1)

The radial velocity divided by radius [s^-1]

init(fuel='', oxidizer='O2', stoich=-1.0)

Set the initial guess for the solution. The fuel species must be specified, and the oxidizer may be

>>> f.init(fuel='CH4')

The initial guess is generated by assuming infinitely-fast chemistry.

set(tol=None, energy='', tol_time=None)

Set parameters.

Parameters:
  • tol – (rtol, atol) for steady-state
  • tol_time – (rtol, atol) for time stepping
  • energy – ‘on’ or ‘off’ to enable or disable the energy equation
setGasState(j)

Set the state of the object representing the gas to the current solution at grid point j.

setGridMin(gridmin)

Set the minimum allowable grid spacing in a domain.

Parameters:
  • domain – domain object
  • gridmin – The minimum allowable grid spacing [m] for this domain
setProfile(component, locs, vals)

Set an initial estimate for a profile of one component in one domain.

Parameters:
  • dom – domain object
  • comp – component name
  • pos – sequence of relative positions, from 0 on the left to 1 on the right
  • v – sequence of values at the relative positions specified in ‘pos’
>>> s.setProfile(d, 'T', [0.0, 0.2, 1.0], [400.0, 800.0, 1500.0])
setRefineCriteria(ratio=10.0, slope=0.8, curve=0.8, prune=0.0)

Set the criteria used to refine one domain.

Parameters:
  • domain – domain object
  • ratio – additional points will be added if the ratio of the spacing on either side of a grid point exceeds this value
  • slope – maximum difference in value between two adjacent points, scaled by the maximum difference in the profile (0.0 < slope < 1.0). Adds points in regions of high slope.
  • curve – maximum difference in slope between two adjacent intervals, scaled by the maximum difference in the profile (0.0 < curve < 1.0). Adds points in regions of high curvature.
  • prune – if the slope or curve criteria are satisfied to the level of ‘prune’, the grid point is assumed not to be needed and is removed. Set prune significantly smaller than ‘slope’ and ‘curve’. Set to zero to disable pruning the grid.
>>> s.setRefineCriteria(d, ratio=5.0, slope=0.2, curve=0.3,
...                     prune=0.03)
solution(component='', point=-1)

The solution for one specified component. If a point number is given, return the value of component ‘component’ at this point. Otherwise, return the entire profile for this component.

solve(loglevel=1, refine_grid=1)

Solve the problem.

Parameters:
  • loglevel – integer flag controlling the amount of diagnostic output. Zero suppresses all output, and 5 produces very verbose output. Default: 1
  • refine_grid – if non-zero, enable grid refinement.
u(point=-1)

The axial velocity [m/s]