def initialize(self, settings): """ Initializes the geometry. After geometry, volume, and materials are set, this function completes the geometry. Parameters ---------- settings : openmc_wrapper.Settings Settings to initialize with. """ import copy # Clear out OpenMC openmc.reset_auto_material_id() openmc.reset_auto_surface_id() openmc.reset_auto_cell_id() openmc.reset_auto_universe_id() self.number_density = OrderedDict() self.mat_name = OrderedDict() self.burn_cell_to_ind = OrderedDict() self.burn_list = [] self.fet_order = settings.fet_order cell_ind = 0 # First, for each cell, create an entry in number_density cells = self.geometry.root_universe.get_all_cells() #print(cells) for cid in cells: cell = cells[cid] name = cell.name self.mat_name[cid] = name # Create entry in self.number_density using initial_density self.number_density[cid] = \ copy.deepcopy(self.materials.initial_density[name]) # print('testing...',cid) # Fill with a material (linked to cell id) cell.fill = self.density_dictionary_to_openmc_mat(cid) # If should burn, add to burn list: if self.materials.burn[name]: self.burn_list.append(cid) self.burn_cell_to_ind[str(cid)] = cell_ind cell_ind += 1 # Then, write geometry.xml self.geometry.export_to_xml() # Load participating nuclides self.load_participating(settings.cross_sections) # Create reaction rate tables self.reaction_rates = \ reaction_rates.ReactionRates(self.burn_cell_to_ind, self.burn_nuc_to_ind, self.chain.react_to_ind, self.fet_order) # Finally, calculate total number densities self.total_number = OrderedDict() self.calculate_total_number()
def generate_materials_xml(self): """ Creates materials.xml from self.number_density. Iterates through each cell in self.number_density and creates the openmc material object to generate materials.xml. """ openmc.reset_auto_material_id() mat = [] i = 0 for key_mat in self.number_density: mat.append(openmc.Material(material_id=key_mat)) mat_name = self.mat_name[key_mat] total = 0.0 for key_nuc in self.number_density[key_mat]: # Check if in participating nuclides if key_nuc in self.participating_nuclides: nuc = openmc.Nuclide(key_nuc, xs=self.materials.library[mat_name]) if type(self.number_density[key_mat][key_nuc]) is zernike.ZernikePolynomial: nuc.poly_coeffs = self.number_density[key_mat][key_nuc].openmc_form(radial_only=False) self.total_number[key_mat][key_nuc] = self.number_density[key_mat][key_nuc] * self.volume[key_mat] nuc.poly_type = "zernike" mat[i].add_nuclide(nuc, self.number_density[key_mat][key_nuc].coeffs[0]) total += self.number_density[key_mat][key_nuc].coeffs[0] else: mat[i].add_nuclide(nuc, self.number_density[key_mat][key_nuc]) total += self.number_density[key_mat][key_nuc] mat[i].set_density('atom/cm3', total) if mat_name in self.materials.sab: mat[i].add_s_alpha_beta(self.materials.sab[mat_name], self.materials.library_sab[mat_name]) i += 1 materials_file = openmc.Materials() materials_file.add_materials(mat) materials_file.export_to_xml()
def reset_auto_ids(): openmc.reset_auto_material_id() openmc.reset_auto_surface_id() openmc.reset_auto_cell_id() openmc.reset_auto_universe_id()
def reset_auto_ids(): """Reset counters for all auto-generated IDs""" openmc.reset_auto_material_id() openmc.reset_auto_surface_id() openmc.reset_auto_cell_id() openmc.reset_auto_universe_id()