mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Merge pull request #861 from paulromano/multipole-tally-fix
Fix bug tallying reaction rates with multipole
This commit is contained in:
commit
9d22f149d7
8 changed files with 147 additions and 125 deletions
|
|
@ -306,7 +306,7 @@
|
|||
<parameters>-160 -160 -183 160 160 183</parameters>
|
||||
</space>
|
||||
</source>
|
||||
<temperature_multipole>True</temperature_multipole>
|
||||
<temperature_multipole>true</temperature_multipole>
|
||||
</settings>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<tallies>
|
||||
|
|
|
|||
|
|
@ -43,19 +43,13 @@
|
|||
<parameters>-1 -1 -1 1 1 1</parameters>
|
||||
</space>
|
||||
</source>
|
||||
<temperature_multipole>True</temperature_multipole>
|
||||
<temperature_multipole>true</temperature_multipole>
|
||||
<temperature_tolerance>1000</temperature_tolerance>
|
||||
</settings>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<plots>
|
||||
<plot basis="xy" color_by="cell" filename="cellplot" id="1" type="slice">
|
||||
<origin>0 0 0</origin>
|
||||
<width>7 7</width>
|
||||
<pixels>400 400</pixels>
|
||||
</plot>
|
||||
<plot basis="xy" color_by="material" filename="matplot" id="2" type="slice">
|
||||
<origin>0 0 0</origin>
|
||||
<width>7 7</width>
|
||||
<pixels>400 400</pixels>
|
||||
</plot>
|
||||
</plots>
|
||||
<tallies>
|
||||
<tally id="10000">
|
||||
<nuclides>U235 O16 total</nuclides>
|
||||
<scores>total fission (n,gamma) elastic (n,p)</scores>
|
||||
</tally>
|
||||
</tallies>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,36 @@
|
|||
k-combined:
|
||||
1.363786E+00 1.103929E-02
|
||||
tally 1:
|
||||
3.960375E+00
|
||||
3.138356E+00
|
||||
2.875799E+00
|
||||
1.655329E+00
|
||||
5.521904E-01
|
||||
6.105083E-02
|
||||
4.617974E-01
|
||||
4.274130E-02
|
||||
0.000000E+00
|
||||
0.000000E+00
|
||||
2.254165E+01
|
||||
1.016444E+02
|
||||
0.000000E+00
|
||||
0.000000E+00
|
||||
6.839351E-04
|
||||
9.359599E-08
|
||||
2.251829E+01
|
||||
1.014341E+02
|
||||
4.903575E-05
|
||||
1.199780E-09
|
||||
3.595002E+02
|
||||
2.586079E+04
|
||||
2.875799E+00
|
||||
1.655329E+00
|
||||
2.174747E+00
|
||||
9.465589E-01
|
||||
3.543564E+02
|
||||
2.512619E+04
|
||||
4.903575E-05
|
||||
1.199780E-09
|
||||
Cell
|
||||
ID = 11
|
||||
Name =
|
||||
|
|
|
|||
|
|
@ -4,94 +4,69 @@ import sys
|
|||
sys.path.insert(0, os.pardir)
|
||||
from testing_harness import TestHarness, PyAPITestHarness
|
||||
import openmc
|
||||
import openmc.model
|
||||
|
||||
|
||||
def make_model():
|
||||
model = openmc.model.Model()
|
||||
|
||||
# Materials
|
||||
moderator = openmc.Material(material_id=1)
|
||||
moderator.set_density('g/cc', 1.0)
|
||||
moderator.add_nuclide('H1', 2.0)
|
||||
moderator.add_nuclide('O16', 1.0)
|
||||
moderator.add_s_alpha_beta('c_H_in_H2O')
|
||||
|
||||
dense_fuel = openmc.Material(material_id=2)
|
||||
dense_fuel.set_density('g/cc', 4.5)
|
||||
dense_fuel.add_nuclide('U235', 1.0)
|
||||
|
||||
model.materials += [moderator, dense_fuel]
|
||||
|
||||
# Geometry
|
||||
c1 = openmc.Cell(cell_id=1, fill=moderator)
|
||||
mod_univ = openmc.Universe(universe_id=1, cells=(c1,))
|
||||
|
||||
r0 = openmc.ZCylinder(R=0.3)
|
||||
c11 = openmc.Cell(cell_id=11, fill=dense_fuel, region=-r0)
|
||||
c11.temperature = [500, 0, 700, 800]
|
||||
c12 = openmc.Cell(cell_id=12, fill=moderator, region=+r0)
|
||||
fuel_univ = openmc.Universe(universe_id=11, cells=(c11, c12))
|
||||
|
||||
lat = openmc.RectLattice(lattice_id=101)
|
||||
lat.dimension = [2, 2]
|
||||
lat.lower_left = [-2.0, -2.0]
|
||||
lat.pitch = [2.0, 2.0]
|
||||
lat.universes = [[fuel_univ]*2]*2
|
||||
lat.outer = mod_univ
|
||||
|
||||
x0 = openmc.XPlane(x0=-3.0)
|
||||
x1 = openmc.XPlane(x0=3.0)
|
||||
y0 = openmc.YPlane(y0=-3.0)
|
||||
y1 = openmc.YPlane(y0=3.0)
|
||||
for s in [x0, x1, y0, y1]:
|
||||
s.boundary_type = 'reflective'
|
||||
c101 = openmc.Cell(cell_id=101, fill=lat, region=+x0 & -x1 & +y0 & -y1)
|
||||
model.geometry.root_universe = openmc.Universe(universe_id=0, cells=(c101,))
|
||||
|
||||
# Settings
|
||||
model.settings.batches = 5
|
||||
model.settings.inactive = 0
|
||||
model.settings.particles = 1000
|
||||
model.settings.source = openmc.Source(space=openmc.stats.Box(
|
||||
[-1, -1, -1], [1, 1, 1]))
|
||||
model.settings.temperature = {'tolerance': 1000, 'multipole': True}
|
||||
|
||||
# Tallies
|
||||
tally = openmc.Tally()
|
||||
tally.nuclides = ['U235', 'O16', 'total']
|
||||
tally.scores = ['total', 'fission', '(n,gamma)', 'elastic', '(n,p)']
|
||||
model.tallies.append(tally)
|
||||
|
||||
return model
|
||||
|
||||
|
||||
class MultipoleTestHarness(PyAPITestHarness):
|
||||
def _build_inputs(self):
|
||||
####################
|
||||
# Materials
|
||||
####################
|
||||
|
||||
moderator = openmc.Material(material_id=1)
|
||||
moderator.set_density('g/cc', 1.0)
|
||||
moderator.add_nuclide('H1', 2.0)
|
||||
moderator.add_nuclide('O16', 1.0)
|
||||
moderator.add_s_alpha_beta('c_H_in_H2O')
|
||||
|
||||
dense_fuel = openmc.Material(material_id=2)
|
||||
dense_fuel.set_density('g/cc', 4.5)
|
||||
dense_fuel.add_nuclide('U235', 1.0)
|
||||
|
||||
mats_file = openmc.Materials([moderator, dense_fuel])
|
||||
mats_file.export_to_xml()
|
||||
|
||||
####################
|
||||
# Geometry
|
||||
####################
|
||||
|
||||
c1 = openmc.Cell(cell_id=1, fill=moderator)
|
||||
mod_univ = openmc.Universe(universe_id=1, cells=(c1,))
|
||||
|
||||
r0 = openmc.ZCylinder(R=0.3)
|
||||
c11 = openmc.Cell(cell_id=11, fill=dense_fuel, region=-r0)
|
||||
c11.temperature = [500, 0, 700, 800]
|
||||
c12 = openmc.Cell(cell_id=12, fill=moderator, region=+r0)
|
||||
fuel_univ = openmc.Universe(universe_id=11, cells=(c11, c12))
|
||||
|
||||
lat = openmc.RectLattice(lattice_id=101)
|
||||
lat.dimension = [2, 2]
|
||||
lat.lower_left = [-2.0, -2.0]
|
||||
lat.pitch = [2.0, 2.0]
|
||||
lat.universes = [[fuel_univ]*2]*2
|
||||
lat.outer = mod_univ
|
||||
|
||||
x0 = openmc.XPlane(x0=-3.0)
|
||||
x1 = openmc.XPlane(x0=3.0)
|
||||
y0 = openmc.YPlane(y0=-3.0)
|
||||
y1 = openmc.YPlane(y0=3.0)
|
||||
for s in [x0, x1, y0, y1]:
|
||||
s.boundary_type = 'reflective'
|
||||
c101 = openmc.Cell(cell_id=101, fill=lat, region=+x0 & -x1 & +y0 & -y1)
|
||||
root_univ = openmc.Universe(universe_id=0, cells=(c101,))
|
||||
|
||||
geometry = openmc.Geometry(root_univ)
|
||||
geometry.export_to_xml()
|
||||
|
||||
####################
|
||||
# Settings
|
||||
####################
|
||||
|
||||
sets_file = openmc.Settings()
|
||||
sets_file.batches = 5
|
||||
sets_file.inactive = 0
|
||||
sets_file.particles = 1000
|
||||
sets_file.source = openmc.Source(space=openmc.stats.Box(
|
||||
[-1, -1, -1], [1, 1, 1]))
|
||||
sets_file.temperature = {'tolerance': 1000, 'multipole': True}
|
||||
sets_file.export_to_xml()
|
||||
|
||||
####################
|
||||
# Plots
|
||||
####################
|
||||
|
||||
plot1 = openmc.Plot(plot_id=1)
|
||||
plot1.basis = 'xy'
|
||||
plot1.color_by = 'cell'
|
||||
plot1.filename = 'cellplot'
|
||||
plot1.origin = (0, 0, 0)
|
||||
plot1.width = (7, 7)
|
||||
plot1.pixels = (400, 400)
|
||||
|
||||
plot2 = openmc.Plot(plot_id=2)
|
||||
plot2.basis = 'xy'
|
||||
plot2.color_by = 'material'
|
||||
plot2.filename = 'matplot'
|
||||
plot2.origin = (0, 0, 0)
|
||||
plot2.width = (7, 7)
|
||||
plot2.pixels = (400, 400)
|
||||
|
||||
plots = openmc.Plots([plot1, plot2])
|
||||
plots.export_to_xml()
|
||||
|
||||
def execute_test(self):
|
||||
if not 'OPENMC_MULTIPOLE_LIBRARY' in os.environ:
|
||||
raise RuntimeError("The 'OPENMC_MULTIPOLE_LIBRARY' environment "
|
||||
|
|
@ -107,5 +82,6 @@ class MultipoleTestHarness(PyAPITestHarness):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = MultipoleTestHarness('statepoint.5.h5')
|
||||
model = make_model()
|
||||
harness = MultipoleTestHarness('statepoint.5.h5', model)
|
||||
harness.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue