YAML to Chemkin conversion#
For documentation of the command line interface, see YAML to Chemkin conversion.
Module-level documentation#
Convert YAML input files or Solution
instances to CHEMKIN input format. The
supported CHEMKIN syntax follows the documentation in [Kee1989].
New in version 3.0.
- Supported Thermodynamics:
NASA7
- Supported Reaction models:
Elementary, Three-Body, Falloff, Pressure-Dependent-Arrhenius (PLOG), Chebyshev
- Unsupported Thermodynamic Property Models:
NASA9, Shomate, constant-Cp
- Unsupported Reaction models (not comprehensive):
Chemically-activated, Blowers-Masel, Surface Reactions
Kee, RJ; Rupley, FM; Miller, JA. Chemkin-II: A Fortran chemical kinetics package for the analysis of gas-phase chemical kinetics, Sandia Report SAND-89-8009, September 1989.
- class cantera.yaml2ck.HeaderTextWrapper(input_files: Iterable[str], *args, **kwargs)#
Bases:
TextWrapper
Wrap header text from a YAML file, including Cantera metadata.
- Parameters:
input_files – Iterable of string input file names to include in the header
New in version 3.0.
- wrap(text: string) [string] #
Reformat the single paragraph in ‘text’ so it fits in lines of no more than ‘self.width’ columns, and return a list of wrapped lines. Tabs in ‘text’ are expanded with string.expandtabs(), and all other whitespace characters (including newline) are converted to space.
- cantera.yaml2ck.build_elements_text(elements: Iterable[Element], max_width=80) str #
Create element definition text.
- Parameters:
elements – List of
cantera.Element
instances for the elements in this file.max_width – The maximum width of a line in this section.
New in version 3.0.
- cantera.yaml2ck.build_reactions_text(reactions: Iterable[Reaction])#
Create the reaction definition section of this file.
- Parameters:
reactions – An iterable of
cantera.Reaction
instances to be included.
New in version 3.0.
- cantera.yaml2ck.build_species_text(species: Iterable[Species], max_width=80) str #
Create species definition text.
- Parameters:
species – List of
cantera.Species
instances of the species in this file.max_width – The maximum width of a line in this section.
New in version 3.0.
- cantera.yaml2ck.build_thermodynamics_text(species: Iterable[Species], separate_file: bool = False) str #
Creates the thermodynamic definition text of all species.
- Parameters:
species – An iterable of
cantera.Species
definitions for this file.separate_file – A Boolean flag to indicate if the file will be written separately or in the mechanism file
The global/default temperature limits of the NASA polynomials are chosen as follows:
Lower temperature limit: Minimum of the lower temperature limits among all the species in the phase.
Midpoint temperature: 1000 K
Upper temperature limit: Maximum of the upper temperature limits among all the species in the phase.
These values are included in the CHEMKIN thermodynamic input format documentation in the heading information for the thermodynamic section/file, that is:
THERMO [ALL] LOW_TEMP MID_TEMP HIGH_TEMP
Despite appearing in the documentation, these values do not appear to be used by CHEMKIN because CHEMKIN seems to require each species to contain the polynomial temperature limits for that species. However, this requirement is not documented and since modern CHEMKIN is closed-source (including the documentation), we cannot verify this.
New in version 3.0.
- cantera.yaml2ck.build_transport_text(species: Iterable[Species], separate_file: bool = False)#
Create the transport section of this file.
- Parameters:
species – A list of
cantera.Species
instances to include in the file.separate_file – A Boolean flag to indicate if the file will be written separately or in the mechanism file
New in version 3.0.
- cantera.yaml2ck.convert(solution: str | pathlib.Path | cantera.composite.Solution, phase_name: str = '', mechanism_path: str | pathlib.Path | None = None, thermo_path: str | pathlib.Path | None = None, transport_path: str | pathlib.Path | None = None, sort_elements: Optional[Literal['alphabetical', 'molar-mass']] = None, sort_species: Optional[Literal['alphabetical', 'molar-mass']] = None, overwrite: bool = False) tuple[pathlib.Path | None, pathlib.Path | None, pathlib.Path | None] #
Writes Cantera solution object to Chemkin-format file(s).
- Parameters:
solution – Either the
cantera.Solution
object being converted or the path of a YAML input file as astr
orpathlib.Path
instance.phase_name – If a YAML input file is provided with multiple phase definitions, the name provided here will be used to load a single phase from the input file. Otherwise, Cantera’s default behavior will load the first definition from the file.
mechanism_path – The path to the output mechanism file. Optional. If not provided, the name of the input file will be used, with the extension replaced by
.ck
. If acantera.Solution
instance is provided, thename
attribute is used to generate the mechanism file name. Ifmechanism_path
is an existing directory, the output files will be placed in that directory.thermo_path – The path to the output thermodynamics database file. Optional. If not provided, the thermodynamic data will be included in the
mechanism_path
file.transport_path – The path to the output transport database file. Optional. If not provided, the transport data will be included in the
mechanism_path
file.sort_elements – Optional. One of
'alphabetical'
,'molar-mass'
, orNone
. The former two options will sort the elements in themechanism_path
file alphabetically or by atomic mass, respectively. The default is to output elements in the same order defined in the inputcantera.Solution
.sort_species – Optional. One of
'alphabetical'
,'molar-mass'
, orNone
. The former two options will sort the species definitions and their thermodynamic data alphabetically or by molecular weight, respectively. The default is to output the species in the same order defined in the inputcantera.Solution
.overwrite – Boolean flag to overwrite existing files.
New in version 3.0.
- cantera.yaml2ck.create_argparser()#
Create argparse parser