Objects Representing Phases#

Composite Phase Objects#

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

class cantera.Solution(infile='', name='', *, origin=None, yaml=None, thermo=None, species=(), kinetics=None, reactions=())#

Bases: Transport, Kinetics, ThermoPhase

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 no methods of its own, and is provided so that a single object can be used to compute thermodynamic, kinetic, and transport properties of a solution.

To skip initialization of the Transport object, pass the keyword argument transport_model=None to the Solution constructor.

The most common way to instantiate Solution objects is by using a phase definition, species and reactions defined in an input file:

gas = ct.Solution('gri30.yaml')

If an input file defines multiple phases, the corresponding key in the phases map can be used to specify the desired phase via the name keyword argument of the constructor:

gas = ct.Solution('diamond.yaml', name='gas')
diamond = ct.Solution('diamond.yaml', name='diamond')

The name of the Solution object defaults to the phase identifier specified in the input file. Upon initialization of a Solution object, a custom name can assigned via:

gas.name = 'my_custom_name'

Solution objects can also be constructed using Species and Reaction objects which can themselves either be imported from input files or defined directly in Python:

spec = ct.Species.list_from_file("gri30.yaml")
spec_gas = ct.Solution(thermo='ideal-gas', species=spec)
rxns = ct.Reaction.list_from_file("gri30.yaml", spec_gas)
gas = ct.Solution(thermo='ideal-tas', kinetics='gas',
                  species=spec, reactions=rxns, name='my_custom_name')

where the thermo and kinetics keyword arguments are strings specifying the thermodynamic and kinetics model, respectively, and species and reactions keyword arguments are lists of Species and Reaction objects, respectively. Note that importing the reactions from a YAML input file requires a Kinetics object containing the species, as shown.

Types of underlying models that form the composite Solution object are queried using the thermo_model, kinetics_model and transport_model attributes; further, the composite attribute is a shorthand returning a tuple containing the types of the three constitutive models.

For non-trivial uses cases of this functionality, see the examples extract_submechanism.py and mechanism_reduction.py.

In addition, Solution objects can be constructed by passing the text of the YAML phase definition in directly, using the yaml keyword argument:

yaml_def = '''
phases:
- name: gas
  thermo: ideal-gas
  kinetics: gas
  elements: [O, H, Ar]
  species:
  - gri30.yaml/species: all
  reactions:
  - gri30.yaml/reactions: declared-species
  skip-undeclared-elements: true
  skip-undeclared-third-bodies: true
  state: {T: 300, P: 1 atm}
'''
gas = ct.Solution(yaml=yaml_def)
class cantera.solutionbase._SolutionBase#

Bases: object

Class _SolutionBase is a common base class for the ThermoPhase, Kinetics, and Transport classes. Its methods are available for all Solution, Interface, PureFluid, Quantity, and SolutionArray objects as well.

clear_user_data()#

Clear all saved input data, so that the data given by input_data or write_yaml will only include values generated by Cantera based on the current object state.

clear_user_header()#

Clear all saved header data, so that the data given by input_header or write_yaml will only include values generated by Cantera based on the current object state.

composite#

Returns tuple of thermo/kinetics/transport models associated with this SolutionBase object.

input_data#

Get input data corresponding to the current state of this Solution, along with any user-specified data provided with its input (YAML) definition.

input_header#

Retrieve input header data not associated with the current state of this Solution, which corresponds to fields at the root level of the YAML input that are not required for the instantiation of Cantera objects.

name#

The name assigned to this object. The default value corresponds to the YAML input file phase entry.

selected_species#

Get/set the set of species that are included when returning results that have a value for each species, such as species_names, partial_molar_enthalpies, or net_production_rates. The list of selected species can be set by name or index. This property returns the species by index.:

>>> gas.selected_species = ["H2", "O2"]
>>> print(gas.molecular_weights)
[ 2.016 31.998]

This method is often used implicitly by using an indexing expression on a Solution object:

>>> print(gas["H2", "O2"].molecular_weights)
[ 2.016 31.998]
source#

The source of this object (such as a file name).

update_user_data(data)#

Add the contents of the provided dict as additional fields when generating YAML phase definition files with write_yaml or in the data returned by input_data. Existing keys with matching names are overwritten.

update_user_header(data)#

Add the contents of the provided dict as additional top-level YAML fields when generating files with write_yaml or in the data returned by input_header. Existing keys with matching names are overwritten.

write_chemkin(mechanism_path=None, thermo_path=None, transport_path=None, sort_species=None, sort_elements=None, overwrite=False, quiet=False)#

Write this Solution instance to one or more Chemkin-format files. See the documentation for cantera.yaml2ck.convert for information about the arguments to this function.

write_yaml(filename=None, phases=None, units=None, precision=None, skip_user_defined=None, header=True)#

Write the definition for this phase, any additional phases specified, and their species and reactions to the specified file.

Parameters:
  • filename – The name of the output file; if None, a YAML string is returned

  • phases – Additional ThermoPhase / Solution objects to be included in the output file

  • units – A UnitSystem object or dictionary of the units to be used for each dimension. See YamlWriter.output_units.

  • precision – For output floating point values, the maximum number of digits to the right of the decimal point. The default is 15 digits.

  • skip_user_defined – If True, user-defined fields which are not used by Cantera will be stripped from the output. These additional contents can also be controlled using the update_user_data and clear_user_data functions.

  • header – If True, fields of the input_header will be added to the YAML header; note that fields name generator, cantera-version, git-commit and date are reserved, which means that any existing data are replaced by automatically generated content when the file is written.

class cantera.Interface(infile='', name='', adjacent=(), *, origin=None, yaml=None, thermo=None, species=(), kinetics=None, reactions=())#

Bases: InterfaceKinetics, InterfacePhase

Instances of class Interface represent reacting 2D surfaces between bulk 3D phases, or 1D edges where multiple surfaces (and bulk phases) meet. Class Interface defines no methods of its own. All of its methods derive from either InterfacePhase or InterfaceKinetics.

Constructing an Interface object also involves constructing adjacent bulk phases that participate in reactions. This is done automatically if the adjacent phases are specified as part of the adjacent-phases entry in the YAML phase definition:

diamond_surf = ct.Interface("diamond.yaml", name="diamond_100")
gas = diamond_surf.adjacent["gas"]
diamond = diamond_surf.adjacent["diamond"]

This behavior can be overridden by specifying the adjacent phases explicitly, either using their name in the input file, or by constructing corresponding Solution objects:

gas = ct.Solution("diamond.yaml", name="gas")
diamond = ct.Solution("diamond.yaml", name="diamond")
diamond_surf = ct.Interface("diamond.yaml", name="diamond_100",
                            adjacent=[gas, diamond])
class cantera.DustyGas(infile, name='')#

Bases: DustyGasTransport, Kinetics, ThermoPhase

A composite class which models a gas in a stationary, solid, porous medium.

The only transport properties computed are the multicomponent diffusion coefficients. The model does not compute viscosity or thermal conductivity.

Pure Fluid Phases#

The following convenience functions can be used to create PureFluid objects with the indicated equation of state:

cantera.CarbonDioxide()#

Create a PureFluid object using the equation of state for carbon dioxide.

The object returned by this method implements an accurate equation of state for carbon dioxide that can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram. The equation of state is taken from

W. C. Reynolds, Thermodynamic Properties in SI: graphs, tables, and computational equations for forty substances. Stanford: Stanford University, 1979. Print.

For more details, see classes PureFluidPhase and tpx::CarbonDioxide in the Cantera C++ source code documentation.

cantera.Heptane()#

Create a PureFluid object using the equation of state for heptane.

The object returned by this method implements an accurate equation of state for n-heptane that can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram. The equation of state is taken from

W. C. Reynolds, Thermodynamic Properties in SI: graphs, tables, and computational equations for forty substances. Stanford: Stanford University, 1979. Print.

For more details, see classes PureFluidPhase and tpx::Heptane in the Cantera C++ source code documentation.

cantera.Hfc134a()#

Create a PureFluid object using the equation of state for HFC-134a.

The object returned by this method implements an accurate equation of state for refrigerant HFC134a (R134a) that can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram. Implements the equation of state given in:

R. Tillner-Roth, H. D. Baehr. An International Standard Formulation for The Thermodynamic Properties of 1,1,1,2-Tetrafluoroethane (HFC-134a) for Temperatures From 170 K to 455 K and Pressures up to 70 MPa. J. Phys. Chem. Ref. Data, Vol. 23, No. 5, 1994. pp. 657–729. http://dx.doi.org/10.1063/1.555958

For more details, see classes PureFluidPhase and tpx::HFC134a in the Cantera C++ source code documentation.

cantera.Hydrogen()#

Create a PureFluid object using the equation of state for hydrogen.

The object returned by this method implements an accurate equation of state for hydrogen that can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram. The equation of state is taken from

W. C. Reynolds, Thermodynamic Properties in SI: graphs, tables, and computational equations for forty substances Stanford: Stanford University, 1979. Print.

For more details, see classes PureFluidPhase and tpx::hydrogen in the Cantera C++ source code documentation.

cantera.Methane()#

Create a PureFluid object using the equation of state for methane.

The object returned by this method implements an accurate equation of state for methane that can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram. The equation of state is taken from

W. C. Reynolds, Thermodynamic Properties in SI: graphs, tables, and computational equations for forty substances Stanford: Stanford University, 1979. Print.

For more details, see classes PureFluidPhase and tpx::methane in the Cantera C++ source code documentation.

cantera.Nitrogen()#

Create a PureFluid object using the equation of state for nitrogen.

The object returned by this method implements an accurate equation of state for nitrogen that can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram. The equation of state is taken from

W. C. Reynolds, Thermodynamic Properties in SI: graphs, tables, and computational equations for forty substances Stanford: Stanford University, 1979. Print.

For more details, see classes PureFluidPhase and tpx::nitrogen in the Cantera C++ source code documentation.

cantera.Oxygen()#

Create a PureFluid object using the equation of state for oxygen.

The object returned by this method implements an accurate equation of state for oxygen that can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram. The equation of state is taken from

W. C. Reynolds, Thermodynamic Properties in SI: graphs, tables, and computational equations for forty substances Stanford: Stanford University, 1979. Print.

For more details, see classes PureFluidPhase and tpx::oxygen in the Cantera C++ source code documentation.

cantera.Water(backend='Reynolds')#

Create a PureFluid object using the equation of state for water and the WaterTransport class for viscosity and thermal conductivity.

The object returned by this method implements an accurate equation of state for water, where implementations are selected using the backend switch.

For the Reynolds backend, the equation of state is taken from

W. C. Reynolds, Thermodynamic Properties in SI: graphs, tables, and computational equations for forty substances. Stanford: Stanford University, 1979. Print.

which can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram.

The IAPWS95 backend implements an IAPWS (International Association for the Properties of Water and Steam) formulation for thermodynamic properties taken from

W. Wagner, A. Pruss, The IAPWS Formulation 1995 for the Thermodynamic Properties of Ordinary Water Substance for General and Scientific Use, J. Phys. Chem. Ref. Dat, 31, 387, 2002.

