Exporting a mechanism
TCKDB writes a mechanism in two formats. Both take the same request, make the same selection of records and apply the same rules: a record one format leaves out, the other leaves out too, with the same gap in the manifest. The few records one format cannot express are listed under what differs between the formats.
| Route | Archive contents |
|---|---|
POST /api/v1/scientific/export/chemkin |
chem.inp, therm.dat, tran.dat (when transport is written), manifest.json |
POST /api/v1/scientific/export/cantera |
mechanism.yaml, manifest.json |
Both routes need a curator or admin account.
The request
import os
from tckdb_client import TCKDBClient
with TCKDBClient(os.environ["TCKDB_BASE_URL"], api_key=os.environ["TCKDB_API_KEY"]) as client:
archive = client.export_cantera(
{"reaction_refs": ["rxe_..."], "species_refs": ["spe_..."]},
thermo_refs=["thm_..."], # only where a species has several thermo records
kinetics_refs=["kin_..."], # only where a reaction has several kinetics records
energy_units="kj/mol", # cal/mol (default), kcal/mol, j/mol, kj/mol, k
)
with open("tckdb_cantera_export.zip", "wb") as fh:
fh.write(archive)
export_chemkin takes the same arguments.
energy_units is the unit of every activation energy in the file, and the
file names it: in the REACTIONS line of chem.inp and in the units block
of mechanism.yaml. The CHEMKIN words cal/mole, kcal/mole,
joules/mole, kjoules/mole and kelvins are accepted for the same five
units, in any letter case. Any other value is refused with 422
export_energy_unit_unknown; context.accepted lists the accepted values.
A mechanism holds one thermo, one transport and one kinetics record per
species or reaction, and TCKDB does not pick one. Where there are several
candidates the request is refused with 422 export_selection_ambiguous, which
lists every candidate; name the one you want in thermo_refs,
transport_refs or kinetics_refs and send the request again. The
select_* methods of the client show the evidence behind each candidate.
A reaction is written as a rate in one direction. A kinetics record that
states no direction is written as no reaction and listed as a
kinetics_direction gap. When no record in the export states a direction the
request is refused with 422 export_no_reaction_direction. Both formats
refuse the same requests with this code.
A mechanism file with no species does not load. When no species in the
export has thermo the format can state, the request is refused with 422
export_no_species_entry; context.species counts the species of the export.
A file with species and no reaction is returned.
What is left out
A species entry in a mechanism file is its thermo. A species is left out of every file of the export, with a gap, when:
- it has no thermo record, or its structure gives no composition;
- it is a free electron, which this export does not write;
- its thermo is not gas phase at a reference pressure of 1 atm (1.01325 bar);
- its thermo has no fit the format holds, or the fit is incomplete.
A reaction is left out, with a kinetics gap, when:
- a participant or a third-body collider has no species entry in the file;
- a side of the reaction has no participant;
- it has collider efficiencies and no third body, or it is a third-body PLOG or Chebyshev rate;
- it is a Troe rate without alpha, T3 and T1, or an SRI rate without a, b and c or with only one of d and e;
- it is a fall-off rate whose low-pressure A has no stored unit. The unit of the high-pressure A is of another order and is not used for it;
- a mechanism reader refuses it, which would make the whole file unloadable: a fall-off rate whose high- and low-pressure A have opposite signs, and a PLOG rate that is not positive at one of its pressures;
- a parameter is missing or not finite.
A transport record of a species with no entry is a transport gap. When
transport is written for some species of the file, every species of the file
with no transport record is a transport gap too.
Written with an assumption, each a kinetics_units_assumed gap:
- An Arrhenius A with no stored unit, written as the mol, cm, s value.
- Chebyshev coefficients with no stored unit, written as mol, cm, s values.
Written after a conversion:
- Every A, to mol, cm, s.
- Chebyshev coefficients stored for a rate in other units. The series is of log10 k, so the logarithm of the unit factor is added to its first coefficient. Both files hold the converted fit to a relative 1e-12 of the stored one, in every unit TCKDB stores a rate in.
Isotope labels are not written: the species is written with its elements and
a composition gap says the labels were dropped. A missing activation energy
is written as zero.
A third-body collider is written under the name its species has in the file. No file of an export contains a database id.
The manifest
manifest.json states what was written and what was not:
counts.reaction_lines: reactions written. A sum of Arrhenius terms writes one reaction per term.gaps: one entry for each species or reaction that is missing or incomplete in the file, with its ref, akindand the reason.counts.gaps_by_kind: the gaps counted by kind.transport(Cantera) ortransport_file(CHEMKIN):written, and when it is false areason_codeandreason. The Cantera block also hasphase_model. Neither block counts species; a species whose transport is missing is atransportgap.
Read the gaps before using the file. A gap of kind kinetics is a reaction
that is not in the file. A gap of kind kinetics_units_assumed is a reaction
that is in the file with a value read as mol, cm, s because the record stores
no unit for it. A gap of kind kinetics_reversible is a reaction that is in
the file with <=> because its kinetics record does not state whether the
rate is reversible.
CHEMKIN
chem.inp and therm.dat load with Cantera's ck2yaml; the export is tested
against Cantera 3.2.0.
The charge of an ion is written as its electron count, element E, in the
ELEMENTS block and in the element fields of its NASA-7 card: E -1 for a
cation of charge +1. A composition that does not fit the four element fields
of a card (more than four elements, the charge counting as one, or a count of
more than three digits) is written in CHEMKIN's extended form: the first line
of the card ends with & and the next line lists every element and its
count. This is the & continuation of later CHEMKIN releases. Cantera's
ck2yaml reads it; a strict CHEMKIN-II reader will not. No other reader was
tested.
A species name is limited to 18 characters, the name field of a NASA-7 card;
a longer name would shift every column after it. The public_ref naming
policy is therefore refused with 422
export_chemkin_naming_policy_unsupported. Under the formula policy, an
export with a species whose name is longer is refused with 422
export_chemkin_species_name_too_long; context.species lists the species
entries. Leave them out, or use the Cantera YAML export, which has no limit.
tran.dat is written only when it has a line for every species of the file:
a reader that takes a transport file needs every species in it. When some
species have none, no tran.dat is written,
transport_file.reason_code is not_every_species_has_transport,
transport_file.reason counts the species that have a line, and each species
without one is a transport gap.
Cantera YAML
mechanism.yaml is a Cantera input file with one ideal-gas phase. It loads
with cantera.Solution("mechanism.yaml"); the export is tested against
Cantera 3.2.0.
The units block is length: cm, time: s, quantity: mol and the
activation-energy unit you asked for. Pressures are written in bar.
| TCKDB record | Cantera YAML |
|---|---|
| NASA-7 thermo | thermo: {model: NASA7} |
| NASA-9 thermo | thermo: {model: NASA9} |
| Lennard-Jones transport | transport: {model: gas} with geometry, well-depth, diameter and, when stored, dipole, polarizability, rotational-relaxation |
| Arrhenius, modified Arrhenius | type: elementary |
| Third-body Arrhenius | type: three-body with efficiencies |
| Lindemann, Troe, SRI | type: falloff with Troe or SRI parameters and efficiencies |
| PLOG | type: pressure-dependent-Arrhenius |
| Chebyshev | type: Chebyshev |
| Sum of Arrhenius terms | one elementary reaction per term, each with duplicate: true |
Rate whose record states reversible: false |
=> in the equation; otherwise <=> |
Each species and reaction carries a note with its TCKDB refs, so a line in
the file can be traced to its record. A reaction written with an assumed unit
has units_assumed=mol,cm,s in its note.
What differs between the formats
Only the Cantera file holds:
- NASA-9 thermo. CHEMKIN holds NASA-7 only, so a species with NASA-9 thermo
alone has no entry in the CHEMKIN files and its reactions are
kineticsgaps there. - Numbers with every stored digit. The CHEMKIN files write nine significant digits, except a Chebyshev block, which is written with every digit.
- The
public_refnaming policy, and a species name of more than 18 characters. The CHEMKIN export refuses both. - Transport for some species only. The Cantera phase names the
mixture-averagedtransport model only when every species in the file has transport data; otherwise the species that have data keep it, the phase names no transport model, and the manifest says so undertransport.phase_model. The CHEMKIN export writes notran.datthen.
For every other record the two manifests list the same gaps in the same
words, and counts is the same.
Uncertainties, reaction-path degeneracy and tunnelling corrections are stored by TCKDB and written by neither format.