Cantera

Previous topic

Transport Properties

Next topic

Zero-Dimensional Reactors

This Page

Warning

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

Composite Classes

These classes are composite representations of a substance which has thermodynamic, chemical kinetic, and transport properties.

class Cantera.Solution(src='', id='', loglevel=0, debug=0)

Bases: Cantera.ThermoPhase.ThermoPhase, Cantera.Kinetics.Kinetics, Cantera.Transport.Transport

A class for chemically-reacting solutions.

Instances can be created to represent any type of solution – a mixture of gases, a liquid solution, or a solid solution, for example.

Class Solution derives from classes ThermoPhase, Kinetics, and Transport. It defines very few methods of its own, and is provided largely for convenience, so that a single object can be used to compute thermodynamic, kinetic, and transport properties of a solution. Functions like IdealGasMix() and others defined in module gases return objects of class Solution.

name()
set(**options)

Set various properties.

Parameters:
  • T – temperature [K]
  • P – pressure [Pa]
  • Rho – density [kg/m3]
  • V – specific volume [m3/kg]
  • H – specific enthalpy [J/kg]
  • U – specific internal energy [J/kg]
  • S – specific entropy [J/kg/K]
  • X – mole fractions (string or array)
  • Y – mass fractions (string or array)
  • Vapor – saturated vapor fraction
  • Liquid – saturated liquid fraction
class Cantera.Interface.Interface(src='', root=None, phases=[], debug=0)

Bases: Cantera.SurfacePhase.SurfacePhase, Cantera.Kinetics.Kinetics

Two-dimensional interfaces.

Instances of class Interface represent reacting 2D interfaces between bulk 3D phases. Class Interface defines no methods of its own. All of its methods derive from either SurfacePhase or Kinetics.

Function importInterface() should usually be used to build an Interface object from a CTI file definition, rather than calling the Interface constructor directly.

Parameters:
  • src – CTML or CTI input file name. If more than one phase is defined in the file, src should be specified as filename#id If the file is not CTML, it will be run through the CTI -> CTML preprocessor first.
  • root – If a CTML tree has already been read in that contains the definition of this interface, the root of this tree can be specified instead of specifying src.
  • phases – A list of all objects representing the neighboring phases which participate in the reaction mechanism.
class Cantera.Edge.Edge(src='', root=None, surfaces=[])

Bases: Cantera.SurfacePhase.EdgePhase, Cantera.Kinetics.Kinetics

One-dimensional edge between two surfaces.

Instances of class Edge represent reacting 1D edges between between 2D surfaces. Class Edge defines no methods of its own. All of its methods derive from either EdgePhase or Kinetics.

Function importInterface() should usually be used to build an Edge object from a CTI file definition, rather than calling the Edge constructor directly.

Parameters:
  • src – CTML or CTI input file name. If more than one phase is defined in the file, src should be specified as filename#id If the file is not CTML, it will be run through the CTI -> CTML preprocessor first.
  • root – If a CTML tree has already been read in that contains the definition of this interface, the root of this tree can be specified instead of specifying src.
  • phases – A list of all objects representing the neighboring surface phases which participate in the reaction mechanism.
class Cantera.Mixture(phases=[])

Multiphase mixtures. Class Mixture represents mixtures of one or more phases of matter. To construct a mixture, supply a list of phases to the constructor, each paired with the number of moles for that phase:

>>> gas = importPhase('gas.cti')
>>> gas.speciesNames()
['H2', 'H', 'O2', 'O', 'OH']
>>> graphite = importPhase('graphite.cti')
>>> graphite.speciesNames()
['C(g)']
>>> mix = Mixture([(gas, 1.0), (graphite, 0.1)])
>>> mix.speciesNames()
['H2', 'H', 'O2', 'O', 'OH', 'C(g)']

Note that the objects representing each phase compute only the intensive state of the phase – they do not store any information on the amount of this phase. Mixture objects, on the other hand, represent the full extensive state.

Mixture objects are ‘lightweight’ in the sense that they do not store parameters needed to compute thermodynamic or kinetic properties of the phases. These are contained in the (‘heavyweight’) phase objects. Multiple mixture objects may be constructed using the same set of phase objects. Each one stores its own state information locally, and synchronizes the phases objects whenever it requires phase properties.

charge()

The total charge in Coulombs, summed over all phases.

chemPotentials(species=[])

The chemical potentials of all species [J/kmol].

elementIndex(element)

Index of element with name ‘element’.

>>> mix.elementIndex('H')
2
elementMoles(m)

Total number of moles of element m, summed over all species. The element may be referenced either by index number or by name.

equilibrate(XY='TP', err=1e-09, maxsteps=1000, maxiter=200, loglevel=0)

Set the mixture to a state of chemical equilibrium.

This method uses a version of the VCS algorithm to find the composition that minimizes the total Gibbs free energy of the mixture, subject to element conservation constraints. For a description of the theory, see Smith and Missen, “Chemical Reaction Equilibrium.” The VCS algorithm is implemented in Cantera kernel class MultiPhaseEquil.

The VCS algorithm solves for the equilibrium composition for specified temperature and pressure. If any other property pair other than TP is specified, then an outer iteration loop is used to adjust T and/or P so that the specified property values are obtained.

Parameters:
  • XY – Two-letter string specifying the two properties to hold fixed. Currently, 'TP', 'HP', and 'SP' are implemented. Default: 'TP'.
  • err – Error tolerance. Iteration will continue until (Delta mu)/RT is less than this value for each reaction. Default: 1.0e-9. Note that this default is very conservative, and good equilibrium solutions may be obtained with larger error tolerances.
  • maxsteps – Maximum number of steps to take while solving the equilibrium problem for specified T and P. Default: 1000.
  • maxiter – Maximum number of temperature and/or pressure iterations. This is only relevant if a property pair other than (T,P) is specified. Default: 200.
  • loglevel – Controls the amount of diagnostic output. If loglevel = 0, no diagnostic output is written. For values > 0, more detailed information is written to the log file as loglevel increases. The default is loglevel = 0. The logfile is written in HTML format, and may be viewed with any web browser. The default log file name is equilibrium_log.html, but if this file exists, the log information will be written to “equilibrium_log{n}.html”, where {n} is an integer chosen so that the log file does not already exist. Therefore, if ‘equilibrate’ is called multiple times, multiple log files will be written, with names equilibrate_log.html, equilibrate_log1.html, equilibrate_log2.html, and so on. Existing log files will not be overwritten.
>>> mix.equilibrate('TP')
>>> mix.equilibrate('TP', err = 1.0e-6, maxiter = 500)
maxTemp()

The maximum temperature for which all species in multi-species solutions have valid thermo data. Stoichiometric phases are not considered in determining maxTemp.

minTemp()

The minimum temperature for which all species in multi-species solutions have valid thermo data. Stoichiometric phases are not considered in determining minTemp.

nAtoms(k, m)

Number of atoms of element m in species k. Both the species and the element may be referenced either by name or by index number.

>>> n = mix.nAtoms('CH4','H')
4.0
nElements()

Total number of elements present in the mixture.

nPhases()

Total number of phases defined for the mixture.

nSpecies()

Total number of species present in the mixture. This is the sum of the numbers of species in each phase.

phase(n)

Return the object representing the nth phase in the mixture.

phaseCharge(p)

The charge of phase p (Coulombs).

phaseIndex(phase)

Index of phase with name phase

phaseMoles(n=-1)

Moles of phase n.

phaseName(n)

Name of phase n.

phaseNames()

Names of all phases in the order added.

pressure()

The pressure [Pa].

selectSpecies(f, species)

Given an array f of floating-point species properties, return an array of those values corresponding to species listed in species. This method is used internally to implement species selection in methods like moleFractions(), massFractions(), etc.

>>> f = mix.chemPotentials()
>>> muo2, muh2 = mix.selectSpecies(f, ['O2', 'H2'])
set(**p)
setPhaseMoles(n, moles)

Set the number of moles of phase n.

setPressure(p)

Set the pressure [Pa]. The pressures of all phases are set to the specified value, holding the temperature fixed.

setSpeciesMoles(moles)

Set the moles of the species [kmol]. The moles may be specified either as a string, or as an array. If an array is used, it must be dimensioned at least as large as the total number of species in the mixture. Note that the species may belong to any phase, and unspecified species are set to zero.

>>> mix.setSpeciesMoles('C(s):1.0, CH4:2.0, O2:0.2')
setTemperature(t)

Set the temperature [K]. The temperatures of all phases are set to this value, holding the pressure fixed.

speciesIndex(species)

Index of species with name species. If species is not a string, then it is simply returned.

speciesMoles(species='')

Moles of species k.

speciesName(k)

Name of the species with index k. Note that index numbers are assigned in order as phases are added.

speciesNames()
temperature()

The temperature [K].

vcs_equilibrate(XY='TP', estimateEquil=0, printLvl=0, solver=2, rtol=1e-09, maxsteps=1000, maxiter=1000, loglevel=0)

Set the mixture to a state of chemical equilibrium.

This method uses a version of the VCS algorithm to find the composition that minimizes the total Gibbs free energy of the mixture, subject to element conservation constraints. For a description of the theory, see Smith and Missen, “Chemical Reaction Equilibrium.” The VCS algorithm is implemented in Cantera kernel class MultiPhaseEquil.

The VCS algorithm solves for the equilibrium composition for specified temperature and pressure. If any other property pair other than 'TP' is specified, then an outer iteration loop is used to adjust T and/or P so that the specified property values are obtained.

Parameters:
  • XY – Two-letter string specifying the two properties to hold fixed. Currently, 'TP', 'HP', and 'SP' are implemented. Default: 'TP'.
  • printLvl – Controls the amount of diagnostic output written to cout. If printLvl = 0, no diagnostic output is written. For values > 0, more detailed information is written to cout. The default is printLvl = 0.
  • solver
    Determines which solver is used.
    • 1 MultiPhaseEquil solver
    • 2 VCSnonideal Solver (default)
  • err – Error tolerance. Iteration will continue until (Delta mu)/RT is less than this value for each reaction. Default: 1.0e-9. Note that this default is very conservative, and good equilibrium solutions May be obtained with larger error tolerances.
  • maxsteps – Maximum number of steps to take while solving the equilibrium problem for specified T and P. Default: 1000.
  • maxiter – Maximum number of temperature and/or pressure iterations. This is only relevant if a property pair other than (T,P) is specified. Default: 200.
  • loglevel – Controls the amount of diagnostic output written to html. If loglevel = 0, no diagnostic output is written. For values > 0, more detailed information is written to the log file as loglevel increases. The default is loglevel = 0. The logfile is written in HTML format, and may be viewed with any web browser. The default log file name is “equilibrium_log.html”, but if this file exists, the log information will be written to “equilibrium_log{n}.html”, where {n} is an integer chosen so that the log file does not already exist. Therefore, if ‘equilibrate’ is called multiple times, multiple log files will be written, with names “equilibrate_log.html”, “equilibrate_log1.html”, “equilibrate_log2.html”, and so on. Existing log files will not be overwritten.