Have openmc-update-inputs change 'surfaces' to 'region'

This commit is contained in:
Paul Romano 2015-09-28 19:01:10 +07:00
parent 463991ce86
commit 6c6676cc14
5 changed files with 28 additions and 19 deletions

View file

@ -5,11 +5,11 @@
<cell id="1" universe="0" fill="37" region="-2" />
<cell id="100" universe="37" material="40" region="-1" />
<cell id="101" universe="37" material="41" region="1" />
<cell id="2" universe="0" material="41" surfaces = "2 -3" />
<cell id="2" universe="0" material="41" region="2 -3" />
<!-- Defition of Surfaces -->
<surface id="1" type="z-cylinder" coeffs="0 0 7" />
<surface id="2" type="z-cylinder" coeffs="0 0 9" />
<surface id="3" type="z-cylinder" coeffs="0 0 11" boundary="vacuum" />
</geometry>

View file

@ -5,15 +5,15 @@
<cell id="1">
<universe>0</universe>
<material>1</material>
<surfaces>1 -2 3 -4 5 -6</surfaces>
<region>1 -2 3 -4 5 -6</region>
</cell>
<!-- Defition of Surfaces -->
<surface id="1" type="x-plane" coeffs="-1" boundary="vacuum" />
<surface id="2" type="x-plane" coeffs="1" boundary="vacuum" />
<surface id="3" type="y-plane" coeffs="-1" boundary="reflective" />
<surface id="3" type="y-plane" coeffs="-1" boundary="reflective" />
<surface id="4" type="y-plane" coeffs="1" boundary="reflective" />
<surface id="5" type="z-plane" coeffs="-1" boundary="reflective" />
<surface id="5" type="z-plane" coeffs="-1" boundary="reflective" />
<surface id="6" type="z-plane" coeffs="1" boundary="reflective" />
</geometry>

View file

@ -1,14 +1,15 @@
#!/usr/bin/env python
"""Update OpenMC's input XML files to the latest format.
Usage information can be obtained by running 'update_inputs.py --help':
Usage information can be obtained by running 'openmc-update-inputs --help':
usage: update_lattices.py [-h] IN [IN ...]
usage: openmc-update-inputs [-h] IN [IN ...]
Update lattices in geometry.xml files to the latest format. This will remove
'outside' attributes/elements and replace them with 'outer' attributes. Note
that this script will not delete the given files; it will append '.original'
to the given files and write new ones.
Update geometry.xml files to the latest format. This will remove 'outside'
attributes/elements from lattices and replace them with 'outer' attributes. For
'cell' elements, any 'surfaces' attributes/elements will be renamed
'region'. Note that this script will not delete the given files; it will append
'.original' to the given files and write new ones.
positional arguments:
IN Input geometry.xml file(s).
@ -173,9 +174,6 @@ def update_geometry(geometry_root):
root = geometry_root
was_updated = False
# Ignore files that do not contain lattices.
if all([child.tag != 'lattice' for child in root]): return False
# Get a set of already-used universe and cell ids.
uids = get_universe_ids(root)
cids = get_cell_ids(root)
@ -233,6 +231,17 @@ def update_geometry(geometry_root):
del lat.attrib['width']
was_updated = True
# Change 'surfaces' to 'region' in cell definitions
for cell in root.iter('cell'):
elem = cell.find('surfaces')
if elem is not None:
elem.tag = 'region'
was_updated = True
if 'surfaces' in cell.attrib:
cell.attrib['region'] = cell.attrib['surfaces']
del cell.attrib['surfaces']
was_updated = True
return was_updated

View file

@ -4,7 +4,7 @@
<!-- Definition of Cells -->
<cell id="1">
<universe>0</universe>
<surfaces>-1 2 -3 4 -5 6</surfaces>
<region>-1 2 -3 4 -5 6</region>
<material>1</material>
</cell>
@ -39,5 +39,5 @@
<coeffs>-1</coeffs>
<boundary>reflective</boundary>
</surface>
</geometry>

View file

@ -4,7 +4,7 @@
<!-- Definition of Cells -->
<cell id="1">
<universe>0</universe>
<surfaces>-1 2 -3 4 -5 6</surfaces>
<region>-1 2 -3 4 -5 6</region>
<material>1</material>
</cell>
@ -39,5 +39,5 @@
<coeffs>-1</coeffs>
<boundary>reflective</boundary>
</surface>
</geometry>