Add photon tests

This commit is contained in:
amandalund 2018-07-04 20:57:29 -05:00
parent 11516a8e5c
commit 042c1f94de
10 changed files with 248 additions and 5 deletions

View file

@ -0,0 +1,41 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="13" material="13" region="-9" universe="9" />
<surface boundary="reflective" coeffs="0.0 0.0 0.0 1000000000.0" id="9" type="sphere" />
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material id="13">
<density units="g/cm3" value="0.998207" />
<nuclide ao="0.11187657362844" name="H1" />
<nuclide ao="1.7426371559999997e-05" name="H2" />
<nuclide ao="0.8877694078259999" name="O16" />
<nuclide ao="0.000336592174" name="O17" />
</material>
</materials>
<?xml version='1.0' encoding='utf-8'?>
<settings>
<run_mode>fixed source</run_mode>
<particles>10000</particles>
<batches>1</batches>
<source particle="photon" strength="1.0">
<space type="point">
<parameters>0 0 0</parameters>
</space>
<angle type="isotropic" />
<energy type="discrete">
<parameters>10000000.0 1.0</parameters>
</energy>
</source>
<electron_treatment>ttb</electron_treatment>
<photon_transport>true</photon_transport>
<cutoff>
<energy_photon>1000.0</energy_photon>
</cutoff>
</settings>
<?xml version='1.0' encoding='utf-8'?>
<tallies>
<tally id="1">
<scores>flux</scores>
</tally>
</tallies>

View file

@ -0,0 +1,3 @@
tally 1:
sum = 2.254985E+02
sum_sq = 5.084955E+04

View file

@ -0,0 +1,61 @@
from math import pi
import numpy as np
import openmc
from tests.testing_harness import PyAPITestHarness
class SourceTestHarness(PyAPITestHarness):
def _build_inputs(self):
mat = openmc.Material()
mat.set_density('g/cm3', 0.998207)
mat.add_element('H', 0.111894)
mat.add_element('O', 0.888106)
materials = openmc.Materials([mat])
materials.export_to_xml()
sphere = openmc.Sphere(R=1.0e9, boundary_type='reflective')
inside_sphere = openmc.Cell()
inside_sphere.region = -sphere
inside_sphere.fill = mat
root = openmc.Universe()
root.add_cell(inside_sphere)
geometry = openmc.Geometry(root)
geometry.export_to_xml()
source = openmc.Source()
source.space = openmc.stats.Point((0, 0, 0))
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([10.0e6], [1.0])
source.particle = 'photon'
settings = openmc.Settings()
settings.particles = 10000
settings.batches = 1
settings.photon_transport = True
settings.electron_treatment = 'ttb'
settings.cutoff = {'energy_photon' : 1000.0}
settings.run_mode = 'fixed source'
settings.source = source
settings.export_to_xml()
tally = openmc.Tally()
tally.scores = ['flux']
tallies = openmc.Tallies([tally])
tallies.export_to_xml()
def _get_results(self):
sp = openmc.StatePoint(self._sp_name)
outstr = ''
t = sp.get_tally()
outstr += 'tally {}:\n'.format(t.id)
outstr += 'sum = {:12.6E}\n'.format(t.sum[0, 0, 0])
outstr += 'sum_sq = {:12.6E}\n'.format(t.sum_sq[0, 0, 0])
return outstr
def test_source():
harness = SourceTestHarness('statepoint.1.h5')
harness.main()