def get_openmoc_material(opencg_material): if not isinstance(opencg_material, opencg.Material): msg = 'Unable to create an OpenMOC Material from {0} ' \ 'which is not an OpenCG Material'.format(opencg_material) raise ValueError(msg) global OPENMOC_MATERIALS material_id = opencg_material._id # If this Material was already created, use it if material_id in OPENMOC_MATERIALS: return OPENMOC_MATERIALS[material_id] # Create an OpenMOC Material to represent this OpenCG Material name = opencg_material._name openmoc_material = openmoc.Material(id=material_id, name=name) # Add the OpenMOC Material to the global collection of all OpenMOC Materials OPENMOC_MATERIALS[material_id] = openmoc_material # Add the OpenCG Material to the global collection of all OpenCG Materials OPENCG_MATERIALS[material_id] = opencg_material # FIXME openmoc_material.thisown = 0 return openmoc_material
def get_openmoc_material(openmc_material): """Return an OpenMOC material corresponding to an OpenMC material. Parameters ---------- openmc_material : openmc.Material OpenMC material Returns ------- openmoc_material : openmoc.Material Equivalent OpenMOC material """ cv.check_type('openmc_material', openmc_material, openmc.Material) material_id = openmc_material.id # If this Material was already created, use it if material_id in OPENMOC_MATERIALS: return OPENMOC_MATERIALS[material_id] # Create an OpenMOC Material to represent this OpenMC Material name = str(openmc_material.name) openmoc_material = openmoc.Material(id=material_id, name=name) # Add the OpenMC Material to the global collection of all OpenMC Materials OPENMC_MATERIALS[material_id] = openmc_material # Add the OpenMOC Material to the global collection of all OpenMOC Materials OPENMOC_MATERIALS[material_id] = openmoc_material return openmoc_material
def test_rotations(self): # Test setting a rotation angle rotation = np.array([6, 2, 1]) with self.assertRaises(Exception): self.cell.setRotation(np.array([0, 2.])) with self.assertRaises(Exception): self.cell.setRotation(rotation, "fake") material = openmoc.Material() self.cell.setFill(material) with self.assertRaises(Exception): self.cell.setRotation(rotation) universe = openmoc.Universe() self.cell.setFill(universe) self.cell.setRotation(rotation, "radians") # Test retrieving a rotation angle with self.assertRaises(Exception): self.cell.retrieveRotation(3, "fake") degrees = self.cell.retrieveRotation(3, "degrees") radians = self.cell.retrieveRotation(3, "radians") np.testing.assert_array_almost_equal(degrees, rotation / np.pi * 180, 10) np.testing.assert_array_almost_equal(radians, rotation, 10)
def test_fission_matrix(self): material = openmoc.Material() with self.assertRaises(Exception): material.buildFissionMatrix() self.test_material.buildFissionMatrix() self.assertAlmostEqual( self.test_material.getFissionMatrixByGroup(1, 1), .0015) self.assertAlmostEqual( self.test_material.getFissionMatrixByGroup(2, 1), .325)
def test_get_cross_section(self): material = openmoc.Material() with self.assertRaises(Exception): material.getSigmaS() with self.assertRaises(Exception): material.getSigmaA() with self.assertRaises(Exception): material.getSigmaT() with self.assertRaises(Exception): material.getSigmaF() with self.assertRaises(Exception): material.getNuSigmaF()
def create_materials(self): sigma_f = numpy.array([0.000625, 0.135416667]) nu_sigma_f = numpy.array([0.0015, 0.325]) sigma_s = numpy.array([[0.1, 0.117], [0., 1.42]]) chi = numpy.array([1.0, 0.0]) sigma_t = numpy.array([0.2208, 1.604]) self.materials['infinite medium'] = openmoc.Material() self.materials['infinite medium'].setName('2-group infinite medium') self.materials['infinite medium'].setNumEnergyGroups(2) self.materials['infinite medium'].setSigmaF(sigma_f) self.materials['infinite medium'].setNuSigmaF(nu_sigma_f) self.materials['infinite medium'].setSigmaS(sigma_s.flat) self.materials['infinite medium'].setChi(chi) self.materials['infinite medium'].setSigmaT(sigma_t)
def test_translations(self): # Test setting a rotation angle translation = np.array([6, 2, 1]) with self.assertRaises(Exception): self.cell.setTranslation(np.array([0, 2.])) material = openmoc.Material() self.cell.setFill(material) with self.assertRaises(Exception): self.cell.setTranslation(translation) universe = openmoc.Universe() self.cell.setFill(universe) self.cell.setTranslation(translation) # Test retrieving a rotation angle output = self.cell.retrieveTranslation(3) np.testing.assert_array_almost_equal(translation, output, 10)
def test_cross_section_alignment(self): material = openmoc.Material() with self.assertRaises(Exception): material.alignData() self.test_material.alignData() self.assertEqual(self.test_material.isDataAligned(), True) self.assertEqual(self.test_material.getNumVectorGroups(), 1) self.assertAlmostEqual(self.test_material.getSigmaTByGroup(1), 0.2208) #FIXME SigmaA is not copied during alignment process self.assertAlmostEqual(self.test_material.getSigmaAByGroup(1), 0.1208) self.assertAlmostEqual(self.test_material.getSigmaFByGroup(1), 0.000625) self.assertAlmostEqual(self.test_material.getSigmaSByGroup(1, 1), 0.1) self.assertAlmostEqual(self.test_material.getChiByGroup(1), 1.) self.assertAlmostEqual(self.test_material.getNuSigmaFByGroup(1), 0.0015)
'Simulating a two group homogeneous infinite medium...') openmoc.log.py_printf('HEADER', 'The reference keff = 1.72...') ############################################################################### # Creating Materials ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating materials...') sigma_f = numpy.array([0.000625, 0.135416667]) nu_sigma_f = numpy.array([0.0015, 0.325]) sigma_s = numpy.array([[0.1, 0.117], [0., 1.42]]) chi = numpy.array([1.0, 0.0]) sigma_t = numpy.array([0.2208, 1.604]) infinite_medium = openmoc.Material(name='2-group infinite medium') infinite_medium.setNumEnergyGroups(2) infinite_medium.setSigmaF(sigma_f) infinite_medium.setNuSigmaF(nu_sigma_f) infinite_medium.setSigmaS(sigma_s.flat) infinite_medium.setChi(chi) infinite_medium.setSigmaT(sigma_t) ############################################################################### # Creating Surfaces ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating surfaces...') left = openmoc.XPlane(x=-100.0, name='left') right = openmoc.XPlane(x=100.0, name='right')
def materialize(filename): xs_types = ['Total XS', 'Absorption XS', 'Scattering XS', \ 'Fission XS', 'Nu Fission XS', 'Chi', 'Diffusion Coefficient'] materials = {} # Check that the filename is a string if not isinstance(filename, str): py_printf('ERROR', 'Unable to materialize using filename %s ' + \ 'since it is not a string', str(filename)) ############################################################################## # HDF5 DATA FILES ############################################################################## if filename.endswith('.h5') or filename.endswith('.hdf5'): import h5py import numpy as np # Create a h5py file handle for the file try: f = h5py.File(filename,'r') except: py_printf('ERROR', 'Unable to materialize file %s because it ' + \ 'cannot be opened. Check the file path.',filename) # Check that the file has an 'energy groups' attribute if not 'Energy Groups' in f.attrs: py_printf('ERROR', 'Unable to materialize file %s since it does ' + \ 'not contain an \'Energy Groups\' attribute', filename) num_groups = f.attrs['Energy Groups'] # Check that the number of energy groups is an integer if not is_integer(num_groups): py_printf('ERROR', 'Unable to materialize file %s since the number of' + \ 'energy groups %s could not be converted to an integer', \ filename, str(num_groups)) material_names = list(f) # Loop over each material and for name in material_names: py_printf('INFO', 'Importing material %s', str(name)) new_material = openmoc.Material(openmoc.material_id()) new_material.setNumEnergyGroups(int(num_groups)) # Retrieve and load the cross-section data into the material object if 'Total XS' in f[name]: new_material.setSigmaT(f[name]['Total XS'][...]) if 'Scattering XS' in f[name]: new_material.setSigmaS(f[name]['Scattering XS'][...]) if 'Fission XS' in f[name]: new_material.setSigmaF(f[name]['Fission XS'][...]) if 'Nu Fission XS' in f[name]: new_material.setNuSigmaF(f[name]['Nu Fission XS'][...]) if 'Chi' in f[name]: new_material.setChi(f[name]['Chi'][...]) if 'Diffusion Coefficient' in f[name]: new_material.setDifCoef(f[name]['Diffusion Coefficient'][...]) if 'Buckling' in f[name]: new_material.setBuckling(f[name]['Buckling'][...]) if 'Absorption XS' in f[name]: new_material.setSigmaA(f[name]['Absorption XS'][...]) # Make sure this Material's cross-sections add up to # its total cross-section new_material.checkSigmaT() # Add this material to the list materials[name] = new_material ############################################################################## # PYTHON DICTIONARY DATA FILES ############################################################################## elif filename.endswith('.py'): import imp try: data = imp.load_source(filename, filename).dataset except IOError: py_printf('ERROR', 'Unable to materialize file %s because it ' + \ 'cannot be opened. Check the file path.',filename) # Check that the file has an 'energy groups' attribute if not 'Energy Groups' in data.keys(): py_printf('ERROR', 'Unable to materialize file %s since it does not ' + \ 'contain an \'Energy Groups\' attribute', filename) num_groups = data['Energy Groups'] # Check that the number of energy groups is an integer if not is_integer(num_groups): py_printf('ERROR', 'Unable to materialize file %s since the number of' + \ 'energy groups %s is not an integer', filename, str(num_groups)) data = data['Materials'] material_names = data.keys() # Loop over each material and for name in material_names: py_printf('INFO', 'Importing material %s', str(name)) new_material = openmoc.Material(openmoc.material_id()) new_material.setNumEnergyGroups(int(num_groups)) if 'Total XS' in data[name].keys(): new_material.setSigmaT(data[name]['Total XS']) if 'Scattering XS' in data[name].keys(): new_material.setSigmaS(data[name]['Scattering XS']) if 'Fission XS' in data[name].keys(): new_material.setSigmaF(data[name]['Fission XS']) if 'Nu Fission XS' in data[name].keys(): new_material.setNuSigmaF(data[name]['Nu Fission XS']) if 'Chi' in data[name].keys(): new_material.setChi(data[name]['Chi']) if 'Diffusion Coefficient' in data[name].keys(): new_material.setDifCoef(data[name]['Diffusion Coefficient']) if 'Buckling' in data[name].keys(): new_material.setBuckling(data[name]['Buckling']) if 'Absorption XS' in data[name].keys(): new_material.setSigmaA(data[name]['Absorption XS']) # Add this material to the list materials[name] = new_material ############################################################################## # UNSUPPORTED DATA FILE TYPES ############################################################################## else: py_printf('ERROR', 'Unable to materialize using filename %s ' + \ 'since it has an unkown extension. Supported ' + \ 'extension types are .hdf5 and .py', filename) # Return the list of materials return materials
def load_from_hdf5(filename='mgxs.h5', directory='mgxs', geometry=None, domain_type='material', suffix=''): """This routine loads an HDF5 file of multi-group cross section data. The routine instantiates material with multi-group cross section data and returns a dictionary of each Material object keyed by its name or ID. An OpenMOC geometry may optionally be given and the routine will directly insert the multi-group cross sections into each material in the geometry. If a geometry is passed in, materials from the geometry will be used in place of those instantiated by this routine. Parameters ---------- filename : str Filename for cross sections HDF5 file (default is 'mgxs.h5') directory : str Directory for cross sections HDF5 file (default is 'mgxs') geometry : openmoc.Geometry, optional An optional geometry populated with materials, cells, etc. domain_type : str The domain type ('material' or 'cell') upon which the cross sections are defined (default is 'material') suffix : str, optional An optional string suffix to index the HDF5 file beyond the assumed domain_type/domain_id/mgxs_type group sequence (default is '') Returns ------- materials : dict A dictionary of Materials keyed by ID """ cv.check_type('filename', filename, basestring) cv.check_type('directory', directory, basestring) cv.check_value('domain_type', domain_type, ('material', 'cell')) cv.check_type('suffix', suffix, basestring) if geometry: cv.check_type('geometry', geometry, openmoc.Geometry) # Create a h5py file handle for the file import h5py filename = os.path.join(directory, filename) f = h5py.File(filename, 'r') # Check that the file has an 'energy groups' attribute if '# groups' not in f.attrs: py_printf( 'ERROR', 'Unable to load HDF5 file "%s" since it does ' 'not contain an \'# groups\' attribute', filename) if domain_type not in f.keys(): py_printf( 'ERROR', 'Unable to load HDF5 file "%s" since it does ' 'not contain domain type "%s"', filename, domain_type) # Instantiate dictionary to hold Materials to return to user materials = {} old_materials = {} num_groups = int(f.attrs['# groups']) # If a Geometry was passed in, extract all cells or materials from it if geometry: if domain_type == 'material': domains = geometry.getAllMaterials() elif domain_type == 'cell': domains = geometry.getAllMaterialCells() else: py_printf('ERROR', 'Domain type "%s" is not supported', domain_type) # Iterate over all domains (e.g., materials or cells) in the HDF5 file for domain_spec in sorted(f[domain_type]): py_printf('INFO', 'Importing cross sections for %s "%s"', domain_type, str(domain_spec)) # Create shortcut to HDF5 group for this domain domain_group = f[domain_type][domain_spec] # If domain_spec is an integer, it is an ID; otherwise a string name if domain_spec.isdigit(): domain_spec = int(domain_spec) else: domain_spec = str(domain_spec) # If using an OpenMOC Geometry, extract a Material from it if geometry: if domain_type == 'material': material = _get_domain(domains, domain_spec) elif domain_type == 'cell': cell = _get_domain(domains, domain_spec) material = cell.getFillMaterial() # If the user filled multiple Cells with the same Material, # the Material must be cloned for each unique Cell if material != None: if len(domains) > geometry.getNumMaterials(): old_materials[material.getId()] = material material = material.clone() # If the Cell does not contain a Material, create one for it else: if isinstance(domain_spec, int): material = openmoc.Material(id=domain_spec) else: # Reproducibly hash the domain name into an integer ID domain_id = hashlib.md5(domain_spec.encode('utf-8')) domain_id = int(domain_id.hexdigest()[:4], 16) material = \ openmoc.Material(id=domain_id, name=domain_spec) # Fill the Cell with the new Material cell.setFill(material) # If not Geometry, instantiate a new Material with the ID/name else: if isinstance(domain_spec, int): material = openmoc.Material(id=domain_spec) else: # Reproducibly hash the domain name into an integer ID domain_id = hashlib.md5(domain_spec.encode('utf-8')) domain_id = int(domain_id.hexdigest()[:4], 16) material = openmoc.Material(id=domain_id, name=domain_spec) # Add material to the collection materials[domain_spec] = material material.setNumEnergyGroups(num_groups) # Search for the total/transport cross section if 'transport' in domain_group: sigma = _get_numpy_array(domain_group, 'transport', suffix) material.setSigmaT(sigma) py_printf('DEBUG', 'Loaded "transport" MGXS for "%s %s"', domain_type, str(domain_spec)) elif 'total' in domain_group: sigma = _get_numpy_array(domain_group, 'total', suffix) material.setSigmaT(sigma) py_printf('DEBUG', 'Loaded "total" MGXS for "%s %s"', domain_type, str(domain_spec)) else: py_printf('WARNING', 'No "total" or "transport" MGXS found for' '"%s %s"', domain_type, str(domain_spec)) # Search for the fission production cross section if 'nu-fission' in domain_group: sigma = _get_numpy_array(domain_group, 'nu-fission', suffix) material.setNuSigmaF(sigma) py_printf('DEBUG', 'Loaded "nu-fission" MGXS for "%s %s"', domain_type, str(domain_spec)) else: py_printf('WARNING', 'No "nu-fission" MGXS found for' '"%s %s"', domain_type, str(domain_spec)) # Search for the scattering matrix cross section if 'consistent nu-scatter matrix' in domain_group: sigma = _get_numpy_array(domain_group, 'consistent nu-scatter matrix', suffix) material.setSigmaS(sigma) py_printf( 'DEBUG', 'Loaded "consistent nu-scatter matrix" MGXS for "%s %s"', domain_type, str(domain_spec)) elif 'nu-scatter matrix' in domain_group: sigma = _get_numpy_array(domain_group, 'nu-scatter matrix', suffix) material.setSigmaS(sigma) py_printf('DEBUG', 'Loaded "nu-scatter matrix" MGXS for "%s %s"', domain_type, str(domain_spec)) elif 'consistent scatter matrix' in domain_group: sigma = _get_numpy_array(domain_group, 'consistent scatter matrix', suffix) material.setSigmaS(sigma) py_printf('DEBUG', 'Loaded "consistent scatter matrix" MGXS for "%s %s"', domain_type, str(domain_spec)) elif 'scatter matrix' in domain_group: sigma = _get_numpy_array(domain_group, 'scatter matrix', suffix) material.setSigmaS(sigma) py_printf('DEBUG', 'Loaded "scatter matrix" MGXS for "%s %s"', domain_type, str(domain_spec)) else: py_printf('WARNING', 'No "scatter matrix" found for "%s %s"', domain_type, str(domain_spec)) # Search for chi (fission spectrum) if 'chi' in domain_group: chi = _get_numpy_array(domain_group, 'chi', suffix) material.setChi(chi) py_printf('DEBUG', 'Loaded "chi" MGXS for "%s %s"', domain_type, str(domain_spec)) else: py_printf('WARNING', 'No "chi" MGXS found for "%s %s"', domain_type, str(domain_spec)) # Search for optional cross sections if 'fission' in domain_group: sigma = _get_numpy_array(domain_group, 'fission', suffix) material.setSigmaF(sigma) py_printf('DEBUG', 'Loaded "fission" MGXS for "%s %s"', domain_type, str(domain_spec)) # Inform SWIG to garbage collect any old Materials from the Geometry for material_id in old_materials: old_materials[material_id].thisown = False # Return collection of materials return materials
def load_openmc_mgxs_lib(mgxs_lib, geometry=None): """This routine loads an OpenMC Library of multi-group cross section data. The routine instantiates materials with multi-group cross section data and returns a dictionary of each material keyed by its ID. An OpenMOC geometry may optionally be given and the routine will directly insert the multi-group cross sections into each material in the geometry. If a geometry is passed in, materials from the geometry will be used in place of those instantiated by this routine. Parameters ---------- mgxs_lib : openmc.mgxs.Library An OpenMC multi-group cross section library library geometry : openmoc.Geometry, optional An optional geometry populated with materials, cells, etc. Returns ------- materials : dict A dictionary of Materials keyed by ID """ # Attempt to import openmc try: import openmc except ImportError: py_printf('ERROR', 'The OpenMC code must be installed on your system') cv.check_type('mgxs_lib', mgxs_lib, openmc.mgxs.Library) if geometry: cv.check_type('geometry', geometry, openmoc.Geometry) # Instantiate dictionary to hold Materials to return to user materials = {} old_materials = {} num_groups = mgxs_lib.num_groups domain_type = mgxs_lib.domain_type # If a Geometry was passed in, extract all cells or materials from it if geometry: if domain_type == 'material': domains = geometry.getAllMaterials() elif domain_type == 'cell': domains = geometry.getAllMaterialCells() else: py_printf( 'ERROR', 'Unable to load a cross sections library with ' 'domain type %s', mgxs_lib.domain_type) # Iterate over all domains (e.g., materials or cells) in the HDF5 file for domain in mgxs_lib.domains: # If using an OpenMOC Geometry, extract a Material from it if geometry: if domain_type == 'material': material = _get_domain(domains, domain.id) # Ignore materials which cannot be found in the OpenMOC Geometry if material is None: domain_name = domain.name.replace('%', '%%') py_printf('WARNING', 'Ignoring cross sections for %s "%d" "%s"', domain_type, domain.id, str(domain_name)) continue elif domain_type == 'cell': cell = _get_domain(domains, domain.id) # Ignore cells which cannot be found in the OpenMOC Geometry if cell is None: domain_name = domain.name.replace('%', '%%') py_printf('WARNING', 'Ignoring cross sections for %s "%d" "%s"', domain_type, domain.id, str(domain_name)) continue else: material = cell.getFillMaterial() # If the user filled multiple Cells with the same Material, # the Material must be cloned for each unique Cell if material != None: if len(domains) > geometry.getNumMaterials(): old_materials[material.getId()] = material material = material.clone() # If the Cell does not contain a Material, create one for it else: material = openmoc.Material(id=domain.id) # Fill the Cell with the new Material cell.setFill(material) # If not Geometry, instantiate a new Material with the ID/name else: material = openmoc.Material(id=domain.id) domain_name = domain.name.replace('%', '%%') py_printf('INFO', 'Importing cross sections for %s "%d" "%s"', domain_type, domain.id, str(domain_name)) # Add material to the collection materials[domain.id] = material material.setNumEnergyGroups(num_groups) # Search for the total/transport cross section if 'transport' in mgxs_lib.mgxs_types: mgxs = mgxs_lib.get_mgxs(domain, 'transport') sigma = mgxs.get_xs(nuclides='sum') material.setSigmaT(sigma) py_printf('DEBUG', 'Loaded "transport" MGXS for "%s %d"', domain_type, domain.id) elif 'nu-transport' in mgxs_lib.mgxs_types: mgxs = mgxs_lib.get_mgxs(domain, 'nu-transport') sigma = mgxs.get_xs(nuclides='sum') material.setSigmaT(sigma) py_printf('DEBUG', 'Loaded "nu-transport" MGXS for "%s %d"', domain_type, domain.id) elif 'total' in mgxs_lib.mgxs_types: mgxs = mgxs_lib.get_mgxs(domain, 'total') sigma = mgxs.get_xs(nuclides='sum') material.setSigmaT(sigma) py_printf('DEBUG', 'Loaded "total" MGXS for "%s %d"', domain_type, domain.id) else: py_printf('WARNING', 'No "total" or "transport" MGXS found for' '"%s %d"', domain_type, domain.id) # Search for the fission production cross section if 'nu-fission' in mgxs_lib.mgxs_types: mgxs = mgxs_lib.get_mgxs(domain, 'nu-fission') sigma = mgxs.get_xs(nuclides='sum') material.setNuSigmaF(sigma) py_printf('DEBUG', 'Loaded "nu-fission" MGXS for "%s %d"', domain_type, domain.id) else: py_printf('WARNING', 'No "nu-fission" MGXS found for' '"%s %d"', domain_type, domain.id) # Search for the scattering matrix cross section if 'consistent nu-scatter matrix' in mgxs_lib.mgxs_types: mgxs = mgxs_lib.get_mgxs(domain, 'consistent nu-scatter matrix') sigma = mgxs.get_xs(nuclides='sum').flatten() material.setSigmaS(sigma) py_printf( 'DEBUG', 'Loaded "consistent nu-scatter matrix" MGXS for "%s %d"', domain_type, domain.id) elif 'nu-scatter matrix' in mgxs_lib.mgxs_types: mgxs = mgxs_lib.get_mgxs(domain, 'nu-scatter matrix') sigma = mgxs.get_xs(nuclides='sum').flatten() material.setSigmaS(sigma) py_printf('DEBUG', 'Loaded "nu-scatter matrix" MGXS for "%s %d"', domain_type, domain.id) elif 'consistent scatter matrix' in mgxs_lib.mgxs_types: mgxs = mgxs_lib.get_mgxs(domain, 'consistent scatter matrix') sigma = mgxs.get_xs(nuclides='sum').flatten() material.setSigmaS(sigma) py_printf('DEBUG', 'Loaded "consistent scatter matrix" MGXS for "%s %d"', domain_type, domain.id) elif 'scatter matrix' in mgxs_lib.mgxs_types: mgxs = mgxs_lib.get_mgxs(domain, 'scatter matrix') sigma = mgxs.get_xs(nuclides='sum').flatten() material.setSigmaS(sigma) py_printf('DEBUG', 'Loaded "scatter matrix" MGXS for "%s %d"', domain_type, domain.id) else: py_printf( 'WARNING', 'No "scatter matrix" or "nu-scatter matrix" ' 'found for "%s %d"', domain_type, domain.id) # Search for chi (fission spectrum) if 'chi' in mgxs_lib.mgxs_types: mgxs = mgxs_lib.get_mgxs(domain, 'chi') chi = mgxs.get_xs(nuclides='sum') material.setChi(chi) py_printf('DEBUG', 'Loaded "chi" MGXS for "%s %d"', domain_type, domain.id) else: py_printf('WARNING', 'No "chi" MGXS found for "%s %d"', domain_type, domain.id) # Search for optional cross sections if 'fission' in mgxs_lib.mgxs_types: mgxs = mgxs_lib.get_mgxs(domain, 'fission') sigma = mgxs.get_xs(nuclides='sum') material.setSigmaF(sigma) py_printf('DEBUG', 'Loaded "fission" MGXS for "%s %d"', domain_type, domain.id) # Inform SWIG to garbage collect any old Materials from the Geometry for material_id in old_materials: old_materials[material_id].thisown = False # Return collection of materials return materials
def test_clone(self): self.cell.setFill(openmoc.Material()) clone = self.lattice.clone() self.assertEqual( self.lattice.getUniverse(0, 0, 0).getName(), "Universe 2")
# Main Simulation Parameters ############################################################################### opts = openmoc.options.Options() openmoc.log.set_log_level('NORMAL') openmoc.log.py_printf('TITLE', 'Simulating HW3 from Fall 2010 22.212...') ############################################################################### # Creating Materials ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating materials...') fuel = openmoc.Material(name='fuel') moderator = openmoc.Material(name='moderator') fuel.setNumEnergyGroups(1) moderator.setNumEnergyGroups(1) fuel.setSigmaT(numpy.array([0.452648699])) fuel.setSigmaF(numpy.array([0.0414198575])) fuel.setNuSigmaF(numpy.array([0.0994076580])) fuel.setSigmaS(numpy.array([0.38259177])) fuel.setChi(numpy.array([1.0])) moderator.setSigmaT(numpy.array([0.841545641])) moderator.setSigmaF(numpy.array([0.0])) moderator.setNuSigmaF(numpy.array([0.0])) moderator.setSigmaS(numpy.array([0.837794542]))
def test_clone(self): self.cell.setFill(openmoc.Material()) clone = self.universe.clone() self.assertEqual( self.universe.getCell(self.cell.getId()).getName(), "test cell")
import openmoc ############################################################################### ####################### Main Simulation Parameters ######################## ############################################################################### length = 10.0 num_cells_x = 100 num_cells_y = 1 ############################################################################### ####################### Define Material Properties ######################## ############################################################################### basic_material = openmoc.Material(name='1-group infinite medium') basic_material.setNumEnergyGroups(1) basic_material.setSigmaF([0.0414198575]) basic_material.setNuSigmaF([0.0994076580]) basic_material.setSigmaS([0.383259177]) basic_material.setChi([1.0]) basic_material.setSigmaT([0.452648699]) ############################################################################# ########################## Creating Surfaces ############################ ############################################################################# left = openmoc.XPlane(x=-length / 2, name='left') right = openmoc.XPlane(x=length / 2, name='right') top = openmoc.YPlane(y=length / 2, name='top') bottom = openmoc.YPlane(y=-length / 2, name='bottom')