CTI to YAML conversion#
See also
For documentation of the command line interface, see the cti2yaml section. For a tutorial, refer to the Converting Legacy CTI and XML Input Files to YAML page.
Module-level documentation#
Convert legacy CTI input files to YAML.
There are two main entry points to this script, main and convert. The former is
used from the command line interface and parses the arguments passed. The latter
accepts either the name of the CTI input file or a string containing the CTI
content.
- class cantera.cti2yaml.Arrhenius(A=0.0, b=0.0, E=0.0, coverage=())#
Bases:
object- Parameters:
A – The pre-exponential coefficient. Required input. If entered without units, the units will be computed considering all factors that affect the units. The resulting units string is written to the CTML file individually for each reaction pre-exponential coefficient.
b – The temperature exponent. Dimensionless. Default: 0.0.
E – Activation energy. Default: 0.0.
coverage – For a single coverage dependency, a list with four elements: the species name followed by the three coverage parameters. For multiple coverage dependencies, a list of lists containing the individual sets of coverage parameters. Only used for surface and edge reactions.
- classmethod to_yaml(representer, node)#
- class cantera.cti2yaml.BinarySolutionTabulatedThermo(name='', elements='', species='', note='', transport='None', initial_state=None, standard_concentration=None, tabulated_species=None, tabulated_thermo=None, options=())#
Bases:
IdealSolidSolutionA BinarySolutionTabulatedThermo phase.
The parameters correspond to those of
phase, with the following modifications:- Parameters:
standard_concentration – Basis for the standard concentration. One of
unity,molar_volume, orsolvent_volume.tabulated_species – The name of the species for to which the
tabulated_thermois added.tabulated_thermo – An instance of class
tableproviding the excess enthalpy and entropy to be added to thetabulated_species.
- get_yaml(out)#
- cantera.cti2yaml.FlowList(*args, **kwargs)#
- cantera.cti2yaml.FlowMap(*args, **kwargs)#
- class cantera.cti2yaml.IdealSolidSolution(name='', elements='', species='', note='', transport='None', initial_state=None, standard_concentration=None, options=())#
Bases:
phaseAn IdealSolidSolution phase.
- Parameters:
name – A string to identify the phase. Must be unique among the phase names within the file.
elements – The elements. A string of element symbols.
species – The species. A string or sequence of strings in the format described in Defining the Species.
note – A user-defined comment. Not evaluated by Cantera itself.
reactions – The homogeneous reactions. If omitted, no reactions will be included. A string or sequence of strings in the format described in Declaring the Reactions. This field is not allowed for
stoichiometric_solidandstoichiometric_liquidentries.initial_state – Initial thermodynamic state, specified with an embedded state entry.
options – Special processing options. Optional.
- get_yaml(out)#
- exception cantera.cti2yaml.InputError(msg, *args)#
Bases:
ExceptionException raised if an error is encountered while parsing the input file.
- class cantera.cti2yaml.NASA(Trange=(0.0, 0.0), coeffs=(), p0=None)#
Bases:
thermoThe 7-coefficient NASA polynomial parameterization.
- Parameters:
Trange – The temperature range over which the parameterization is valid. This must be entered as a sequence of two temperature values. Required.
coeffs – List of seven coefficients \((a_0, \ldots , a_6)\)
p0 – The reference-state pressure, usually 1 atm or 1 bar. If omitted, the default value is used, which is set by the
standard_pressuredirective.
- class cantera.cti2yaml.NASA9(Trange=(0.0, 0.0), coeffs=(), p0=None)#
Bases:
thermoNASA9 polynomial parameterization for a single temperature region.
- Parameters:
Trange – The temperature range over which the parameterization is valid. This must be entered as a sequence of two temperature values. Required.
coeffs – List of nine coefficients \((a_0, \ldots , a_8)\)
p0 – The reference-state pressure, usually 1 atm or 1 bar. If omitted, the default value is used, which is set by the
standard_pressuredirective.
- class cantera.cti2yaml.RedlichKwongMFTP(name='', elements='', species='', note='', reactions='none', kinetics='GasKinetics', initial_state=None, activity_coefficients=None, transport='None', options=())#
Bases:
phaseA multi-component fluid model for non-ideal gas fluids.
- Parameters:
name – A string to identify the phase. Must be unique among the phase names within the file.
elements – The elements. A string of element symbols.
species – The species. A string or sequence of strings in the format described in Defining the Species.
note – A user-defined comment. Not evaluated by Cantera itself.
reactions – The homogeneous reactions. If omitted, no reactions will be included. A string or sequence of strings in the format described in Declaring the Reactions. This field is not allowed for
stoichiometric_solidandstoichiometric_liquidentries.initial_state – Initial thermodynamic state, specified with an embedded state entry.
options – Special processing options. Optional.
- get_yaml(out)#
- class cantera.cti2yaml.SRI(A=0.0, B=0.0, C=0.0, D=None, E=None)#
Bases:
objectThe SRI falloff function.
Parameters: A, B, C, D, E. These must be entered as pure numbers without attached dimensions.
- get_yaml(out)#
- class cantera.cti2yaml.Shomate(Trange=(0.0, 0.0), coeffs=(), p0=None)#
Bases:
thermoShomate polynomial parameterization.
- Parameters:
Trange – The temperature range over which the parameterization is valid. This must be entered as a sequence of two temperature values. Required input.
coeffs – Sequence of seven coefficients \((A, \ldots , G)\)
p0 – The reference-state pressure, usually 1 atm or 1 bar. If omitted, the default value set by the
standard_pressuredirective is used.
- class cantera.cti2yaml.Troe(A=0.0, T3=0.0, T1=0.0, T2=None)#
Bases:
objectThe Troe falloff function.
Parameters: A, T3, T1, T2. These must be entered as pure numbers with no attached dimensions.
- get_yaml(out)#
- cantera.cti2yaml.applyUnits(value)#
- class cantera.cti2yaml.chebyshev_reaction(equation, Tmin=300.0, Tmax=2500.0, Pmin=(0.001, 'atm'), Pmax=(100.0, 'atm'), coeffs=(), **kwargs)#
Bases:
reactionPressure-dependent rate calculated in terms of a bivariate Chebyshev polynomial.
- Parameters:
equation – A string specifying the chemical equation.
Tmin – The minimum temperature at which the rate expression is defined
Tmax – the maximum temperature at which the rate expression is defined
Pmin – The minimum pressure at which the rate expression is defined
Pmax – The maximum pressure at which the rate expression is defined
coeffs – A 2D array of the coefficients defining the rate expression. For a polynomial with M points in temperature and N points in pressure, this should be a list of M lists each with N elements.
kwargs –
id,order, andoptionsmay be specified as keyword arguments, with the same meanings as for classreaction.
- get_yaml(out)#
- class cantera.cti2yaml.chemically_activated_reaction(equation, kLow, kHigh, efficiencies='', falloff=None, id='', options=())#
Bases:
falloff_baseA gas-phase, chemically activated reaction.
- Parameters:
equation – A string specifying the chemical equation.
kLow – The rate coefficient for the forward direction in the low-pressure limit. If a sequence of three numbers is given, these will be interpreted as [A, b, E] in the modified Arrhenius function.
kHigh – The rate coefficient for the forward direction in the high-pressure limit. If a sequence of three numbers is given, these will be interpreted as [A, b, E] in the modified Arrhenius function.
efficiencies – A string specifying the third-body collision efficiencies. The efficiency for unspecified species is set to 1.0.
falloff – An embedded entry specifying a falloff function. If omitted, a unity falloff function (Lindemann form) will be used.
id – An optional identification string.
options – Processing options, as described in Options.
- class cantera.cti2yaml.const_cp(t0=None, cp0=None, h0=None, s0=None, tmax=None, tmin=None)#
Bases:
thermoConstant specific heat.
- Parameters:
t0 – Temperature parameter T0. Default: 298.15 K.
cp0 – Reference-state molar heat capacity (constant). Default: 0.0.
h0 – Reference-state molar enthalpy at temperature T0. Default: 0.0.
s0 – Reference-state molar entropy at temperature T0. Default: 0.0.
- get_yaml(out)#
- class cantera.cti2yaml.constantIncompressible(molarVolume=0.0)#
Bases:
objectConstant molar volume.
- Parameters:
molarVolume – Reference-state molar volume. Default: 0.0.
- cantera.cti2yaml.convert(filename=None, output_name=None, text=None, encoding='latin-1')#
- cantera.cti2yaml.create_argparser()#
Create argparse parser
- cantera.cti2yaml.dataset(nm)#
Set the dataset name. Invoke this to change the name of the YAML file.
- cantera.cti2yaml.disable_motz_wise()#
Disable the Motz & Wise correction by default for all sticking reactions.
- class cantera.cti2yaml.edge(name='', elements='', species='', note='', reactions='none', site_density=0.0, phases=(), kinetics='Edge', transport='None', initial_state=None, options=())#
Bases:
ideal_interfaceA 1D boundary between two surface phases.
The parameters correspond to those of
phase, with the following modifications:- Parameters:
reactions – The heterogeneous reactions at this interface. If omitted, no reactions will be included. A string or sequence of strings in the format described in Declaring the Reactions.
site_density – The number of adsorption sites per unit area.
phases – A string listing the bulk phases that participate in reactions at this interface.
- class cantera.cti2yaml.edge_reaction(equation, kf, id='', order='', beta=None, options=(), rate_coeff_type='')#
Bases:
surface_reaction- Parameters:
equation – A string specifying the chemical equation.
kf – The rate coefficient for the forward direction. If a sequence of three numbers is given, these will be interpreted as [A, b, E] in the modified Arrhenius function.
id – An optional identification string.
beta – Charge transfer coefficient: A number between 0 and 1 which, for a charge transfer reaction, determines how much of the electric potential difference between two phases is applied to the activation energy of the fwd reaction. The remainder is applied to the reverse reaction.
options – Processing options, as described in Options.
- class cantera.cti2yaml.element(symbol='', atomic_mass=0.01, atomic_number=None)#
Bases:
objectAn atomic element or isotope.
- Parameters:
symbol – The symbol for the element or isotope.
atomic_mass – The atomic mass in amu.
atomic_number – The atomic number of the element or isotope. Optional.
- classmethod to_yaml(representer, node)#
- cantera.cti2yaml.enable_motz_wise()#
Enable the Motz & Wise correction by default for all sticking reactions.
- class cantera.cti2yaml.falloff_base(equation, klow, khigh, efficiencies, falloff, id, options)#
Bases:
reactionBase class for falloff_reaction and chemically_activated_reaction
- Parameters:
equation – A string specifying the chemical equation.
kf – The rate coefficient for the forward direction. If a sequence of three numbers is given, these will be interpreted as [A, b, E] in the modified Arrhenius function \(A T^b exp(-E/\hat{R}T)\).
id – An optional identification string.
order – Override the default reaction orders implied by the reactant stoichiometric coefficients. Given as a string of key:value pairs, for example,
"CH4:0.25 O2:1.5".options – Processing options, as described in Options. May be one or more (as a list) of the following:
'duplicate','negative_A','negative_orders','nonreactant_orders'.
- get_yaml(out)#
- class cantera.cti2yaml.falloff_reaction(equation, kf0, kf, efficiencies='', falloff=None, id='', options=())#
Bases:
falloff_baseA gas-phase falloff reaction.
- Parameters:
equation – A string specifying the chemical equation.
kf – The rate coefficient for the forward direction in the high-pressure limit. If a sequence of three numbers is given, these will be interpreted as [A, b, E] in the modified Arrhenius function.
kf0 – The rate coefficient for the forward direction in the low-pressure limit. If a sequence of three numbers is given, these will be interpreted as [A, b, E] in the modified Arrhenius function.
efficiencies – A string specifying the third-body collision efficiencies. The efficiency for unspecified species is set to 1.0.
falloff – An embedded entry specifying a falloff function. If omitted, a unity falloff function (Lindemann form) will be used.
id – An optional identification string.
options – Processing options, as described in Options.
- cantera.cti2yaml.float2string(data)#
- class cantera.cti2yaml.gas_transport(geom, diam, well_depth, dipole=0.0, polar=0.0, rot_relax=0.0, acentric_factor=None, disp_coeff=0.0, quad_polar=0.0)#
Bases:
objectSpecies-specific Transport coefficients for gas-phase transport models.
- Parameters:
geom – A string specifying the molecular geometry. One of
atom,linear, ornonlinear. Required.diam – The Lennard-Jones collision diameter in Angstroms. Required.
well_depth – The Lennard-Jones well depth in Kelvin. Required.
dipole – The permanent dipole moment in Debye. Default: 0.0
polar – The polarizability in A^3. Default: 0.0
rot_relax – The rotational relaxation collision number at 298 K. Dimensionless. Default: 0.0
acentric_factor – Pitzer’s acentric factor. Dimensionless. Default: 0.0
disp_coeff – The dispersion coefficient in A^5 Default: 0.0
quad_polar – The quadrupole polarizability Default: 0.0
- classmethod to_yaml(representer, node)#
- cantera.cti2yaml.get_composition(atoms)#
- class cantera.cti2yaml.ideal_gas(name='', elements='', species='', note='', reactions='none', kinetics='GasKinetics', transport=None, initial_state=None, options=())#
Bases:
phaseAn ideal gas mixture.
The parameters correspond to those of
phase, with the following modifications:- Parameters:
kinetics – The kinetics model. Usually this field is omitted, in which case kinetics model GasKinetics, appropriate for reactions in ideal gas mixtures, is used.
transport – The transport property model. One of the strings
'none','multi', or'mix'. Default:'none'.
- class cantera.cti2yaml.ideal_interface(name='', elements='', species='', note='', reactions='none', site_density=0.0, phases=(), kinetics='Interface', transport='None', initial_state=None, options=())#
Bases:
phaseA chemically-reacting ideal surface solution of multiple species.
The parameters correspond to those of
phase, with the following modifications:- Parameters:
reactions – The heterogeneous reactions at this interface. If omitted, no reactions will be included. A string or sequence of strings in the format described in Declaring the Reactions.
site_density – The number of adsorption sites per unit area.
phases – A string listing the bulk phases that participate in reactions at this interface.
- get_yaml(out)#
- class cantera.cti2yaml.lattice(name='', elements='', species='', note='', reactions='none', transport='None', initial_state=None, options=(), site_density=None)#
Bases:
phase- Parameters:
name – A string to identify the phase. Must be unique among the phase names within the file.
elements – The elements. A string of element symbols.
species – The species. A string or sequence of strings in the format described in Defining the Species.
note – A user-defined comment. Not evaluated by Cantera itself.
reactions – The homogeneous reactions. If omitted, no reactions will be included. A string or sequence of strings in the format described in Declaring the Reactions. This field is not allowed for
stoichiometric_solidandstoichiometric_liquidentries.initial_state – Initial thermodynamic state, specified with an embedded state entry.
options – Special processing options. Optional.
- get_yaml(out)#
- class cantera.cti2yaml.liquid_vapor(name='', elements='', species='', note='', substance_flag=0, initial_state=None, options=())#
Bases:
phaseA fluid with a complete liquid/vapor equation of state. This entry type selects one of a set of predefined fluids with built-in liquid/vapor equations of state. The substance_flag parameter selects the fluid. See liquidvapor.cti and liquidvapor.py for the usage of this entry type.
- Parameters:
name – A string to identify the phase. Must be unique among the phase names within the file.
elements – The elements. A string of element symbols.
species – The species. A string or sequence of strings in the format described in Defining the Species.
note – A user-defined comment. Not evaluated by Cantera itself.
reactions – The homogeneous reactions. If omitted, no reactions will be included. A string or sequence of strings in the format described in Declaring the Reactions. This field is not allowed for
stoichiometric_solidandstoichiometric_liquidentries.initial_state – Initial thermodynamic state, specified with an embedded state entry.
options – Special processing options. Optional.
- get_yaml(out)#
- pure_fluids = {0: 'water', 1: 'nitrogen', 2: 'methane', 3: 'hydrogen', 4: 'oxygen', 5: 'HFC-134a', 7: 'carbon-dioxide', 8: 'heptane'}#
- class cantera.cti2yaml.metal(name='', elements='', species='', note='', density=-1.0, transport='None', initial_state=None, options=())#
Bases:
phaseA metal.
- Parameters:
name – A string to identify the phase. Must be unique among the phase names within the file.
elements – The elements. A string of element symbols.
species – The species. A string or sequence of strings in the format described in Defining the Species.
note – A user-defined comment. Not evaluated by Cantera itself.
reactions – The homogeneous reactions. If omitted, no reactions will be included. A string or sequence of strings in the format described in Declaring the Reactions. This field is not allowed for
stoichiometric_solidandstoichiometric_liquidentries.initial_state – Initial thermodynamic state, specified with an embedded state entry.
options – Special processing options. Optional.
- get_yaml(out)#
- class cantera.cti2yaml.pdep_arrhenius(equation, *args, **kwargs)#
Bases:
reactionPressure-dependent rate calculated by interpolating between Arrhenius expressions at different pressures.
- Parameters:
equation – A string specifying the chemical equation.
args – Each additional argument is a sequence of four elements specifying the pressure and the Arrhenius parameters at that pressure.
kwargs –
id,order, andoptionsmay be specified as keyword arguments, with the same meanings as for classreaction.
- get_yaml(out)#
- class cantera.cti2yaml.phase(name='', elements='', species='', note='', reactions='none', initial_state=None, options=())#
Bases:
objectBase class for phases of matter.
- Parameters:
name – A string to identify the phase. Must be unique among the phase names within the file.
elements – The elements. A string of element symbols.
species – The species. A string or sequence of strings in the format described in Defining the Species.
note – A user-defined comment. Not evaluated by Cantera itself.
reactions – The homogeneous reactions. If omitted, no reactions will be included. A string or sequence of strings in the format described in Declaring the Reactions. This field is not allowed for
stoichiometric_solidandstoichiometric_liquidentries.initial_state – Initial thermodynamic state, specified with an embedded state entry.
options – Special processing options. Optional.
- get_yaml(out)#
- classmethod to_yaml(representer, node)#
- class cantera.cti2yaml.reaction(equation, kf, id='', order='', options=())#
Bases:
objectA homogeneous chemical reaction with pressure-independent rate coefficient and mass-action kinetics.
- Parameters:
equation – A string specifying the chemical equation.
kf – The rate coefficient for the forward direction. If a sequence of three numbers is given, these will be interpreted as [A, b, E] in the modified Arrhenius function \(A T^b exp(-E/\hat{R}T)\).
id – An optional identification string.
order – Override the default reaction orders implied by the reactant stoichiometric coefficients. Given as a string of key:value pairs, for example,
"CH4:0.25 O2:1.5".options – Processing options, as described in Options. May be one or more (as a list) of the following:
'duplicate','negative_A','negative_orders','nonreactant_orders'.
- get_yaml(out)#
- classmethod to_yaml(representer, node)#
- cantera.cti2yaml.represent_float(self, data)#
- class cantera.cti2yaml.species(name, atoms='', note='', thermo=None, transport=None, charge=None, size=1.0, standardState=None)#
Bases:
objectA constituent of a phase or interface.
- Parameters:
name – The species name (or formula). The name may be arbitrarily long, although usually a relatively short, abbreviated name is most convenient. Required parameter.
atoms – The atomic composition, specified by a string containing space-delimited
<element>:<atoms>pairs. The number of atoms may be either an integer or a floating-point number.note – A user-defined comment. Not evaluated by Cantera itself.
thermo – The parameterization to use to compute the reference-state thermodynamic properties. This must be one of the entry types described in Thermodynamic Property Models. To specify multiple parameterizations, each for a different temperature range, group them in parentheses.
transport – An entry specifying parameters to compute this species’ contribution to the transport properties. This must be one of the entry types described in Species Transport Coefficients, and must be consistent with the transport model of the phase into which the species is imported. To specify parameters for multiple transport models, group the entries in parentheses.
charge – The charge, in multiples of \(|e|\). If not specified, the charge will be calculated from the number of “atoms” of element
E, which represents an electron.size – The species “size”. Currently used only for surface species, where it represents the number of sites occupied.
standardState – The species standard state model. Currently used only for
IdealSolidSolutionand derived classes where it is used to calculate the phase density.
- classmethod to_yaml(representer, node)#
- cantera.cti2yaml.standard_pressure(p0)#
Set the default standard-state pressure.
- class cantera.cti2yaml.state(temperature=None, pressure=None, mole_fractions=None, mass_fractions=None, density=None, coverages=None, solute_molalities=None)#
Bases:
objectAn embedded entry that specifies the thermodynamic state of a phase or interface.
- Parameters:
temperature – The temperature.
pressure – The pressure.
mole_fractions – A string specifying the species mole fractions. Unspecified species are set to zero.
mass_fractions – A string specifying the species mass fractions. Unspecified species are set to zero.
density – The density. Cannot be specified if the phase is incompressible.
coverages – A string specifying the species coverages. Unspecified species are set to zero. Can only be specified for interfaces.
solute_molalities – A string specifying the solute molalities. Unspecified molalities are set to zero. Only applies to molality-based thermodynamic models.
- classmethod to_yaml(representer, node)#
- class cantera.cti2yaml.stick(*args, **kwargs)#
Bases:
ArrheniusA rate expression for a surface reaction given as a sticking probability, parameterized using a modified Arrhenius expression.
- Parameters:
motz_wise –
Trueif the Motz & Wise correction should be used,Falseif not. If unspecified, use the mechanism default (set using the functionsenable_motz_wiseordisable_motz_wise).
- class cantera.cti2yaml.stoichiometric_liquid(name='', elements='', species='', note='', density=None, transport='None', initial_state=None, options=())#
Bases:
stoichiometric_solidAn incompressible stoichiometric liquid. Currently, there is no distinction between stoichiometric liquids and solids.
See
phasefor descriptions of the parameters.
- class cantera.cti2yaml.stoichiometric_solid(name='', elements='', species='', note='', density=None, transport='None', initial_state=None, options=())#
Bases:
phaseA solid compound or pure element. Stoichiometric solid phases contain exactly one species, which always has unit activity. The solid is assumed to have constant density. Therefore the rates of reactions involving these phases do not contain any concentration terms for the (one) species in the phase, since the concentration is always the same.
See
phasefor descriptions of the parameters.- get_yaml(out)#
- class cantera.cti2yaml.surface_reaction(equation, kf, id='', order='', beta=None, options=(), rate_coeff_type='')#
Bases:
reactionA heterogeneous chemical reaction with pressure-independent rate coefficient and mass-action kinetics.
- Parameters:
equation – A string specifying the chemical equation.
kf – The rate coefficient for the forward direction. If a sequence of three numbers is given, these will be interpreted as [A, b, E] in the modified Arrhenius function.
id – An optional identification string.
beta – Charge transfer coefficient: A number between 0 and 1 which, for a charge transfer reaction, determines how much of the electric potential difference between two phases is applied to the activation energy of the fwd reaction. The remainder is applied to the reverse reaction.
options – Processing options, as described in Options.
- get_yaml(out)#
- class cantera.cti2yaml.table(moleFraction=([], ''), enthalpy=([], ''), entropy=([], ''))#
Bases:
objectUser provided thermo table for BinarySolutionTabulatedThermo
- Parameters:
moleFraction – The mole fraction of the tabulated species. Required parameter.
enthalpy – The enthalpy of the tabulated species. Required parameter.
entropy – The entropy of the tabulated species. Required parameter.
- class cantera.cti2yaml.thermo#
Bases:
objectBase class for species thermodynamic properties.
- get_yaml(out)#
- classmethod to_yaml(representer, node)#
- class cantera.cti2yaml.three_body_reaction(equation, kf, efficiencies='', id='', options=())#
Bases:
reactionA three-body reaction.
- Parameters:
equation – A string specifying the chemical equation. The reaction can be written in either the association or dissociation directions, and may be reversible or irreversible.
kf – The rate coefficient for the forward direction. If a sequence of three numbers is given, these will be interpreted as [A, b, E] in the modified Arrhenius function.
efficiencies – A string specifying the third-body collision efficiencies. The efficiencies for unspecified species are set to 1.0.
id – An optional identification string.
options – Processing options, as described in Options.
- get_yaml(out)#
- cantera.cti2yaml.units(length='', quantity='', mass='', time='', act_energy='', energy='', pressure='')#
Set the default units.
- Parameters:
length – The default units for length. Default:
'm'mass – The default units for mass. Default:
'kg'quantity – The default units to specify number of molecules. Default:
'kmol'time – The default units for time. Default:
's'energy – The default units for energies. Default:
'J'act_energy – The default units for activation energies. Default:
'K'pressure – The default units for pressure. Default:
'Pa'
- cantera.cti2yaml.validate(species='yes', reactions='yes')#