mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Replace four source tests with a single comprehensive one. Also fix a few bugs.
This commit is contained in:
parent
daeddd8002
commit
d244913b4c
27 changed files with 89 additions and 194 deletions
|
|
@ -278,7 +278,7 @@ class SpatialIndependent(Spatial):
|
|||
cv.check_type('y coordinate', y, Univariate)
|
||||
self._y = y
|
||||
|
||||
@x.setter
|
||||
@z.setter
|
||||
def z(self, z):
|
||||
cv.check_type('z coordinate', z, Univariate)
|
||||
self._z = z
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ class Maxwell(Univariate):
|
|||
|
||||
def to_xml(self):
|
||||
element = ET.Element(self.name)
|
||||
element.set("type", "uniform")
|
||||
element.set("type", "maxwell")
|
||||
element.set("parameters", str(self.theta))
|
||||
return element
|
||||
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ element settings {
|
|||
distribution =
|
||||
(element type { xsd:string { maxLength = "16" } } |
|
||||
attribute type { xsd:string { maxLength = "16" } }) &
|
||||
(element interpolation { xsd:string { maxLength = "10" } } |
|
||||
attribute interpolation { xsd:string { maxLength = "10" } })? &
|
||||
(element interpolation { xsd:string } |
|
||||
attribute interpolation { xsd:string })? &
|
||||
(element parameters { list { xsd:double+ } } |
|
||||
attribute parameters { list { xsd:double+ } })?
|
||||
}
|
||||
|
|
|
|||
|
|
@ -350,16 +350,18 @@
|
|||
<optional>
|
||||
<choice>
|
||||
<element name="reference_uvw">
|
||||
<data type="double"/>
|
||||
<data type="double"/>
|
||||
<data type="double"/>
|
||||
<list>
|
||||
<data type="double"/>
|
||||
<data type="double"/>
|
||||
<data type="double"/>
|
||||
</list>
|
||||
</element>
|
||||
<attribute name="reference_uvw">
|
||||
<group>
|
||||
<list>
|
||||
<data type="double"/>
|
||||
<data type="double"/>
|
||||
<data type="double"/>
|
||||
</group>
|
||||
</list>
|
||||
</attribute>
|
||||
</choice>
|
||||
</optional>
|
||||
|
|
@ -410,14 +412,10 @@
|
|||
<optional>
|
||||
<choice>
|
||||
<element name="interpolation">
|
||||
<data type="string">
|
||||
<param name="maxLength">10</param>
|
||||
</data>
|
||||
<data type="string"/>
|
||||
</element>
|
||||
<attribute name="interpolation">
|
||||
<data type="string">
|
||||
<param name="maxLength">10</param>
|
||||
</data>
|
||||
<data type="string"/>
|
||||
</attribute>
|
||||
</choice>
|
||||
</optional>
|
||||
|
|
|
|||
1
tests/test_source/inputs_true.dat
Normal file
1
tests/test_source/inputs_true.dat
Normal file
|
|
@ -0,0 +1 @@
|
|||
8469cedcf2d3511a80d0f931bc665178ef1bd5b51352dc567385e52c32ad680a1131c8ee079bc022d320c3ea454798afac6b8cac8937a17de92d6cd50d04d72c
|
||||
2
tests/test_source/results_true.dat
Normal file
2
tests/test_source/results_true.dat
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
k-combined:
|
||||
3.014392E-01 7.185055E-03
|
||||
73
tests/test_source/test_source.py
Normal file
73
tests/test_source/test_source.py
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from math import pi
|
||||
import os
|
||||
import sys
|
||||
|
||||
import numpy as np
|
||||
|
||||
sys.path.insert(0, os.pardir)
|
||||
from testing_harness import PyAPITestHarness
|
||||
import openmc
|
||||
import openmc.stats
|
||||
from openmc.source import Source
|
||||
|
||||
|
||||
class SourceTestHarness(PyAPITestHarness):
|
||||
def _build_inputs(self):
|
||||
mat1 = openmc.Material(material_id=1)
|
||||
mat1.set_density('g/cm3', 4.5)
|
||||
mat1.add_nuclide(openmc.Nuclide('U-235', '71c'), 1.0)
|
||||
materials = openmc.MaterialsFile()
|
||||
materials.add_material(mat1)
|
||||
materials.export_to_xml()
|
||||
|
||||
sphere = openmc.Sphere(surface_id=1, R=10.0, boundary_type='vacuum')
|
||||
inside_sphere = openmc.Cell(cell_id=1)
|
||||
inside_sphere.region = -sphere
|
||||
inside_sphere.fill = mat1
|
||||
|
||||
root = openmc.Universe(universe_id=0)
|
||||
root.add_cell(inside_sphere)
|
||||
geometry = openmc.Geometry()
|
||||
geometry.root_universe = root
|
||||
geometry_xml = openmc.GeometryFile()
|
||||
geometry_xml.geometry = geometry
|
||||
geometry_xml.export_to_xml()
|
||||
|
||||
# Create an array of different sources
|
||||
x_dist = openmc.stats.Uniform('x', -3., 3.)
|
||||
y_dist = openmc.stats.Discrete('y', [-4., -1., 3.], [0.2, 0.3, 0.5])
|
||||
z_dist = openmc.stats.Tabular('z', [-2., 0., 2.], [0.2, 0.3, 0.2])
|
||||
spatial1 = openmc.stats.SpatialIndependent(x_dist, y_dist, z_dist)
|
||||
spatial2 = openmc.stats.SpatialBox([-4., -4., -4.], [4., 4., 4.])
|
||||
spatial3 = openmc.stats.SpatialPoint([1.2, -2.3, 0.781])
|
||||
|
||||
mu_dist = openmc.stats.Discrete('mu', [-1., 0., 1.], [0.5, 0.25, 0.25])
|
||||
phi_dist = openmc.stats.Uniform('phi', 0., 2.*pi)
|
||||
angle1 = openmc.stats.PolarAzimuthal(mu_dist, phi_dist)
|
||||
angle2 = openmc.stats.Monodirectional(reference_uvw=[0., 1., 0.])
|
||||
angle3 = openmc.stats.Isotropic()
|
||||
|
||||
E = np.logspace(-6, 1)
|
||||
p = np.sin(np.linspace(0., pi))
|
||||
p /= sum(np.diff(E)*p[:-1])
|
||||
energy1 = openmc.stats.Maxwell(1.2895)
|
||||
energy2 = openmc.stats.Watt(0.988, 2.249)
|
||||
energy3 = openmc.stats.Tabular('energy', E, p, interpolation='histogram')
|
||||
|
||||
source1 = Source(spatial1, angle1, energy1, strength=0.5)
|
||||
source2 = Source(spatial2, angle2, energy2, strength=0.3)
|
||||
source3 = Source(spatial3, angle3, energy3, strength=0.2)
|
||||
|
||||
settings = openmc.SettingsFile()
|
||||
settings.batches = 10
|
||||
settings.inactive = 5
|
||||
settings.particles = 1000
|
||||
settings.source = [source1, source2, source3]
|
||||
settings.export_to_xml()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = SourceTestHarness('statepoint.10.h5')
|
||||
harness.main()
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<geometry>
|
||||
|
||||
<!-- Sphere with radius 10 -->
|
||||
<surface id="1" type="sphere" coeffs="0 0 0 10" boundary="vacuum"/>
|
||||
<cell id="1" material="1" region="-1" />
|
||||
|
||||
</geometry>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<materials>
|
||||
|
||||
<material id="1">
|
||||
<density value="4.5" units="g/cc" />
|
||||
<nuclide name="U-235" xs="71c" ao="1.0" />
|
||||
</material>
|
||||
|
||||
</materials>
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
k-combined:
|
||||
2.964943E-01 1.201478E-02
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<settings>
|
||||
|
||||
<eigenvalue>
|
||||
<batches>10</batches>
|
||||
<inactive>5</inactive>
|
||||
<particles>1000</particles>
|
||||
</eigenvalue>
|
||||
|
||||
<source>
|
||||
<space type="box" parameters="-4 -4 -4 4 4 4" />
|
||||
<angle type="monodirectional" reference_uvw="1 0 0" />
|
||||
</source>
|
||||
|
||||
</settings>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.pardir)
|
||||
from testing_harness import TestHarness
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.main()
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<geometry>
|
||||
|
||||
<!-- Sphere with radius 10 -->
|
||||
<surface id="1" type="sphere" coeffs="0 0 0 10" boundary="vacuum"/>
|
||||
<cell id="1" material="1" region="-1" />
|
||||
|
||||
</geometry>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<materials>
|
||||
|
||||
<material id="1">
|
||||
<density value="4.5" units="g/cc" />
|
||||
<nuclide name="U-235" xs="71c" ao="1.0" />
|
||||
</material>
|
||||
|
||||
</materials>
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
k-combined:
|
||||
2.886671E-01 7.534631E-03
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<settings>
|
||||
|
||||
<eigenvalue>
|
||||
<batches>10</batches>
|
||||
<inactive>5</inactive>
|
||||
<particles>1000</particles>
|
||||
</eigenvalue>
|
||||
|
||||
<source>
|
||||
<space type="box" parameters="-4 -4 -4 4 4 4" />
|
||||
<energy type="maxwell" parameters="1.2895" />
|
||||
</source>
|
||||
|
||||
</settings>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.pardir)
|
||||
from testing_harness import TestHarness
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.main()
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<geometry>
|
||||
|
||||
<!-- Sphere with radius 10 -->
|
||||
<surface id="1" type="sphere" coeffs="0 0 0 10" boundary="vacuum"/>
|
||||
<cell id="1" material="1" region="-1" />
|
||||
|
||||
</geometry>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<materials>
|
||||
|
||||
<material id="1">
|
||||
<density value="4.5" units="g/cc" />
|
||||
<nuclide name="U-235" xs="71c" ao="1.0" />
|
||||
</material>
|
||||
|
||||
</materials>
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
k-combined:
|
||||
3.002731E-01 7.561170E-03
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<settings>
|
||||
|
||||
<eigenvalue>
|
||||
<batches>10</batches>
|
||||
<inactive>5</inactive>
|
||||
<particles>1000</particles>
|
||||
</eigenvalue>
|
||||
|
||||
<source>
|
||||
<space type="box" parameters="-4 -4 -4 4 4 4" />
|
||||
<energy type="discrete" parameters="0.0253e-6 1.0" />
|
||||
</source>
|
||||
|
||||
</settings>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.pardir)
|
||||
from testing_harness import TestHarness
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.main()
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<geometry>
|
||||
|
||||
<!-- Sphere with radius 10 -->
|
||||
<surface id="1" type="sphere" coeffs="0 0 0 10" boundary="vacuum"/>
|
||||
<cell id="1" material="1" region="-1" />
|
||||
|
||||
</geometry>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<materials>
|
||||
|
||||
<material id="1">
|
||||
<density value="4.5" units="g/cc" />
|
||||
<nuclide name="U-235" xs="71c" ao="1.0" />
|
||||
</material>
|
||||
|
||||
</materials>
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
k-combined:
|
||||
3.041148E-01 4.558319E-03
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<settings>
|
||||
|
||||
<eigenvalue>
|
||||
<batches>10</batches>
|
||||
<inactive>5</inactive>
|
||||
<particles>1000</particles>
|
||||
</eigenvalue>
|
||||
|
||||
<source>
|
||||
<space type="point" parameters="1.2 -2.3 0.781" />
|
||||
</source>
|
||||
|
||||
</settings>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.pardir)
|
||||
from testing_harness import TestHarness
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = TestHarness('statepoint.10.*')
|
||||
harness.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue