Units in between different YAML files

215 views
Skip to first unread message

mathieu laignel

unread,
Apr 4, 2024, 9:50:31 AM4/4/24
to Cantera Users' Group
Hello everyone,

I use CANTERA files as input in a 3D - CFD software for complex chemistry. I was previously using the XML format. With the new CANTERA version, this format is deprecated. 

I compared two files from the same mechanism (Varga,2016 in this case) and it seems that this is a different of units on pre - exponent factor when the same mechanism has been converted from CK to XML then YAML compared to a conversion from CK to YAML (directly).
I used the ctml2yaml and ck2yaml converter. One of my collegue using CANTERA 2.4.0 gave me the XML corresponding to the kinetic mechanism.
This observation has been made on pre - exponent factor only.

I wanted to know if it is an issue or a feature or if there is any documentation about it ?
If this is a feature, how can I acces the units used for each file by reading the YAML file ?

You can find enclosed all the file used.

Thanks in advance for your time,
Mathieu

Note : I tested, for an adiabatic flame, the two different YAML input files in CANTERA using Python and the laminar flame speed is identic when the pre - exponent factor are not. Is this some implicit unit conversion ?

Varga2016_from_CK.yaml
Varga2016.inp
Varga_2016.pdf
Varga2016.xml
transport_Varga2016.txt
Varga2016_from_XML.yaml

Ray Speth

unread,
Apr 18, 2024, 9:36:27 AM4/18/24
to Cantera Users' Group

Hi Mathieu,

In the XML format, pre-exponential factors were always expressed in mks+kmol units. In the YAML format, we preserve the unit system from the source input file (whether that’s CK or CTI) and do the conversion to mks+kmol when loading the mechanism. The units applying to the file are contained in the units section at the top of the file. Anything not appearing here is assumed to follow the mks+kmol default. For example, here is the units section for Varga2016_from_CK.yaml:

units: {length: cm, time: s, quantity: mol, activation-energy: K}

In contrast, Varga2016_from_XML.yaml doesn’t contain a units section, but does specify units for some quantities—namely, activation energies—on the individual values. In addition to the high-level test that the flame speed is identical when using either input file, you can also see this by examining the reaction parameters directly from the Python interface, which always uses mks+kmol units:

>>> from_ck = ct.Solution('Varga2016_from_CK.yaml') >>> from_xml = ct.Solution('Varga2016_from_XML.yaml') >>> from_ck.reaction(0) Out[4]: H + O2 <=> O + OH <Arrhenius> >>> from_ck.reaction(0).rate.pre_exponential_factor 5071200000000.001 >>> from_xml.reaction(0).rate.pre_exponential_factor 5071200000000.0 >>> from_ck.reaction(0).rate.activation_energy 67481010.05519351 >>> from_xml.reaction(0).rate.activation_energy 67481010.05519351

Finally, if you want to create a YAML file with all the values converted to a particular unit system for use in an external application, you can load the file in Python and then write a new YAML file where certain units have been specified using the write_yaml method:

fromck.write_yaml('outfile.yaml', units={'quantity': 'kmol', 'activation-energy': 'eV'})

Regards,
Ray

mathieu laignel

unread,
Apr 24, 2024, 5:50:33 AM4/24/24
to Cantera Users' Group
Hi Ray,

Thank you for your answer and your time. The option to write a yaml file with units seems to be appropriate for my use.

I still took a look at the falloff reactions of ```Varga2016_from_XML.yaml``` and ```Varga2016_from_CK.yaml``` and compared this reactions.
Looking directly in the yaml file without the python interface, I see the difference of units for example for the reaction 9 : H + O2 (+M) <=> HO2 (+M).
The high pressure rate is in cm^3/mol/s and the low pressure rate in cm^6/mol^2/s changed for kmol for XML. Everything make complete sense with what you did describe.

But, when I am looking at the reaction 26 : HCO (+ M) <=> H + CO (+ M) (a falloff reaction) , I see no difference of unit for the high pressure rate which seems not coherent.

From Varga2016_from_CK
```
  equation: HCO (+M) <=> H + CO (+M)  # Reaction 26
  type: falloff
  low-P-rate-constant: {A: 4.9426e+10, b: 0.95965, Ea: 7367.9}
  high-P-rate-constant: {A: 4.93e+16, b: -0.93, Ea: 9927.0}
  Troe: {A: 0.852, T3: 51.4, T1: 3570.0, T2: 3420.0}
  efficiencies: {H2: 2.0, O2: 1.0, AR: 0.55, HE: 0.786, H2O: 12.0, CO: 1.5, CO2: 2.0}
```
From Varga2016_from_XML
```
  equation: HCO (+ M) <=> H + CO (+ M)
  type: falloff
  high-P-rate-constant: {A: 4.93e+16, b: -0.93, Ea: 9927.0 K}
  low-P-rate-constant: {A: 4.9426e+07, b: 0.95965, Ea: 7367.9 K}
  efficiencies: {AR: 0.55, CO: 1.5, CO2: 2.0, H2: 2.0, H2O: 12.0, HE: 0.786, O2: 1.0}
  Troe: {A: 0.852, T3: 51.4, T1: 3570.0, T2: 3420.0}
```

I checked on python. The same reaction appear to be the same :

```
>>> from_xml.reaction(25).input_data
{'equation': 'HCO (+M) <=> CO + H (+M)',
 'type': 'falloff',
 'low-P-rate-constant': {'A': 49426000.0,
  'b': 0.95965,
  'Ea': 61260129.124291256},
 'high-P-rate-constant': {'A': 4.93e+16, 'b': -0.93, 'Ea': 82537670.41040722},
 'Troe': {'A': 0.852, 'T3': 51.4, 'T1': 3570.0000000000005, 'T2': 3420.0},
 'efficiencies': {'AR': 0.55,  'CO': 1.5,  'CO2': 2.0,  'H2': 2.0,'H2O': 12.0, 'HE': 0.786, 'O2': 1.0}}

>>> from_ck.reaction(25).input_data
{'equation': 'HCO (+M) <=> CO + H (+M)',
 'type': 'falloff',
 'low-P-rate-constant': {'A': 49426000.00000001,
  'b': 0.95965,
  'Ea': 61260129.124291256},
 'high-P-rate-constant': {'A': 4.93e+16, 'b': -0.93, 'Ea': 82537670.41040722},
 'Troe': {'A': 0.852, 'T3': 51.4, 'T1': 3570.0000000000005, 'T2': 3420.0},
 'efficiencies': {'AR': 0.55, 'CO': 1.5, 'CO2': 2.0,'H2': 2.0,'H2O': 12.0,  'HE': 0.786, 'O2': 1.0},
```
I checked on another mech : mei2021 (enclosed) for the two different imports and the falloff pre exponent factor might sometimes be different (reaction : HNO2 (+M) <=> HONO (+M)  # Reaction 228)
Is it something normal linked to TROE reaction ? I did not found any details on this.

Thank you again for your time,
Best regards,
Mathieu
Mei2021_from_CK.yaml
Mei2021_from_XML.yaml
Reply all
Reply to author
Forward
0 new messages