adapt the openmc-update-inputs script for surfaces (#3131)

Co-authored-by: r.haddad <r.haddad@naarea.fr>
This commit is contained in:
Rayan HADDAD 2024-10-04 01:13:18 +02:00 committed by GitHub
parent 9686851e7a
commit 3a5b218728
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,7 +1,5 @@
#!/usr/bin/env python3
"""Update OpenMC's input XML files to the latest format.
"""
"""Update OpenMC's input XML files to the latest format."""
import argparse
from itertools import chain
@ -201,6 +199,16 @@ def update_geometry(geometry_root):
was_updated = True
for surface in root.findall('surface'):
for attribute in ['type', 'coeffs', 'boundary']:
if surface.find(attribute) is not None:
value = surface.find(attribute).text
surface.attrib[attribute] = value
child_element = surface.find(attribute)
surface.remove(child_element)
was_updated = True
# Remove 'type' from lattice definitions.
for lat in root.iter('lattice'):
elem = lat.find('type')
@ -296,4 +304,4 @@ if __name__ == '__main__':
move(fname, fname + '.original')
# Write a new geometry file.
tree.write(fname, xml_declaration=True)
tree.write(fname, xml_declaration=True)