[ctml2yaml] Add SRI falloff reaction type

This commit is contained in:
Bryan W. Weber
2019-12-01 21:07:42 -05:00
parent 7b2a2f9b53
commit 51ae226642
2 changed files with 28 additions and 1 deletions
+21 -1
View File
@@ -1410,7 +1410,7 @@ class Reaction:
"Falloff reaction types must have a falloff node.", rate_coeff
)
falloff_type = falloff_node.get("type")
if falloff_type not in ["Lindemann", "Troe"]:
if falloff_type not in ["Lindemann", "Troe", "SRI"]:
raise TypeError(
"Unknown falloff type '{}' for reaction id {}".format(
falloff_type, reaction.get("id")
@@ -1488,6 +1488,26 @@ class Reaction:
def to_yaml(cls, representer, data):
return representer.represent_dict(data.attribs)
def sri(
self, rate_coeff: etree.Element
) -> Dict[str, Union[str, Iterable, Dict[str, float]]]:
"""Process an SRI reaction.
Returns a dictionary with the appropriate fields set that is
used to update the parent reaction entry dictionary.
"""
reaction_attribs = self.lindemann((rate_coeff))
falloff_node = rate_coeff.find("falloff")
if falloff_node is None:
raise MissingXMLNode("SRI reaction requires falloff node", rate_coeff)
SRI_names = list("ABCDE")
SRI_data = FlowMap({})
for name, param in zip(SRI_names, clean_node_text(falloff_node).split()):
SRI_data[name] = float(param)
reaction_attribs["SRI"] = SRI_data
return reaction_attribs
def threebody(
self, rate_coeff: etree.Element
) -> Dict[str, Union[str, Iterable, Dict[str, float]]]:
@@ -1095,3 +1095,10 @@ class ctml2yamlTest(utilities.CanteraTest):
Path(self.test_work_dir).joinpath('species-names.yaml'))
ctmlGas, yamlGas = self.checkConversion('species-names')
self.checkThermo(ctmlGas, yamlGas, [300, 500, 1300, 2000])
def test_sri_falloff_reaction(self):
ctml2yaml.convert(Path(self.test_data_dir).joinpath("sri-falloff.xml"),
Path(self.test_work_dir).joinpath("sri-falloff.yaml"))
ctmlGas, yamlGas = self.checkConversion("sri-falloff")
self.checkThermo(ctmlGas, yamlGas, [300, 500, 1300, 2000])
self.checkKinetics(ctmlGas, yamlGas, [900, 1800], [2e5, 20e5])