Skip to content

Commit dff3ad4

Browse files
authored
Merge pull request #2271 from eepeterson/include_volume_in_xml
Include volume in xml
2 parents 7d6bdd1 + 1a67755 commit dff3ad4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

openmc/cell.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,9 @@ def create_surface_elements(node, element, memo=None):
634634
if self.rotation is not None:
635635
element.set("rotation", ' '.join(map(str, self.rotation.ravel())))
636636

637+
if self.volume is not None:
638+
element.set("volume", str(self.volume))
639+
637640
return element
638641

639642
@classmethod
@@ -687,6 +690,9 @@ def from_xml_element(cls, elem, surfaces, materials, get_universe):
687690
c.temperature = [float(t_i) for t_i in t.split()]
688691
else:
689692
c.temperature = float(t)
693+
v = get_text(elem, 'volume')
694+
if v is not None:
695+
c.volume = float(v)
690696
for key in ('temperature', 'rotation', 'translation'):
691697
value = get_text(elem, key)
692698
if value is not None:

tests/unit_tests/test_cell.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,11 @@ def test_to_xml_element(cell_with_lattice):
294294

295295
c = cells[0]
296296
c.temperature = 900.0
297+
c.volume = 1.0
297298
elem = c.create_xml_subelement(root)
298299
assert elem.get('region') == str(c.region)
299300
assert elem.get('temperature') == str(c.temperature)
301+
assert elem.get('volume') == str(c.volume)
300302

301303

302304
@pytest.mark.parametrize("rotation", [

0 commit comments

Comments
 (0)