diff --git a/src/utils/openmc/cmfd.py b/src/utils/openmc/cmfd.py index 443867284a..5d10ba5383 100644 --- a/src/utils/openmc/cmfd.py +++ b/src/utils/openmc/cmfd.py @@ -1,7 +1,9 @@ +from xml.etree import ElementTree as ET + +import numpy as np + from openmc.checkvalue import * from openmc.clean_xml import * -from xml.etree import ElementTree as ET -import numpy as np class CMFDMesh(object): diff --git a/src/utils/openmc/executor.py b/src/utils/openmc/executor.py index abc2e9e49e..446111c3d9 100644 --- a/src/utils/openmc/executor.py +++ b/src/utils/openmc/executor.py @@ -1,7 +1,8 @@ -from openmc.checkvalue import * import subprocess import os +from openmc.checkvalue import * + class Executor(object): diff --git a/src/utils/openmc/geometry.py b/src/utils/openmc/geometry.py index 17d0f5fa87..db2227ba5a 100644 --- a/src/utils/openmc/geometry.py +++ b/src/utils/openmc/geometry.py @@ -1,6 +1,8 @@ +from xml.etree import ElementTree as ET + import openmc from openmc.clean_xml import * -from xml.etree import ElementTree as ET + def reset_auto_ids(): openmc.reset_auto_material_id() diff --git a/src/utils/openmc/material.py b/src/utils/openmc/material.py index 0d6e39b992..99402ef75e 100644 --- a/src/utils/openmc/material.py +++ b/src/utils/openmc/material.py @@ -1,12 +1,13 @@ +from collections import MappingView +from copy import deepcopy import warnings +from xml.etree import ElementTree as ET + +import numpy as np import openmc from openmc.checkvalue import * from openmc.clean_xml import * -from xml.etree import ElementTree as ET -from collections import MappingView -from copy import deepcopy -import numpy as np # A list of all IDs for all Materials created @@ -70,14 +71,13 @@ class Material(object): def set_id(self, material_id=None): - global MATERIAL_IDS + global AUTO_MATERIAL_ID, MATERIAL_IDS # If the Material already has an ID, remove it from global list if not self._id is None: MATERIAL_IDS.remove(self._id) if material_id is None: - global AUTO_MATERIAL_ID self._id = AUTO_MATERIAL_ID MATERIAL_IDS.append(AUTO_MATERIAL_ID) AUTO_MATERIAL_ID += 1 @@ -260,13 +260,13 @@ class Material(object): string += '{0: <16}{1}{2}'.format('\tDensity', '=\t', self._density) string += ' [{0}]\n'.format(self._density_units) - string += '{0: <16}'.format('\tS(a,b) Tables') + '\n' + 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', sab[0], sab[1]) - string += '{0: <16}'.format('\tNuclides') + '\n' + string += '{0: <16}\n'.format('\tNuclides') for nuclide in self._nuclides: percent = self._nuclides[nuclide][1] diff --git a/src/utils/openmc/nuclide.py b/src/utils/openmc/nuclide.py index e100d6d74e..5281eacd4c 100644 --- a/src/utils/openmc/nuclide.py +++ b/src/utils/openmc/nuclide.py @@ -36,10 +36,7 @@ class Nuclide(object): def __hash__(self): - hashable = [] - hashable.append(self._name) - hashable.append(self._xs) - return hash(tuple(hashable)) + return hash((self._name, self._xs)) def set_name(self, name): diff --git a/src/utils/openmc/opencg_compatible.py b/src/utils/openmc/opencg_compatible.py index f80eb2c2c7..b7644aa48c 100644 --- a/src/utils/openmc/opencg_compatible.py +++ b/src/utils/openmc/opencg_compatible.py @@ -1,7 +1,9 @@ -import openmc -import opencg import copy + import numpy as np +import opencg + +import openmc # A dictionary of all OpenMC Materials created diff --git a/src/utils/openmc/plots.py b/src/utils/openmc/plots.py index dbea64b09e..a69fb1abc1 100644 --- a/src/utils/openmc/plots.py +++ b/src/utils/openmc/plots.py @@ -1,7 +1,9 @@ +from xml.etree import ElementTree as ET + +import numpy as np + from openmc.checkvalue import * from openmc.clean_xml import * -from xml.etree import ElementTree as ET -import numpy as np # A static variable for auto-generated Plot IDs diff --git a/src/utils/openmc/settings.py b/src/utils/openmc/settings.py index 0e314545a2..240892e420 100644 --- a/src/utils/openmc/settings.py +++ b/src/utils/openmc/settings.py @@ -1,10 +1,11 @@ +import collections import warnings +from xml.etree import ElementTree as ET + +import numpy as np from openmc.checkvalue import * from openmc.clean_xml import * -from xml.etree import ElementTree as ET -import numpy as np -import multiprocessing class SettingsFile(object): @@ -152,16 +153,16 @@ class SettingsFile(object): self._source_file = source_file - def set_source_space(self, type, params): + def set_source_space(self, stype, params): - if not is_string(type): + if not is_string(stype): msg = 'Unable to set source space type to a non-string ' \ - 'value {0}'.format(type) + 'value {0}'.format(stype) raise ValueError(msg) - elif not type in ['box', 'point']: + elif not stype in ['box', 'point']: msg = 'Unable to set source space type to {0} since it is not ' \ - 'box or point'.format(type) + 'box or point'.format(stype) raise ValueError(msg) elif not isinstance(params, (tuple, list, np.ndarray)): @@ -181,20 +182,20 @@ class SettingsFile(object): 'is not an integer or floating point value'.format(param) raise ValueError(msg) - self._source_space_type = type + self._source_space_type = stype self._source_space_params = params - def set_source_angle(self, type, params=[]): + def set_source_angle(self, stype, params=[]): - if not is_string(type): + if not is_string(stype): msg = 'Unable to set source angle type to a non-string ' \ - 'value {0}'.format(type) + 'value {0}'.format(stype) raise ValueError(msg) - elif not type in ['isotropic', 'monodirectional']: + elif not stype in ['isotropic', 'monodirectional']: msg = 'Unable to set source angle type to {0} since it is not ' \ - 'isotropic or monodirectional'.format(type) + 'isotropic or monodirectional'.format(stype) raise ValueError(msg) elif not isinstance(params, (tuple, list, np.ndarray)): @@ -202,12 +203,12 @@ class SettingsFile(object): 'not a Python list/tuple or NumPy array'.format(params) raise ValueError(msg) - elif type is 'isotropic' and not params is None: + elif stype == 'isotropic' and not params is None: msg = 'Unable to set source angle parameters since they are not ' \ 'it is not supported for isotropic type sources' raise ValueError(msg) - elif type is 'monodirectional' and len(params) != 3: + elif stype == 'monodirectional' and len(params) != 3: msg = 'Unable to set source angle parameters to {0} ' \ 'since 3 parameters are required for monodirectional ' \ 'sources'.format(params) @@ -220,20 +221,20 @@ class SettingsFile(object): 'is not an integer or floating point value'.format(param) raise ValueError(msg) - self._source_angle_type = type + self._source_angle_type = stype self._source_angle_params = params - def set_source_energy(self, type, params=[]): + def set_source_energy(self, stype, params=[]): - if not is_string(type): + if not is_string(stype): msg = 'Unable to set source energy type to a non-string ' \ - 'value {0}'.format(type) + 'value {0}'.format(stype) raise ValueError(msg) - elif not type in ['monoenergetic', 'watt', 'maxwell']: + elif not stype in ['monoenergetic', 'watt', 'maxwell']: msg = 'Unable to set source energy type to {0} since it is not ' \ - 'monoenergetic, watt or maxwell'.format(type) + 'monoenergetic, watt or maxwell'.format(stype) raise ValueError(msg) elif not isinstance(params, (tuple, list, np.ndarray)): @@ -241,19 +242,19 @@ class SettingsFile(object): 'is not a Python list/tuple or NumPy array'.format(params) raise ValueError(msg) - elif type is 'monoenergetic' and not len(params) != 1: + elif stype == 'monoenergetic' and not len(params) != 1: msg = 'Unable to set source energy parameters to {0} ' \ 'since 1 paramater is required for monenergetic ' \ 'sources'.format(params) raise ValueError(msg) - elif type is 'watt' and len(params) != 2: + elif stype == 'watt' and len(params) != 2: msg = 'Unable to set source energy parameters to {0} ' \ 'since 2 parameters are required for monoenergetic ' \ 'sources'.format(params) raise ValueError(msg) - elif type is 'maxwell' and len(params) != 2: + elif stype == 'maxwell' and len(params) != 2: msg = 'Unable to set source energy parameters to {0} since 1 ' \ 'parameter is required for maxwell sources'.format(params) raise ValueError(msg) @@ -266,7 +267,7 @@ class SettingsFile(object): 'value'.format(param) raise ValueError(msg) - self._source_energy_type = type + self._source_energy_type = stype self._source_energy_params = params @@ -806,7 +807,7 @@ class SettingsFile(object): warnings.warn('This feature is not yet implemented in a release ' \ 'version of openmc') - if not type(allow) == bool: + if not isinstance(allow, bool): msg = 'Unable to set DD allow_leakage {0} which is ' \ 'not a Python bool'.format(dimension) raise ValueError(msg) @@ -820,7 +821,7 @@ class SettingsFile(object): warnings.warn('This feature is not yet implemented in a release ' \ 'version of openmc') - if not type(interactions) == bool: + if not isinstance(interactions, bool): msg = 'Unable to set DD count_interactions {0} which is ' \ 'not a Python bool'.format(dimension) raise ValueError(msg) diff --git a/src/utils/openmc/statepoint.py b/src/utils/openmc/statepoint.py index 4ded8d1b65..eadfcc4c1f 100644 --- a/src/utils/openmc/statepoint.py +++ b/src/utils/openmc/statepoint.py @@ -1,11 +1,13 @@ -import struct, copy +import copy +import struct + import numpy as np import scipy.stats + import openmc from openmc.constants import * - class SourceSite(object): def __init__(self): diff --git a/src/utils/openmc/summary.py b/src/utils/openmc/summary.py index fe179a971e..caddc99a98 100644 --- a/src/utils/openmc/summary.py +++ b/src/utils/openmc/summary.py @@ -1,6 +1,7 @@ +import numpy as np + import openmc from openmc.opencg_compatible import get_opencg_geometry -import numpy as np try: import h5py diff --git a/src/utils/openmc/surface.py b/src/utils/openmc/surface.py index 9e4660eced..2ed28e3835 100644 --- a/src/utils/openmc/surface.py +++ b/src/utils/openmc/surface.py @@ -1,6 +1,7 @@ +from xml.etree import ElementTree as ET + from openmc.checkvalue import * from openmc.constants import BC_TYPES -from xml.etree import ElementTree as ET # A static variable for auto-generated Surface IDs diff --git a/src/utils/openmc/tallies.py b/src/utils/openmc/tallies.py index 4250aa4635..9d9f8acaf2 100644 --- a/src/utils/openmc/tallies.py +++ b/src/utils/openmc/tallies.py @@ -1,10 +1,12 @@ +from xml.etree import ElementTree as ET +import os, copy + +import numpy as np + from openmc import Nuclide from openmc.clean_xml import * from openmc.checkvalue import * from openmc.constants import * -from xml.etree import ElementTree as ET -import numpy as np -import os, copy # "Static" variables for auto-generated Tally and Mesh IDs diff --git a/src/utils/openmc/universe.py b/src/utils/openmc/universe.py index 676c94587f..5bb9c29304 100644 --- a/src/utils/openmc/universe.py +++ b/src/utils/openmc/universe.py @@ -1,9 +1,11 @@ +import abc +from collections import OrderedDict +from xml.etree import ElementTree as ET + +import numpy as np + import openmc from openmc.checkvalue import * -from xml.etree import ElementTree as ET -from collections import OrderedDict -import numpy as np -import abc ################################################################################