mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Added double quotes around exception msgs in Python API
This commit is contained in:
parent
34716e6e0e
commit
bf15c255c3
19 changed files with 298 additions and 298 deletions
|
|
@ -49,14 +49,14 @@ def ascii_to_binary(ascii_file, binary_file):
|
|||
# that XSS will start at the second record
|
||||
nxs = list(map(int, ' '.join(lines[idx + 6:idx + 8]).split()))
|
||||
jxs = list(map(int, ' '.join(lines[idx + 8:idx + 12]).split()))
|
||||
binary.write(pack('=16i32i{0}x'.format(record_length - 500), *(nxs + jxs)))
|
||||
binary.write(pack('=16i32i"{0}"x'.format(record_length - 500), *(nxs + jxs)))
|
||||
|
||||
# Read/write XSS array. Null bytes are added to form a complete record
|
||||
# at the end of the file
|
||||
n_lines = (nxs[0] + 3)//4
|
||||
xss = list(map(float, ' '.join(lines[idx + 12:idx + 12 + n_lines]).split()))
|
||||
extra_bytes = record_length - ((len(xss)*8 - 1) % record_length + 1)
|
||||
binary.write(pack('={0}d{1}x'.format(nxs[0], extra_bytes), *xss))
|
||||
binary.write(pack('="{0}"d"{1}"x'.format(nxs[0], extra_bytes), *xss))
|
||||
|
||||
# Advance to next table in file
|
||||
idx += 12 + n_lines
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ def check_type(name, value, expected_type, expected_iter_type=None):
|
|||
"""
|
||||
|
||||
if not isinstance(value, expected_type):
|
||||
msg = 'Unable to set {0} to {1} which is not of type {2}'.format(
|
||||
msg = 'Unable to set "{0}" to "{1}" which is not of type "{2}"'.format(
|
||||
name, value, expected_type.__name__)
|
||||
raise ValueError(msg)
|
||||
|
||||
if expected_iter_type:
|
||||
for item in value:
|
||||
if not isinstance(item, expected_iter_type):
|
||||
msg = 'Unable to set {0} to {1} since each item must be ' \
|
||||
'of type {2}'.format(name, value,
|
||||
msg = 'Unable to set "{0}" to "{1}" since each item must be ' \
|
||||
'of type "{2}"'.format(name, value,
|
||||
expected_iter_type.__name__)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -49,16 +49,16 @@ def check_length(name, value, length_min, length_max=None):
|
|||
|
||||
if length_max is None:
|
||||
if len(value) != length_min:
|
||||
msg = 'Unable to set {0} to {1} since it must be of ' \
|
||||
'length {2}'.format(name, value, length_min)
|
||||
msg = 'Unable to set "{0}" to "{1}" since it must be of ' \
|
||||
'length "{2}"'.format(name, value, length_min)
|
||||
raise ValueError(msg)
|
||||
elif not length_min <= len(value) <= length_max:
|
||||
if length_min == length_max:
|
||||
msg = 'Unable to set {0} to {1} since it must be of ' \
|
||||
'length {2}'.format(name, value, length_min)
|
||||
msg = 'Unable to set "{0}" to "{1}" since it must be of ' \
|
||||
'length "{2}"'.format(name, value, length_min)
|
||||
else:
|
||||
msg = 'Unable to set {0} to {1} since it must have length ' \
|
||||
'between {2} and {3}'.format(name, value, length_min,
|
||||
msg = 'Unable to set "{0}" to "{1}" since it must have length ' \
|
||||
'between "{2}" and "{3}"'.format(name, value, length_min,
|
||||
length_max)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ def check_value(name, value, accepted_values):
|
|||
"""
|
||||
|
||||
if value not in accepted_values:
|
||||
msg = 'Unable to set {0} to {1} since it is not in {2}'.format(
|
||||
msg = 'Unable to set "{0}" to "{1}" since it is not in "{2}"'.format(
|
||||
name, value, accepted_values)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -100,13 +100,13 @@ def check_less_than(name, value, maximum, equality=False):
|
|||
|
||||
if equality:
|
||||
if value > maximum:
|
||||
msg = 'Unable to set {0} to {1} since it is greater than ' \
|
||||
'{2}'.format(name, value, maximum)
|
||||
msg = 'Unable to set "{0}" to "{1}" since it is greater than ' \
|
||||
'"{2}"'.format(name, value, maximum)
|
||||
raise ValueError(msg)
|
||||
else:
|
||||
if value >= maximum:
|
||||
msg = 'Unable to set {0} to {1} since it is greater than ' \
|
||||
'or equal to {2}'.format(name, value, maximum)
|
||||
msg = 'Unable to set "{0}" to "{1}" since it is greater than ' \
|
||||
'or equal to "{2}"'.format(name, value, maximum)
|
||||
raise ValueError(msg)
|
||||
|
||||
def check_greater_than(name, value, minimum, equality=False):
|
||||
|
|
@ -127,11 +127,11 @@ def check_greater_than(name, value, minimum, equality=False):
|
|||
|
||||
if equality:
|
||||
if value < minimum:
|
||||
msg = 'Unable to set {0} to {1} since it is less than ' \
|
||||
'{2}'.format(name, value, minimum)
|
||||
msg = 'Unable to set "{0}" to "{1}" since it is less than ' \
|
||||
'"{2}"'.format(name, value, minimum)
|
||||
raise ValueError(msg)
|
||||
else:
|
||||
if value <= minimum:
|
||||
msg = 'Unable to set {0} to {1} since it is less than ' \
|
||||
'or equal to {2}'.format(name, value, minimum)
|
||||
msg = 'Unable to set "{0}" to "{1}" since it is less than ' \
|
||||
'or equal to "{2}"'.format(name, value, minimum)
|
||||
raise ValueError(msg)
|
||||
|
|
|
|||
|
|
@ -73,6 +73,6 @@ class Element(object):
|
|||
self._name = name
|
||||
|
||||
def __repr__(self):
|
||||
string = 'Element - {0}\n'.format(self._name)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tXS', '=\t', self._xs)
|
||||
string = 'Element - "{0}"\n'.format(self._name)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tXS', '=\t', self._xs)
|
||||
return string
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class Executor(object):
|
|||
check_type("Executor's working directory", working_directory,
|
||||
basestring)
|
||||
if not os.path.isdir(working_directory):
|
||||
msg = 'Unable to set Executor\'s working directory to {0} ' \
|
||||
msg = 'Unable to set Executor\'s working directory to "{0}" ' \
|
||||
'which does not exist'.format(working_directory)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -92,16 +92,16 @@ class Executor(object):
|
|||
pre_args = ''
|
||||
|
||||
if isinstance(particles, Integral) and particles > 0:
|
||||
post_args += '-n {0} '.format(particles)
|
||||
post_args += '-n "{0}" '.format(particles)
|
||||
|
||||
if isinstance(threads, Integral) and threads > 0:
|
||||
post_args += '-s {0} '.format(threads)
|
||||
post_args += '-s "{0}" '.format(threads)
|
||||
|
||||
if geometry_debug:
|
||||
post_args += '-g '
|
||||
|
||||
if isinstance(restart_file, basestring):
|
||||
post_args += '-r {0} '.format(restart_file)
|
||||
post_args += '-r "{0}" '.format(restart_file)
|
||||
|
||||
if tracks:
|
||||
post_args += '-t'
|
||||
|
|
@ -121,7 +121,7 @@ class Executor(object):
|
|||
pre_args += mpi_exec + ' '
|
||||
else:
|
||||
pre_args += 'mpirun '
|
||||
pre_args += '-n {0} '.format(mpi_procs)
|
||||
pre_args += '-n "{0}" '.format(mpi_procs)
|
||||
|
||||
command = pre_args + openmc_exec + ' ' + post_args
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ class Filter(object):
|
|||
if type is None:
|
||||
self._type = type
|
||||
elif type not in FILTER_TYPES.values():
|
||||
msg = 'Unable to set Filter type to "{0}" since it is not one ' \
|
||||
msg = 'Unable to set Filter type to ""{0}"" since it is not one ' \
|
||||
'of the supported types'.format(type)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ class Filter(object):
|
|||
if bins is None:
|
||||
self.num_bins = 0
|
||||
elif self._type is None:
|
||||
msg = 'Unable to set bins for Filter to "{0}" since ' \
|
||||
msg = 'Unable to set bins for Filter to ""{0}"" since ' \
|
||||
'the Filter type has not yet been set'.format(bins)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -136,30 +136,30 @@ class Filter(object):
|
|||
'universe', 'distribcell']:
|
||||
for edge in bins:
|
||||
if not isinstance(edge, Integral):
|
||||
msg = 'Unable to add bin "{0}" to a {1} Filter since ' \
|
||||
msg = 'Unable to add bin ""{0}"" to a "{1}" Filter since ' \
|
||||
'it is not an integer'.format(edge, self._type)
|
||||
raise ValueError(msg)
|
||||
elif edge < 0:
|
||||
msg = 'Unable to add bin "{0}" to a {1} Filter since ' \
|
||||
msg = 'Unable to add bin ""{0}"" to a "{1}" Filter since ' \
|
||||
'it is negative'.format(edge, self._type)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif self._type in ['energy', 'energyout']:
|
||||
for edge in bins:
|
||||
if not isinstance(edge, Real):
|
||||
msg = 'Unable to add bin edge "{0}" to a {1} Filter ' \
|
||||
msg = 'Unable to add bin edge ""{0}"" to a "{1}" Filter ' \
|
||||
'since it is a non-integer or floating point ' \
|
||||
'value'.format(edge, self._type)
|
||||
raise ValueError(msg)
|
||||
elif edge < 0.:
|
||||
msg = 'Unable to add bin edge "{0}" to a {1} Filter ' \
|
||||
msg = 'Unable to add bin edge ""{0}"" to a "{1}" Filter ' \
|
||||
'since it is a negative value'.format(edge, self._type)
|
||||
raise ValueError(msg)
|
||||
|
||||
# Check that bin edges are monotonically increasing
|
||||
for index in range(len(bins)):
|
||||
if index > 0 and bins[index] < bins[index-1]:
|
||||
msg = 'Unable to add bin edges "{0}" to a {1} Filter ' \
|
||||
msg = 'Unable to add bin edges ""{0}"" to a "{1}" Filter ' \
|
||||
'since they are not monotonically ' \
|
||||
'increasing'.format(bins, self._type)
|
||||
raise ValueError(msg)
|
||||
|
|
@ -167,15 +167,15 @@ class Filter(object):
|
|||
# mesh filters
|
||||
elif self._type == 'mesh':
|
||||
if not len(bins) == 1:
|
||||
msg = 'Unable to add bins "{0}" to a mesh Filter since ' \
|
||||
msg = 'Unable to add bins ""{0}"" to a mesh Filter since ' \
|
||||
'only a single mesh can be used per tally'.format(bins)
|
||||
raise ValueError(msg)
|
||||
elif not isinstance(bins[0], Integral):
|
||||
msg = 'Unable to add bin "{0}" to mesh Filter since it ' \
|
||||
msg = 'Unable to add bin ""{0}"" to mesh Filter since it ' \
|
||||
'is a non-integer'.format(bins[0])
|
||||
raise ValueError(msg)
|
||||
elif bins[0] < 0:
|
||||
msg = 'Unable to add bin "{0}" to mesh Filter since it ' \
|
||||
msg = 'Unable to add bin ""{0}"" to mesh Filter since it ' \
|
||||
'is a negative integer'.format(bins[0])
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ class Filter(object):
|
|||
@num_bins.setter
|
||||
def num_bins(self, num_bins):
|
||||
if not isinstance(num_bins, Integral) or num_bins < 0:
|
||||
msg = 'Unable to set the number of bins "{0}" for a {1} Filter ' \
|
||||
msg = 'Unable to set the number of bins ""{0}"" for a "{1}" Filter ' \
|
||||
'since it is not a positive ' \
|
||||
'integer'.format(num_bins, self._type)
|
||||
raise ValueError(msg)
|
||||
|
|
@ -210,7 +210,7 @@ class Filter(object):
|
|||
def stride(self, stride):
|
||||
check_type('filter stride', stride, Integral)
|
||||
if stride < 0:
|
||||
msg = 'Unable to set stride "{0}" for a {1} Filter since it is a ' \
|
||||
msg = 'Unable to set stride ""{0}"" for a "{1}" Filter since it is a ' \
|
||||
'negative value'.format(stride, self._type)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -269,7 +269,7 @@ class Filter(object):
|
|||
"""
|
||||
|
||||
if not self.can_merge(filter):
|
||||
msg = 'Unable to merge {0} with {1} filters'.format(self._type, filter._type)
|
||||
msg = 'Unable to merge "{0}" with "{1}" filters'.format(self._type, filter._type)
|
||||
raise ValueError(msg)
|
||||
|
||||
# Create deep copy of filter to return as merged filter
|
||||
|
|
@ -336,7 +336,7 @@ class Filter(object):
|
|||
filter_index = val
|
||||
|
||||
except ValueError:
|
||||
msg = 'Unable to get the bin index for Filter since "{0}" ' \
|
||||
msg = 'Unable to get the bin index for Filter since ""{0}"" ' \
|
||||
'is not one of the bins'.format(filter_bin)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -344,7 +344,7 @@ class Filter(object):
|
|||
|
||||
def __repr__(self):
|
||||
string = 'Filter\n'
|
||||
string += '{0: <16}{1}{2}\n'.format('\tType', '=\t', self._type)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tBins', '=\t', self._bins)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tOffset', '=\t', self._offset)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tType', '=\t', self._type)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tBins', '=\t', self._bins)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tOffset', '=\t', self._offset)
|
||||
return string
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ class Geometry(object):
|
|||
def root_universe(self, root_universe):
|
||||
check_type('root universe', root_universe, openmc.Universe)
|
||||
if root_universe._id != 0:
|
||||
msg = 'Unable to add root Universe {0} to Geometry since ' \
|
||||
'it has ID={1} instead of ' \
|
||||
msg = 'Unable to add root Universe "{0}" to Geometry since ' \
|
||||
'it has ID="{1}" instead of ' \
|
||||
'ID=0'.format(root_universe, root_universe._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class Material(object):
|
|||
else:
|
||||
check_type('material ID', material_id, Integral)
|
||||
if material_id in MATERIAL_IDS:
|
||||
msg = 'Unable to set Material ID to {0} since a Material with ' \
|
||||
msg = 'Unable to set Material ID to "{0}" since a Material with ' \
|
||||
'this ID was already initialized'.format(material_id)
|
||||
raise ValueError(msg)
|
||||
check_greater_than('material ID', material_id, 0)
|
||||
|
|
@ -132,7 +132,7 @@ class Material(object):
|
|||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
check_type('name for Material ID={0}'.format(self._id),
|
||||
check_type('name for Material ID="{0}"'.format(self._id),
|
||||
name, basestring)
|
||||
self._name = name
|
||||
|
||||
|
|
@ -149,12 +149,12 @@ class Material(object):
|
|||
|
||||
"""
|
||||
|
||||
check_type('the density for Material ID={0}'.format(self._id),
|
||||
check_type('the density for Material ID="{0}"'.format(self._id),
|
||||
density, Real)
|
||||
check_value('density units', units, DENSITY_UNITS)
|
||||
|
||||
if density == NO_DENSITY and units is not 'sum':
|
||||
msg = 'Unable to set the density Material ID={0} ' \
|
||||
msg = 'Unable to set the density Material ID="{0}" ' \
|
||||
'because a density must be set when not using ' \
|
||||
'sum unit'.format(self._id)
|
||||
raise ValueError(msg)
|
||||
|
|
@ -169,8 +169,8 @@ class Material(object):
|
|||
'version of openmc')
|
||||
|
||||
if not isinstance(filename, basestring) and filename is not None:
|
||||
msg = 'Unable to add OTF material file to Material ID={0} with a ' \
|
||||
'non-string name {1}'.format(self._id, filename)
|
||||
msg = 'Unable to add OTF material file to Material ID="{0}" with a ' \
|
||||
'non-string name "{1}"'.format(self._id, filename)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._distrib_otf_file = filename
|
||||
|
|
@ -198,18 +198,18 @@ class Material(object):
|
|||
"""
|
||||
|
||||
if not isinstance(nuclide, (openmc.Nuclide, str)):
|
||||
msg = 'Unable to add a Nuclide to Material ID={0} with a ' \
|
||||
'non-Nuclide value {1}'.format(self._id, nuclide)
|
||||
msg = 'Unable to add a Nuclide to Material ID="{0}" with a ' \
|
||||
'non-Nuclide value "{1}"'.format(self._id, nuclide)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif not isinstance(percent, Real):
|
||||
msg = 'Unable to add a Nuclide to Material ID={0} with a ' \
|
||||
'non-floating point value {1}'.format(self._id, percent)
|
||||
msg = 'Unable to add a Nuclide to Material ID="{0}" with a ' \
|
||||
'non-floating point value "{1}"'.format(self._id, percent)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif percent_type not in ['ao', 'wo', 'at/g-cm']:
|
||||
msg = 'Unable to add a Nuclide to Material ID={0} with a ' \
|
||||
'percent type {1}'.format(self._id, percent_type)
|
||||
msg = 'Unable to add a Nuclide to Material ID="{0}" with a ' \
|
||||
'percent type "{1}"'.format(self._id, percent_type)
|
||||
raise ValueError(msg)
|
||||
|
||||
if isinstance(nuclide, openmc.Nuclide):
|
||||
|
|
@ -232,7 +232,7 @@ class Material(object):
|
|||
"""
|
||||
|
||||
if not isinstance(nuclide, openmc.Nuclide):
|
||||
msg = 'Unable to remove a Nuclide {0} in Material ID={1} ' \
|
||||
msg = 'Unable to remove a Nuclide "{0}" in Material ID="{1}" ' \
|
||||
'since it is not a Nuclide'.format(self._id, nuclide)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -255,18 +255,18 @@ class Material(object):
|
|||
"""
|
||||
|
||||
if not isinstance(element, openmc.Element):
|
||||
msg = 'Unable to add an Element to Material ID={0} with a ' \
|
||||
'non-Element value {1}'.format(self._id, element)
|
||||
msg = 'Unable to add an Element to Material ID="{0}" with a ' \
|
||||
'non-Element value "{1}"'.format(self._id, element)
|
||||
raise ValueError(msg)
|
||||
|
||||
if not isinstance(percent, Real):
|
||||
msg = 'Unable to add an Element to Material ID={0} with a ' \
|
||||
'non-floating point value {1}'.format(self._id, percent)
|
||||
msg = 'Unable to add an Element to Material ID="{0}" with a ' \
|
||||
'non-floating point value "{1}"'.format(self._id, percent)
|
||||
raise ValueError(msg)
|
||||
|
||||
if percent_type not in ['ao', 'wo']:
|
||||
msg = 'Unable to add an Element to Material ID={0} with a ' \
|
||||
'percent type {1}'.format(self._id, percent_type)
|
||||
msg = 'Unable to add an Element to Material ID="{0}" with a ' \
|
||||
'percent type "{1}"'.format(self._id, percent_type)
|
||||
raise ValueError(msg)
|
||||
|
||||
# Copy this Element to separate it from same Element in other Materials
|
||||
|
|
@ -301,13 +301,13 @@ class Material(object):
|
|||
"""
|
||||
|
||||
if not isinstance(name, basestring):
|
||||
msg = 'Unable to add an S(a,b) table to Material ID={0} with a ' \
|
||||
'non-string table name {1}'.format(self._id, name)
|
||||
msg = 'Unable to add an S(a,b) table to Material ID="{0}" with a ' \
|
||||
'non-string table name "{1}"'.format(self._id, name)
|
||||
raise ValueError(msg)
|
||||
|
||||
if not isinstance(xs, basestring):
|
||||
msg = 'Unable to add an S(a,b) table to Material ID={0} with a ' \
|
||||
'non-string cross-section identifier {1}'.format(self._id, xs)
|
||||
msg = 'Unable to add an S(a,b) table to Material ID="{0}" with a ' \
|
||||
'non-string cross-section identifier "{1}"'.format(self._id, xs)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._sab.append((name, xs))
|
||||
|
|
@ -334,16 +334,16 @@ class Material(object):
|
|||
|
||||
def _repr__(self):
|
||||
string = 'Material\n'
|
||||
string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name)
|
||||
|
||||
string += '{0: <16}{1}{2}'.format('\tDensity', '=\t', self._density)
|
||||
string += ' [{0}]\n'.format(self._density_units)
|
||||
string += '{0: <16}"{1}""{2}"'.format('\tDensity', '=\t', self._density)
|
||||
string += ' ["{0}"]\n'.format(self._density_units)
|
||||
|
||||
string += '{0: <16}\n'.format('\tS(a,b) Tables')
|
||||
|
||||
for sab in self._sab:
|
||||
string += '{0: <16}{1}[{2}{3}]\n'.format('\tS(a,b)', '=\t',
|
||||
string += '{0: <16}"{1}"["{2}""{3}"]\n'.format('\tS(a,b)', '=\t',
|
||||
sab[0], sab[1])
|
||||
|
||||
string += '{0: <16}\n'.format('\tNuclides')
|
||||
|
|
@ -351,16 +351,16 @@ class Material(object):
|
|||
for nuclide in self._nuclides:
|
||||
percent = self._nuclides[nuclide][1]
|
||||
percent_type = self._nuclides[nuclide][2]
|
||||
string += '{0: <16}'.format('\t{0}'.format(nuclide))
|
||||
string += '=\t{0: <12} [{1}]\n'.format(percent, percent_type)
|
||||
string += '{0: <16}'.format('\t"{0}"'.format(nuclide))
|
||||
string += '=\t{0: <12} ["{1}"]\n'.format(percent, percent_type)
|
||||
|
||||
string += '{0: <16}\n'.format('\tElements')
|
||||
|
||||
for element in self._elements:
|
||||
percent = self._nuclides[element][1]
|
||||
percent_type = self._nuclides[element][2]
|
||||
string += '{0: >16}'.format('\t{0}'.format(element))
|
||||
string += '=\t{0: <12} [{1}]\n'.format(percent, percent_type)
|
||||
string += '{0: >16}'.format('\t"{0}"'.format(element))
|
||||
string += '=\t{0: <12} ["{1}"]\n'.format(percent, percent_type)
|
||||
|
||||
return string
|
||||
|
||||
|
|
@ -522,7 +522,7 @@ class MaterialsFile(object):
|
|||
"""
|
||||
|
||||
if not isinstance(material, Material):
|
||||
msg = 'Unable to add a non-Material {0} to the ' \
|
||||
msg = 'Unable to add a non-Material "{0}" to the ' \
|
||||
'MaterialsFile'.format(material)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -539,7 +539,7 @@ class MaterialsFile(object):
|
|||
"""
|
||||
|
||||
if not isinstance(materials, Iterable):
|
||||
msg = 'Unable to create OpenMC materials.xml file from {0} which ' \
|
||||
msg = 'Unable to create OpenMC materials.xml file from "{0}" which ' \
|
||||
'is not iterable'.format(materials)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -557,7 +557,7 @@ class MaterialsFile(object):
|
|||
"""
|
||||
|
||||
if not isinstance(material, Material):
|
||||
msg = 'Unable to remove a non-Material {0} from the ' \
|
||||
msg = 'Unable to remove a non-Material "{0}" from the ' \
|
||||
'MaterialsFile'.format(material)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
|
|||
|
|
@ -148,14 +148,14 @@ class Mesh(object):
|
|||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
check_type('name for mesh ID={0}'.format(self._id), name, basestring)
|
||||
check_type('name for mesh ID="{0}"'.format(self._id), name, basestring)
|
||||
self._name = name
|
||||
|
||||
@type.setter
|
||||
def type(self, meshtype):
|
||||
check_type('type for mesh ID={0}'.format(self._id),
|
||||
check_type('type for mesh ID="{0}"'.format(self._id),
|
||||
meshtype, basestring)
|
||||
check_value('type for mesh ID={0}'.format(self._id),
|
||||
check_value('type for mesh ID="{0}"'.format(self._id),
|
||||
meshtype, ['rectangular', 'hexagonal'])
|
||||
self._type = meshtype
|
||||
|
||||
|
|
@ -185,13 +185,13 @@ class Mesh(object):
|
|||
|
||||
def __repr__(self):
|
||||
string = 'Mesh\n'
|
||||
string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tType', '=\t', self._type)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tBasis', '=\t', self._dimension)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tWidth', '=\t', self._lower_left)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tOrigin', '=\t', self._upper_right)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tPixels', '=\t', self._width)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tType', '=\t', self._type)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tBasis', '=\t', self._dimension)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tWidth', '=\t', self._lower_left)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tOrigin', '=\t', self._upper_right)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tPixels', '=\t', self._width)
|
||||
return string
|
||||
|
||||
def get_mesh_xml(self):
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@ class Nuclide(object):
|
|||
self._zaid = zaid
|
||||
|
||||
def __repr__(self):
|
||||
string = 'Nuclide - {0}\n'.format(self._name)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tXS', '=\t', self._xs)
|
||||
string = 'Nuclide - "{0}"\n'.format(self._name)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tXS', '=\t', self._xs)
|
||||
if self._zaid is not None:
|
||||
string += '{0: <16}{1}{2}\n'.format('\tZAID', '=\t', self._zaid)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tZAID', '=\t', self._zaid)
|
||||
return string
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ def get_opencg_material(openmc_material):
|
|||
"""
|
||||
|
||||
if not isinstance(openmc_material, openmc.Material):
|
||||
msg = 'Unable to create an OpenCG Material from {0} ' \
|
||||
msg = 'Unable to create an OpenCG Material from "{0}" ' \
|
||||
'which is not an OpenMC Material'.format(openmc_material)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ def get_openmc_material(opencg_material):
|
|||
"""
|
||||
|
||||
if not isinstance(opencg_material, opencg.Material):
|
||||
msg = 'Unable to create an OpenMC Material from {0} ' \
|
||||
msg = 'Unable to create an OpenMC Material from "{0}" ' \
|
||||
'which is not an OpenCG Material'.format(opencg_material)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -165,7 +165,7 @@ def is_opencg_surface_compatible(opencg_surface):
|
|||
|
||||
if not isinstance(opencg_surface, opencg.Surface):
|
||||
msg = 'Unable to check if OpenCG Surface is compatible' \
|
||||
'since {0} is not a Surface'.format(opencg_surface)
|
||||
'since "{0}" is not a Surface'.format(opencg_surface)
|
||||
raise ValueError(msg)
|
||||
|
||||
if opencg_surface._type in ['x-squareprism',
|
||||
|
|
@ -191,7 +191,7 @@ def get_opencg_surface(openmc_surface):
|
|||
"""
|
||||
|
||||
if not isinstance(openmc_surface, openmc.Surface):
|
||||
msg = 'Unable to create an OpenCG Surface from {0} ' \
|
||||
msg = 'Unable to create an OpenCG Surface from "{0}" ' \
|
||||
'which is not an OpenMC Surface'.format(openmc_surface)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -277,7 +277,7 @@ def get_openmc_surface(opencg_surface):
|
|||
"""
|
||||
|
||||
if not isinstance(opencg_surface, opencg.Surface):
|
||||
msg = 'Unable to create an OpenMC Surface from {0} which ' \
|
||||
msg = 'Unable to create an OpenMC Surface from "{0}" which ' \
|
||||
'is not an OpenCG Surface'.format(opencg_surface)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -335,7 +335,7 @@ def get_openmc_surface(opencg_surface):
|
|||
|
||||
else:
|
||||
msg = 'Unable to create an OpenMC Surface from an OpenCG ' \
|
||||
'Surface of type {0} since it is not a compatible ' \
|
||||
'Surface of type "{0}" since it is not a compatible ' \
|
||||
'Surface type in OpenMC'.format(opencg_surface._type)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -368,7 +368,7 @@ def get_compatible_opencg_surfaces(opencg_surface):
|
|||
"""
|
||||
|
||||
if not isinstance(opencg_surface, opencg.Surface):
|
||||
msg = 'Unable to create an OpenMC Surface from {0} which ' \
|
||||
msg = 'Unable to create an OpenMC Surface from "{0}" which ' \
|
||||
'is not an OpenCG Surface'.format(opencg_surface)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -421,7 +421,7 @@ def get_compatible_opencg_surfaces(opencg_surface):
|
|||
|
||||
else:
|
||||
msg = 'Unable to create a compatible OpenMC Surface an OpenCG ' \
|
||||
'Surface of type {0} since it already a compatible ' \
|
||||
'Surface of type "{0}" since it already a compatible ' \
|
||||
'Surface type in OpenMC'.format(opencg_surface._type)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -450,7 +450,7 @@ def get_opencg_cell(openmc_cell):
|
|||
"""
|
||||
|
||||
if not isinstance(openmc_cell, openmc.Cell):
|
||||
msg = 'Unable to create an OpenCG Cell from {0} which ' \
|
||||
msg = 'Unable to create an OpenCG Cell from "{0}" which ' \
|
||||
'is not an OpenMC Cell'.format(openmc_cell)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -518,17 +518,17 @@ def get_compatible_opencg_cells(opencg_cell, opencg_surface, halfspace):
|
|||
|
||||
"""
|
||||
if not isinstance(opencg_cell, opencg.Cell):
|
||||
msg = 'Unable to create compatible OpenMC Cell from {0} which ' \
|
||||
msg = 'Unable to create compatible OpenMC Cell from "{0}" which ' \
|
||||
'is not an OpenCG Cell'.format(opencg_cell)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif not isinstance(opencg_surface, opencg.Surface):
|
||||
msg = 'Unable to create compatible OpenMC Cell since {0} is ' \
|
||||
msg = 'Unable to create compatible OpenMC Cell since "{0}" is ' \
|
||||
'not an OpenCG Surface'.format(opencg_surface)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif halfspace not in [-1, +1]:
|
||||
msg = 'Unable to create compatible Cell since {0}' \
|
||||
msg = 'Unable to create compatible Cell since "{0}"' \
|
||||
'is not a +/-1 halfspace'.format(halfspace)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -626,7 +626,7 @@ def make_opencg_cells_compatible(opencg_universe):
|
|||
"""
|
||||
|
||||
if not isinstance(opencg_universe, opencg.Universe):
|
||||
msg = 'Unable to make compatible OpenCG Cells for {0} which ' \
|
||||
msg = 'Unable to make compatible OpenCG Cells for "{0}" which ' \
|
||||
'is not an OpenCG Universe'.format(opencg_universe)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -685,7 +685,7 @@ def get_openmc_cell(opencg_cell):
|
|||
"""
|
||||
|
||||
if not isinstance(opencg_cell, opencg.Cell):
|
||||
msg = 'Unable to create an OpenMC Cell from {0} which ' \
|
||||
msg = 'Unable to create an OpenMC Cell from "{0}" which ' \
|
||||
'is not an OpenCG Cell'.format(opencg_cell)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -749,7 +749,7 @@ def get_opencg_universe(openmc_universe):
|
|||
"""
|
||||
|
||||
if not isinstance(openmc_universe, openmc.Universe):
|
||||
msg = 'Unable to create an OpenCG Universe from {0} which ' \
|
||||
msg = 'Unable to create an OpenCG Universe from "{0}" which ' \
|
||||
'is not an OpenMC Universe'.format(openmc_universe)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -796,7 +796,7 @@ def get_openmc_universe(opencg_universe):
|
|||
"""
|
||||
|
||||
if not isinstance(opencg_universe, opencg.Universe):
|
||||
msg = 'Unable to create an OpenMC Universe from {0} which ' \
|
||||
msg = 'Unable to create an OpenMC Universe from "{0}" which ' \
|
||||
'is not an OpenCG Universe'.format(opencg_universe)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -846,7 +846,7 @@ def get_opencg_lattice(openmc_lattice):
|
|||
"""
|
||||
|
||||
if not isinstance(openmc_lattice, openmc.Lattice):
|
||||
msg = 'Unable to create an OpenCG Lattice from {0} which ' \
|
||||
msg = 'Unable to create an OpenCG Lattice from "{0}" which ' \
|
||||
'is not an OpenMC Lattice'.format(openmc_lattice)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -926,7 +926,7 @@ def get_openmc_lattice(opencg_lattice):
|
|||
"""
|
||||
|
||||
if not isinstance(opencg_lattice, opencg.Lattice):
|
||||
msg = 'Unable to create an OpenMC Lattice from {0} which ' \
|
||||
msg = 'Unable to create an OpenMC Lattice from "{0}" which ' \
|
||||
'is not an OpenCG Lattice'.format(opencg_lattice)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -997,7 +997,7 @@ def get_opencg_geometry(openmc_geometry):
|
|||
"""
|
||||
|
||||
if not isinstance(openmc_geometry, openmc.Geometry):
|
||||
msg = 'Unable to get OpenCG geometry from {0} which is ' \
|
||||
msg = 'Unable to get OpenCG geometry from "{0}" which is ' \
|
||||
'not an OpenMC Geometry object'.format(openmc_geometry)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -1037,7 +1037,7 @@ def get_openmc_geometry(opencg_geometry):
|
|||
"""
|
||||
|
||||
if not isinstance(opencg_geometry, opencg.Geometry):
|
||||
msg = 'Unable to get OpenMC geometry from {0} which is ' \
|
||||
msg = 'Unable to get OpenMC geometry from "{0}" which is ' \
|
||||
'not an OpenCG Geometry object'.format(opencg_geometry)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class Particle(object):
|
|||
self.uvw = self._get_double(3, path='uvw')
|
||||
|
||||
def _get_data(self, n, typeCode, size):
|
||||
return list(struct.unpack('={0}{1}'.format(n, typeCode),
|
||||
return list(struct.unpack('="{0}""{1}"'.format(n, typeCode),
|
||||
self._f.read(n*size)))
|
||||
|
||||
def _get_int(self, n=1, path=None):
|
||||
|
|
|
|||
|
|
@ -210,18 +210,18 @@ class Plot(object):
|
|||
|
||||
for key in col_spec:
|
||||
if key < 0:
|
||||
msg = 'Unable to create Plot ID={0} with col_spec ID {1} ' \
|
||||
msg = 'Unable to create Plot ID="{0}" with col_spec ID "{1}" ' \
|
||||
'which is less than 0'.format(self._id, key)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif not isinstance(col_spec[key], Iterable):
|
||||
msg = 'Unable to create Plot ID={0} with col_spec RGB values' \
|
||||
' {1} which is not iterable'.format(self._id, col_spec[key])
|
||||
msg = 'Unable to create Plot ID="{0}" with col_spec RGB values' \
|
||||
' "{1}" which is not iterable'.format(self._id, col_spec[key])
|
||||
raise ValueError(msg)
|
||||
|
||||
elif len(col_spec[key]) != 3:
|
||||
msg = 'Unable to create Plot ID={0} with col_spec RGB ' \
|
||||
'values of length {1} since 3 values must be ' \
|
||||
msg = 'Unable to create Plot ID="{0}" with col_spec RGB ' \
|
||||
'values of length "{1}" since 3 values must be ' \
|
||||
'input'.format(self._id, len(col_spec[key]))
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -245,20 +245,20 @@ class Plot(object):
|
|||
|
||||
def __repr__(self):
|
||||
string = 'Plot\n'
|
||||
string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tFilename', '=\t', self._filename)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tType', '=\t', self._type)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tBasis', '=\t', self._basis)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tWidth', '=\t', self._width)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tOrigin', '=\t', self._origin)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tPixels', '=\t', self._origin)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tColor', '=\t', self._color)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tMask', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tFilename', '=\t', self._filename)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tType', '=\t', self._type)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tBasis', '=\t', self._basis)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tWidth', '=\t', self._width)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tOrigin', '=\t', self._origin)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tPixels', '=\t', self._origin)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tColor', '=\t', self._color)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tMask', '=\t',
|
||||
self._mask_components)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tMask', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tMask', '=\t',
|
||||
self._mask_background)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tCol Spec', '=\t', self._col_spec)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tCol Spec', '=\t', self._col_spec)
|
||||
return string
|
||||
|
||||
def get_plot_xml(self):
|
||||
|
|
@ -332,7 +332,7 @@ class PlotsFile(object):
|
|||
"""
|
||||
|
||||
if not isinstance(plot, Plot):
|
||||
msg = 'Unable to add a non-Plot {0} to the PlotsFile'.format(plot)
|
||||
msg = 'Unable to add a non-Plot "{0}" to the PlotsFile'.format(plot)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._plots.append(plot)
|
||||
|
|
|
|||
|
|
@ -426,28 +426,28 @@ class SettingsFile(object):
|
|||
@keff_trigger.setter
|
||||
def keff_trigger(self, keff_trigger):
|
||||
if not isinstance(keff_trigger, dict):
|
||||
msg = 'Unable to set a trigger on keff from {0} which ' \
|
||||
msg = 'Unable to set a trigger on keff from "{0}" which ' \
|
||||
'is not a Python dictionary'.format(keff_trigger)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif 'type' not in keff_trigger:
|
||||
msg = 'Unable to set a trigger on keff from {0} which ' \
|
||||
msg = 'Unable to set a trigger on keff from "{0}" which ' \
|
||||
'does not have a "type" key'.format(keff_trigger)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif keff_trigger['type'] not in ['variance', 'std_dev', 'rel_err']:
|
||||
msg = 'Unable to set a trigger on keff with ' \
|
||||
'type {0}'.format(keff_trigger['type'])
|
||||
'type "{0}"'.format(keff_trigger['type'])
|
||||
raise ValueError(msg)
|
||||
|
||||
elif 'threshold' not in keff_trigger:
|
||||
msg = 'Unable to set a trigger on keff from {0} which ' \
|
||||
msg = 'Unable to set a trigger on keff from "{0}" which ' \
|
||||
'does not have a "threshold" key'.format(keff_trigger)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif not isinstance(keff_trigger['threshold'], Real):
|
||||
msg = 'Unable to set a trigger on keff with ' \
|
||||
'threshold {0}'.format(keff_trigger['threshold'])
|
||||
'threshold "{0}"'.format(keff_trigger['threshold'])
|
||||
raise ValueError(msg)
|
||||
|
||||
self._keff_trigger = keff_trigger
|
||||
|
|
@ -574,20 +574,20 @@ class SettingsFile(object):
|
|||
@output.setter
|
||||
def output(self, output):
|
||||
if not isinstance(output, dict):
|
||||
msg = 'Unable to set output to {0} which is not a Python ' \
|
||||
msg = 'Unable to set output to "{0}" which is not a Python ' \
|
||||
'dictionary of string keys and boolean values'.format(output)
|
||||
raise ValueError(msg)
|
||||
|
||||
for element in output:
|
||||
keys = ['summary', 'cross_sections', 'tallies', 'distribmats']
|
||||
if element not in keys:
|
||||
msg = 'Unable to set output to {0} which is unsupported by ' \
|
||||
msg = 'Unable to set output to "{0}" which is unsupported by ' \
|
||||
'OpenMC'.format(element)
|
||||
raise ValueError(msg)
|
||||
|
||||
if not isinstance(output[element], (bool, np.bool)):
|
||||
msg = 'Unable to set output for {0} to a non-boolean ' \
|
||||
'value {1}'.format(element, output[element])
|
||||
msg = 'Unable to set output for "{0}" to a non-boolean ' \
|
||||
'value "{1}"'.format(element, output[element])
|
||||
raise ValueError(msg)
|
||||
|
||||
self._output = output
|
||||
|
|
@ -753,7 +753,7 @@ class SettingsFile(object):
|
|||
def track(self, track):
|
||||
check_type('track', track, Iterable, Integral)
|
||||
if len(track) % 3 != 0:
|
||||
msg = 'Unable to set the track to {0} since its length is ' \
|
||||
msg = 'Unable to set the track to "{0}" since its length is ' \
|
||||
'not a multiple of 3'.format(track)
|
||||
raise ValueError(msg)
|
||||
for t in zip(track[::3], track[1::3], track[2::3]):
|
||||
|
|
@ -832,7 +832,7 @@ class SettingsFile(object):
|
|||
len_nodemap = np.prod(self._dd_mesh_dimension)
|
||||
|
||||
if len(nodemap) < len_nodemap or len(nodemap) > len_nodemap:
|
||||
msg = 'Unable to set DD nodemap with length {0} which ' \
|
||||
msg = 'Unable to set DD nodemap with length "{0}" which ' \
|
||||
'does not have the same dimensionality as the domain ' \
|
||||
'mesh'.format(len(nodemap))
|
||||
raise ValueError(msg)
|
||||
|
|
|
|||
|
|
@ -36,10 +36,10 @@ class SourceSite(object):
|
|||
|
||||
def __repr__(self):
|
||||
string = 'SourceSite\n'
|
||||
string += '{0: <16}{1}{2}\n'.format('\tweight', '=\t', self._weight)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tE', '=\t', self._E)
|
||||
string += '{0: <16}{1}{2}\n'.format('\t(x,y,z)', '=\t', self._xyz)
|
||||
string += '{0: <16}{1}{2}\n'.format('\t(u,v,w)', '=\t', self._uvw)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tweight', '=\t', self._weight)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tE', '=\t', self._E)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\t(x,y,z)', '=\t', self._xyz)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\t(u,v,w)', '=\t', self._uvw)
|
||||
return string
|
||||
|
||||
@property
|
||||
|
|
@ -230,21 +230,21 @@ class StatePoint(object):
|
|||
|
||||
if self._cmfd_on == 1:
|
||||
|
||||
self._cmfd_indices = self._get_int(4, path='{0}/indices'.format(base))
|
||||
self._cmfd_indices = self._get_int(4, path='"{0}"/indices'.format(base))
|
||||
self._k_cmfd = self._get_double(self._current_batch,
|
||||
path='{0}/k_cmfd'.format(base))
|
||||
path='"{0}"/k_cmfd'.format(base))
|
||||
self._cmfd_src = self._get_double_array(np.product(self._cmfd_indices),
|
||||
path='{0}/cmfd_src'.format(base))
|
||||
path='"{0}"/cmfd_src'.format(base))
|
||||
self._cmfd_src = np.reshape(self._cmfd_src, tuple(self._cmfd_indices),
|
||||
order='F')
|
||||
self._cmfd_entropy = self._get_double(self._current_batch,
|
||||
path='{0}/cmfd_entropy'.format(base))
|
||||
path='"{0}"/cmfd_entropy'.format(base))
|
||||
self._cmfd_balance = self._get_double(self._current_batch,
|
||||
path='{0}/cmfd_balance'.format(base))
|
||||
path='"{0}"/cmfd_balance'.format(base))
|
||||
self._cmfd_dominance = self._get_double(self._current_batch,
|
||||
path='{0}/cmfd_dominance'.format(base))
|
||||
path='"{0}"/cmfd_dominance'.format(base))
|
||||
self._cmfd_srccmp = self._get_double(self._current_batch,
|
||||
path='{0}/cmfd_srccmp'.format(base))
|
||||
path='"{0}"/cmfd_srccmp'.format(base))
|
||||
|
||||
def _read_meshes(self):
|
||||
# Initialize dictionaries for the Meshes
|
||||
|
|
@ -277,23 +277,23 @@ class StatePoint(object):
|
|||
for mesh_key in self._mesh_keys:
|
||||
|
||||
# Read the user-specified Mesh ID and type
|
||||
mesh_id = self._get_int(path='{0}{1}/id'.format(base, mesh_key))[0]
|
||||
mesh_type = self._get_int(path='{0}{1}/type'.format(base, mesh_key))[0]
|
||||
mesh_id = self._get_int(path='"{0}""{1}"/id'.format(base, mesh_key))[0]
|
||||
mesh_type = self._get_int(path='"{0}""{1}"/type'.format(base, mesh_key))[0]
|
||||
|
||||
# Get the Mesh dimension
|
||||
n_dimension = self._get_int(
|
||||
path='{0}{1}/n_dimension'.format(base, mesh_key))[0]
|
||||
path='"{0}""{1}"/n_dimension'.format(base, mesh_key))[0]
|
||||
|
||||
# Read the mesh dimensions, lower-left coordinates,
|
||||
# upper-right coordinates, and width of each mesh cell
|
||||
dimension = self._get_int(
|
||||
n_dimension, path='{0}{1}/dimension'.format(base, mesh_key))
|
||||
n_dimension, path='"{0}""{1}"/dimension'.format(base, mesh_key))
|
||||
lower_left = self._get_double(
|
||||
n_dimension, path='{0}{1}/lower_left'.format(base, mesh_key))
|
||||
n_dimension, path='"{0}""{1}"/lower_left'.format(base, mesh_key))
|
||||
upper_right = self._get_double(
|
||||
n_dimension, path='{0}{1}/upper_right'.format(base, mesh_key))
|
||||
n_dimension, path='"{0}""{1}"/upper_right'.format(base, mesh_key))
|
||||
width = self._get_double(
|
||||
n_dimension, path='{0}{1}/width'.format(base, mesh_key))
|
||||
n_dimension, path='"{0}""{1}"/width'.format(base, mesh_key))
|
||||
|
||||
# Create the Mesh and assign properties to it
|
||||
mesh = openmc.Mesh(mesh_id)
|
||||
|
|
@ -340,11 +340,11 @@ class StatePoint(object):
|
|||
|
||||
# Read integer Tally estimator type code (analog or tracklength)
|
||||
estimator_type = self._get_int(
|
||||
path='{0}{1}/estimator'.format(base, tally_key))[0]
|
||||
path='"{0}""{1}"/estimator'.format(base, tally_key))[0]
|
||||
|
||||
# Read the Tally size specifications
|
||||
n_realizations = self._get_int(
|
||||
path='{0}{1}/n_realizations'.format(base, tally_key))[0]
|
||||
path='"{0}""{1}"/n_realizations'.format(base, tally_key))[0]
|
||||
|
||||
# Create Tally object and assign basic properties
|
||||
tally = openmc.Tally(tally_key)
|
||||
|
|
@ -353,41 +353,41 @@ class StatePoint(object):
|
|||
|
||||
# Read the number of Filters
|
||||
n_filters = self._get_int(
|
||||
path='{0}{1}/n_filters'.format(base, tally_key))[0]
|
||||
path='"{0}""{1}"/n_filters'.format(base, tally_key))[0]
|
||||
|
||||
subbase = '{0}{1}/filter '.format(base, tally_key)
|
||||
subbase = '"{0}""{1}"/filter '.format(base, tally_key)
|
||||
|
||||
# Initialize all Filters
|
||||
for j in range(1, n_filters+1):
|
||||
|
||||
# Read the integer Filter type code
|
||||
filter_type = self._get_int(
|
||||
path='{0}{1}/type'.format(subbase, j))[0]
|
||||
path='"{0}""{1}"/type'.format(subbase, j))[0]
|
||||
|
||||
# Read the Filter offset
|
||||
offset = self._get_int(
|
||||
path='{0}{1}/offset'.format(subbase, j))[0]
|
||||
path='"{0}""{1}"/offset'.format(subbase, j))[0]
|
||||
|
||||
n_bins = self._get_int(
|
||||
path='{0}{1}/n_bins'.format(subbase, j))[0]
|
||||
path='"{0}""{1}"/n_bins'.format(subbase, j))[0]
|
||||
|
||||
if n_bins <= 0:
|
||||
msg = 'Unable to create Filter {0} for Tally ID={2} ' \
|
||||
msg = 'Unable to create Filter "{0}" for Tally ID="{2}" ' \
|
||||
'since no bins were specified'.format(j, tally_key)
|
||||
raise ValueError(msg)
|
||||
|
||||
# Read the bin values
|
||||
if FILTER_TYPES[filter_type] in ['energy', 'energyout']:
|
||||
bins = self._get_double(
|
||||
n_bins+1, path='{0}{1}/bins'.format(subbase, j))
|
||||
n_bins+1, path='"{0}""{1}"/bins'.format(subbase, j))
|
||||
|
||||
elif FILTER_TYPES[filter_type] in ['mesh', 'distribcell']:
|
||||
bins = self._get_int(
|
||||
path='{0}{1}/bins'.format(subbase, j))[0]
|
||||
path='"{0}""{1}"/bins'.format(subbase, j))[0]
|
||||
|
||||
else:
|
||||
bins = self._get_int(
|
||||
n_bins, path='{0}{1}/bins'.format(subbase, j))
|
||||
n_bins, path='"{0}""{1}"/bins'.format(subbase, j))
|
||||
|
||||
# Create Filter object
|
||||
filter = openmc.Filter(FILTER_TYPES[filter_type], bins)
|
||||
|
|
@ -403,10 +403,10 @@ class StatePoint(object):
|
|||
|
||||
# Read Nuclide bins
|
||||
n_nuclides = self._get_int(
|
||||
path='{0}{1}/n_nuclides'.format(base, tally_key))[0]
|
||||
path='"{0}""{1}"/n_nuclides'.format(base, tally_key))[0]
|
||||
|
||||
nuclide_zaids = self._get_int(
|
||||
n_nuclides, path='{0}{1}/nuclides'.format(base, tally_key))
|
||||
n_nuclides, path='"{0}""{1}"/nuclides'.format(base, tally_key))
|
||||
|
||||
# Add all Nuclides to the Tally
|
||||
for nuclide_zaid in nuclide_zaids:
|
||||
|
|
@ -414,14 +414,14 @@ class StatePoint(object):
|
|||
|
||||
# Read score bins
|
||||
n_score_bins = self._get_int(
|
||||
path='{0}{1}/n_score_bins'.format(base, tally_key))[0]
|
||||
path='"{0}""{1}"/n_score_bins'.format(base, tally_key))[0]
|
||||
|
||||
tally.num_score_bins = n_score_bins
|
||||
|
||||
scores = [SCORE_TYPES[j] for j in self._get_int(
|
||||
n_score_bins, path='{0}{1}/score_bins'.format(base, tally_key))]
|
||||
n_score_bins, path='"{0}""{1}"/score_bins'.format(base, tally_key))]
|
||||
n_user_scores = self._get_int(
|
||||
path='{0}{1}/n_user_score_bins'.format(base, tally_key))[0]
|
||||
path='"{0}""{1}"/n_user_score_bins'.format(base, tally_key))[0]
|
||||
|
||||
# Compute and set the filter strides
|
||||
for i in range(n_filters):
|
||||
|
|
@ -433,12 +433,12 @@ class StatePoint(object):
|
|||
|
||||
# Read scattering moment order strings (e.g., P3, Y-1,2, etc.)
|
||||
moments = []
|
||||
subbase = '{0}{1}/moments/'.format(base, tally_key)
|
||||
subbase = '"{0}""{1}"/moments/'.format(base, tally_key)
|
||||
|
||||
# Extract the moment order string for each score
|
||||
for k in range(len(scores)):
|
||||
moment = self._get_string(8,
|
||||
path='{0}order{1}'.format(subbase, k+1))
|
||||
path='"{0}"order"{1}"'.format(subbase, k+1))
|
||||
moment = moment.lstrip('[\'')
|
||||
moment = moment.rstrip('\']')
|
||||
|
||||
|
|
@ -500,7 +500,7 @@ class StatePoint(object):
|
|||
|
||||
# Extract Tally data from the file
|
||||
if self._hdf5:
|
||||
data = self._f['{0}{1}/results'.format(base, tally_key)].value
|
||||
data = self._f['"{0}""{1}"/results'.format(base, tally_key)].value
|
||||
sum = data['sum']
|
||||
sum_sq = data['sum_sq']
|
||||
|
||||
|
|
@ -748,7 +748,7 @@ class StatePoint(object):
|
|||
"""
|
||||
|
||||
if not isinstance(summary, openmc.summary.Summary):
|
||||
msg = 'Unable to link statepoint with {0} which ' \
|
||||
msg = 'Unable to link statepoint with "{0}" which ' \
|
||||
'is not a Summary object'.format(summary)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -794,7 +794,7 @@ class StatePoint(object):
|
|||
self._with_summary = True
|
||||
|
||||
def _get_data(self, n, typeCode, size):
|
||||
return list(struct.unpack('={0}{1}'.format(n, typeCode),
|
||||
return list(struct.unpack('="{0}""{1}"'.format(n, typeCode),
|
||||
self._f.read(n*size)))
|
||||
|
||||
def _get_int(self, n=1, path=None):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class Summary(object):
|
|||
openmc.reset_auto_ids()
|
||||
|
||||
if not filename.endswith(('.h5', '.hdf5')):
|
||||
msg = 'Unable to open "{0}" which is not an HDF5 summary file'
|
||||
msg = 'Unable to open ""{0}"" which is not an HDF5 summary file'
|
||||
raise ValueError(msg)
|
||||
|
||||
self._f = h5py.File(filename, 'r')
|
||||
|
|
@ -479,12 +479,12 @@ class Summary(object):
|
|||
for tally_key in tally_keys:
|
||||
|
||||
tally_id = int(tally_key.strip('tally '))
|
||||
subbase = '{0}{1}'.format(base, tally_id)
|
||||
subbase = '"{0}""{1}"'.format(base, tally_id)
|
||||
|
||||
# Read Tally name metadata
|
||||
name_size = self._f['{0}/name_size'.format(subbase)][0]
|
||||
name_size = self._f['"{0}"/name_size'.format(subbase)][0]
|
||||
if (name_size > 0):
|
||||
tally_name = self._f['{0}/name'.format(subbase)][0]
|
||||
tally_name = self._f['"{0}"/name'.format(subbase)][0]
|
||||
tally_name = tally_name.lstrip('[\'')
|
||||
tally_name = tally_name.rstrip('\']')
|
||||
else:
|
||||
|
|
@ -494,27 +494,27 @@ class Summary(object):
|
|||
tally = openmc.Tally(tally_id, tally_name)
|
||||
|
||||
# Read score metadata
|
||||
score_bins = self._f['{0}/score_bins'.format(subbase)][...]
|
||||
score_bins = self._f['"{0}"/score_bins'.format(subbase)][...]
|
||||
for score_bin in score_bins:
|
||||
tally.add_score(openmc.SCORE_TYPES[score_bin])
|
||||
num_score_bins = self._f['{0}/n_score_bins'.format(subbase)][...]
|
||||
num_score_bins = self._f['"{0}"/n_score_bins'.format(subbase)][...]
|
||||
tally.num_score_bins = num_score_bins
|
||||
|
||||
# Read filter metadata
|
||||
num_filters = self._f['{0}/n_filters'.format(subbase)][0]
|
||||
num_filters = self._f['"{0}"/n_filters'.format(subbase)][0]
|
||||
|
||||
# Initialize all Filters
|
||||
for j in range(1, num_filters+1):
|
||||
|
||||
subsubbase = '{0}/filter {1}'.format(subbase, j)
|
||||
subsubbase = '"{0}"/filter "{1}"'.format(subbase, j)
|
||||
|
||||
# Read filter type (e.g., "cell", "energy", etc.)
|
||||
filter_type_code = self._f['{0}/type'.format(subsubbase)][0]
|
||||
filter_type_code = self._f['"{0}"/type'.format(subsubbase)][0]
|
||||
filter_type = openmc.FILTER_TYPES[filter_type_code]
|
||||
|
||||
# Read the filter bins
|
||||
num_bins = self._f['{0}/n_bins'.format(subsubbase)][0]
|
||||
bins = self._f['{0}/bins'.format(subsubbase)][...]
|
||||
num_bins = self._f['"{0}"/n_bins'.format(subsubbase)][0]
|
||||
bins = self._f['"{0}"/bins'.format(subsubbase)][...]
|
||||
|
||||
# Create Filter object
|
||||
filter = openmc.Filter(filter_type, bins)
|
||||
|
|
|
|||
|
|
@ -111,15 +111,15 @@ class Surface(object):
|
|||
|
||||
def __repr__(self):
|
||||
string = 'Surface\n'
|
||||
string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tType', '=\t', self._type)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tBoundary', '=\t', self._boundary_type)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tType', '=\t', self._type)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tBoundary', '=\t', self._boundary_type)
|
||||
|
||||
coeffs = '{0: <16}'.format('\tCoefficients') + '\n'
|
||||
|
||||
for coeff in self._coeffs:
|
||||
coeffs += '{0: <16}{1}{2}\n'.format(coeff, '=\t', self._coeffs[coeff])
|
||||
coeffs += '{0: <16}"{1}""{2}"\n'.format(coeff, '=\t', self._coeffs[coeff])
|
||||
|
||||
string += coeffs
|
||||
|
||||
|
|
|
|||
|
|
@ -297,8 +297,8 @@ class Tally(object):
|
|||
"""
|
||||
|
||||
if not isinstance(trigger, Trigger):
|
||||
msg = 'Unable to add a tally trigger for Tally ID={0} to ' \
|
||||
'since "{1}" is not a Trigger'.format(self.id, trigger)
|
||||
msg = 'Unable to add a tally trigger for Tally ID="{0}" to ' \
|
||||
'since ""{1}"" is not a Trigger'.format(self.id, trigger)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._triggers.append(trigger)
|
||||
|
|
@ -330,7 +330,7 @@ class Tally(object):
|
|||
"""
|
||||
|
||||
if not isinstance(filter, Filter):
|
||||
msg = 'Unable to add Filter "{0}" to Tally ID={1} since it is ' \
|
||||
msg = 'Unable to add Filter ""{0}"" to Tally ID="{1}" since it is ' \
|
||||
'not a Filter object'.format(filter, self.id)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -359,7 +359,7 @@ class Tally(object):
|
|||
"""
|
||||
|
||||
if not isinstance(score, basestring):
|
||||
msg = 'Unable to add score "{0}" to Tally ID={1} since it is ' \
|
||||
msg = 'Unable to add score ""{0}"" to Tally ID="{1}" since it is ' \
|
||||
'not a string'.format(score, self.id)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -405,7 +405,7 @@ class Tally(object):
|
|||
"""
|
||||
|
||||
if score not in self.scores:
|
||||
msg = 'Unable to remove score "{0}" from Tally ID={1} since the ' \
|
||||
msg = 'Unable to remove score ""{0}"" from Tally ID="{1}" since the ' \
|
||||
'Tally does not contain this score'.format(score, self.id)
|
||||
ValueError(msg)
|
||||
|
||||
|
|
@ -422,7 +422,7 @@ class Tally(object):
|
|||
"""
|
||||
|
||||
if filter not in self.filters:
|
||||
msg = 'Unable to remove filter "{0}" from Tally ID={1} since the ' \
|
||||
msg = 'Unable to remove filter ""{0}"" from Tally ID="{1}" since the ' \
|
||||
'Tally does not contain this filter'.format(filter, self.id)
|
||||
ValueError(msg)
|
||||
|
||||
|
|
@ -439,7 +439,7 @@ class Tally(object):
|
|||
"""
|
||||
|
||||
if nuclide not in self.nuclides:
|
||||
msg = 'Unable to remove nuclide "{0}" from Tally ID={1} since the ' \
|
||||
msg = 'Unable to remove nuclide ""{0}"" from Tally ID="{1}" since the ' \
|
||||
'Tally does not contain this nuclide'.format(nuclide, self.id)
|
||||
ValueError(msg)
|
||||
|
||||
|
|
@ -470,27 +470,27 @@ class Tally(object):
|
|||
|
||||
def __repr__(self):
|
||||
string = 'Tally\n'
|
||||
string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self.id)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self.name)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self.id)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self.name)
|
||||
|
||||
string += '{0: <16}\n'.format('\tFilters')
|
||||
|
||||
for filter in self.filters:
|
||||
string += '{0: <16}\t\t{1}\t{2}\n'.format('', filter.type,
|
||||
string += '{0: <16}\t\t"{1}"\t"{2}"\n'.format('', filter.type,
|
||||
filter.bins)
|
||||
|
||||
string += '{0: <16}{1}'.format('\tNuclides', '=\t')
|
||||
string += '{0: <16}"{1}"'.format('\tNuclides', '=\t')
|
||||
|
||||
for nuclide in self.nuclides:
|
||||
if isinstance(nuclide, Nuclide):
|
||||
string += '{0} '.format(nuclide.name)
|
||||
string += '"{0}" '.format(nuclide.name)
|
||||
else:
|
||||
string += '{0} '.format(nuclide)
|
||||
string += '"{0}" '.format(nuclide)
|
||||
|
||||
string += '\n'
|
||||
|
||||
string += '{0: <16}{1}{2}\n'.format('\tScores', '=\t', self.scores)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tEstimator', '=\t', self.estimator)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tScores', '=\t', self.scores)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tEstimator', '=\t', self.estimator)
|
||||
|
||||
return string
|
||||
|
||||
|
|
@ -555,7 +555,7 @@ class Tally(object):
|
|||
"""
|
||||
|
||||
if not self.can_merge(tally):
|
||||
msg = 'Unable to merge tally ID={0} with {1}'.format(tally.id, self.id)
|
||||
msg = 'Unable to merge tally ID="{0}" with "{1}"'.format(tally.id, self.id)
|
||||
raise ValueError(msg)
|
||||
|
||||
# Create deep copy of tally to return as merged tally
|
||||
|
|
@ -609,7 +609,7 @@ class Tally(object):
|
|||
if filter.bins is not None:
|
||||
bins = ''
|
||||
for bin in filter.bins:
|
||||
bins += '{0} '.format(bin)
|
||||
bins += '"{0}" '.format(bin)
|
||||
|
||||
subelement.set("bins", bins.rstrip(' '))
|
||||
|
||||
|
|
@ -618,23 +618,23 @@ class Tally(object):
|
|||
nuclides = ''
|
||||
for nuclide in self.nuclides:
|
||||
if isinstance(nuclide, Nuclide):
|
||||
nuclides += '{0} '.format(nuclide.name)
|
||||
nuclides += '"{0}" '.format(nuclide.name)
|
||||
else:
|
||||
nuclides += '{0} '.format(nuclide)
|
||||
nuclides += '"{0}" '.format(nuclide)
|
||||
|
||||
subelement = ET.SubElement(element, "nuclides")
|
||||
subelement.text = nuclides.rstrip(' ')
|
||||
|
||||
# Scores
|
||||
if len(self.scores) == 0:
|
||||
msg = 'Unable to get XML for Tally ID={0} since it does not ' \
|
||||
msg = 'Unable to get XML for Tally ID="{0}" since it does not ' \
|
||||
'contain any scores'.format(self.id)
|
||||
raise ValueError(msg)
|
||||
|
||||
else:
|
||||
scores = ''
|
||||
for score in self.scores:
|
||||
scores += '{0} '.format(score)
|
||||
scores += '"{0}" '.format(score)
|
||||
|
||||
subelement = ET.SubElement(element, "scores")
|
||||
subelement.text = scores.rstrip(' ')
|
||||
|
|
@ -681,8 +681,8 @@ class Tally(object):
|
|||
|
||||
# If we did not find the Filter, throw an Exception
|
||||
if filter is None:
|
||||
msg = 'Unable to find filter type "{0}" in ' \
|
||||
'Tally ID={1}'.format(filter_type, self.id)
|
||||
msg = 'Unable to find filter type ""{0}"" in ' \
|
||||
'Tally ID="{1}"'.format(filter_type, self.id)
|
||||
raise ValueError(msg)
|
||||
|
||||
return filter
|
||||
|
|
@ -756,7 +756,7 @@ class Tally(object):
|
|||
break
|
||||
|
||||
if nuclide_index == -1:
|
||||
msg = 'Unable to get the nuclide index for Tally since "{0}" ' \
|
||||
msg = 'Unable to get the nuclide index for Tally since ""{0}"" ' \
|
||||
'is not one of the nuclides'.format(nuclide)
|
||||
raise KeyError(msg)
|
||||
else:
|
||||
|
|
@ -787,7 +787,7 @@ class Tally(object):
|
|||
score_index = self.scores.index(score)
|
||||
|
||||
except ValueError:
|
||||
msg = 'Unable to get the score index for Tally since "{0}" ' \
|
||||
msg = 'Unable to get the score index for Tally since ""{0}"" ' \
|
||||
'is not one of the scores'.format(score)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -849,7 +849,7 @@ class Tally(object):
|
|||
|
||||
# Ensure that StatePoint.read_results() was called first
|
||||
if self._sum is None or self._sum_sq is None:
|
||||
msg = 'The Tally ID={0} has no data to return. Call the ' \
|
||||
msg = 'The Tally ID="{0}" has no data to return. Call the ' \
|
||||
'StatePoint.read_results() routine before using ' \
|
||||
'Tally.get_values(...)'.format(self.id)
|
||||
raise ValueError(msg)
|
||||
|
|
@ -944,8 +944,8 @@ class Tally(object):
|
|||
elif value == 'sum_sq':
|
||||
data = self.sum_sq[indices]
|
||||
else:
|
||||
msg = 'Unable to return results from Tally ID={0} since the ' \
|
||||
'the requested value "{1}" is not \'mean\', \'std_dev\', ' \
|
||||
msg = 'Unable to return results from Tally ID="{0}" since the ' \
|
||||
'the requested value ""{1}"" is not \'mean\', \'std_dev\', ' \
|
||||
'\rel_err\', \'sum\', or \'sum_sq\''.format(self.id, value)
|
||||
raise LookupError(msg)
|
||||
|
||||
|
|
@ -996,14 +996,14 @@ class Tally(object):
|
|||
|
||||
# Ensure that StatePoint.read_results() was called first
|
||||
if self._sum is None or self._sum_sq is None:
|
||||
msg = 'The Tally ID={0} has no data to return. Call the ' \
|
||||
msg = 'The Tally ID="{0}" has no data to return. Call the ' \
|
||||
'StatePoint.read_results() routine before using ' \
|
||||
'Tally.get_pandas_dataframe(...)'.format(self.id)
|
||||
raise KeyError(msg)
|
||||
|
||||
# If using Summary, ensure StatePoint.link_with_summary(...) was called
|
||||
if summary and not self.with_summary:
|
||||
msg = 'The Tally ID={0} has not been linked with the Summary. ' \
|
||||
msg = 'The Tally ID="{0}" has not been linked with the Summary. ' \
|
||||
'Call the StatePoint.link_with_summary(...) routine ' \
|
||||
'before using Tally.get_pandas_dataframe(...) with ' \
|
||||
'Summary info'.format(self.id)
|
||||
|
|
@ -1036,7 +1036,7 @@ class Tally(object):
|
|||
|
||||
# Append Mesh ID as outermost index of mult-index
|
||||
mesh_id = filter.mesh.id
|
||||
mesh_key = 'mesh {0}'.format(mesh_id)
|
||||
mesh_key = 'mesh "{0}"'.format(mesh_id)
|
||||
|
||||
# Find mesh dimensions - use 3D indices for simplicity
|
||||
if (len(filter.mesh.dimension) == 3):
|
||||
|
|
@ -1128,7 +1128,7 @@ class Tally(object):
|
|||
|
||||
# Initialize prefix Multi-index keys
|
||||
counter += 1
|
||||
level_key = 'level {0}'.format(counter)
|
||||
level_key = 'level "{0}"'.format(counter)
|
||||
univ_key = (level_key, 'univ', 'id')
|
||||
cell_key = (level_key, 'cell', 'id')
|
||||
lat_id_key = (level_key, 'lat', 'id')
|
||||
|
|
@ -1292,30 +1292,30 @@ class Tally(object):
|
|||
|
||||
# Ensure that StatePoint.read_results() was called first
|
||||
if self._sum is None or self._sum_sq is None:
|
||||
msg = 'The Tally ID={0} has no data to export. Call the ' \
|
||||
msg = 'The Tally ID="{0}" has no data to export. Call the ' \
|
||||
'StatePoint.read_results() routine before using ' \
|
||||
'Tally.export_results(...)'.format(self.id)
|
||||
raise KeyError(msg)
|
||||
|
||||
if not isinstance(filename, basestring):
|
||||
msg = 'Unable to export the results for Tally ID={0} to ' \
|
||||
'filename="{1}" since it is not a ' \
|
||||
msg = 'Unable to export the results for Tally ID="{0}" to ' \
|
||||
'filename=""{1}"" since it is not a ' \
|
||||
'string'.format(self.id, filename)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif not isinstance(directory, basestring):
|
||||
msg = 'Unable to export the results for Tally ID={0} to ' \
|
||||
'directory="{1}" since it is not a ' \
|
||||
msg = 'Unable to export the results for Tally ID="{0}" to ' \
|
||||
'directory=""{1}"" since it is not a ' \
|
||||
'string'.format(self.id, directory)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif format not in ['hdf5', 'pkl', 'csv']:
|
||||
msg = 'Unable to export the results for Tally ID={0} to format ' \
|
||||
'"{1}" since it is not supported'.format(self.id, format)
|
||||
msg = 'Unable to export the results for Tally ID="{0}" to format ' \
|
||||
'""{1}"" since it is not supported'.format(self.id, format)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif not isinstance(append, bool):
|
||||
msg = 'Unable to export the results for Tally ID={0} since the ' \
|
||||
msg = 'Unable to export the results for Tally ID="{0}" since the ' \
|
||||
'append parameter is not True/False'.format(self.id, append)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -1335,7 +1335,7 @@ class Tally(object):
|
|||
tally_results = h5py.File(filename, 'w')
|
||||
|
||||
# Create an HDF5 group within the file for this particular Tally
|
||||
tally_group = tally_results.create_group('Tally-{0}'.format(self.id))
|
||||
tally_group = tally_results.create_group('Tally-"{0}"'.format(self.id))
|
||||
|
||||
# Add basic Tally data to the HDF5 group
|
||||
tally_group.create_dataset('id', data=self.id)
|
||||
|
|
@ -1377,8 +1377,8 @@ class Tally(object):
|
|||
tally_results = {}
|
||||
|
||||
# Create a nested dictionary within the file for this particular Tally
|
||||
tally_results['Tally-{0}'.format(self.id)] = {}
|
||||
tally_group = tally_results['Tally-{0}'.format(self.id)]
|
||||
tally_results['Tally-"{0}"'.format(self.id)] = {}
|
||||
tally_group = tally_results['Tally-"{0}"'.format(self.id)]
|
||||
|
||||
# Add basic Tally data to the nested dictionary
|
||||
tally_group['id'] = self.id
|
||||
|
|
@ -1437,7 +1437,7 @@ class TalliesFile(object):
|
|||
"""
|
||||
|
||||
if not isinstance(tally, Tally):
|
||||
msg = 'Unable to add a non-Tally {0} to the TalliesFile'.format(tally)
|
||||
msg = 'Unable to add a non-Tally "{0}" to the TalliesFile'.format(tally)
|
||||
raise ValueError(msg)
|
||||
|
||||
if merge:
|
||||
|
|
@ -1508,7 +1508,7 @@ class TalliesFile(object):
|
|||
"""
|
||||
|
||||
if not isinstance(mesh, Mesh):
|
||||
msg = 'Unable to add a non-Mesh {0} to the TalliesFile'.format(mesh)
|
||||
msg = 'Unable to add a non-Mesh "{0}" to the TalliesFile'.format(mesh)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._meshes.append(mesh)
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class Trigger(object):
|
|||
"""
|
||||
|
||||
if not isinstance(score, basestring):
|
||||
msg = 'Unable to add score "{0}" to tally trigger since ' \
|
||||
msg = 'Unable to add score ""{0}"" to tally trigger since ' \
|
||||
'it is not a string'.format(score)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -104,9 +104,9 @@ class Trigger(object):
|
|||
|
||||
def __repr__(self):
|
||||
string = 'Trigger\n'
|
||||
string += '{0: <16}{1}{2}\n'.format('\tType', '=\t', self._trigger_type)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tThreshold', '=\t', self._threshold)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tScores', '=\t', self._scores)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tType', '=\t', self._trigger_type)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tThreshold', '=\t', self._threshold)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tScores', '=\t', self._scores)
|
||||
return string
|
||||
|
||||
def get_trigger_xml(self, element):
|
||||
|
|
|
|||
|
|
@ -126,8 +126,8 @@ class Cell(object):
|
|||
if fill.strip().lower() == 'void':
|
||||
self._type = 'void'
|
||||
else:
|
||||
msg = 'Unable to set Cell ID={0} to use a non-Material or ' \
|
||||
'Universe fill {1}'.format(self._id, fill)
|
||||
msg = 'Unable to set Cell ID="{0}" to use a non-Material or ' \
|
||||
'Universe fill "{1}"'.format(self._id, fill)
|
||||
raise ValueError(msg)
|
||||
|
||||
elif isinstance(fill, openmc.Material):
|
||||
|
|
@ -140,8 +140,8 @@ class Cell(object):
|
|||
self._type = 'lattice'
|
||||
|
||||
else:
|
||||
msg = 'Unable to set Cell ID={0} to use a non-Material or ' \
|
||||
'Universe fill {1}'.format(self._id, fill)
|
||||
msg = 'Unable to set Cell ID="{0}" to use a non-Material or ' \
|
||||
'Universe fill "{1}"'.format(self._id, fill)
|
||||
raise ValueError(msg)
|
||||
|
||||
self._fill = fill
|
||||
|
|
@ -177,13 +177,13 @@ class Cell(object):
|
|||
"""
|
||||
|
||||
if not isinstance(surface, openmc.Surface):
|
||||
msg = 'Unable to add Surface {0} to Cell ID={1} since it is ' \
|
||||
msg = 'Unable to add Surface "{0}" to Cell ID="{1}" since it is ' \
|
||||
'not a Surface object'.format(surface, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
if halfspace not in [-1, +1]:
|
||||
msg = 'Unable to add Surface {0} to Cell ID={1} with halfspace ' \
|
||||
'{2} since it is not +/-1'.format(surface, self._id, halfspace)
|
||||
msg = 'Unable to add Surface "{0}" to Cell ID="{1}" with halfspace ' \
|
||||
'"{2}" since it is not +/-1'.format(surface, self._id, halfspace)
|
||||
raise ValueError(msg)
|
||||
|
||||
# If the Cell does not already contain the Surface, add it
|
||||
|
|
@ -201,7 +201,7 @@ class Cell(object):
|
|||
"""
|
||||
|
||||
if not isinstance(surface, openmc.Surface):
|
||||
msg = 'Unable to remove Surface {0} from Cell ID={1} since it is ' \
|
||||
msg = 'Unable to remove Surface "{0}" from Cell ID="{1}" since it is ' \
|
||||
'not a Surface object'.format(surface, self._id)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -289,31 +289,31 @@ class Cell(object):
|
|||
|
||||
def __repr__(self):
|
||||
string = 'Cell\n'
|
||||
string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name)
|
||||
|
||||
if isinstance(self._fill, openmc.Material):
|
||||
string += '{0: <16}{1}{2}\n'.format('\tMaterial', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tMaterial', '=\t',
|
||||
self._fill._id)
|
||||
elif isinstance(self._fill, (Universe, Lattice)):
|
||||
string += '{0: <16}{1}{2}\n'.format('\tFill', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tFill', '=\t',
|
||||
self._fill._id)
|
||||
else:
|
||||
string += '{0: <16}{1}{2}\n'.format('\tFill', '=\t', self._fill)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tFill', '=\t', self._fill)
|
||||
|
||||
string += '{0: <16}{1}\n'.format('\tSurfaces', '=\t')
|
||||
string += '{0: <16}"{1}"\n'.format('\tSurfaces', '=\t')
|
||||
|
||||
for surface_id in self._surfaces:
|
||||
halfspace = self._surfaces[surface_id][1]
|
||||
string += '{0} '.format(halfspace * surface_id)
|
||||
string += '"{0}" '.format(halfspace * surface_id)
|
||||
|
||||
string = string.rstrip(' ') + '\n'
|
||||
|
||||
string += '{0: <16}{1}{2}\n'.format('\tRotation', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tRotation', '=\t',
|
||||
self._rotation)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tTranslation', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tTranslation', '=\t',
|
||||
self._translation)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tOffset', '=\t', self._offsets)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tOffset', '=\t', self._offsets)
|
||||
|
||||
return string
|
||||
|
||||
|
|
@ -343,7 +343,7 @@ class Cell(object):
|
|||
|
||||
for surface_id in self._surfaces:
|
||||
# Determine if XML element already includes this Surface
|
||||
path = './surface[@id=\'{0}\']'.format(surface_id)
|
||||
path = './surface[@id=\'"{0}"\']'.format(surface_id)
|
||||
test = xml_element.find(path)
|
||||
|
||||
# If the element does not contain the Surface subelement
|
||||
|
|
@ -355,7 +355,7 @@ class Cell(object):
|
|||
|
||||
# Append the halfspace and Surface ID
|
||||
halfspace = self._surfaces[surface_id][1]
|
||||
surfaces += '{0} '.format(halfspace * surface_id)
|
||||
surfaces += '"{0}" '.format(halfspace * surface_id)
|
||||
|
||||
element.set("surfaces", surfaces.rstrip(' '))
|
||||
|
||||
|
|
@ -452,7 +452,7 @@ class Universe(object):
|
|||
"""
|
||||
|
||||
if not isinstance(cell, Cell):
|
||||
msg = 'Unable to add a Cell to Universe ID={0} since {1} is not ' \
|
||||
msg = 'Unable to add a Cell to Universe ID="{0}" since "{1}" is not ' \
|
||||
'a Cell'.format(self._id, cell)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -472,7 +472,7 @@ class Universe(object):
|
|||
"""
|
||||
|
||||
if not isinstance(cells, Iterable):
|
||||
msg = 'Unable to add Cells to Universe ID={0} since {1} is not ' \
|
||||
msg = 'Unable to add Cells to Universe ID="{0}" since "{1}" is not ' \
|
||||
'iterable'.format(self._id, cells)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -490,7 +490,7 @@ class Universe(object):
|
|||
"""
|
||||
|
||||
if not isinstance(cell, Cell):
|
||||
msg = 'Unable to remove a Cell from Universe ID={0} since {1} is ' \
|
||||
msg = 'Unable to remove a Cell from Universe ID="{0}" since "{1}" is ' \
|
||||
'not a Cell'.format(self._id, cell)
|
||||
raise ValueError(msg)
|
||||
|
||||
|
|
@ -582,11 +582,11 @@ class Universe(object):
|
|||
|
||||
def __repr__(self):
|
||||
string = 'Universe\n'
|
||||
string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tCells', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tCells', '=\t',
|
||||
list(self._cells.keys()))
|
||||
string += '{0: <16}{1}{2}\n'.format('\t# Regions', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\t# Regions', '=\t',
|
||||
self._num_regions)
|
||||
return string
|
||||
|
||||
|
|
@ -870,26 +870,26 @@ class RectLattice(Lattice):
|
|||
|
||||
def __repr__(self):
|
||||
string = 'RectLattice\n'
|
||||
string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tDimension', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tDimension', '=\t',
|
||||
self._dimension)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tLower Left', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tLower Left', '=\t',
|
||||
self._lower_left)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tPitch', '=\t', self._pitch)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tPitch', '=\t', self._pitch)
|
||||
|
||||
if self._outer is not None:
|
||||
string += '{0: <16}{1}{2}\n'.format('\tOuter', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tOuter', '=\t',
|
||||
self._outer._id)
|
||||
else:
|
||||
string += '{0: <16}{1}{2}\n'.format('\tOuter', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tOuter', '=\t',
|
||||
self._outer)
|
||||
|
||||
string += '{0: <16}\n'.format('\tUniverses')
|
||||
|
||||
# Lattice nested Universe IDs - column major for Fortran
|
||||
for i, universe in enumerate(np.ravel(self._universes)):
|
||||
string += '{0} '.format(universe._id)
|
||||
string += '"{0}" '.format(universe._id)
|
||||
|
||||
# Add a newline character every time we reach end of row of cells
|
||||
if (i+1) % self._dimension[-1] == 0:
|
||||
|
|
@ -902,7 +902,7 @@ class RectLattice(Lattice):
|
|||
|
||||
# Lattice cell offsets
|
||||
for i, offset in enumerate(np.ravel(self._offsets)):
|
||||
string += '{0} '.format(offset)
|
||||
string += '"{0}" '.format(offset)
|
||||
|
||||
# Add a newline character when we reach end of row of cells
|
||||
if (i+1) % self._dimension[-1] == 0:
|
||||
|
|
@ -914,7 +914,7 @@ class RectLattice(Lattice):
|
|||
|
||||
def create_xml_subelement(self, xml_element):
|
||||
# Determine if XML element already contains subelement for this Lattice
|
||||
path = './lattice[@id=\'{0}\']'.format(self._id)
|
||||
path = './lattice[@id=\'"{0}"\']'.format(self._id)
|
||||
test = xml_element.find(path)
|
||||
|
||||
# If the element does contain the Lattice subelement, then return
|
||||
|
|
@ -934,7 +934,7 @@ class RectLattice(Lattice):
|
|||
# Export the Lattice outer Universe (if specified)
|
||||
if self._outer is not None:
|
||||
outer = ET.SubElement(lattice_subelement, "outer")
|
||||
outer.text = '{0}'.format(self._outer._id)
|
||||
outer.text = '"{0}"'.format(self._outer._id)
|
||||
self._outer.create_xml_subelement(xml_element)
|
||||
|
||||
# Export Lattice cell dimensions
|
||||
|
|
@ -956,7 +956,7 @@ class RectLattice(Lattice):
|
|||
universe = self._universes[x][y][z]
|
||||
|
||||
# Append Universe ID to the Lattice XML subelement
|
||||
universe_ids += '{0} '.format(universe._id)
|
||||
universe_ids += '"{0}" '.format(universe._id)
|
||||
|
||||
# Create XML subelement for this Universe
|
||||
universe.create_xml_subelement(xml_element)
|
||||
|
|
@ -974,7 +974,7 @@ class RectLattice(Lattice):
|
|||
universe = self._universes[x][y]
|
||||
|
||||
# Append Universe ID to Lattice XML subelement
|
||||
universe_ids += '{0} '.format(universe._id)
|
||||
universe_ids += '"{0}" '.format(universe._id)
|
||||
|
||||
# Create XML subelement for this Universe
|
||||
universe.create_xml_subelement(xml_element)
|
||||
|
|
@ -1149,19 +1149,19 @@ class HexLattice(Lattice):
|
|||
|
||||
def __repr__(self):
|
||||
string = 'HexLattice\n'
|
||||
string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}{1}{2}\n'.format('\t# Rings', '=\t', self._num_rings)
|
||||
string += '{0: <16}{1}{2}\n'.format('\t# Axial', '=\t', self._num_axial)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tCenter', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tID', '=\t', self._id)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tName', '=\t', self._name)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\t# Rings', '=\t', self._num_rings)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\t# Axial', '=\t', self._num_axial)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tCenter', '=\t',
|
||||
self._center)
|
||||
string += '{0: <16}{1}{2}\n'.format('\tPitch', '=\t', self._pitch)
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tPitch', '=\t', self._pitch)
|
||||
|
||||
if self._outer is not None:
|
||||
string += '{0: <16}{1}{2}\n'.format('\tOuter', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tOuter', '=\t',
|
||||
self._outer._id)
|
||||
else:
|
||||
string += '{0: <16}{1}{2}\n'.format('\tOuter', '=\t',
|
||||
string += '{0: <16}"{1}""{2}"\n'.format('\tOuter', '=\t',
|
||||
self._outer)
|
||||
|
||||
string += '{0: <16}\n'.format('\tUniverses')
|
||||
|
|
@ -1177,7 +1177,7 @@ class HexLattice(Lattice):
|
|||
|
||||
def create_xml_subelement(self, xml_element):
|
||||
# Determine if XML element already contains subelement for this Lattice
|
||||
path = './hex_lattice[@id=\'{0}\']'.format(self._id)
|
||||
path = './hex_lattice[@id=\'"{0}"\']'.format(self._id)
|
||||
test = xml_element.find(path)
|
||||
|
||||
# If the element does contain the Lattice subelement, then return
|
||||
|
|
@ -1197,7 +1197,7 @@ class HexLattice(Lattice):
|
|||
# Export the Lattice outer Universe (if specified)
|
||||
if self._outer is not None:
|
||||
outer = ET.SubElement(lattice_subelement, "outer")
|
||||
outer.text = '{0}'.format(self._outer._id)
|
||||
outer.text = '"{0}"'.format(self._outer._id)
|
||||
self._outer.create_xml_subelement(xml_element)
|
||||
|
||||
lattice_subelement.set("n_rings", str(self._num_rings))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue