mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
added two tests to check centre was written/read to/from xml
This commit is contained in:
parent
f0f5e34b33
commit
5787616ae4
2 changed files with 60 additions and 0 deletions
30
tests/unit_tests/test_cylindrical_mesh.py
Normal file
30
tests/unit_tests/test_cylindrical_mesh.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import openmc
|
||||
import numpy as np
|
||||
|
||||
def test_centre_read_write_to_xml():
|
||||
"""Tests that the centre attribute can be written and read back to XML
|
||||
"""
|
||||
# build
|
||||
mesh = openmc.CylindricalMesh()
|
||||
mesh.phi_grid = [1, 2, 3]
|
||||
mesh.z_grid = [1, 2, 3]
|
||||
mesh.r_grid = [1, 2, 3]
|
||||
|
||||
mesh.centre = [0.1, 0.2, 0.3]
|
||||
|
||||
tally = openmc.Tally()
|
||||
|
||||
mesh_filter = openmc.MeshFilter(mesh)
|
||||
tally.filters.append(mesh_filter)
|
||||
|
||||
tally.scores.append("heating")
|
||||
|
||||
tallies = openmc.Tallies([tally])
|
||||
|
||||
tallies.export_to_xml()
|
||||
|
||||
# read back
|
||||
new_tallies = openmc.Tallies.from_xml()
|
||||
new_tally = new_tallies[0]
|
||||
new_mesh = new_tally.filters[0].mesh
|
||||
assert np.allclose(new_mesh.centre, mesh.centre)
|
||||
30
tests/unit_tests/test_spherical_mesh.py
Normal file
30
tests/unit_tests/test_spherical_mesh.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import openmc
|
||||
import numpy as np
|
||||
|
||||
def test_centre_read_write_to_xml():
|
||||
"""Tests that the centre attribute can be written and read back to XML
|
||||
"""
|
||||
# build
|
||||
mesh = openmc.SphericalMesh()
|
||||
mesh.phi_grid = [1, 2, 3]
|
||||
mesh.theta_grid = [1, 2, 3]
|
||||
mesh.r_grid = [1, 2, 3]
|
||||
|
||||
mesh.centre = [0.1, 0.2, 0.3]
|
||||
|
||||
tally = openmc.Tally()
|
||||
|
||||
mesh_filter = openmc.MeshFilter(mesh)
|
||||
tally.filters.append(mesh_filter)
|
||||
|
||||
tally.scores.append("heating")
|
||||
|
||||
tallies = openmc.Tallies([tally])
|
||||
|
||||
tallies.export_to_xml()
|
||||
|
||||
# read back
|
||||
new_tallies = openmc.Tallies.from_xml()
|
||||
new_tally = new_tallies[0]
|
||||
new_mesh = new_tally.filters[0].mesh
|
||||
assert np.allclose(new_mesh.centre, mesh.centre)
|
||||
Loading…
Add table
Add a link
Reference in a new issue