Respond to various scopatz comments in pull request #331

This commit is contained in:
Paul Romano 2015-04-16 13:13:54 -05:00
parent db61158325
commit 37a9b7478f
13 changed files with 74 additions and 59 deletions

View file

@ -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):

View file

@ -1,7 +1,8 @@
from openmc.checkvalue import *
import subprocess
import os
from openmc.checkvalue import *
class Executor(object):

View file

@ -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()

View file

@ -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]

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
################################################################################