mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Add source tests and fix one failing test
This commit is contained in:
parent
18695c2878
commit
d75b715026
2 changed files with 31 additions and 1 deletions
30
tests/unit_tests/test_source.py
Normal file
30
tests/unit_tests/test_source.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import openmc
|
||||
import openmc.stats
|
||||
|
||||
|
||||
def test_source():
|
||||
space = openmc.stats.Point()
|
||||
energy = openmc.stats.Discrete([1.0e6], [1.0])
|
||||
angle = openmc.stats.Isotropic()
|
||||
|
||||
src = openmc.Source(space=space, angle=angle, energy=energy)
|
||||
assert src.space == space
|
||||
assert src.angle == angle
|
||||
assert src.energy == energy
|
||||
assert src.strength == 1.0
|
||||
|
||||
elem = src.to_xml_element()
|
||||
assert 'strength' in elem.attrib
|
||||
assert elem.find('space') is not None
|
||||
assert elem.find('angle') is not None
|
||||
assert elem.find('energy') is not None
|
||||
|
||||
|
||||
def test_source_file():
|
||||
filename = 'source.h5'
|
||||
src = openmc.Source(filename=filename)
|
||||
assert src.file == filename
|
||||
|
||||
elem = src.to_xml_element()
|
||||
assert 'strength' in elem.attrib
|
||||
assert 'file' in elem.attrib
|
||||
|
|
@ -23,7 +23,7 @@ def test_discrete():
|
|||
|
||||
|
||||
def test_uniform():
|
||||
a, b = 10, 20
|
||||
a, b = 10.0, 20.0
|
||||
d = openmc.stats.Uniform(a, b)
|
||||
assert d.a == a
|
||||
assert d.b == b
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue