mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Python API MultiGroupXS.load_from_statepoint(...) routine now resets domain type to get isotopic number densities from OpenMC
This commit is contained in:
parent
0374a07c6f
commit
6e9dc5b09f
3 changed files with 40 additions and 6 deletions
|
|
@ -359,6 +359,25 @@ class MultiGroupXS(object):
|
|||
|
||||
cv.check_type('statepoint', statepoint, openmc.statepoint.StatePoint)
|
||||
|
||||
if not statepoint.with_summary:
|
||||
msg = 'Unable to load data from a statepoint which has not been ' \
|
||||
'linked with a summary file'
|
||||
raise ValueError(msg)
|
||||
|
||||
# Override the domain object that loaded from an OpenMC summary file
|
||||
# NOTE: This is necessary for micro cross-sections which require
|
||||
# the isotopic number densities as computed by OpenMC
|
||||
if self.domain_type == 'cell':
|
||||
self.domain = statepoint.summary.get_cell_by_id(self.domain.id)
|
||||
elif self.domain_type == 'universe':
|
||||
self.domain = statepoint.summary.get_universe_by_id(self.domain.id)
|
||||
elif self.domain_type == 'material':
|
||||
self.domain = statepoint.summary.get_material_by_id(self.domain.id)
|
||||
else:
|
||||
msg = 'Unable to load data from a statepoint for domain type {} ' \
|
||||
'which is not yet supported'.format(self.domain_type)
|
||||
raise ValueError(msg)
|
||||
|
||||
# Create Tallies to search for in StatePoint
|
||||
self.create_tallies()
|
||||
|
||||
|
|
@ -424,6 +443,7 @@ class MultiGroupXS(object):
|
|||
raise ValueError(msg)
|
||||
|
||||
cv.check_value('value', value, ['mean', 'std_dev', 'rel_err'])
|
||||
cv.check_value('xs_type', xs_type, ['macro', 'micro'])
|
||||
|
||||
filters = []
|
||||
filter_bins = []
|
||||
|
|
@ -631,6 +651,8 @@ class MultiGroupXS(object):
|
|||
|
||||
"""
|
||||
|
||||
cv.check_value('xs_type', xs_type, ['macro', 'micro'])
|
||||
|
||||
if subdomains != 'all':
|
||||
cv.check_iterable_type('subdomains', subdomains, Integral)
|
||||
if nuclides != 'all':
|
||||
|
|
@ -1323,6 +1345,7 @@ class ScatterMatrixXS(MultiGroupXS):
|
|||
raise ValueError(msg)
|
||||
|
||||
cv.check_value('value', value, ['mean', 'std_dev', 'rel_err'])
|
||||
cv.check_value('xs_type', xs_type, ['macro', 'micro'])
|
||||
|
||||
filters = []
|
||||
filter_bins = []
|
||||
|
|
@ -1384,6 +1407,8 @@ class ScatterMatrixXS(MultiGroupXS):
|
|||
|
||||
"""
|
||||
|
||||
cv.check_value('xs_type', xs_type, ['macro', 'micro'])
|
||||
|
||||
if subdomains != 'all':
|
||||
cv.check_iterable_type('subdomains', subdomains, Integral)
|
||||
if nuclides != 'all':
|
||||
|
|
@ -1587,6 +1612,8 @@ class Chi(MultiGroupXS):
|
|||
|
||||
"""
|
||||
|
||||
cv.check_value('xs_type', xs_type, ['macro', 'micro'])
|
||||
|
||||
if self.xs_type == 'micro' and xs_type == 'macro':
|
||||
raise NotImplementedError('Unable to compute macro Chi from micros')
|
||||
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ class StatePoint(object):
|
|||
Indicate whether user-defined tallies are present
|
||||
version: tuple of int
|
||||
Version of OpenMC
|
||||
with_summary : bool
|
||||
Indicate whether statepoint data has been linked against a summary file
|
||||
summary : None or openmc.summary.Summary
|
||||
A summary object if the statepoint has been linked with a summary file
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ class StatePoint(object):
|
|||
# Set flags for what data has been read
|
||||
self._meshes_read = False
|
||||
self._tallies_read = False
|
||||
self._with_summary = False
|
||||
self._summary = False
|
||||
self._global_tallies = None
|
||||
|
||||
def close(self):
|
||||
|
|
@ -457,9 +457,16 @@ class StatePoint(object):
|
|||
self._f['version_minor'].value,
|
||||
self._f['version_release'].value)
|
||||
|
||||
@property
|
||||
def summary(self):
|
||||
return self._summary
|
||||
|
||||
@property
|
||||
def with_summary(self):
|
||||
return self._with_summary
|
||||
if self.summary is None:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def get_tally(self, scores=[], filters=[], nuclides=[],
|
||||
name=None, id=None, estimator=None):
|
||||
|
|
@ -628,4 +635,4 @@ class StatePoint(object):
|
|||
material_ids.append(summary.materials[bin].id)
|
||||
filter.bins = material_ids
|
||||
|
||||
self._with_summary = True
|
||||
self._summary = summary
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class Summary(object):
|
|||
material = openmc.Material(material_id=material_id, name=name)
|
||||
|
||||
# Set the Material's density to g/cm3 - this is what is used in OpenMC
|
||||
material.set_density(density=density, units='g/cm3')
|
||||
material.set_density(density=density, units='atom/b-cm')
|
||||
|
||||
# Add all nuclides to the Material
|
||||
for fullname, density in zip(nuclides, nuc_densities):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue