Chemkin to YAML conversion#
For documentation and tutorial, refer to the Converting Chemkin-format files pages.
Module-level documentation#
ck2yaml.py: Convert Chemkin-format mechanisms to Cantera YAML input files
- Usage:
- ck2yaml [–input=<filename>]
[–thermo=<filename>] [–transport=<filename>] [–surface=<filename>] [–name=<name>] [–extra=<filename>] [–output=<filename>] [–single-intermediate-temperature] [–permissive] [–quiet] [–no-validate] [-d | –debug]
- Example:
ck2yaml –input=chem.inp –thermo=therm.dat –transport=tran.dat
If the output file name is not given, an output file with the same name as the input file, with the extension changed to ‘.yaml’.
An input file containing only species definitions (which can be referenced from phase definitions in other input files) can be created by specifying only a thermo file.
For the case of a surface mechanism, the gas phase input file should be specified as ‘input’ and the surface phase input file should be specified as ‘surface’.
The ‘–single-intermediate-temperature’ option should be used with thermo data where only a single break temperature is used and the last value in the first line of each species thermo entry is the molecular weight instead.
The ‘–permissive’ option allows certain recoverable parsing errors (such as duplicate transport data) to be ignored. The ‘–name=<name>’ option is used to override default phase names (that is, ‘gas’).
The ‘–extra=<filename>’ option takes a YAML file as input. This option can be used to add to the file description, or to define custom fields that are included in the YAML output.
- class cantera.ck2yaml.Arrhenius(A=0.0, b=0.0, Ea=0.0, *, parser)#
Bases:
objectRepresent a modified Arrhenius rate.
- Parameters:
A – The pre-exponential factor, given as a tuple consisting of a floating point value and a units string
b – The temperature exponent
Ea – The activation energy, given as a tuple consisting of a floating point value and a units string
- as_yaml(extra=())#
- class cantera.ck2yaml.Chebyshev(coeffs, *, Tmin, Tmax, Pmin, Pmax, quantity_units, **kwargs)#
Bases:
KineticsModelA rate calculated in terms of a bivariate Chebyshev polynomial. See https://cantera.org/science/kinetics.html#chebyshev-reaction-rate-expressions
- Parameters:
coeffs – Matrix of Chebyshev coefficients, dimension N_T by N_P
Tmin – Minimum temperature for which the parameterization is valid
Tmax – Maximum temperature for which the parameterization is valid
Pmin – Minimum pressure for which the parameterization is valid, given as a
(value, units)tuplePmax – Maximum pressure for which the parameterization is valid, given as a
(value, units)tuplequantity_units – Quantity units for the rate constant
- pressure_dependent = True#
- reduce(output)#
Assign data from this object to the YAML mapping
output
- class cantera.ck2yaml.ChemicallyActivated(low_rate=None, F=None, **kwargs)#
Bases:
ThreeBodyA rate for a chemically-activated reaction. See https://cantera.org/science/kinetics.html#chemically-activated-reactions
- Parameters:
low_rate – The Arrhenius kinetics at the low-pressure limit
high_rate – The Arrhenius kinetics at the high-pressure limit
efficiencies – A mapping of species names to collider efficiencies
F – Falloff function parameterization
- reaction_string_suffix(species)#
Suffix for reactant and product strings, used for pressure-dependent reactions
- reduce(output)#
Assign data from this object to the YAML mapping
output
- class cantera.ck2yaml.ElementaryRate(rate, **kwargs)#
Bases:
KineticsModelA reaction rate described by a single Arrhenius expression. See https://cantera.org/science/kinetics.html#reactions-with-a-pressure-independent-rate
- Parameters:
rate – The Arrhenius expression describing this reaction rate.
- pressure_dependent = False#
- reduce(output)#
Assign data from this object to the YAML mapping
output
- class cantera.ck2yaml.Falloff(low_rate=None, F=None, **kwargs)#
Bases:
ThreeBodyA rate for a pressure-dependent falloff reaction. See https://cantera.org/science/kinetics.html#falloff-reactions
- Parameters:
low_rate – The Arrhenius kinetics at the low-pressure limit
high_rate – The Arrhenius kinetics at the high-pressure limit
efficiencies – A mapping of species names to collider efficiencies
F – Falloff function parameterization
- reaction_string_suffix(species)#
Suffix for reactant and product strings, used for pressure-dependent reactions
- reduce(output)#
Assign data from this object to the YAML mapping
output
- cantera.ck2yaml.FlowList(*args, **kwargs)#
- cantera.ck2yaml.FlowMap(*args, **kwargs)#
- exception cantera.ck2yaml.InputError(message, *args, **kwargs)#
Bases:
ExceptionAn exception class for exceptional behavior involving Chemkin-format mechanism files. Pass a string describing the circumstances that caused the exceptional behavior.
- class cantera.ck2yaml.KineticsModel#
Bases:
objectA base class for kinetics models
- pressure_dependent = None#
- reaction_string_suffix(species)#
Suffix for reactant and product strings, used for pressure-dependent reactions
- reduce(output)#
Assign data from this object to the YAML mapping
output
- class cantera.ck2yaml.Nasa7(*, Tmin, Tmax, Tmid, low_coeffs, high_coeffs, note='')#
Bases:
objectThermodynamic data parameterized as two seven-coefficient NASA polynomials. See https://cantera.org/science/species-thermo.html#the-nasa-7-coefficient-polynomial-parameterization
- classmethod to_yaml(representer, node)#
- class cantera.ck2yaml.Nasa9(*, data, note='')#
Bases:
objectThermodynamic data parameterized as any number of nine-coefficient NASA polynomials. See https://cantera.org/science/species-thermo.html#the-nasa-9-coefficient-polynomial-parameterization
- Parameters:
data – List of polynomials, where each polynomial is written as
` [(T_low, T_high), [a_0, a_1, ..., a_8]] `
- classmethod to_yaml(representer, node)#
- class cantera.ck2yaml.PDepArrhenius(*, pressures, pressure_units, arrhenius, **kwargs)#
Bases:
KineticsModelA rate calculated by interpolating between Arrhenius expressions at various pressures. See https://cantera.org/science/kinetics.html#pressure-dependent-arrhenius-rate-expressions-p-log
- Parameters:
pressures – A list of pressures at which Arrhenius expressions are given.
pressure_units – A string indicating the units used for the pressures
arrhenius – A list of
Arrheniusobjects at each given pressure
- pressure_dependent = True#
- reduce(output)#
Assign data from this object to the YAML mapping
output
- class cantera.ck2yaml.Parser#
Bases:
object- add_element(element_string)#
- static convert_mech(input_file, thermo_file=None, transport_file=None, surface_file=None, phase_name='gas', extra_file=None, out_name=None, single_intermediate_temperature=False, quiet=False, permissive=None)#
- static get_rate_constant_units(length_dims, length_units, quantity_dims, quantity_units, time_dims=1, time_units='s')#
- load_chemkin_file(path, skip_undeclared_species=True, surface=False)#
Load a Chemkin-format input file from
pathon disk.
- load_extra_file(path)#
Load YAML-formatted entries from
pathon disk.
- static parse_composition(elements, nElements, width)#
Parse the elemental composition from a 7 or 9 coefficient NASA polynomial entry.
- parse_transport_data(lines, filename, line_offset)#
Parse the Chemkin-format transport data in
lines(a list of strings) and add that transport data to the previously-loaded species.
- read_NASA7_entry(lines, TintDefault, comments)#
Read a thermodynamics entry for one species in a Chemkin-format file (consisting of two 7-coefficient NASA polynomials). Returns the label of the species, the thermodynamics model as a
Nasa7object, and the elemental composition of the species.For more details on this format, see Debugging common errors in CK files.
- read_NASA9_entry(entry, comments)#
Read a thermodynamics
entryfor one species given as one or more 9-coefficient NASA polynomials, written in the format described in Appendix A of NASA Reference Publication 1311 (McBride and Gordon, 1996). Returns the label of the species, the thermodynamics model as aNasa9object, and the elemental composition of the species
- read_kinetics_entry(entry, surface)#
Read a kinetics
entryfor a single reaction as loaded from a Chemkin-format file. Returns aReactionobject with the reaction and its associated kinetics.
- setup_kinetics()#
- show_duplicate_reactions(error_message)#
- warn(message)#
- write_yaml(name='gas', out_name='mech.yaml')#
- class cantera.ck2yaml.Reaction(parser, index=-1, reactants=None, products=None, kinetics=None, reversible=True, duplicate=False, forward_orders=None, third_body=None)#
Bases:
object- Parameters:
index – A unique nonnegative integer index
reactants – A list of
(stoichiometry, species name)tuplesproducts – A list of
(stoichiometry, species name)tupleskinetics – A
KineticsModelinstance which describes the rate constantreversible – Boolean indicating whether the reaction is reversible
duplicate – Boolean indicating whether the reaction is a known (permitted) duplicate
forward_orders – A dictionary specifying a non-default reaction order (value) for each specified species (key)
third_body – A string name used for the third-body species written in pressure-dependent reaction types (usually “M”)
- classmethod to_yaml(representer, node)#
- class cantera.ck2yaml.Species(label, sites=None)#
Bases:
object- classmethod to_yaml(representer, node)#
- class cantera.ck2yaml.Sri(*, A, B, C, D=None, E=None)#
Bases:
objectThe SRI falloff function, described with either 3 or 5 parameters. See https://cantera.org/science/kinetics.html#the-sri-falloff-function
- reduce(output)#
- class cantera.ck2yaml.SurfaceRate(*, rate, coverages, is_sticking, motz_wise, **kwargs)#
Bases:
KineticsModelAn Arrhenius-like reaction occurring on a surface See https://cantera.org/science/kinetics.html#surface-reactions
- Parameters:
rate – The Arrhenius expression describing this reaction rate.
coverages – A list of tuples where each tuple specifies the coverage dependencies for a species, in the form
(species_name, a_k, m_k, E_k)is_sticking – True if the Arrhenius expression is a parameterization of a sticking coefficient, rather than the rate constant itself.
motz_wise – True if the sticking coefficient should be translated into a rate coefficient using the correction factor developed by Motz & Wise for reactions with high (near-unity) sticking coefficients
- pressure_dependent = False#
- reduce(output)#
Assign data from this object to the YAML mapping
output
- class cantera.ck2yaml.ThreeBody(high_rate=None, efficiencies=None, **kwargs)#
Bases:
KineticsModelA rate calculated for a reaction which includes a third-body collider. See https://cantera.org/science/kinetics.html#three-body-reactions
- Parameters:
high_rate – The Arrhenius kinetics (high-pressure limit)
efficiencies – A mapping of species names to collider efficiencies
- pressure_dependent = True#
- reaction_string_suffix(species)#
Suffix for reactant and product strings, used for pressure-dependent reactions
- reduce(output)#
Assign data from this object to the YAML mapping
output
- class cantera.ck2yaml.TransportData(parser, label, geometry, well_depth, collision_diameter, dipole_moment, polarizability, z_rot, note='')#
Bases:
object- geometry_flags = ['atom', 'linear', 'nonlinear']#
- classmethod to_yaml(representer, node)#
- class cantera.ck2yaml.Troe(A=0.0, T3=0.0, T1=0.0, T2=None)#
Bases:
objectThe Troe falloff function, described with either 3 or 4 parameters. See https://cantera.org/science/kinetics.html#the-troe-falloff-function
- reduce(output)#
- cantera.ck2yaml.compatible_quantities(quantity_basis, units)#
- cantera.ck2yaml.contains(seq, value)#
- cantera.ck2yaml.convert_mech(input_file, thermo_file=None, transport_file=None, surface_file=None, phase_name='gas', extra_file=None, out_name=None, single_intermediate_temperature=False, quiet=False, permissive=None)#
- cantera.ck2yaml.float2string(data)#
- cantera.ck2yaml.fortFloat(s)#
Convert a string representation of a floating point value to a float, allowing for some of the peculiarities of allowable Fortran representations.
- cantera.ck2yaml.get_index(seq, value)#
Find the first location in seq which contains a case-insensitive, whitespace-insensitive match for value. Returns None if no match is found.
- cantera.ck2yaml.main(argv)#
- cantera.ck2yaml.represent_float(self, data)#
- cantera.ck2yaml.script_entry_point()#
- cantera.ck2yaml.strip_nonascii(s)#