Add source tests and fix one failing test

This commit is contained in:
Paul Romano 2018-01-29 17:41:10 -06:00
parent 18695c2878
commit d75b715026
2 changed files with 31 additions and 1 deletions

View 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

View file

@ -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