which currently only implements liquid and supercritical regions.

In both cases, formulas for transport are taken from

J. V. Sengers, J. T. R. Watson, Improved International Formulations for the Viscosity and Thermal Conductivity of Water Substance, J. Phys. Chem. Ref. Data, 15, 1291, 1986.

For more details, see classes PureFluidPhase, tpx::water, WaterSSTP and WaterTransport in the Cantera C++ source code documentation.

Representing Quantities of Phases#

class cantera.Quantity(phase, mass=None, moles=None, constant='UV')#

Bases: object

A class representing a specific quantity of a Solution. In addition to the properties which can be computed for class Solution, class Quantity provides several additional capabilities. A Quantity object is created from a Solution with either the mass or number of moles specified:

>>> gas = ct.Solution('gri30.yaml')
>>> gas.TPX = 300, 5e5, 'O2:1.0, N2:3.76'
>>> q1 = ct.Quantity(gas, mass=5) # 5 kg of air

The state of a Quantity can be changed in the same way as a Solution:

>>> q1.TP = 500, 101325

Quantities have properties which provide access to extensive properties:

>>> q1.volume
7.1105094
>>> q1.enthalpy
1032237.84

The size of a Quantity can be changed by setting the mass or number of moles:

>>> q1.moles = 3
>>> q1.mass
86.552196
>>> q1.volume
123.086

or by multiplication:

>>> q1 *= 2
>>> q1.moles
6.0

Finally, Quantities can be added, providing an easy way of calculating the state resulting from mixing two substances:

>>> q1.mass = 5
>>> q2 = ct.Quantity(gas)
>>> q2.TPX = 300, 101325, 'CH4:1.0'
>>> q2.mass = 1
>>> q3 = q1 + q2 # combine at constant UV
>>> q3.T
432.31234
>>> q3.P
97974.9871
>>> q3.mole_fraction_dict()
{'CH4': 0.26452900448117395,
 'N2': 0.5809602821745349,
 'O2': 0.1545107133442912}

If a different property pair should be held constant when combining, this can be specified as follows:

>>> q1.constant = q2.constant = 'HP'
>>> q3 = q1 + q2 # combine at constant HP
>>> q3.T
436.03320
>>> q3.P
101325.0
property CK_mode#

Boolean to indicate if the chemkin interpretation is used.

property DP#

Get/Set density [kg/m^3] and pressure [Pa].

property DPX#

Get/Set density [kg/m^3], pressure [Pa], and mole fractions.

property DPY#

Get/Set density [kg/m^3], pressure [Pa], and mass fractions.

property G#

Get the total Gibbs free energy [J] represented by the Quantity.

property H#

Get the total enthalpy [J] represented by the Quantity.

property HP#

Get/Set enthalpy [J/kg or J/kmol] and pressure [Pa].

property HPX#

Get/Set enthalpy [J/kg or J/kmol], pressure [Pa] and mole fractions.

property HPY#

Get/Set enthalpy [J/kg or J/kmol], pressure [Pa] and mass fractions.

property P#

Pressure [Pa].

property P_sat#

Saturation pressure [Pa] at the current temperature.

property Pe#

Get electron Pressure [Pa].

property S#

Get the total entropy [J/K] represented by the Quantity.

property SP#

Get/Set entropy [J/kg/K or J/kmol/K] and pressure [Pa].

property SPX#

Get/Set entropy [J/kg/K or J/kmol/K], pressure [Pa], and mole fractions.

property SPY#

Get/Set entropy [J/kg/K or J/kmol/K], pressure [Pa], and mass fractions.

property SV#

Get/Set entropy [J/kg/K or J/kmol/K] and specific volume [m^3/kg or m^3/kmol].

property SVX#

Get/Set entropy [J/kg/K or J/kmol/K], specific volume [m^3/kg or m^3/kmol], and mole fractions.

property SVY#

Get/Set entropy [J/kg/K or J/kmol/K], specific volume [m^3/kg or m^3/kmol], and mass fractions.

property T#

Temperature [K].

property TD#

Get/Set temperature [K] and density [kg/m^3 or kmol/m^3].

property TDX#

Get/Set temperature [K], density [kg/m^3 or kmol/m^3], and mole fractions.

property TDY#

Get/Set temperature [K] and density [kg/m^3 or kmol/m^3], and mass fractions.

property TP#

Get/Set temperature [K] and pressure [Pa].

property TPX#

Get/Set temperature [K], pressure [Pa], and mole fractions.

property TPY#

Get/Set temperature [K], pressure [Pa], and mass fractions.

property T_sat#

Saturation temperature [K] at the current pressure.

property Te#

Get/Set electron Temperature [K].

property U#

Get the total internal energy [J] represented by the Quantity.

property UV#

Get/Set internal energy [J/kg or J/kmol] and specific volume [m^3/kg or m^3/kmol].

property UVX#

Get/Set internal energy [J/kg or J/kmol], specific volume [m^3/kg or m^3/kmol], and mole fractions.

property UVY#

Get/Set internal energy [J/kg or J/kmol], specific volume [m^3/kg or m^3/kmol], and mass fractions.

property V#

Get the total volume [m^3] represented by the Quantity.

property X#

Get/Set the species mole fractions. Can be set as an array, as a dictionary, or as a string. Always returns an array:

>>> phase.X = [0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5]
>>> phase.X = {'H2':0.1, 'O2':0.4, 'AR':0.5}
>>> phase.X = 'H2:0.1, O2:0.4, AR:0.5'
>>> phase.X
array([0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5])
property Y#

Get/Set the species mass fractions. Can be set as an array, as a dictionary, or as a string. Always returns an array:

>>> phase.Y = [0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5]
>>> phase.Y = {'H2':0.1, 'O2':0.4, 'AR':0.5}
>>> phase.Y = 'H2:0.1, O2:0.4, AR:0.5'
>>> phase.Y
array([0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5])
property activities#

Array of nondimensional activities. Returns either molar or molal activities depending on the convention of the thermodynamic model.

property activity_coefficients#

Array of nondimensional, molar activity coefficients.

add_reaction(*args, **kwargs)#

Add a new reaction to this phase.

add_species(*args, **kwargs)#

Add a new species to this phase. Missing elements will be added automatically.

add_species_alias(*args, **kwargs)#

Add the alternate species name alias for an original species name.

atomic_weight(*args, **kwargs)#

Atomic weight [kg/kmol] of element m

property atomic_weights#

Array of atomic weight [kg/kmol] for each element in the mixture.

property auxiliary_data#

Intermediate or model-specific parameters used by particular derived classes.

property basis#

Determines whether intensive thermodynamic properties are treated on a mass (per kg) or molar (per kmol) basis. This affects the values returned by the properties h, u, s, g, v, density, cv, and cp, as well as the values used with the state-setting properties such as HPX and UV.

property binary_diff_coeffs#

Binary diffusion coefficients [m^2/s].

property case_sensitive_species_names#

Enforce case-sensitivity for look up of species names

property charges#

Array of species charges [elem. charge].

property chemical_potentials#

Array of species chemical potentials [J/kmol].

clear_user_data(*args, **kwargs)#

Clear all saved input data, so that the data given by input_data or write_yaml will only include values generated by Cantera based on the current object state.

clear_user_header(*args, **kwargs)#

Clear all saved header data, so that the data given by input_header or write_yaml will only include values generated by Cantera based on the current object state.

property composite#

Returns tuple of thermo/kinetics/transport models associated with this SolutionBase object.

property concentrations#

Get/Set the species concentrations. Units are kmol/m^3 for bulk phases, kmol/m^2 for surface phases, and kmol/m for edge phases.

constant#
property cp#

Heat capacity at constant pressure [J/kg/K or J/kmol/K] depending on basis.

property cp_mass#

Specific heat capacity at constant pressure [J/kg/K].

property cp_mole#

Molar heat capacity at constant pressure [J/kmol/K].

property creation_rates#

Creation rates for each species. [kmol/m^3/s] for bulk phases or [kmol/m^2/s] for surface phases.

property creation_rates_ddC#

Calculate derivatives of species creation rates with respect to molar concentration at constant temperature, pressure and mole fractions.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property creation_rates_ddCi#

Calculate derivatives for species creation rates with respect to species concentration at constant temperature, pressure, and concentration of all other species. For sparse output, set ct.use_sparse(True).

The method returns a matrix with n_total_species rows and n_total_species columns.

For a derivative with respect to :math: c_i, all other :math: c_i are held constant.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

Added in version 3.0.

property creation_rates_ddP#

Calculate derivatives of species creation rates with respect to pressure at constant temperature, molar concentration and mole fractions.

property creation_rates_ddT#

Calculate derivatives of species creation rates with respect to temperature at constant pressure, molar concentration and mole fractions.

property creation_rates_ddX#

Calculate derivatives for species creation rates with respect to species concentrations at constant temperature, pressure and molar concentration. For sparse output, set ct.use_sparse(True).

Note that for derivatives with respect to \(X_i\), all other \(X_j\) are held constant, rather than enforcing \(\sum X_j = 1\).

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property critical_density#

Critical density [kg/m^3 or kmol/m^3] depending on basis.

property critical_pressure#

Critical pressure [Pa].

property critical_temperature#

Critical temperature [K].

property cv#

Heat capacity at constant volume [J/kg/K or J/kmol/K] depending on basis.

property cv_mass#

Specific heat capacity at constant volume [J/kg/K].

property cv_mole#

Molar heat capacity at constant volume [J/kmol/K].

property delta_enthalpy#

Change in enthalpy for each reaction [J/kmol].

property delta_entropy#

Change in entropy for each reaction [J/kmol/K].

property delta_gibbs#

Change in Gibbs free energy for each reaction [J/kmol].

property delta_standard_enthalpy#

Change in standard-state enthalpy (independent of composition) for each reaction [J/kmol].

property delta_standard_entropy#

Change in standard-state entropy (independent of composition) for each reaction [J/kmol/K].

property delta_standard_gibbs#

Change in standard-state Gibbs free energy (independent of composition) for each reaction [J/kmol].

property density#

Density [kg/m^3 or kmol/m^3] depending on basis.

property density_mass#

(Mass) density [kg/m^3].

property density_mole#

Molar density [kmol/m^3].

property derivative_settings#

Property setting behavior of derivative evaluation.

For BulkKinetics, the following keyword/value pairs are supported:

  • skip-third-bodies (boolean) … if False (default), third body concentrations are considered for the evaluation of derivatives

  • skip-falloff (boolean) … if True (default), third-body effects on reaction rates are not considered.

  • rtol-delta (double) … relative tolerance used to perturb properties when calculating numerical derivatives. The default value is 1e-8.

Derivative settings are updated using a dictionary:

>>> gas.derivative_settings = {"skip-falloff": True}

Passing an empty dictionary will reset all values to their defaults.

property destruction_rates#

Destruction rates for each species. [kmol/m^3/s] for bulk phases or [kmol/m^2/s] for surface phases.

property destruction_rates_ddC#

Calculate derivatives of species destruction rates with respect to molar concentration at constant temperature, pressure and mole fractions.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property destruction_rates_ddCi#

Calculate derivatives for species destruction rates with respect to species concentration at constant temperature, pressure, and concentration of all other species. For sparse output, set ct.use_sparse(True).

The method returns a matrix with n_total_species rows and n_total_species columns. For a derivative with respect to :math: c_i, all other :math: c_i are held constant.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

Added in version 3.0.

property destruction_rates_ddP#

Calculate derivatives of species destruction rates with respect to pressure at constant temperature, molar concentration and mole fractions.

property destruction_rates_ddT#

Calculate derivatives of species destruction rates with respect to temperature at constant pressure, molar concentration and mole fractions.

property destruction_rates_ddX#

Calculate derivatives for species destruction rates with respect to species concentrations at constant temperature, pressure and molar concentration. For sparse output, set ct.use_sparse(True).

Note that for derivatives with respect to \(X_i\), all other \(X_j\) are held constant, rather than enforcing \(\sum X_j = 1\).

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property electric_potential#

Get/Set the electric potential [V] for this phase.

property electrical_conductivity#

Electrical conductivity. [S/m].

property electrochemical_potentials#

Array of species electrochemical potentials [J/kmol].

property electron_energy_distribution#

Electron energy distribution

property electron_energy_distribution_type#

Electron energy distribution type

property electron_energy_levels#

Electron energy levels [eV]

property electron_species_name#

Electron species name

element_index(*args, **kwargs)#

The index of element element, which may be specified as a string or an integer. In the latter case, the index is checked for validity and returned. If no such element is present, an exception is thrown.

element_name(*args, **kwargs)#

Name of the element with index m.

property element_names#

A list of all the element names.

elemental_mass_fraction(*args, **kwargs)#

Get the elemental mass fraction \(Z_{\mathrm{mass},m}\) of element \(m\) as defined by:

\[Z_{\mathrm{mass},m} = \sum_k \frac{a_{m,k} M_m}{M_k} Y_k\]

with \(a_{m,k}\) being the number of atoms of element \(m\) in species \(k\), \(M_m\) the atomic weight of element \(m\), \(M_k\) the molecular weight of species \(k\), and \(Y_k\) the mass fraction of species \(k\):

>>> phase.elemental_mass_fraction('H')
1.0
Parameters:

m – Base element, may be specified by name or by index.

elemental_mole_fraction(*args, **kwargs)#

Get the elemental mole fraction \(Z_{\mathrm{mole},m}\) of element \(m\) (the number of atoms of element m divided by the total number of atoms) as defined by:

\[Z_{\mathrm{mole},m} = \frac{\sum_k a_{m,k} X_k} {\sum_k \sum_j a_{j,k} X_k}\]

with \(a_{m,k}\) being the number of atoms of element \(m\) in species \(k\), \(\sum_j\) being a sum over all elements, and \(X_k\) being the mole fraction of species \(k\):

>>> phase.elemental_mole_fraction('H')
1.0
Parameters:

m – Base element, may be specified by name or by index.

property enthalpy#

Get the total enthalpy [J] represented by the Quantity.

property enthalpy_mass#

Specific enthalpy [J/kg].

property enthalpy_mole#

Molar enthalpy [J/kmol].

property entropy#

Get the total entropy [J/K] represented by the Quantity.

property entropy_mass#

Specific entropy [J/kg/K].

property entropy_mole#

Molar entropy [J/kmol/K].

equilibrate(XY=None, *args, **kwargs)#

Set the state to equilibrium. By default, the property pair self.constant is held constant. See ThermoPhase.equilibrate.

property equilibrium_constants#

Equilibrium constants in concentration units for all reactions.

equivalence_ratio(*args, **kwargs)#

Get the equivalence ratio \(\phi\) of the current mixture, which is a conserved quantity. Considers the oxidation of C to CO2, H to H2O and S to SO2. Other elements are assumed not to participate in oxidation (that is, N ends up as N2). If fuel and oxidizer are not specified, the equivalence ratio is computed from the available oxygen and the required oxygen for complete oxidation:

\[\phi = \frac{Z_{\mathrm{mole},C} + Z_{\mathrm{mole},S} + \frac{1}{4}Z_{\mathrm{mole},H}} {\frac{1}{2}Z_{\mathrm{mole},O}}\]

where \(Z_{\mathrm{mole},e}\) is the elemental mole fraction of element \(e\). If the fuel and oxidizer compositions are specified, \(\phi\) is computed from:

\[\phi = \frac{Z}{1-Z}\frac{1-Z_{\mathrm{st}}}{Z_{\mathrm{st}}}\]

where \(Z\) is the Bilger mixture fraction and \(Z_{\mathrm{st}}\) the Bilger mixture fraction at stoichiometric conditions. The basis determines the composition of fuel and oxidizer: basis='mole' (default) means mole fractions, basis='mass' means mass fractions. Note that this definition takes all species into account. In case certain species like inert diluents should be ignored, a list of species can be provided with include_species. This means that only these species are considered for the computation of the equivalence ratio. For more information, see Python example

>>> gas.set_equivalence_ratio(0.5, fuel='CH3:0.5, CH3OH:.5, N2:0.125', oxidizer='O2:0.21, N2:0.79, NO:0.01')
>>> gas.equivalence_ratio(fuel='CH3:0.5, CH3OH:.5, N2:0.125', oxidizer='O2:0.21, N2:0.79, NO:0.01')
0.5
Parameters:
  • fuel – Fuel species name or mole/mass fractions as string, array, or dict.

  • oxidizer – Oxidizer species name or mole/mass fractions as a string, array, or dict.

  • basis – Determines if fuel and oxidizer are given in mole fractions (basis="mole") or mass fractions (basis="mass")

  • include_species – List of species names (optional). Only these species are considered for the computation of the equivalence ratio. By default, all species are considered

find_isomers(*args, **kwargs)#

Find species/isomers matching a composition specified by comp.

property forward_rate_constants#

Forward rate constants for all reactions.

The computed values include all temperature-dependent and pressure-dependent contributions. By default, third-body concentrations are only considered if they are part of the reaction rate definition; for a legacy implementation that includes third-body concentrations, see use_legacy_rate_constants.

property forward_rate_constants_ddC#

Calculate derivatives for forward rate constants with respect to molar concentration at constant temperature, pressure and mole fractions.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property forward_rate_constants_ddP#

Calculate derivatives for forward rate constants with respect to pressure at constant temperature, molar concentration and mole fractions.

property forward_rate_constants_ddT#

Calculate derivatives for forward rate constants with respect to temperature at constant pressure, molar concentration and mole fractions.

property forward_rates_of_progress#

Forward rates of progress for the reactions. [kmol/m^3/s] for bulk phases or [kmol/m^2/s] for surface phases.

property forward_rates_of_progress_ddC#

Calculate derivatives for forward rates-of-progress with respect to molar concentration at constant temperature, pressure and mole fractions.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property forward_rates_of_progress_ddCi#

Calculate derivatives for forward rates-of-progress with respect to species concentrations at constant temperature, pressure and remaining species concentrations. For sparse output, set ct.use_sparse(True).

Note that for derivatives with respect to \(c_i\), all other \(c_j\) are held constant.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

Added in version 3.0.

property forward_rates_of_progress_ddP#

Calculate derivatives for forward rates-of-progress with respect to pressure at constant temperature, molar concentration and mole fractions.

property forward_rates_of_progress_ddT#

Calculate derivatives for forward rates-of-progress with respect to temperature at constant pressure, molar concentration and mole fractions.

property forward_rates_of_progress_ddX#

Calculate derivatives for forward rates-of-progress with respect to species concentrations at constant temperature, pressure and molar concentration. For sparse output, set ct.use_sparse(True).

Note that for derivatives with respect to \(X_i\), all other \(X_j\) are held constant, rather than enforcing \(\sum X_j = 1\).

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property g#

Gibbs free energy [J/kg or J/kmol] depending on basis.

get_binary_diff_coeffs_polynomial(*args, **kwargs)#

Get the polynomial fit to the logarithm of temperature for the binary diffusion coefficient of species i and j.

get_collision_integral_polynomials(*args, **kwargs)#

Get the polynomial fit to the logarithm of temperature for the collision integral of species i and j.

get_thermal_conductivity_polynomial(*args, **kwargs)#

Get the polynomial fit to the logarithm of temperature for the thermal conductivity of species i.

get_viscosity_polynomial(*args, **kwargs)#

Get the polynomial fit to the logarithm of temperature for the viscosity of species i.

property gibbs#

Get the total Gibbs free energy [J] represented by the Quantity.

property gibbs_mass#

Specific Gibbs free energy [J/kg].

property gibbs_mole#

Molar Gibbs free energy [J/kmol].

property h#

Enthalpy [J/kg or J/kmol] depending on basis.

property has_phase_transition#

Returns true if the phase represents a substance with phase transitions

property heat_production_rates#

Get the volumetric heat production rates [W/m^3] on a per-reaction basis. The sum over all reactions results in the total volumetric heat release rate. Example: C. K. Law: Combustion Physics (2006), Fig. 7.8.6

>>> gas.heat_production_rates[1]  # heat production rate of the 2nd reaction
property heat_release_rate#

Get the total volumetric heat release rate [W/m^3].

property input_data#

Get input data corresponding to the current state of this Solution, along with any user-specified data provided with its input (YAML) definition.

property input_header#

Retrieve input header data not associated with the current state of this Solution, which corresponds to fields at the root level of the YAML input that are not required for the instantiation of Cantera objects.

property int_energy#

Get the total internal energy [J] represented by the Quantity.

property int_energy_mass#

Specific internal energy [J/kg].

property int_energy_mole#

Molar internal energy [J/kmol].

property is_compressible#

Returns true if the density of the phase is an independent variable defining the thermodynamic state of a substance

property is_pure#

Returns true if the phase represents a pure (fixed composition) substance

property isothermal_compressibility#

Isothermal compressibility [1/Pa].

property isotropic_shape_factor#

Shape factor of isotropic-velocity distribution for electron energy

property kinetics_model#

Return type of kinetics.

kinetics_species_index(*args, **kwargs)#

The index of species species of phase phase within arrays returned by methods of class Kinetics. If species is a string, the phase argument is unused.

kinetics_species_name(*args, **kwargs)#

Name of the species with index k in the arrays returned by methods of class Kinetics.

property kinetics_species_names#

A list of all species names, corresponding to the arrays returned by methods of class Kinetics.

mass#
mass_fraction_dict(*args, **kwargs)#

Return a dictionary giving the mass fraction for each species by name where the mass fraction is greater than threshold.

property max_temp#

Maximum temperature for which the thermodynamic data for the phase are valid.

property mean_electron_energy#

Mean electron energy [eV]

property mean_molecular_weight#

The mean molecular weight (molar mass) [kg/kmol].

property min_temp#

Minimum temperature for which the thermodynamic data for the phase are valid.

property mix_diff_coeffs#

Mixture-averaged diffusion coefficients [m^2/s] relating the mass-averaged diffusive fluxes (with respect to the mass averaged velocity) to gradients in the species mole fractions.

property mix_diff_coeffs_mass#

Mixture-averaged diffusion coefficients [m^2/s] relating the diffusive mass fluxes to gradients in the species mass fractions.

property mix_diff_coeffs_mole#

Mixture-averaged diffusion coefficients [m^2/s] relating the molar diffusive fluxes to gradients in the species mole fractions.

mixture_fraction(*args, **kwargs)#

Get the mixture fraction of the current mixture in (kg fuel / (kg oxidizer + kg fuel)). This is a quantity that is conserved after oxidation. Considers the oxidation of C to CO2, H to H2O and S to SO2. Other elements are assumed not to participate in oxidation (that is, N ends up as N2). The basis determines the composition of fuel and oxidizer: basis="mole" (default) means mole fractions, basis="mass" means mass fractions. The mixture fraction can be computed from a single element (for example, carbon with element="C")

\[Z_m = \frac{Z_{\mathrm{mass},m}-Z_{\mathrm{mass},m,\mathrm{ox}}} {Z_{\mathrm{mass},\mathrm{fuel}}-Z_{\mathrm{mass},m,\mathrm{ox}}}\]

where \(Z_{\mathrm{mass},m}\) is the elemental mass fraction of element \(m\) in the mixture, and \(Z_{\mathrm{mass},m,\mathrm{ox}}\) and \(Z_{\mathrm{mass},\mathrm{fuel}}\) are the elemental mass fractions of the oxidizer and fuel, or from the Bilger mixture fraction (element="Bilger"), which considers the elements C, S, H and O [Bilger, 1979]. The Bilger mixture fraction is computed by default:

\[Z_m = Z_{\mathrm{Bilger}} = \frac{\beta-\beta_{\mathrm{ox}}} {\beta_{\mathrm{fuel}}-\beta_{\mathrm{ox}}}\]

with

\[\beta = 2\frac{Z_C}{M_C}+2\frac{Z_S}{M_S}+\frac{1}{2}\frac{Z_H}{M_H} - \frac{Z_O}{M_O}\]

and \(M_m\) the atomic weight of element \(m\). For more information, see Python example.:

>>> gas.set_mixture_fraction(0.5, 'CH3:0.5, CH3OH:0.5, N2:0.125', 'O2:0.21, N2:0.79, NO:0.01')
>>> gas.mixture_fraction('CH3:0.5, CH3OH:0.5, N2:0.125', 'O2:0.21, N2:0.79, NO:.01')
0.5
Parameters:
  • fuel – Fuel species name or mole/mass fractions as string, array, or dict.

  • oxidizer – Oxidizer species name or mole/mass fractions as a string, array, or dict.

  • basis – Determines if fuel and oxidizer are given in mole fractions (basis='mole') or mass fractions (basis='mass')

  • element – Computes the mixture fraction from the specified elemental mass fraction (given by element name or element index) or as the Bilger mixture fraction (default)

property mobilities#

Electrical mobilities of charged species [m^2/s-V]

modify_reaction(*args, **kwargs)#

Modify the Reaction with index irxn to have the same rate parameters as rxn. rxn must have the same reactants and products and use the same rate parameterization (for example, ArrheniusRate, FalloffRate, PlogRate, etc.) as the existing reaction. This method does not modify the third-body efficiencies, reaction orders, or reversibility of the reaction.

modify_species(*args, **kwargs)#

Modify the thermodynamic data associated with a species. The species name, elemental composition, and type of thermo parameterization must be unchanged.

mole_fraction_dict(*args, **kwargs)#

Return a dictionary giving the mole fraction for each species by name where the mole fraction is greater than threshold.

property molecular_weights#

Array of species molecular weights (molar masses) [kg/kmol].

property moles#

Get/Set the number of moles [kmol] represented by the Quantity.

property multi_diff_coeffs#

Multicomponent diffusion coefficients, D[i,j], the diffusion coefficient for species i due to concentration gradients in species j [m**2/s].

multiplier(*args, **kwargs)#

A scaling factor applied to the rate coefficient for reaction i_reaction. Can be used to carry out sensitivity analysis or to selectively disable a particular reaction. See set_multiplier.

n_atoms(*args, **kwargs)#

Number of atoms of element element in species species. The element and species may be specified by name or by index.

>>> phase.n_atoms('CH4','H')
4
property n_electron_energy_levels#

Number of electron energy levels

property n_elements#

Number of elements.

property n_phases#

Number of phases in the reaction mechanism.

property n_reactions#

Number of reactions in the reaction mechanism.

property n_selected_species#

Number of species selected for output (by slicing of Solution object)

property n_species#

Number of species.

property n_total_species#

Total number of species in all phases participating in the kinetics mechanism.

property name#

The name assigned to this object. The default value corresponds to the YAML input file phase entry.

property net_production_rates#

Net production rates for each species. [kmol/m^3/s] for bulk phases or [kmol/m^2/s] for surface phases.

property net_production_rates_ddC#

Calculate derivatives of species net production rates with respect to molar density at constant temperature, pressure and mole fractions.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property net_production_rates_ddCi#

Calculate derivatives for species net production rates with respect to species concentration at constant temperature, pressure, and concentration of all other species. For sparse output, set ct.use_sparse(True).

The method returns a matrix with n_total_species rows and n_total_species columns. For a derivative with respect to :math: c_i, all other :math: c_i are held constant.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

Added in version 3.0.

property net_production_rates_ddP#

Calculate derivatives of species net production rates with respect to pressure at constant temperature, molar concentration and mole fractions.

property net_production_rates_ddT#

Calculate derivatives of species net production rates with respect to temperature at constant pressure, molar concentration and mole fractions.

property net_production_rates_ddX#

Calculate derivatives for species net production rates with respect to species concentrations at constant temperature, pressure and molar concentration. For sparse output, set ct.use_sparse(True).

Note that for derivatives with respect to \(X_i\), all other \(X_j\) are held constant, rather than enforcing \(\sum X_j = 1\).

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property net_rates_of_progress#

Net rates of progress for the reactions. [kmol/m^3/s] for bulk phases or [kmol/m^2/s] for surface phases.

property net_rates_of_progress_ddC#

Calculate derivatives for net rates-of-progress with respect to molar concentration at constant temperature, pressure and mole fractions.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property net_rates_of_progress_ddCi#

Calculate derivatives for net rates-of-progress with respect to species concentrations at constant temperature, pressure and remaining species concentrations. For sparse output, set ct.use_sparse(True).

Note that for derivatives with respect to \(c_i\), all other \(c_j\) are held constant.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

Added in version 3.0.

property net_rates_of_progress_ddP#

Calculate derivatives for net rates-of-progress with respect to pressure at constant temperature, molar concentration and mole fractions.

property net_rates_of_progress_ddT#

Calculate derivatives for net rates-of-progress with respect to temperature at constant pressure, molar concentration and mole fractions.

property net_rates_of_progress_ddX#

Calculate derivatives for net rates-of-progress with respect to species concentrations at constant temperature, pressure and molar concentration. For sparse output, set ct.use_sparse(True).

Note that for derivatives with respect to \(X_i\), all other \(X_j\) are held constant, rather than enforcing \(\sum X_j = 1\).

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property normalize_electron_energy_distribution_enabled#

Automatically normalize electron energy distribution

property partial_molar_cp#

Array of species partial molar specific heat capacities at constant pressure [J/kmol/K].

property partial_molar_enthalpies#

Array of species partial molar enthalpies [J/kmol].

property partial_molar_entropies#

Array of species partial molar entropies [J/kmol/K].

property partial_molar_int_energies#

Array of species partial molar internal energies [J/kmol].

property partial_molar_volumes#

Array of species partial molar volumes [m^3/kmol].

property phase#

Get the underlying Solution object, with the state set to match the wrapping Quantity object.

property phase_of_matter#

Get the thermodynamic phase (gas, liquid, etc.) at the current conditions.

product_stoich_coeff(*args, **kwargs)#

The stoichiometric coefficient of species k_spec as a product in reaction i_reaction.

property product_stoich_coeffs#

The array of product stoichiometric coefficients. Element [k,i] of this array is the product stoichiometric coefficient of species k in reaction i.

For sparse output, set ct.use_sparse(True).

Changed in version 3.0: Method was changed to a property in Cantera 3.0.

property product_stoich_coeffs_reversible#

The array of product stoichiometric coefficients of reversible reactions. Element [k,i] of this array is the product stoichiometric coefficient of species k in reaction i.

For sparse output, set ct.use_sparse(True).

property quadrature_method#

Quadrature method

reactant_stoich_coeff(*args, **kwargs)#

The stoichiometric coefficient of species k_spec as a reactant in reaction i_reaction.

property reactant_stoich_coeffs#

The array of reactant stoichiometric coefficients. Element [k,i] of this array is the reactant stoichiometric coefficient of species k in reaction i.

For sparse output, set ct.use_sparse(True).

Changed in version 3.0: Method was changed to a property in Cantera 3.0.

reaction(*args, **kwargs)#

Return a Reaction object representing the reaction with index i_reaction. Changes to this object do not affect the Kinetics or Solution object until the modify_reaction function is called.

reaction_equations(*args, **kwargs)#

Returns a list containing the reaction equation for all reactions in the mechanism if indices is unspecified, or the equations for each reaction in the sequence indices. For example:

>>> gas.reaction_equations()
['2 O + M <=> O2 + M', 'O + H + M <=> OH + M', 'O + H2 <=> H + OH', ...]
>>> gas.reaction_equations([2,3])
['O + H + M <=> OH + M', 'O + H2 <=> H + OH']

See also reaction_equation.

property reaction_phase_index#

The index of the phase where the reactions occur.

Deprecated since version 3.0: After Cantera 3.0, the reacting phase is always the first phase associated with the Kinetics object. This method will be removed after Cantera 3.1.

reactions(*args, **kwargs)#

Return a list of all Reaction objects. Changes to these objects do not affect the Kinetics or Solution object until the modify_reaction function is called.

property reference_pressure#

Reference state pressure [Pa].

report(*args, **kwargs)#

Generate a report describing the thermodynamic state of this phase. To print the report to the terminal, simply call the phase object. The following two statements are equivalent:

>>> phase()
>>> print(phase.report())
Parameters:
  • show_thermo – A Boolean argument specifying whether to show phase thermodynamic information in the ouptut.

  • threshold – The threshold used to clip data in the output. Values below the threshold are not displayed.

property reverse_rate_constants#

Reverse rate constants for all reactions.

The computed values include all temperature-dependent and pressure-dependent contributions. By default, third-body concentrations are only considered if they are part of the reaction rate definition; for a legacy implementation that includes third-body concentrations, see use_legacy_rate_constants.

property reverse_rates_of_progress#

Reverse rates of progress for the reactions. [kmol/m^3/s] for bulk phases or [kmol/m^2/s] for surface phases.

property reverse_rates_of_progress_ddC#

Calculate derivatives for reverse rates-of-progress with respect to molar concentration at constant temperature, pressure and mole fractions.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property reverse_rates_of_progress_ddCi#

Calculate derivatives for reverse rates-of-progress with respect to species concentrations at constant temperature, pressure and remaining species concentrations. For sparse output, set ct.use_sparse(True).

Note that for derivatives with respect to \(c_i\), all other \(c_j\) are held constant.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

Added in version 3.0.

property reverse_rates_of_progress_ddP#

Calculate derivatives for reverse rates-of-progress with respect to pressure at constant temperature, molar concentration and mole fractions.

property reverse_rates_of_progress_ddT#

Calculate derivatives for reverse rates-of-progress with respect to temperature at constant pressure, molar concentration and mole fractions.

property reverse_rates_of_progress_ddX#

Calculate derivatives for reverse rates-of-progress with respect to species concentrations at constant temperature, pressure and molar concentration. For sparse output, set ct.use_sparse(True).

Note that for derivatives with respect to \(X_i\), all other \(X_j\) are held constant, rather than enforcing \(\sum X_j = 1\).

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property s#

Entropy [J/kg/K or J/kmol/K] depending on basis.

property selected_species#

Get/set the set of species that are included when returning results that have a value for each species, such as species_names, partial_molar_enthalpies, or net_production_rates. The list of selected species can be set by name or index. This property returns the species by index.:

>>> gas.selected_species = ["H2", "O2"]
>>> print(gas.molecular_weights)
[ 2.016 31.998]

This method is often used implicitly by using an indexing expression on a Solution object:

>>> print(gas["H2", "O2"].molecular_weights)
[ 2.016 31.998]
set_binary_diff_coeffs_polynomial(*args, **kwargs)#

Set the polynomial fit to the logarithm of temperature for the binary diffusion coefficient of species i and j.

set_collision_integral_polynomial(*args, **kwargs)#

Get the polynomial fit to the logarithm of temperature for the collision integral of species i and j.

set_discretized_electron_energy_distribution(*args, **kwargs)#

Set electron energy distribution. When this method is used, electron temperature is calculated from the distribution.

Parameters:
  • levels – vector of electron energy levels [eV]

  • distribution – vector of distribution

set_equivalence_ratio(phi, fuel, oxidizer, basis='mole', *, diluent=None, fraction=None)#

Set the composition to a mixture of fuel and oxidizer at the specified equivalence ratio phi, holding temperature and pressure constant. Considers the oxidation of C to CO2, H to H2O and S to SO2. Other elements are assumed not to participate in oxidation (that is, N ends up as N2). The basis determines the fuel and oxidizer compositions: basis='mole' means mole fractions (default), basis='mass' means mass fractions. The fuel/oxidizer mixture can be be diluted by a diluent based on a mixing fraction. The amount of diluent is quantified as a fraction of fuel, oxidizer or the fuel/oxidizer mixture. For more information, see Python example

>>> gas.set_equivalence_ratio(0.5, 'CH4', 'O2:1.0, N2:3.76', basis='mole')
>>> gas.mass_fraction_dict()
{'CH4': 0.02837633052851, 'N2': 0.7452356312613, 'O2': 0.22638803821018}
>>> gas.set_equivalence_ratio(1.2, 'NH3:0.8,CO:0.2', 'O2:1', basis='mole')
>>> gas.mass_fraction_dict()
{'CO': 0.14784006249290, 'NH3': 0.35956645545401, 'O2': 0.49259348205308}
Parameters:
  • phi – Equivalence ratio

  • fuel – Fuel species name or mole/mass fractions as string, array, or dict.

  • oxidizer – Oxidizer species name or mole/mass fractions as a string, array, or dict.

  • basis – Determines if fuel and oxidizer are given in mole fractions (basis='mole') or mass fractions (basis='mass').

  • diluent – Optional parameter. Required if dilution is used. Specifies the composition of the diluent in mole/mass fractions as a string, array or dict.

  • fraction – Optional parameter. Dilutes the fuel/oxidizer mixture with the diluent according to fraction. Fraction can refer to the fraction of diluent in the mixture (for example fraction="diluent:0.7" will create a mixture with 30 % fuel/oxidizer and 70 % diluent), the fraction of fuel in the mixture (for example fraction="fuel:0.1" means that the mixture contains 10 % fuel. The amount of oxidizer is determined from the equivalence ratio and the remaining mixture is the diluent) or fraction of oxidizer in the mixture (for example fraction="oxidizer:0.1"). The fraction itself is interpreted as mole or mass fraction based on basis. The diluent is not considered in the computation of the equivalence ratio. Default is no dilution or fraction=None. May be given as string or dictionary (for example fraction={"fuel":0.7}).

set_mixture_fraction(mixture_fraction, fuel, oxidizer, basis='mole')#

Set the composition to a mixture of fuel and oxidizer at the specified mixture fraction mixture_fraction (kg fuel / kg mixture), holding temperature and pressure constant. Considers the oxidation of C to CO2, H to H2O and S to SO2. Other elements are assumed not to participate in oxidation (that is, N ends up as N2). The basis determines the composition of fuel and oxidizer: basis='mole' (default) means mole fractions, basis='mass' means mass fractions. For more information, see Python example

>>> gas.set_mixture_fraction(0.5, 'CH4', 'O2:1.0, N2:3.76')
>>> gas.mass_fraction_dict()
{'CH4': 0.5, 'N2': 0.38350014242997776, 'O2': 0.11649985757002226}
>>> gas.set_mixture_fraction(0.5, {'NH3':0.8, 'CO':0.2}, 'O2:1.0')
>>> gas.mass_fraction_dict()
{'CO': 0.145682068778996, 'NH3': 0.354317931221004, 'O2': 0.5}
Parameters:
  • mixture_fraction – Mixture fraction (kg fuel / kg mixture)

  • fuel – Fuel species name or mole/mass fractions as string, array, or dict.

  • oxidizer – Oxidizer species name or mole/mass fractions as a string, array, or dict.

  • basis – determines if fuel and oxidizer are given in mole fractions (basis='mole') or mass fractions (basis='mass')

set_multiplier(*args, **kwargs)#

Set the multiplier for for reaction i_reaction to value. If i_reaction is not specified, then the multiplier for all reactions is set to value. See multiplier.

set_thermal_conductivity_polynomial(*args, **kwargs)#

Set the polynomial fit to the logarithm of temperature for the thermal conductivity of species i.

set_viscosity_polynomial(*args, **kwargs)#

Set the polynomial fit to the logarithm of temperature for the viscosity of species i.

property sound_speed#

Speed of sound [m/s].

property source#

The source of this object (such as a file name).

species(*args, **kwargs)#

Return the Species object for species k, where k is either the species index or the species name. If k is not specified, a list of all species objects is returned. Changes to this object do not affect the ThermoPhase or Solution object until the modify_species function is called.

species_index(*args, **kwargs)#

The index of species species, which may be specified as a string or an integer. In the latter case, the index is checked for validity and returned. If no such species is present, an exception is thrown.

species_name(*args, **kwargs)#

Name of the species with index k.

property species_names#

A list of all the species names.

property species_viscosities#

Pure species viscosities [Pa-s]

property standard_concentration_units#

Get standard concentration units for this phase.

property standard_cp_R#

Array of nondimensional species standard-state specific heat capacities at constant pressure at the current temperature and pressure.

property standard_enthalpies_RT#

Array of nondimensional species standard-state enthalpies at the current temperature and pressure.

property standard_entropies_R#

Array of nondimensional species standard-state entropies at the current temperature and pressure.

property standard_gibbs_RT#

Array of nondimensional species standard-state Gibbs free energies at the current temperature and pressure.

property standard_int_energies_RT#

Array of nondimensional species standard-state internal energies at the current temperature and pressure.

state#
property state_size#

Return size of vector defining internal state of the phase.

stoich_air_fuel_ratio(*args, **kwargs)#

Get the stoichiometric air to fuel ratio (kg oxidizer / kg fuel). Considers the oxidation of C to CO2, H to H2O and S to SO2. Other elements are assumed not to participate in oxidation (that is, N ends up as N2). The basis determines the composition of fuel and oxidizer: basis='mole' (default) means mole fractions, basis='mass' means mass fractions:

>>> gas.set_mixture_fraction(0.5, 'CH3:0.5, CH3OH:.5, N2:0.125', 'O2:0.21, N2:0.79, NO:0.01')
>>> gas.stoich_air_fuel_ratio('CH3:0.5, CH3OH:.5, N2:0.125', 'O2:0.21, N2:0.79, NO:0.01')
8.148040722239438
Parameters:
  • fuel – Fuel species name or mole/mass fractions as string, array, or dict.

  • oxidizer – Oxidizer species name or mole/mass fractions as a string, array, or dict.

  • basis – Determines if fuel and oxidizer are given in mole fractions (basis='mole') or mass fractions (basis='mass')

property thermal_conductivity#

Thermal conductivity. [W/m/K]

property thermal_diff_coeffs#

Return a one-dimensional array of the species thermal diffusion coefficients [kg/m/s].

property thermal_expansion_coeff#

Thermal expansion coefficient [1/K].

property thermo_model#

Return thermodynamic model describing phase.

property third_body_concentrations#

Effective third-body concentrations used by individual reactions; values are only defined for reactions involving third-bodies and are set to not-a-number otherwise.

property transport_model#

Get/Set the string specifying the transport model, such as multicomponent, mixture-averaged, or unity-Lewis-number.

Setting a new transport model deletes the underlying C++ Transport object and replaces it with a new one implementing the specified model.

property u#

Internal energy in [J/kg or J/kmol].

update_user_data(*args, **kwargs)#

Add the contents of the provided dict as additional fields when generating YAML phase definition files with write_yaml or in the data returned by input_data. Existing keys with matching names are overwritten.

update_user_header(*args, **kwargs)#

Add the contents of the provided dict as additional top-level YAML fields when generating files with write_yaml or in the data returned by input_header. Existing keys with matching names are overwritten.

property v#

Specific volume [m^3/kg or m^3/kmol] depending on basis.

property viscosity#

Viscosity [Pa-s].

property volume#

Get the total volume [m^3] represented by the Quantity.

property volume_mass#

Specific volume [m^3/kg].

property volume_mole#

Molar volume [m^3/kmol].

write_chemkin(*args, **kwargs)#

Write this Solution instance to one or more Chemkin-format files. See the documentation for cantera.yaml2ck.convert for information about the arguments to this function.

write_yaml(*args, **kwargs)#

Write the definition for this phase, any additional phases specified, and their species and reactions to the specified file.

Parameters:
  • filename – The name of the output file; if None, a YAML string is returned

  • phases – Additional ThermoPhase / Solution objects to be included in the output file

  • units – A UnitSystem object or dictionary of the units to be used for each dimension. See YamlWriter.output_units.

  • precision – For output floating point values, the maximum number of digits to the right of the decimal point. The default is 15 digits.

  • skip_user_defined – If True, user-defined fields which are not used by Cantera will be stripped from the output. These additional contents can also be controlled using the update_user_data and clear_user_data functions.

  • header – If True, fields of the input_header will be added to the YAML header; note that fields name generator, cantera-version, git-commit and date are reserved, which means that any existing data are replaced by automatically generated content when the file is written.

Representing Multiple States#

class cantera.SolutionArray(phase, shape=(0,), states=None, extra=None, meta={}, init=True)#

Bases: SolutionArrayBase

A class providing a convenient interface for representing many thermodynamic states using the same Solution object and computing properties for that array of states.

SolutionArray can represent both 1D and multi-dimensional arrays of states, with shapes described in the same way as NumPy arrays. All of the states can be set in a single call:

>>> gas = ct.Solution('gri30.yaml')
>>> states = ct.SolutionArray(gas, (6, 10))
>>> T = np.linspace(300, 1000, 10) # row vector
>>> P = ct.one_atm * np.linspace(0.1, 5.0, 6)[:,np.newaxis] # column vector
>>> X = 'CH4:1.0, O2:1.0, N2:3.76'
>>> states.TPX = T, P, X

Similar to NumPy arrays, input with fewer non-singleton dimensions than the SolutionArray is ‘broadcast’ to generate input of the appropriate shape. In the above example, the single value for the mole fraction input is applied to each input, while each row has a constant temperature and each column has a constant pressure.

Computed properties are returned as NumPy arrays with the same shape as the array of states, with additional dimensions appended as necessary for non- scalar output (for example, per-species or per-reaction properties):

>>> h = states.enthalpy_mass
>>> h[i,j] # -> enthalpy at P[i] and T[j]
>>> sk = states.partial_molar_entropies
>>> sk[i,:,k] # -> entropy of species k at P[i] and each temperature
>>> ropnet = states.net_rates_of_progress
>>> ropnet[i,j,n] # -> net reaction rate for reaction n at P[i] and T[j]

In the case of 1D arrays, additional states can be appended one at a time:

>>> states = ct.SolutionArray(gas) # creates an empty SolutionArray
>>> for phi in np.linspace(0.5, 2.0, 20):
...     states.append(T=300, P=ct.one_atm,
...                   X={'CH4': phi, 'O2': 2, 'N2': 2*3.76})
>>> # 'states' now contains 20 elements
>>> states.equilibrate('HP')
>>> states.T # -> adiabatic flame temperature at various equivalence ratios

SolutionArray objects can also be ‘sliced’ like NumPy arrays, which can be used both for accessing and setting properties:

>>> states = ct.SolutionArray(gas, (6, 10))
>>> states[0].TP = 400, None # set the temperature of the first row to 400 K
>>> cp = states[:,1].cp_mass # heat capacity of the second column

If many slices or elements of a property are going to be accessed (for example, within a loop), it is generally more efficient to compute the property array once and access this directly, rather than repeatedly slicing the SolutionArray object, for example:

>>> mu = states.viscosity
>>> for i,j in np.ndindex(mu.shape):
...     # do something with mu[i,j]

Information about a subset of species may also be accessed, using parentheses to specify the species:

>>> states('CH4').Y # -> mass fraction of CH4 in each state
>>> states('H2','O2').partial_molar_cp # -> cp for H2 and O2

Properties and functions which are not dependent on the thermodynamic state act as pass-throughs to the underlying Solution object, and are not converted to arrays:

>>> states.element_names
['O', 'H', 'C', 'N', 'Ar']
>>> s.reaction_equation(10)
'CH4 + O <=> CH3 + OH'

Data represented by a SolutionArray can be extracted to a CSV file using the save method:

>>> states.save('somefile.csv', basis="mole')

As an alternative to the CSV format, SolutionArray objects can also be saved in YAML or HDF formats, where the keyword argument id allows for saving and accessing of multiple solutions in a single container file:

>>> states.save('somefile.yaml', id='some_key')

YAML and HDF files can be read back into SolutionArray objects using the restore method:

>>> states = ct.SolutionArray(gas)
>>> states.restore('somefile.yaml', id='some_key')

As long as stored columns in a CSV file specify a valid thermodynamic state, the contents of a SolutionArray can be restored using the read_csv method, which is specific to the Python API:

>>> states = ct.SolutionArray(gas)
>>> states.read_csv('somefile.csv')

Note that save and restore for HDF requires Cantera to be compiled with HDF support, as it depends on external HighFive and HDF5 libraries.

Parameters:
  • phase – The Solution object used to compute the thermodynamic, kinetic, and transport properties

  • shape – A tuple or integer indicating the dimensions of the SolutionArray. If the shape is 1D, the array may be extended using the append method. Otherwise, the shape is fixed.

  • states – The initial array of states. Used internally to provide slicing support.

property DP#

Get/Set density [kg/m^3] and pressure [Pa].

property DPQ#

Get the density [kg/m^3], pressure [Pa], and vapor fraction.

property DPX#

Get/Set density [kg/m^3], pressure [Pa], and mole fractions.

property DPY#

Get/Set density [kg/m^3], pressure [Pa], and mass fractions.

property HP#

Get/Set enthalpy [J/kg or J/kmol] and pressure [Pa].

property HPQ#

Get the enthalpy [J/kg or J/kmol], pressure [Pa] and vapor fraction.

property HPX#

Get/Set enthalpy [J/kg or J/kmol], pressure [Pa] and mole fractions.

property HPY#

Get/Set enthalpy [J/kg or J/kmol], pressure [Pa] and mass fractions.

property P#

Pressure [Pa].

property PQ#

Get/Set the pressure [Pa] and vapor fraction of a two-phase state.

property PV#

Get/Set the pressure [Pa] and specific volume [m^3/kg] of a PureFluid.

property P_sat#

Saturation pressure [Pa] at the current temperature.

property Q#

Get/Set vapor fraction (quality). Can be set only when in the two-phase region.

property SH#

Get/Set the specific entropy [J/kg/K] and the specific enthalpy [J/kg] of a PureFluid.

property SP#

Get/Set entropy [J/kg/K or J/kmol/K] and pressure [Pa].

property SPQ#

Get the entropy [J/kg/K or J/kmol/K], pressure [Pa], and vapor fraction.

property SPX#

Get/Set entropy [J/kg/K or J/kmol/K], pressure [Pa], and mole fractions.

property SPY#

Get/Set entropy [J/kg/K or J/kmol/K], pressure [Pa], and mass fractions.

property ST#

Get/Set the entropy [J/kg/K] and temperature [K] of a PureFluid.

property SV#

Get/Set entropy [J/kg/K or J/kmol/K] and specific volume [m^3/kg or m^3/kmol].

property SVQ#

Get the entropy [J/kg/K or J/kmol/K], specific volume [m^3/kg or m^3/kmol], and vapor fraction.

property SVX#

Get/Set entropy [J/kg/K or J/kmol/K], specific volume [m^3/kg or m^3/kmol], and mole fractions.

property SVY#

Get/Set entropy [J/kg/K or J/kmol/K], specific volume [m^3/kg or m^3/kmol], and mass fractions.

property T#

Temperature [K].

property TD#

Get/Set temperature [K] and density [kg/m^3 or kmol/m^3].

property TDQ#

Get the temperature [K], density [kg/m^3 or kmol/m^3], and vapor fraction.

property TDX#

Get/Set temperature [K], density [kg/m^3 or kmol/m^3], and mole fractions.

property TDY#

Get/Set temperature [K] and density [kg/m^3 or kmol/m^3], and mass fractions.

property TH#

Get/Set the temperature [K] and the specific enthalpy [J/kg] of a PureFluid.

property TP#

Get/Set temperature [K] and pressure [Pa].

property TPQ#

Get/Set the temperature [K], pressure [Pa], and vapor fraction of a PureFluid.

An Exception is raised if the thermodynamic state is not consistent.

property TPX#

Get/Set temperature [K], pressure [Pa], and mole fractions.

property TPY#

Get/Set temperature [K], pressure [Pa], and mass fractions.

property TQ#

Get/Set the temperature [K] and vapor fraction of a two-phase state.

property TV#

Get/Set the temperature [K] and specific volume [m^3/kg] of a PureFluid.

property T_sat#

Saturation temperature [K] at the current pressure.

property Te#

Get/Set electron Temperature [K].

property UP#

Get/Set the specific internal energy [J/kg] and the pressure [Pa] of a PureFluid.

property UV#

Get/Set internal energy [J/kg or J/kmol] and specific volume [m^3/kg or m^3/kmol].

property UVQ#

Get the internal energy [J/kg or J/kmol], specific volume [m^3/kg or m^3/kmol], and vapor fraction.

property UVX#

Get/Set internal energy [J/kg or J/kmol], specific volume [m^3/kg or m^3/kmol], and mole fractions.

property UVY#

Get/Set internal energy [J/kg or J/kmol], specific volume [m^3/kg or m^3/kmol], and mass fractions.

property VH#

Get/Set the specific volume [m^3/kg] and the specific enthalpy [J/kg] of a PureFluid.

property X#

Get/Set the species mole fractions. Can be set as an array, as a dictionary, or as a string. Always returns an array:

>>> phase.X = [0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5]
>>> phase.X = {'H2':0.1, 'O2':0.4, 'AR':0.5}
>>> phase.X = 'H2:0.1, O2:0.4, AR:0.5'
>>> phase.X
array([0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5])
property Y#

Get/Set the species mass fractions. Can be set as an array, as a dictionary, or as a string. Always returns an array:

>>> phase.Y = [0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5]
>>> phase.Y = {'H2':0.1, 'O2':0.4, 'AR':0.5}
>>> phase.Y = 'H2:0.1, O2:0.4, AR:0.5'
>>> phase.Y
array([0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5])
property activities#

Array of nondimensional activities. Returns either molar or molal activities depending on the convention of the thermodynamic model.

property activity_coefficients#

Array of nondimensional, molar activity coefficients.

append(state=None, normalize=True, **kwargs)#

Append an element to the array with the specified state. Elements can only be appended in cases where the array of states is one-dimensional.

The state may be specified in one of three ways:

  • as the array of [temperature, density, mass fractions] which is returned by Solution.state:

    mystates.append(gas.state)
    
  • as a tuple of three elements that corresponds to any of the full-state setters of Solution, such as TPY or HPX:

    mystates.append(TPX=(300, 101325, 'O2:1.0, N2:3.76'))
    
  • as separate keywords for each of the elements corresponding to one of the full-state setters:

    mystates.append(T=300, P=101325, X={'O2':1.0, 'N2':3.76})
    

By default, the mass or mole fractions will be normalized i.e negative values are truncated and the mass or mole fractions sum up to 1.0. If this is not desired, the normalize argument can be set to False.

atomic_weight(*args, **kwargs)#

Atomic weight [kg/kmol] of element m

property atomic_weights#

Array of atomic weight [kg/kmol] for each element in the mixture.

property basis#

Determines whether intensive thermodynamic properties are treated on a mass (per kg) or molar (per kmol) basis. This affects the values returned by the properties h, u, s, g, v, density, cv, and cp, as well as the values used with the state-setting properties such as HPX and UV.

property binary_diff_coeffs#

Binary diffusion coefficients [m^2/s].

property charges#

Array of species charges [elem. charge].

property chemical_potentials#

Array of species chemical potentials [J/kmol].

collect_data(cols=None, tabular=False, threshold=0, species=None)#

Returns the data specified by cols in a dictionary, where keys correspond to SolutionArray attributes to be exported.

Parameters:
  • cols – A list of any properties of the solution that are scalars or which have a value for each species or reaction. If species names are specified, then either the mass or mole fraction of that species will be taken, depending on the value of species. cols may also include any arrays which were specified as extra variables when defining the SolutionArray object. The special value ‘extra’ can be used to include all ‘extra’ variables.

  • tabular – Split 2D data into separate 1D columns for each species / reaction

  • threshold – Relative tolerance for including a particular column if tabular output is enabled. The tolerance is applied by comparing the maximum absolute value for a particular column to the maximum absolute value in all columns for the same variable (for example, mass fraction).

  • species – Specifies whether to use mass (‘Y’) or mole (‘X’) fractions for individual species specified in ‘cols’

property concentrations#

Get/Set the species concentrations. Units are kmol/m^3 for bulk phases, kmol/m^2 for surface phases, and kmol/m for edge phases.

property coverages#

Get/Set the fraction of sites covered by each species.

property cp#

Heat capacity at constant pressure [J/kg/K or J/kmol/K] depending on basis.

property cp_mass#

Specific heat capacity at constant pressure [J/kg/K].

property cp_mole#

Molar heat capacity at constant pressure [J/kmol/K].

property creation_rates#

Creation rates for each species. [kmol/m^3/s] for bulk phases or [kmol/m^2/s] for surface phases.

property creation_rates_ddC#

Calculate derivatives of species creation rates with respect to molar concentration at constant temperature, pressure and mole fractions.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property creation_rates_ddCi#

Calculate derivatives for species creation rates with respect to species concentration at constant temperature, pressure, and concentration of all other species. For sparse output, set ct.use_sparse(True).

The method returns a matrix with n_total_species rows and n_total_species columns.

For a derivative with respect to :math: c_i, all other :math: c_i are held constant.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

Added in version 3.0.

property creation_rates_ddP#

Calculate derivatives of species creation rates with respect to pressure at constant temperature, molar concentration and mole fractions.

property creation_rates_ddT#

Calculate derivatives of species creation rates with respect to temperature at constant pressure, molar concentration and mole fractions.

property creation_rates_ddX#

Calculate derivatives for species creation rates with respect to species concentrations at constant temperature, pressure and molar concentration. For sparse output, set ct.use_sparse(True).

Note that for derivatives with respect to \(X_i\), all other \(X_j\) are held constant, rather than enforcing \(\sum X_j = 1\).

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property critical_density#

Critical density [kg/m^3 or kmol/m^3] depending on basis.

property critical_pressure#

Critical pressure [Pa].

property critical_temperature#

Critical temperature [K].

property cv#

Heat capacity at constant volume [J/kg/K or J/kmol/K] depending on basis.

property cv_mass#

Specific heat capacity at constant volume [J/kg/K].

property cv_mole#

Molar heat capacity at constant volume [J/kmol/K].

property delta_enthalpy#

Change in enthalpy for each reaction [J/kmol].

property delta_entropy#

Change in entropy for each reaction [J/kmol/K].

property delta_gibbs#

Change in Gibbs free energy for each reaction [J/kmol].

property delta_standard_enthalpy#

Change in standard-state enthalpy (independent of composition) for each reaction [J/kmol].

property delta_standard_entropy#

Change in standard-state entropy (independent of composition) for each reaction [J/kmol/K].

property delta_standard_gibbs#

Change in standard-state Gibbs free energy (independent of composition) for each reaction [J/kmol].

property density#

Density [kg/m^3 or kmol/m^3] depending on basis.

property density_mass#

(Mass) density [kg/m^3].

property density_mole#

Molar density [kmol/m^3].

property destruction_rates#

Destruction rates for each species. [kmol/m^3/s] for bulk phases or [kmol/m^2/s] for surface phases.

property destruction_rates_ddC#

Calculate derivatives of species destruction rates with respect to molar concentration at constant temperature, pressure and mole fractions.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property destruction_rates_ddCi#

Calculate derivatives for species destruction rates with respect to species concentration at constant temperature, pressure, and concentration of all other species. For sparse output, set ct.use_sparse(True).

The method returns a matrix with n_total_species rows and n_total_species columns. For a derivative with respect to :math: c_i, all other :math: c_i are held constant.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

Added in version 3.0.

property destruction_rates_ddP#

Calculate derivatives of species destruction rates with respect to pressure at constant temperature, molar concentration and mole fractions.

property destruction_rates_ddT#

Calculate derivatives of species destruction rates with respect to temperature at constant pressure, molar concentration and mole fractions.

property destruction_rates_ddX#

Calculate derivatives for species destruction rates with respect to species concentrations at constant temperature, pressure and molar concentration. For sparse output, set ct.use_sparse(True).

Note that for derivatives with respect to \(X_i\), all other \(X_j\) are held constant, rather than enforcing \(\sum X_j = 1\).

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property electric_potential#

Get/Set the electric potential [V] for this phase.

property electrical_conductivity#

Electrical conductivity. [S/m].

property electrochemical_potentials#

Array of species electrochemical potentials [J/kmol].

element_index(*args, **kwargs)#

The index of element element, which may be specified as a string or an integer. In the latter case, the index is checked for validity and returned. If no such element is present, an exception is thrown.

element_name(*args, **kwargs)#

Name of the element with index m.

property element_names#

A list of all the element names.

elemental_mass_fraction(*args, **kwargs)#
elemental_mole_fraction(*args, **kwargs)#
property enthalpy_mass#

Specific enthalpy [J/kg].

property enthalpy_mole#

Molar enthalpy [J/kmol].

property entropy_mass#

Specific entropy [J/kg/K].

property entropy_mole#

Molar entropy [J/kmol/K].

equilibrate(*args, **kwargs)#

See ThermoPhase.equilibrate

property equilibrium_constants#

Equilibrium constants in concentration units for all reactions.

property forward_rate_constants#

Forward rate constants for all reactions.

The computed values include all temperature-dependent and pressure-dependent contributions. By default, third-body concentrations are only considered if they are part of the reaction rate definition; for a legacy implementation that includes third-body concentrations, see use_legacy_rate_constants.

property forward_rate_constants_ddC#

Calculate derivatives for forward rate constants with respect to molar concentration at constant temperature, pressure and mole fractions.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property forward_rate_constants_ddP#

Calculate derivatives for forward rate constants with respect to pressure at constant temperature, molar concentration and mole fractions.

property forward_rate_constants_ddT#

Calculate derivatives for forward rate constants with respect to temperature at constant pressure, molar concentration and mole fractions.

property forward_rates_of_progress#

Forward rates of progress for the reactions. [kmol/m^3/s] for bulk phases or [kmol/m^2/s] for surface phases.

property forward_rates_of_progress_ddC#

Calculate derivatives for forward rates-of-progress with respect to molar concentration at constant temperature, pressure and mole fractions.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property forward_rates_of_progress_ddP#

Calculate derivatives for forward rates-of-progress with respect to pressure at constant temperature, molar concentration and mole fractions.

property forward_rates_of_progress_ddT#

Calculate derivatives for forward rates-of-progress with respect to temperature at constant pressure, molar concentration and mole fractions.

from_pandas(df, normalize=True)#

Restores SolutionArray data from a pandas.DataFrame df.

This method is intended for loading of data that were previously exported by to_pandas. The method requires a working pandas installation. The package pandas can be installed using pip or conda.

The normalize argument is passed on to restore_data to normalize mole or mass fractions. By default, normalize is True.

property g#

Gibbs free energy [J/kg or J/kmol] depending on basis.

property gibbs_mass#

Specific Gibbs free energy [J/kg].

property gibbs_mole#

Molar Gibbs free energy [J/kmol].

property h#

Enthalpy [J/kg or J/kmol] depending on basis.

property heat_production_rates#

Get the volumetric heat production rates [W/m^3] on a per-reaction basis. The sum over all reactions results in the total volumetric heat release rate. Example: C. K. Law: Combustion Physics (2006), Fig. 7.8.6

>>> gas.heat_production_rates[1]  # heat production rate of the 2nd reaction
property heat_release_rate#

Get the total volumetric heat release rate [W/m^3].

property int_energy_mass#

Specific internal energy [J/kg].

property int_energy_mole#

Molar internal energy [J/kmol].

property isothermal_compressibility#

Isothermal compressibility [1/Pa].

kinetics_species_index(*args, **kwargs)#

The index of species species of phase phase within arrays returned by methods of class Kinetics. If species is a string, the phase argument is unused.

property max_temp#

Maximum temperature for which the thermodynamic data for the phase are valid.

property mean_molecular_weight#

The mean molecular weight (molar mass) [kg/kmol].

property min_temp#

Minimum temperature for which the thermodynamic data for the phase are valid.

property mix_diff_coeffs#

Mixture-averaged diffusion coefficients [m^2/s] relating the mass-averaged diffusive fluxes (with respect to the mass averaged velocity) to gradients in the species mole fractions.

property mix_diff_coeffs_mass#

Mixture-averaged diffusion coefficients [m^2/s] relating the diffusive mass fluxes to gradients in the species mass fractions.

property mix_diff_coeffs_mole#

Mixture-averaged diffusion coefficients [m^2/s] relating the molar diffusive fluxes to gradients in the species mole fractions.

property mobilities#

Electrical mobilities of charged species [m^2/s-V]

modify_reaction(*args, **kwargs)#

Modify the Reaction with index irxn to have the same rate parameters as rxn. rxn must have the same reactants and products and use the same rate parameterization (for example, ArrheniusRate, FalloffRate, PlogRate, etc.) as the existing reaction. This method does not modify the third-body efficiencies, reaction orders, or reversibility of the reaction.

property molecular_weights#

Array of species molecular weights (molar masses) [kg/kmol].

property multi_diff_coeffs#

Multicomponent diffusion coefficients, D[i,j], the diffusion coefficient for species i due to concentration gradients in species j [m**2/s].

multiplier(*args, **kwargs)#

A scaling factor applied to the rate coefficient for reaction i_reaction. Can be used to carry out sensitivity analysis or to selectively disable a particular reaction. See set_multiplier.

n_atoms(*args, **kwargs)#

Number of atoms of element element in species species. The element and species may be specified by name or by index.

>>> phase.n_atoms('CH4','H')
4
property n_elements#

Number of elements.

property n_phases#

Number of phases in the reaction mechanism.

property n_reactions#

Number of reactions in the reaction mechanism.

property n_species#

Number of species.

property n_total_species#

Total number of species in all phases participating in the kinetics mechanism.

property name#

The name assigned to this object. The default value corresponds to the YAML input file phase entry.

property ndim: int#

The number of dimensions in the SolutionArray.

Added in version 3.0.

property net_production_rates#

Net production rates for each species. [kmol/m^3/s] for bulk phases or [kmol/m^2/s] for surface phases.

property net_production_rates_ddC#

Calculate derivatives of species net production rates with respect to molar density at constant temperature, pressure and mole fractions.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property net_production_rates_ddCi#

Calculate derivatives for species net production rates with respect to species concentration at constant temperature, pressure, and concentration of all other species. For sparse output, set ct.use_sparse(True).

The method returns a matrix with n_total_species rows and n_total_species columns. For a derivative with respect to :math: c_i, all other :math: c_i are held constant.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

Added in version 3.0.

property net_production_rates_ddP#

Calculate derivatives of species net production rates with respect to pressure at constant temperature, molar concentration and mole fractions.

property net_production_rates_ddT#

Calculate derivatives of species net production rates with respect to temperature at constant pressure, molar concentration and mole fractions.

property net_production_rates_ddX#

Calculate derivatives for species net production rates with respect to species concentrations at constant temperature, pressure and molar concentration. For sparse output, set ct.use_sparse(True).

Note that for derivatives with respect to \(X_i\), all other \(X_j\) are held constant, rather than enforcing \(\sum X_j = 1\).

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property net_rates_of_progress#

Net rates of progress for the reactions. [kmol/m^3/s] for bulk phases or [kmol/m^2/s] for surface phases.

property net_rates_of_progress_ddC#

Calculate derivatives for net rates-of-progress with respect to molar concentration at constant temperature, pressure and mole fractions.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property net_rates_of_progress_ddP#

Calculate derivatives for net rates-of-progress with respect to pressure at constant temperature, molar concentration and mole fractions.

property net_rates_of_progress_ddT#

Calculate derivatives for net rates-of-progress with respect to temperature at constant pressure, molar concentration and mole fractions.

property partial_molar_cp#

Array of species partial molar specific heat capacities at constant pressure [J/kmol/K].

property partial_molar_enthalpies#

Array of species partial molar enthalpies [J/kmol].

property partial_molar_entropies#

Array of species partial molar entropies [J/kmol/K].

property partial_molar_int_energies#

Array of species partial molar internal energies [J/kmol].

property partial_molar_volumes#

Array of species partial molar volumes [m^3/kmol].

property phase_of_matter#

Get the thermodynamic phase (gas, liquid, etc.) at the current conditions.

product_stoich_coeff(*args, **kwargs)#

The stoichiometric coefficient of species k_spec as a product in reaction i_reaction.

property product_stoich_coeffs#

The array of product stoichiometric coefficients. Element [k,i] of this array is the product stoichiometric coefficient of species k in reaction i.

For sparse output, set ct.use_sparse(True).

Changed in version 3.0: Method was changed to a property in Cantera 3.0.

property product_stoich_coeffs_reversible#

The array of product stoichiometric coefficients of reversible reactions. Element [k,i] of this array is the product stoichiometric coefficient of species k in reaction i.

For sparse output, set ct.use_sparse(True).

reactant_stoich_coeff(*args, **kwargs)#

The stoichiometric coefficient of species k_spec as a reactant in reaction i_reaction.

property reactant_stoich_coeffs#

The array of reactant stoichiometric coefficients. Element [k,i] of this array is the reactant stoichiometric coefficient of species k in reaction i.

For sparse output, set ct.use_sparse(True).

Changed in version 3.0: Method was changed to a property in Cantera 3.0.

reaction(*args, **kwargs)#

Return a Reaction object representing the reaction with index i_reaction. Changes to this object do not affect the Kinetics or Solution object until the modify_reaction function is called.

reaction_equations(*args, **kwargs)#

Returns a list containing the reaction equation for all reactions in the mechanism if indices is unspecified, or the equations for each reaction in the sequence indices. For example:

>>> gas.reaction_equations()
['2 O + M <=> O2 + M', 'O + H + M <=> OH + M', 'O + H2 <=> H + OH', ...]
>>> gas.reaction_equations([2,3])
['O + H + M <=> OH + M', 'O + H2 <=> H + OH']

See also reaction_equation.

property reaction_phase_index#

The index of the phase where the reactions occur.

Deprecated since version 3.0: After Cantera 3.0, the reacting phase is always the first phase associated with the Kinetics object. This method will be removed after Cantera 3.1.

reactions(*args, **kwargs)#

Return a list of all Reaction objects. Changes to these objects do not affect the Kinetics or Solution object until the modify_reaction function is called.

read_csv(filename, normalize=True)#

Read a CSV file named filename and restore data to the SolutionArray using restore_data. This method allows for recreation of data previously exported by write_csv.

The normalize argument is passed on to restore_data to normalize mole or mass fractions. By default, normalize is True.

property reference_pressure#

Reference state pressure [Pa].

restore(fname, name=None, sub=None)#

Restore SolutionArray data and header information from a container file.

This method retrieves data from a YAML or HDF files that were previously saved using the save method.

Parameters:
  • fname – Name of container file (YAML or HDF)

  • name – Identifier of location within the container file; this node/group contains header information and a subgroup holding actual SolutionArray data

  • sub – Name identifier for the subgroup holding the SolutionArray data and metadata objects. If None, the subgroup name defaults to data

Returns:

Dictionary holding SolutionArray meta data.

Added in version 3.0.

restore_data(data, normalize=True)#

Restores a SolutionArray based on data specified in an ordered dictionary. Thus, this method allows to restore data exported by collect_data.

Parameters:
  • data – Dictionary holding data to be restored, where keys refer to thermodynamic states (for example, T, density) or extra entries, and values contain corresponding data.

  • normalize – If True, mole or mass fractions are normalized so that they sum up to 1.0. If False, mole or mass fractions are not normalized.

The receiving SolutionArray either has to be empty or should have matching dimensions. Essential state properties and extra entries are detected automatically whereas stored information of calculated properties is omitted. If the receiving SolutionArray has extra entries already specified, only those will be imported; if labels does not contain those entries, an error is raised.

property reverse_rate_constants#

Reverse rate constants for all reactions.

The computed values include all temperature-dependent and pressure-dependent contributions. By default, third-body concentrations are only considered if they are part of the reaction rate definition; for a legacy implementation that includes third-body concentrations, see use_legacy_rate_constants.

property reverse_rates_of_progress#

Reverse rates of progress for the reactions. [kmol/m^3/s] for bulk phases or [kmol/m^2/s] for surface phases.

property reverse_rates_of_progress_ddC#

Calculate derivatives for reverse rates-of-progress with respect to molar concentration at constant temperature, pressure and mole fractions.

Warning

This property is an experimental part of the Cantera API and may be changed or removed without notice.

property reverse_rates_of_progress_ddP#

Calculate derivatives for reverse rates-of-progress with respect to pressure at constant temperature, molar concentration and mole fractions.

property reverse_rates_of_progress_ddT#

Calculate derivatives for reverse rates-of-progress with respect to temperature at constant pressure, molar concentration and mole fractions.

property s#

Entropy [J/kg/K or J/kmol/K] depending on basis.

save(fname, name=None, sub=None, description=None, *, overwrite=False, compression=0, basis=None)#

Save current SolutionArray contents to a data file.

Data can be saved either in CSV format (extension *.csv), YAML container format (extension *.yaml/*.yml) or HDF container format (extension *.h5/*.hdf5/*.hdf). The output format is automatically inferred from the file extension.

CSV files preserve state data and auxiliary data for a single SolutionArray in a comma-separated text format, container files may hold multiple SolutionArray entries in an internal hierarchical structure. While YAML is a human-readable text format, HDF is a binary format that supports compression and is recommended for large datasets.

For container files (YAML and HDF), header information contains automatically generated time stamps, version information and an optional description. Container files also preserve SolutionArray metadata (example: SolutionArray objects generated by Sim1D store simulation settings).

Parameters:
  • fname – Name of output file (CSV, YAML or HDF)

  • name – Identifier of storage location within the container file; this node/group contains header information and a subgroup holding actual SolutionArray data (YAML/HDF only).

  • sub – Name identifier for the subgroup holding the SolutionArray data and metadata objects. If None, the subgroup name defaults to data (YAML/HDF only).

  • description – Custom comment describing the dataset to be stored (YAML/HDF only).

  • overwrite – Force overwrite if file/name exists; optional (default=`False`)

  • compression – Compression level (0-9); optional (default=0; HDF only)

  • basis – Output mass (Y/mass) or mole (Y/mass) fractions; if not specified (None), the native basis of the underlying ThermoPhase manager is used.

Added in version 3.0.

set_equivalence_ratio(phi, *args, **kwargs)#

See ThermoPhase.set_equivalence_ratio

Note that phi either needs to be a scalar value or dimensions have to be matched to the SolutionArray.

set_mixture_fraction(mixture_fraction, *args, **kwargs)#

See ThermoPhase.set_mixture_fraction

Note that mixture_fraction either needs to be a scalar value or dimensions have to be matched to the SolutionArray.

set_multiplier(*args, **kwargs)#

Set the multiplier for for reaction i_reaction to value. If i_reaction is not specified, then the multiplier for all reactions is set to value. See multiplier.

property shape: tuple[int, ...]#

The shape of the SolutionArray.

Added in version 3.0.

Returns:

A tuple of integers with the number of elements in each dimension.

property site_density#

Get/Set the site density. [kmol/m^2] for surface phases; [kmol/m] for edge phases.

sort(col, reverse=False)#

Sort SolutionArray by column col.

Parameters:
  • col – Column that is used to sort the SolutionArray.

  • reverse – If True, the sorted list is reversed (descending order).

property sound_speed#

Speed of sound [m/s].

property source#

The source of this object (such as a file name).

species(*args, **kwargs)#

Return the Species object for species k, where k is either the species index or the species name. If k is not specified, a list of all species objects is returned. Changes to this object do not affect the ThermoPhase or Solution object until the modify_species function is called.

species_index(*args, **kwargs)#

The index of species species, which may be specified as a string or an integer. In the latter case, the index is checked for validity and returned. If no such species is present, an exception is thrown.

species_name(*args, **kwargs)#

Name of the species with index k.

property species_names#

A list of all the species names.

property species_viscosities#

Pure species viscosities [Pa-s]

property standard_cp_R#

Array of nondimensional species standard-state specific heat capacities at constant pressure at the current temperature and pressure.

property standard_enthalpies_RT#

Array of nondimensional species standard-state enthalpies at the current temperature and pressure.

property standard_entropies_R#

Array of nondimensional species standard-state entropies at the current temperature and pressure.

property standard_gibbs_RT#

Array of nondimensional species standard-state Gibbs free energies at the current temperature and pressure.

property standard_int_energies_RT#

Array of nondimensional species standard-state internal energies at the current temperature and pressure.

property thermal_conductivity#

Thermal conductivity. [W/m/K]

property thermal_diff_coeffs#

Return a one-dimensional array of the species thermal diffusion coefficients [kg/m/s].

property thermal_expansion_coeff#

Thermal expansion coefficient [1/K].

property third_body_concentrations#

Effective third-body concentrations used by individual reactions; values are only defined for reactions involving third-bodies and are set to not-a-number otherwise.

to_pandas(cols=None, *args, **kwargs)#

Returns the data specified by cols in a single pandas.DataFrame.

Additional arguments are passed on to collect_data. This method works only with 1D SolutionArray objects and requires a working pandas installation. Use pip or conda to install pandas to enable this method.

property transport_model#

Get/Set the string specifying the transport model, such as multicomponent, mixture-averaged, or unity-Lewis-number.

Setting a new transport model deletes the underlying C++ Transport object and replaces it with a new one implementing the specified model.

property u#

Internal energy in [J/kg or J/kmol].

property v#

Specific volume [m^3/kg or m^3/kmol] depending on basis.

property viscosity#

Viscosity [Pa-s].

property volume_mass#

Specific volume [m^3/kg].

property volume_mole#

Molar volume [m^3/kmol].