mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Rework statepoint and sourcepoint options for openmc.Settings
This commit is contained in:
parent
357aa894c8
commit
f866af1b16
13 changed files with 69 additions and 286 deletions
|
|
@ -605,13 +605,6 @@ following attributes/sub-elements:
|
|||
|
||||
*Default*: Last batch only
|
||||
|
||||
:interval:
|
||||
A single integer :math:`n` indicating that a state point should be written
|
||||
every :math:`n` batches. This option can be given in lieu of listing
|
||||
batches explicitly.
|
||||
|
||||
*Default*: None
|
||||
|
||||
``<source_point>`` Element
|
||||
--------------------------
|
||||
|
||||
|
|
@ -628,15 +621,6 @@ attributes/sub-elements:
|
|||
|
||||
*Default*: Last batch only
|
||||
|
||||
:interval:
|
||||
A single integer :math:`n` indicating that a state point should be written
|
||||
every :math:`n` batches. This option can be given in lieu of listing batches
|
||||
explicitly. It should be noted that if the ``separate`` attribute is not set
|
||||
to "true", this value should produce a list of batches that is a subset of
|
||||
state point batches.
|
||||
|
||||
*Default*: None
|
||||
|
||||
:separate:
|
||||
If this element is set to "true", a separate binary source point file will
|
||||
be written. Otherwise, the source sites will be written in the state point
|
||||
|
|
|
|||
|
|
@ -43,21 +43,18 @@ class Settings(object):
|
|||
Path to write output to
|
||||
verbosity : int
|
||||
Verbosity during simulation between 1 and 10
|
||||
statepoint_batches : Iterable of int
|
||||
List of batches at which to write statepoint files
|
||||
statepoint_interval : int
|
||||
Number of batches after which a new statepoint file should be written
|
||||
sourcepoint_batches : Iterable of int
|
||||
List of batches at which to write source files
|
||||
sourcepoint_interval : int
|
||||
Number of batches after which a new source file should be written
|
||||
sourcepoint_separate : bool
|
||||
Indicate whether the souce should be written as part of the statepoint
|
||||
file or on its own
|
||||
sourcepoint_write : bool
|
||||
Indicate whether the source should be written at all
|
||||
sourcepoint_overwrite : bool
|
||||
Indicate whether to
|
||||
statepoint : dict
|
||||
Options for writing state points. Acceptable keys are:
|
||||
|
||||
:batches: list of batches at which to write source
|
||||
sourcepoint : dict
|
||||
Options for writing source points. Acceptable keys are:
|
||||
|
||||
:batches: list of batches at which to write source
|
||||
:overwrite: bool indicating whether to overwrite
|
||||
:separate: bool indicating whether the source should be written as a
|
||||
separate file
|
||||
:write: bool indicating whether or not to write the source
|
||||
confidence_intervals : bool
|
||||
If True, uncertainties on tally results will be reported as the
|
||||
half-width of the 95% two-sided confidence interval. If False,
|
||||
|
|
@ -193,14 +190,9 @@ class Settings(object):
|
|||
self._output = None
|
||||
self._output_path = None
|
||||
|
||||
# Statepoint subelement
|
||||
self._statepoint_batches = None
|
||||
self._statepoint_interval = None
|
||||
self._sourcepoint_batches = None
|
||||
self._sourcepoint_interval = None
|
||||
self._sourcepoint_separate = None
|
||||
self._sourcepoint_write = None
|
||||
self._sourcepoint_overwrite = None
|
||||
# Output options
|
||||
self._statepoint = {}
|
||||
self._sourcepoint = {}
|
||||
|
||||
self._threads = None
|
||||
self._no_reduce = None
|
||||
|
|
@ -334,32 +326,12 @@ class Settings(object):
|
|||
return self._output_path
|
||||
|
||||
@property
|
||||
def statepoint_batches(self):
|
||||
return self._statepoint_batches
|
||||
def sourcepoint(self):
|
||||
return self._sourcepoint
|
||||
|
||||
@property
|
||||
def statepoint_interval(self):
|
||||
return self._statepoint_interval
|
||||
|
||||
@property
|
||||
def sourcepoint_batches(self):
|
||||
return self._sourcepoint_interval
|
||||
|
||||
@property
|
||||
def sourcepoint_interval(self):
|
||||
return self._sourcepoint_interval
|
||||
|
||||
@property
|
||||
def sourcepoint_separate(self):
|
||||
return self._sourcepoint_separate
|
||||
|
||||
@property
|
||||
def sourcepoint_write(self):
|
||||
return self._sourcepoint_write
|
||||
|
||||
@property
|
||||
def sourcepoint_overwrite(self):
|
||||
return self._sourcepoint_overwrite
|
||||
def statepoint(self):
|
||||
return self._statepoint
|
||||
|
||||
@property
|
||||
def threads(self):
|
||||
|
|
@ -553,44 +525,37 @@ class Settings(object):
|
|||
cv.check_less_than('verbosity', verbosity, 10, True)
|
||||
self._verbosity = verbosity
|
||||
|
||||
@statepoint_batches.setter
|
||||
def statepoint_batches(self, batches):
|
||||
cv.check_type('statepoint batches', batches, Iterable, Integral)
|
||||
for batch in batches:
|
||||
cv.check_greater_than('statepoint batch', batch, 0)
|
||||
self._statepoint_batches = batches
|
||||
@sourcepoint.setter
|
||||
def sourcepoint(self, sourcepoint):
|
||||
cv.check_type('sourcepoint options', sourcepoint, Mapping)
|
||||
for key, value in sourcepoint.items():
|
||||
if key == 'batches':
|
||||
cv.check_type('sourcepoint batches', value, Iterable, Integral)
|
||||
for batch in value:
|
||||
cv.check_greater_than('sourcepoint batch', batch, 0)
|
||||
elif key == 'separate':
|
||||
cv.check_type('sourcepoint separate', value, bool)
|
||||
elif key == 'write':
|
||||
cv.check_type('sourcepoint write', value, bool)
|
||||
elif key == 'overwrite':
|
||||
cv.check_type('sourcepoint overwrite', value, bool)
|
||||
else:
|
||||
raise ValueError("Unknown key '{}' encountered when setting "
|
||||
"sourcepoint options.".format(key))
|
||||
self._sourcepoint = sourcepoint
|
||||
|
||||
@statepoint_interval.setter
|
||||
def statepoint_interval(self, interval):
|
||||
cv.check_type('statepoint interval', interval, Integral)
|
||||
self._statepoint_interval = interval
|
||||
|
||||
@sourcepoint_batches.setter
|
||||
def sourcepoint_batches(self, batches):
|
||||
cv.check_type('sourcepoint batches', batches, Iterable, Integral)
|
||||
for batch in batches:
|
||||
cv.check_greater_than('sourcepoint batch', batch, 0)
|
||||
self._sourcepoint_batches = batches
|
||||
|
||||
@sourcepoint_interval.setter
|
||||
def sourcepoint_interval(self, interval):
|
||||
cv.check_type('sourcepoint interval', interval, Integral)
|
||||
self._sourcepoint_interval = interval
|
||||
|
||||
@sourcepoint_separate.setter
|
||||
def sourcepoint_separate(self, source_separate):
|
||||
cv.check_type('sourcepoint separate', source_separate, bool)
|
||||
self._sourcepoint_separate = source_separate
|
||||
|
||||
@sourcepoint_write.setter
|
||||
def sourcepoint_write(self, source_write):
|
||||
cv.check_type('sourcepoint write', source_write, bool)
|
||||
self._sourcepoint_write = source_write
|
||||
|
||||
@sourcepoint_overwrite.setter
|
||||
def sourcepoint_overwrite(self, source_overwrite):
|
||||
cv.check_type('sourcepoint overwrite', source_overwrite, bool)
|
||||
self._sourcepoint_overwrite = source_overwrite
|
||||
@statepoint.setter
|
||||
def statepoint(self, statepoint):
|
||||
cv.check_type('statepoint options', statepoint, Mapping)
|
||||
for key, value in statepoint.items():
|
||||
if key == 'batches':
|
||||
cv.check_type('statepoint batches', value, Iterable, Integral)
|
||||
for batch in value:
|
||||
cv.check_greater_than('statepoint batch', batch, 0)
|
||||
else:
|
||||
raise ValueError("Unknown key '{}' encountered when setting "
|
||||
"statepoint options.".format(key))
|
||||
self._statepoint = statepoint
|
||||
|
||||
@confidence_intervals.setter
|
||||
def confidence_intervals(self, confidence_intervals):
|
||||
|
|
@ -958,48 +923,34 @@ class Settings(object):
|
|||
element.text = str(self._verbosity)
|
||||
|
||||
def _create_statepoint_subelement(self, root):
|
||||
# Batches subelement
|
||||
if self._statepoint_batches is not None:
|
||||
if self._statepoint:
|
||||
element = ET.SubElement(root, "state_point")
|
||||
subelement = ET.SubElement(element, "batches")
|
||||
subelement.text = ' '.join(map(str, self._statepoint_batches))
|
||||
|
||||
# Interval subelement
|
||||
elif self._statepoint_interval is not None:
|
||||
element = ET.SubElement(root, "state_point")
|
||||
subelement = ET.SubElement(element, "interval")
|
||||
subelement.text = str(self._statepoint_interval)
|
||||
if 'batches' in self._statepoint:
|
||||
subelement = ET.SubElement(element, "batches")
|
||||
subelement.text = ' '.join(
|
||||
str(x) for x in self._statepoint['batches'])
|
||||
|
||||
def _create_sourcepoint_subelement(self, root):
|
||||
# Batches subelement
|
||||
if self._sourcepoint_batches is not None:
|
||||
if self._sourcepoint:
|
||||
element = ET.SubElement(root, "source_point")
|
||||
subelement = ET.SubElement(element, "batches")
|
||||
subelement.text = ' '.join(map(str, self._sourcepoint_batches))
|
||||
|
||||
# Interval subelement
|
||||
elif self._sourcepoint_interval is not None:
|
||||
element = ET.SubElement(root, "source_point")
|
||||
subelement = ET.SubElement(element, "interval")
|
||||
subelement.text = str(self._sourcepoint_interval)
|
||||
if 'batches' in self._sourcepoint:
|
||||
subelement = ET.SubElement(element, "batches")
|
||||
subelement.text = ' '.join(
|
||||
str(x) for x in self._sourcepoint['batches'])
|
||||
|
||||
# Separate subelement
|
||||
if self._sourcepoint_separate is not None:
|
||||
element = ET.SubElement(root, "source_point")
|
||||
subelement = ET.SubElement(element, "separate")
|
||||
subelement.text = str(self._sourcepoint_separate).lower()
|
||||
if 'separate' in self._sourcepoint:
|
||||
subelement = ET.SubElement(element, "separate")
|
||||
subelement.text = str(self._sourcepoint['separate']).lower()
|
||||
|
||||
# Write subelement
|
||||
if self._sourcepoint_write is not None:
|
||||
element = ET.SubElement(root, "source_point")
|
||||
subelement = ET.SubElement(element, "write")
|
||||
subelement.text = str(self._sourcepoint_write).lower()
|
||||
if 'write' in self._sourcepoint:
|
||||
subelement = ET.SubElement(element, "write")
|
||||
subelement.text = str(self._sourcepoint['write']).lower()
|
||||
|
||||
# Overwrite latest subelement
|
||||
if self._sourcepoint_overwrite is not None:
|
||||
element = ET.SubElement(root, "source_point")
|
||||
subelement = ET.SubElement(element, "overwrite_latest")
|
||||
subelement.text = str(self._sourcepoint_overwrite).lower()
|
||||
# Overwrite latest subelement
|
||||
if 'overwrite' in self._sourcepoint:
|
||||
subelement = ET.SubElement(element, "overwrite_latest")
|
||||
subelement.text = str(self._sourcepoint['overwrite']).lower()
|
||||
|
||||
def _create_confidence_intervals(self, root):
|
||||
if self._confidence_intervals is not None:
|
||||
|
|
|
|||
|
|
@ -814,13 +814,6 @@ contains
|
|||
call statepoint_batch % add(temp_int_array(i))
|
||||
end do
|
||||
deallocate(temp_int_array)
|
||||
elseif (check_for_node(node_sp, "interval")) then
|
||||
! User gave an interval for writing state points
|
||||
call get_node_value(node_sp, "interval", temp_int)
|
||||
n_state_points = n_batches / temp_int
|
||||
do i = 1, n_state_points
|
||||
call statepoint_batch % add(temp_int * i)
|
||||
end do
|
||||
else
|
||||
! If neither were specified, write state point at last batch
|
||||
n_state_points = 1
|
||||
|
|
@ -854,13 +847,6 @@ contains
|
|||
call sourcepoint_batch % add(temp_int_array(i))
|
||||
end do
|
||||
deallocate(temp_int_array)
|
||||
elseif (check_for_node(node_sp, "interval")) then
|
||||
! User gave an interval for writing source points
|
||||
call get_node_value(node_sp, "interval", temp_int)
|
||||
n_source_points = n_batches / temp_int
|
||||
do i = 1, n_source_points
|
||||
call sourcepoint_batch % add(temp_int * i)
|
||||
end do
|
||||
else
|
||||
! If neither were specified, write source points with state points
|
||||
n_source_points = n_state_points
|
||||
|
|
|
|||
|
|
@ -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="U235" ao="1.0" />
|
||||
</material>
|
||||
|
||||
</materials>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
k-combined:
|
||||
0.000000E+00 0.000000E+00
|
||||
1.892327E+00 -3.385257E+00 6.702634E-01
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<settings>
|
||||
|
||||
<state_point interval="2"/>
|
||||
<source_point interval="4"/>
|
||||
|
||||
<eigenvalue>
|
||||
<batches>10</batches>
|
||||
<inactive>5</inactive>
|
||||
<particles>1000</particles>
|
||||
</eigenvalue>
|
||||
|
||||
<source>
|
||||
<space type="box">
|
||||
<parameters>-4 -4 -4 4 4 4</parameters>
|
||||
</space>
|
||||
</source>
|
||||
|
||||
</settings>
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.pardir)
|
||||
from testing_harness import TestHarness
|
||||
from openmc.statepoint import StatePoint
|
||||
|
||||
|
||||
class SourcepointTestHarness(TestHarness):
|
||||
def _test_output_created(self):
|
||||
"""Make sure statepoint.* files have been created."""
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), 'statepoint.*'))
|
||||
assert len(statepoint) == 5, '5 statepoint files must exist.'
|
||||
assert statepoint[0].endswith('h5'), \
|
||||
'Statepoint file is not a HDF5 file.'
|
||||
|
||||
def _get_results(self):
|
||||
"""Digest info in the statepoint and return as a string."""
|
||||
# Read the statepoint file.
|
||||
statepoint = glob.glob(os.path.join(os.getcwd(), self._sp_name))[0]
|
||||
sp = StatePoint(statepoint)
|
||||
|
||||
# Get the eigenvalue information.
|
||||
outstr = TestHarness._get_results(self)
|
||||
|
||||
# Add the source information.
|
||||
xyz = sp.source[0]['xyz']
|
||||
outstr += ' '.join(['{0:12.6E}'.format(x) for x in xyz])
|
||||
outstr += "\n"
|
||||
|
||||
return outstr
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = SourcepointTestHarness('statepoint.08.*')
|
||||
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="U235" ao="1.0" />
|
||||
</material>
|
||||
|
||||
</materials>
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
k-combined:
|
||||
2.943619E-01 3.309635E-03
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<settings>
|
||||
|
||||
<state_point interval="2" />
|
||||
|
||||
<eigenvalue>
|
||||
<batches>10</batches>
|
||||
<inactive>5</inactive>
|
||||
<particles>1000</particles>
|
||||
</eigenvalue>
|
||||
|
||||
<source>
|
||||
<space type="box">
|
||||
<parameters>-4 -4 -4 4 4 4</parameters>
|
||||
</space>
|
||||
</source>
|
||||
|
||||
</settings>
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.pardir)
|
||||
from testing_harness import TestHarness
|
||||
|
||||
|
||||
class StatepointTestHarness(TestHarness):
|
||||
def __init__(self):
|
||||
super(StatepointTestHarness, self).__init__(None, False)
|
||||
|
||||
def _test_output_created(self):
|
||||
"""Make sure statepoint files have been created."""
|
||||
sps = ('statepoint.02.*', 'statepoint.04.*', 'statepoint.06.*',
|
||||
'statepoint.08.*', 'statepoint.10.*')
|
||||
for sp in sps:
|
||||
self._sp_name = sp
|
||||
TestHarness._test_output_created(self)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
harness = StatepointTestHarness()
|
||||
harness.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue