[interface] fix lxcat2yaml.py for no product case

This commit is contained in:
Bang-Shiuh Chen
2025-10-09 08:28:38 -04:00
committed by Ray Speth
parent 1768cf649b
commit 3fd5f18d7f
2 changed files with 41 additions and 20 deletions
+30 -20
View File
@@ -203,34 +203,44 @@ def registerProcess(process: etree.Element,
# Parse the equation
product_array=[]
for product_node in get_children(process, "products")[0]:
if product_node.tag.find("electron") != -1:
product_array.append(electron_name)
products = get_children(process, "products")
if products:
for product_node in products[0]:
if product_node.tag.find("electron") != -1:
product_array.append(electron_name)
if product_node.tag.find("molecule") != -1:
product_name = product_node.text
if "state" in product_node.attrib:
state = product_node.attrib["state"].replace(" ","-")
# State is appended in a parenthesis
product_name += f"({state})"
if "charge" in product_node.attrib:
charge = int(product_node.attrib["charge"])
if charge > 0:
product_name += charge*"+"
else:
product_name += -charge*"-"
if product_node.tag.find("molecule") != -1:
product_name = product_node.text
if "state" in product_node.attrib:
state = product_node.attrib["state"].replace(" ","-")
# State is appended in a parenthesis
product_name += f"({state})"
if "charge" in product_node.attrib:
charge = int(product_node.attrib["charge"])
if charge > 0:
product_name += charge*"+"
else:
product_name += -charge*"-"
# Filter the collision based on the existed species in the mechanism file
if gas is not None and not product_name in gas.species_names:
return
# Filter the collision based on the existed species in the mechanism file
if gas is None or product_name in gas.species_names:
product_array.append(product_name)
else:
return
for reactant_node in get_children(process, "reactants")[0]:
if reactant_node.tag.find("molecule") != -1:
reactant = reactant_node.text
# Filter the collision based on the existed species in the mechanism file
if gas is not None and not reactant in gas.species_names:
return
if product_array: # not empty
products = " + ".join(product_array)
else:
# No product is identified. Use the reactant as the product.
products = f"{reactant} + {electron_name}"
products = " + ".join(product_array)
equation = f"{reactant} + {electron_name} => {products}"
# Parse the cross-section data
+11
View File
@@ -4,6 +4,17 @@
<groups>
<group id="CO2">
<processes>
<process collisionType="elastic">
<reactants>
<electron/>
<molecule>CO2</molecule>
</reactants>
<parameters>
<parameter name="mM">1.240000e-5</parameter>
</parameters>
<data_x type="energy" units="eV">0.0 1.0</data_x>
<data_y type="cross_section" units="m2">0.0 1.0e-22</data_y>
</process>
<!-- The electron energy starts from a value larger than the threshold-->
<process collisionType="inelastic" inelasticType="ionization">
<reactants>