OpenMC/tests/regression_tests/photon_source/test.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.6 KiB
Python
Raw Permalink Normal View History

2018-07-04 20:57:29 -05:00
from math import pi
import numpy as np
import openmc
from tests.testing_harness import PyAPITestHarness
class SourceTestHarness(PyAPITestHarness):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
2018-07-04 20:57:29 -05:00
mat = openmc.Material()
mat.set_density('g/cm3', 0.998207)
mat.add_element('H', 0.111894)
mat.add_element('O', 0.888106)
self._model.materials = openmc.Materials([mat])
2018-07-04 20:57:29 -05:00
sphere = openmc.Sphere(r=1.0e9, boundary_type='reflective')
2018-07-04 20:57:29 -05:00
inside_sphere = openmc.Cell()
inside_sphere.region = -sphere
inside_sphere.fill = mat
self._model.geometry = openmc.Geometry([inside_sphere])
source = openmc.IndependentSource()
2018-07-04 20:57:29 -05:00
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'
2018-07-04 20:57:29 -05:00
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
self._model.settings = settings
2018-07-05 23:25:42 -05:00
particle_filter = openmc.ParticleFilter('photon')
2018-07-04 20:57:29 -05:00
tally = openmc.Tally()
2018-07-05 23:25:42 -05:00
tally.filters = [particle_filter]
tally.scores = ['flux', '(n,gamma)']
2018-07-04 20:57:29 -05:00
tallies = openmc.Tallies([tally])
self._model.tallies = tallies
2018-07-04 20:57:29 -05:00
2018-09-13 11:27:40 -05:00
def test_photon_source():
harness = SourceTestHarness('statepoint.1.h5', model=openmc.Model())
2018-07-04 20:57:29 -05:00
harness.main()