def _build_inputs(self): filt1 = openmc.Filter(type='mu', bins=(-1.0, -0.5, 0.0, 0.5, 1.0)) tally1 = openmc.Tally(tally_id=1) tally1.add_filter(filt1) tally1.add_score('scatter') tally1.add_score('nu-scatter') filt2 = openmc.Filter(type='mu', bins=(5, )) tally2 = openmc.Tally(tally_id=2) tally2.add_filter(filt2) tally2.add_score('scatter') tally2.add_score('nu-scatter') mesh = openmc.Mesh(mesh_id=1) mesh.lower_left = [-182.07, -182.07] mesh.upper_right = [182.07, 182.07] mesh.dimension = [2, 2] filt_mesh = openmc.Filter(type='mesh', bins=(1, )) tally3 = openmc.Tally(tally_id=3) tally3.add_filter(filt2) tally3.add_filter(filt_mesh) tally3.add_score('scatter') tally3.add_score('nu-scatter') self._input_set.tallies = openmc.TalliesFile() self._input_set.tallies.add_tally(tally1) self._input_set.tallies.add_tally(tally2) self._input_set.tallies.add_tally(tally3) self._input_set.tallies.add_mesh(mesh) super(FilterMuTestHarness, self)._build_inputs()
def inf_medium_model(cutoff_energy, source_energy): """Infinite medium problem with a monoenergetic photon source""" model = openmc.Model() m = openmc.Material() m.add_nuclide('Zr90', 1.0) m.set_density('g/cm3', 1.0) sph = openmc.Sphere(r=100.0, boundary_type='reflective') cell = openmc.Cell(fill=m, region=-sph) model.geometry = openmc.Geometry([cell]) model.settings.run_mode = 'fixed source' model.settings.source = openmc.Source( particle='photon', energy=openmc.stats.Discrete([source_energy], [1.0]), ) model.settings.particles = 100 model.settings.batches = 10 model.settings.cutoff = {'energy_photon': cutoff_energy} tally_flux = openmc.Tally(name='flux') tally_flux.filters = [ openmc.EnergyFilter([0.0, cutoff_energy, source_energy]), openmc.ParticleFilter(['photon']) ] tally_flux.scores = ['flux'] tally_heating = openmc.Tally(name='heating') tally_heating.scores = ['heating'] model.tallies = openmc.Tallies([tally_flux, tally_heating]) return model
def _build_inputs(self): # Instantiate a tally mesh mesh = openmc.Mesh(mesh_id=1) mesh.type = 'regular' mesh.dimension = [17, 17, 1] mesh.lower_left = [0.0, 0.0, 0.0] mesh.upper_right = [21.42, 21.42, 100.0] # Instantiate some tally filters energy_filter = openmc.Filter(type='energy', bins=[0.0, 20.0]) energyout_filter = openmc.Filter(type='energyout', bins=[0.0, 20.0]) mesh_filter = openmc.Filter() mesh_filter.mesh = mesh mat_filter = openmc.Filter(type='material', bins=[1, 2, 3]) tally1 = openmc.Tally(tally_id=1) tally1.filters = [mesh_filter] tally1.scores = [ 'total', 'absorption', 'flux', 'fission', 'nu-fission' ] tally2 = openmc.Tally(tally_id=2) tally2.filters = [mat_filter, energy_filter, energyout_filter] tally2.scores = ['scatter', 'nu-scatter'] self._input_set.tallies = openmc.Tallies([tally1, tally2]) super(MGTalliesTestHarness, self)._build_inputs()
def __init__(self, *args, **kwargs): super(FilterEnergyFunHarness, self).__init__(*args, **kwargs) # Add Am241 to the fuel. self._model.materials[1].add_nuclide('Am241', 1e-7) # Define Am242m / Am242 branching ratio from ENDF/B-VII.1 data. x = [1e-5, 3.69e-1, 1e3, 1e5, 6e5, 1e6, 2e6, 4e6, 3e7] y = [0.1, 0.1, 0.1333, 0.158, 0.18467, 0.25618, 0.4297, 0.48, 0.48] # Make an EnergyFunctionFilter directly from the x and y lists. filt1 = openmc.EnergyFunctionFilter(x, y) # Also make a filter with the .from_tabulated1d constructor. Make sure # the filters are identical. tab1d = openmc.data.Tabulated1D(x, y) filt2 = openmc.EnergyFunctionFilter.from_tabulated1d(tab1d) assert filt1 == filt2, 'Error with the .from_tabulated1d constructor' # Make tallies. tallies = [openmc.Tally(1), openmc.Tally(2)] for t in tallies: t.scores = ['(n,gamma)'] t.nuclides = ['Am241'] tallies[1].filters = [filt1] self._model.tallies = tallies
def __init__(self, *args, **kwargs): super(TallyArithmeticTestHarness, self).__init__(*args, **kwargs) # Initialize Mesh mesh = openmc.Mesh(mesh_id=1) mesh.type = 'regular' mesh.dimension = [2, 2, 2] mesh.lower_left = [-160.0, -160.0, -183.0] mesh.upper_right = [160.0, 160.0, 183.0] # Initialize the filters energy_filter = openmc.EnergyFilter((0.0, 0.253e-6, 1.0e-3, 1.0, 20.0)) material_filter = openmc.MaterialFilter((1, 3)) distrib_filter = openmc.DistribcellFilter(60) mesh_filter = openmc.MeshFilter(mesh) # Initialized the tallies tally = openmc.Tally(name='tally 1') tally.filters = [material_filter, energy_filter, distrib_filter] tally.scores = ['nu-fission', 'total'] tally.nuclides = ['U234', 'U235'] self._model.tallies.append(tally) tally = openmc.Tally(name='tally 2') tally.filters = [energy_filter, mesh_filter] tally.scores = ['total', 'fission'] tally.nuclides = ['U238', 'U235'] self._model.tallies.append(tally)
def pincell_model(): """Set up a model to test with and delete files when done""" openmc.reset_auto_ids() pincell = openmc.examples.pwr_pin_cell() pincell.settings.verbosity = 1 # Add a tally filter1 = openmc.MaterialFilter(pincell.materials) filter2 = openmc.EnergyFilter([0.0, 1.0, 1.0e3, 20.0e6]) mat_tally = openmc.Tally() mat_tally.filters = [filter1, filter2] mat_tally.nuclides = ['U235', 'U238'] mat_tally.scores = ['total', 'elastic', '(n,gamma)'] pincell.tallies.append(mat_tally) # Add an expansion tally zernike_tally = openmc.Tally() filter3 = openmc.ZernikeFilter(5, r=.63) cells = pincell.geometry.root_universe.cells filter4 = openmc.CellFilter(list(cells.values())) zernike_tally.filters = [filter3, filter4] zernike_tally.scores = ['fission'] pincell.tallies.append(zernike_tally) # Add an energy function tally energyfunc_tally = openmc.Tally() energyfunc_filter = openmc.EnergyFunctionFilter([0.0, 20e6], [0.0, 20e6]) energyfunc_tally.scores = ['fission'] energyfunc_tally.filters = [energyfunc_filter] pincell.tallies.append(energyfunc_tally) # Write XML files in tmpdir with cdtemp(): pincell.export_to_xml() yield
def model(): model = openmc.model.Model() # Materials m1 = openmc.Material() m1.set_density('g/cc', 4.5) m1.add_nuclide('U235', 1.0) m2 = openmc.Material() m2.set_density('g/cc', 1.0) m2.add_nuclide('H1', 1.0) model.materials += [m1, m2] # Geometry cyl1 = openmc.ZCylinder(r=0.7) c1 = openmc.Cell(fill=m1, region=-cyl1) c2 = openmc.Cell(fill=m2, region=+cyl1) # intermediate universe containing only cell 2 u1 = openmc.Universe(cells=[c2]) c3 = openmc.Cell(fill=u1) u2 = openmc.Universe(cells=[c1, c3]) cyl2 = openmc.ZCylinder(r=0.5) c4 = openmc.Cell(fill=m1, region=-cyl2) c5 = openmc.Cell(fill=m2, region=+cyl2) u3 = openmc.Universe(cells=[c4, c5]) lat = openmc.RectLattice() lat.lower_left = (-4, -4) lat.pitch = (2, 2) lat.universes = [[u2, u3, u3, u3], [u3, u2, u3, u3], [u3, u3, u2, u3], [u3, u3, u3, u2]] box = openmc.model.rectangular_prism(8.0, 8.0, boundary_type='reflective') main_cell = openmc.Cell(fill=lat, region=box) model.geometry.root_universe = openmc.Universe(cells=[main_cell]) model.geometry.determine_paths() # Settings model.settings.batches = 5 model.settings.inactive = 0 model.settings.particles = 1000 model.settings.source = openmc.Source(space=openmc.stats.Point()) instances = ([(c4, i) for i in range(c4.num_instances)] + [(c2, i) for i in range(c2.num_instances)] + [(c3, i) for i in range(c3.num_instances)]) f1 = openmc.CellInstanceFilter(instances) f2 = openmc.CellInstanceFilter(instances[::-1]) t1 = openmc.Tally() t1.filters = [f1] t1.scores = ['total'] t2 = openmc.Tally() t2.filters = [f2] t2.scores = ['total'] model.tallies += [t1, t2] return model
def _build_inputs(self): filt = openmc.Filter(type='cell', bins=(21, )) t1 = openmc.Tally(tally_id=1) t1.add_filter(filt) t1.add_score('scatter-0') t1.estimator = 'analog' t2 = openmc.Tally(tally_id=2) t2.add_filter(filt) t2.add_score('scatter-y4') self._input_set.tallies = openmc.TalliesFile() self._input_set.tallies.add_tally(t1) self._input_set.tallies.add_tally(t2) super(ScoreScatterYNTestHarness, self)._build_inputs()
def write_saltproc_openmc_tallies(self, materials, geometry): """ Write tallies for calculating burnup and delayed neutron parameters. Parameters ---------- materials : `openmc.Materials` object The materials for the depletion simulation geometry : `openmc.Geometry` object The geometry for the depletion simulation """ tallies = openmc.Tallies() tally = openmc.Tally(name='delayed-fission-neutrons') tally.filters = [openmc.DelayedGroupFilter([1, 2, 3, 4, 5, 6])] tally.scores = ['delayed-nu-fission'] tallies.append(tally) tally = openmc.Tally(name='total-fission-neutrons') tally.filters = [openmc.UniverseFilter(geometry.root_universe)] tally.scores = ['nu-fission'] tallies.append(tally) tally = openmc.Tally(name='precursor-decay-constants') tally.filters = [openmc.DelayedGroupFilter([1, 2, 3, 4, 5, 6])] tally.scores = ['decay-rate'] tallies.append(tally) tally = openmc.Tally(name='fission-energy') tally.filters = [openmc.UniverseFilter(geometry.root_universe)] tally.scores = [ 'fission-q-recoverable', 'fission-q-prompt', 'kappa-fission'] tallies.append(tally) tally = openmc.Tally(name='normalization-factor') tally.filters = [openmc.UniverseFilter(geometry.root_universe)] tally.scores = ['heating'] tallies.append(tally) out_path = os.path.dirname(self.iter_inputfile['settings']) self.iter_inputfile['tallies'] = \ os.path.join(out_path, 'tallies.xml') tallies.export_to_xml(self.iter_inputfile['tallies']) del tallies
def model(): """Sphere of single nuclide""" model = openmc.model.Model() w = openmc.Material(name='tungsten') w.add_nuclide('W186', 1.0) w.set_density('g/cm3', 19.3) w.depletable = True r = uniform(1.0, 10.0) w.volume = 4 / 3 * pi * r**3 surf = openmc.Sphere(r=r, boundary_type='vacuum') cell = openmc.Cell(fill=w, region=-surf) model.geometry = openmc.Geometry([cell]) model.settings.batches = 10 model.settings.particles = 1000 model.settings.source = openmc.Source(space=openmc.stats.Point(), energy=openmc.stats.Discrete([1.0e6], [1.0])) model.settings.run_mode = 'fixed source' rx_tally = openmc.Tally() rx_tally.scores = ['(n,gamma)'] model.tallies.append(rx_tally) return model
def model(): model = openmc.model.Model() zn = openmc.Material() zn.set_density('g/cm3', 7.14) zn.add_nuclide('Zn64', 1.0) model.materials.append(zn) radii = np.linspace(1.0, 100.0) surfs = [openmc.Sphere(r=r) for r in radii] surfs[-1].boundary_type = 'vacuum' cells = [ openmc.Cell(fill=(zn if i % 2 == 0 else None), region=region) for i, region in enumerate(openmc.model.subdivide(surfs)) ] model.geometry = openmc.Geometry(cells) model.settings.run_mode = 'fixed source' model.settings.batches = 3 model.settings.particles = 1000 model.settings.source = openmc.Source(space=openmc.stats.Point()) cell_filter = openmc.CellFilter(cells) tally = openmc.Tally() tally.filters = [cell_filter] tally.scores = ['total'] model.tallies.append(tally) return model
def _build_inputs(self): # The summary.h5 file needs to be created to read in the tallies self._input_set.settings.output = {'summary': True} # Initialize the nuclides u235 = openmc.Nuclide('U-235') u238 = openmc.Nuclide('U-238') pu239 = openmc.Nuclide('Pu-239') # Initialize the filters energy_filter = openmc.Filter(type='energy', bins=[0.0, 0.253e-6, 1.0e-3, 1.0, 20.0]) distrib_filter = openmc.Filter(type='distribcell', bins=[60]) # Initialized the tallies tally = openmc.Tally(name='distribcell tally') tally.filters = [energy_filter, distrib_filter] tally.scores = ['nu-fission', 'total'] tally.nuclides = [u235, u238, pu239] tallies_file = openmc.Tallies([tally]) # Export tallies to file self._input_set.tallies = tallies_file super(TallyAggregationTestHarness, self)._build_inputs()
def test_fixed_source(): mat = openmc.Material() mat.add_nuclide('O16', 1.0) mat.add_nuclide('U238', 0.0001) mat.set_density('g/cc', 7.5) surf = openmc.Sphere(r=10.0, boundary_type='vacuum') cell = openmc.Cell(fill=mat, region=-surf) model = openmc.model.Model() model.geometry.root_universe = openmc.Universe(cells=[cell]) model.materials.append(mat) model.settings.run_mode = 'fixed source' model.settings.batches = 10 model.settings.particles = 100 model.settings.temperature = {'default': 294} model.settings.source = openmc.Source(space=openmc.stats.Point(), strength=10.0) tally = openmc.Tally() tally.scores = ['flux'] model.tallies.append(tally) harness = FixedSourceTestHarness('statepoint.10.h5', model) harness.main()
def make_tallies(self, r=None): if not self.tally: return None if self.geom == 'IN': return None # Instantiate a tally mesh mesh = openmc.Mesh(mesh_id=1) mesh.type = 'regular' mesh.dimension = self.mesh_dim if self.geom == 'SL' or self.geom == 'ISLC': mesh.lower_left = [-r, -INF, -INF] mesh.upper_right = [r, INF, INF] # Instantiate some tally Filters energy_filter = openmc.EnergyFilter( GROUP_STRUCT[self.groups].group_edges) mesh_filter = openmc.MeshFilter(mesh) # Instantiate the Tally tally = openmc.Tally(tally_id=1, name='tally 1') tally.filters = [energy_filter, mesh_filter] tally.scores = ['flux', 'fission', 'nu-fission'] # Instantiate a Tallies collection, register all Tallies tallies_file = openmc.Tallies([tally]) return tallies_file
def _build_inputs(self): model = openmc.model.Model() # settings model.settings.batches = 5 model.settings.inactive = 0 model.settings.particles = 100 source = openmc.Source(space=Box([-4, -4, -4], [4, 4, 4])) model.settings.source = source model.settings.dagmc = True model.settings.export_to_xml() # geometry dag_univ = openmc.DAGMCUniverse("dagmc.h5m", auto_geom_ids=True) model.geometry = openmc.Geometry(dag_univ) # tally tally = openmc.Tally() tally.scores = ['total'] tally.filters = [openmc.CellFilter(2)] model.tallies = [tally] model.tallies.export_to_xml() model.export_to_xml()
def pincell_model(): """Set up a model to test with and delete files when done""" pincell = openmc.examples.pwr_pin_cell() # Add a tally filter1 = openmc.MaterialFilter(pincell.materials) filter2 = openmc.EnergyFilter([0.0, 1.0, 1.0e3, 20.0e6]) mat_tally = openmc.Tally() mat_tally.filters = [filter1, filter2] mat_tally.nuclides = ['U235', 'U238'] mat_tally.scores = ['total', 'elastic', '(n,gamma)'] pincell.tallies.append(mat_tally) # Write XML files pincell.export_to_xml() yield # Delete generated files files = [ 'geometry.xml', 'materials.xml', 'settings.xml', 'tallies.xml', 'statepoint.10.h5', 'summary.h5', 'test_sp.h5' ] for f in files: if os.path.exists(f): os.remove(f)
def get_flux_tally(self, bucell): flux = openmc.Tally(name='{} flux'.format(bucell.name)) flux.filters = [openmc.CellFilter(bucell.id)] flux.filters.append(self.energy_bin) flux.scores = ['flux'] return flux
def get_flux_spectrum_tally(self, bucell): flux_spectrum = openmc.Tally(name='{} flux spectrum'.format(bucell.name)) flux_spectrum.filters = [openmc.CellFilter(bucell.id)] flux_spectrum.filters.append(self.mg_energy_bin) flux_spectrum.scores = ['flux'] return flux_spectrum
def make_model(): model = openmc.model.Model() # Materials moderator = openmc.Material(material_id=1) moderator.set_density('g/cc', 1.0) moderator.add_nuclide('H1', 2.0) moderator.add_nuclide('O16', 1.0) moderator.add_s_alpha_beta('c_H_in_H2O') dense_fuel = openmc.Material(material_id=2) dense_fuel.set_density('g/cc', 4.5) dense_fuel.add_nuclide('U235', 1.0) model.materials += [moderator, dense_fuel] # Geometry c1 = openmc.Cell(cell_id=1, fill=moderator) mod_univ = openmc.Universe(universe_id=1, cells=(c1, )) r0 = openmc.ZCylinder(R=0.3) c11 = openmc.Cell(cell_id=11, fill=dense_fuel, region=-r0) c11.temperature = [500, 0, 700, 800] c12 = openmc.Cell(cell_id=12, fill=moderator, region=+r0) fuel_univ = openmc.Universe(universe_id=11, cells=(c11, c12)) lat = openmc.RectLattice(lattice_id=101) lat.dimension = [2, 2] lat.lower_left = [-2.0, -2.0] lat.pitch = [2.0, 2.0] lat.universes = [[fuel_univ] * 2] * 2 lat.outer = mod_univ x0 = openmc.XPlane(x0=-3.0) x1 = openmc.XPlane(x0=3.0) y0 = openmc.YPlane(y0=-3.0) y1 = openmc.YPlane(y0=3.0) for s in [x0, x1, y0, y1]: s.boundary_type = 'reflective' c101 = openmc.Cell(cell_id=101, fill=lat, region=+x0 & -x1 & +y0 & -y1) model.geometry.root_universe = openmc.Universe(universe_id=0, cells=(c101, )) # Settings model.settings.batches = 5 model.settings.inactive = 0 model.settings.particles = 1000 model.settings.source = openmc.Source( space=openmc.stats.Box([-1, -1, -1], [1, 1, 1])) model.settings.temperature = {'tolerance': 1000, 'multipole': True} # Tallies tally = openmc.Tally() tally.nuclides = ['U235', 'O16', 'total'] tally.scores = ['total', 'fission', '(n,gamma)', 'elastic', '(n,p)'] model.tallies.append(tally) return model
def model(): model = openmc.model.Model() fuel = openmc.Material() fuel.set_density('g/cm3', 10.0) fuel.add_nuclide('U234', 1.0) fuel.add_nuclide('U235', 4.0) fuel.add_nuclide('U238', 95.0) water = openmc.Material(name='light water') water.add_nuclide('H1', 2.0) water.add_nuclide('O16', 1.0) water.set_density('g/cm3', 1.0) water.add_s_alpha_beta('c_H_in_H2O') model.materials.extend([fuel, water]) cyl1 = openmc.ZCylinder(r=5.0) cyl2 = openmc.ZCylinder(r=10.0, boundary_type='vacuum') cell1 = openmc.Cell(fill=fuel, region=-cyl1) cell2 = openmc.Cell(fill=water, region=+cyl1 & -cyl2) model.geometry = openmc.Geometry([cell1, cell2]) model.settings.batches = 5 model.settings.inactive = 0 model.settings.particles = 1000 mesh = openmc.RegularMesh() mesh.dimension = (2, 2) mesh.lower_left = (-10.0, -10.0) mesh.upper_right = (10.0, 10.0) energy_filter = openmc.EnergyFilter((0.0, 10.0, 20.0e6)) material_filter = openmc.MaterialFilter((fuel, water)) mesh_filter = openmc.MeshFilter(mesh) tally = openmc.Tally(name='tally 1') tally.filters = [material_filter, energy_filter] tally.scores = ['nu-fission', 'total'] tally.nuclides = ['U234', 'U235'] model.tallies.append(tally) tally = openmc.Tally(name='tally 2') tally.filters = [energy_filter, mesh_filter] tally.scores = ['total', 'fission'] tally.nuclides = ['U238', 'U235'] model.tallies.append(tally) return model
def _build_inputs(self): filt = openmc.Filter(type='cell', bins=(21, )) t1 = openmc.Tally(tally_id=1) t1.add_filter(filt) t1.add_score('nu-scatter-0') t2 = openmc.Tally(tally_id=2) t2.add_filter(filt) t2.add_score('nu-scatter-y3') self._input_set.tallies = openmc.TalliesFile() self._input_set.tallies.add_tally(t1) self._input_set.tallies.add_tally(t2) self._input_set.build_default_materials_and_geometry() self._input_set.build_default_settings() self._input_set.settings.inactive = 0 self._input_set.export()
def _build_inputs(self): filt = openmc.Filter(type='cellborn', bins=(10, 21, 22, 23)) tally = openmc.Tally(tally_id=1) tally.add_filter(filt) tally.add_score('total') self._input_set.tallies = openmc.TalliesFile() self._input_set.tallies.add_tally(tally) super(FilterCellbornTestHarness, self)._build_inputs()
def _make_openmc_input(self): """Generate the OpenMC input XML """ # Define material mat = openmc.Material() mat.add_nuclide(self.nuclide, 1.0) if self.thermal is not None: name, suffix = self.thermal.split('.') thermal_name = openmc.data.thermal.get_thermal_name(name) mat.add_s_alpha_beta(thermal_name) mat.set_density('g/cm3', self.density) materials = openmc.Materials([mat]) if self.xsdir is not None: xs_path = (self.openmc_dir / 'cross_sections.xml').resolve() materials.cross_sections = str(xs_path) materials.export_to_xml(self.openmc_dir / 'materials.xml') # Set up geometry x1 = openmc.XPlane(x0=-1.e9, boundary_type='reflective') x2 = openmc.XPlane(x0=+1.e9, boundary_type='reflective') y1 = openmc.YPlane(y0=-1.e9, boundary_type='reflective') y2 = openmc.YPlane(y0=+1.e9, boundary_type='reflective') z1 = openmc.ZPlane(z0=-1.e9, boundary_type='reflective') z2 = openmc.ZPlane(z0=+1.e9, boundary_type='reflective') cell = openmc.Cell(fill=materials) cell.region = +x1 & -x2 & +y1 & -y2 & +z1 & -z2 geometry = openmc.Geometry([cell]) geometry.export_to_xml(self.openmc_dir / 'geometry.xml') # Define source source = openmc.Source() source.space = openmc.stats.Point((0, 0, 0)) source.angle = openmc.stats.Isotropic() source.energy = openmc.stats.Discrete([self.energy], [1.]) # Settings settings = openmc.Settings() if self._temperature is not None: settings.temperature = {'default': self._temperature} settings.source = source settings.particles = self.particles // self._batches settings.run_mode = 'fixed source' settings.batches = self._batches settings.create_fission_neutrons = False settings.export_to_xml(self.openmc_dir / 'settings.xml') # Define tallies energy_bins = np.logspace(np.log10(self._min_energy), np.log10(1.0001 * self.energy), self._bins + 1) energy_filter = openmc.EnergyFilter(energy_bins) tally = openmc.Tally(name='tally') tally.filters = [energy_filter] tally.scores = ['flux'] tallies = openmc.Tallies([tally]) tallies.export_to_xml(self.openmc_dir / 'tallies.xml')
def _build_inputs(self): filt = openmc.Filter(type='delayedgroup', bins=(1, 2, 3, 4, 5, 6)) tally = openmc.Tally(tally_id=1) tally.add_filter(filt) tally.add_score('delayed-nu-fission') self._input_set.tallies = openmc.TalliesFile() self._input_set.tallies.add_tally(tally) super(FilterDelayedgroupTestHarness, self)._build_inputs()
def _build_inputs(self): filt = openmc.Filter(type='universe', bins=(1, 2, 3, 4)) tally = openmc.Tally(tally_id=1) tally.add_filter(filt) tally.add_score('total') self._input_set.tallies = openmc.TalliesFile() self._input_set.tallies.add_tally(tally) super(FilterUniverseTestHarness, self)._build_inputs()
def generate_tally_xml(self, settings): import copy """ Generates tally.xml. Using information from self.depletion_chain as well as the nuclides currently in the problem, this function automatically generates a tally.xml for the simulation. """ chain = self.chain # ---------------------------------------------------------------------- # Create tallies for depleting regions tally_ind = 1 cell_filter_dep = openmc.Filter(type='cell', bins=self.burn_list) tallies_file = openmc.Tallies() nuc_superset = set() for cell in self.burn_list: for key in self.number_density[cell]: # Check if in participating nuclides if key in self.participating_nuclides: nuc_superset.add(key) # For each reaction in the chain, for each nuclide, and for each # cell, make a tally tally_dep = openmc.Tally(tally_id=tally_ind) for key in nuc_superset: if key in chain.nuclide_dict: tally_dep.add_nuclide(key) tally_dep.add_filter(cell_filter_dep) if (settings.fet_order == None): for reaction in chain.react_to_ind: tally_dep.add_score(reaction) tallies_file.add_tally(tally_dep) else: # Add the geomtric norm to tally if we are doing FETs # TODO we need geometry constants in another PYTHON file for easy use tally_dep.add_geom_norm(0.4096) tally_dep.estimator = 'collision' # The current implementation does not allow multiple score pins for FETs # Therefore, we need a unique tally for each reaction fet_tallies = [] for reaction in chain.react_to_ind: fet_tallies.append(copy.deepcopy(tally_dep)) fet_score_name = 'micro-' + reaction + '-z' + str(settings.fet_order) fet_tallies[-1].id = tally_ind fet_tallies[-1].add_score(fet_score_name) tally_ind += 1 [tallies_file.add_tally(t) for t in fet_tallies] tallies_file.export_to_xml()
def _build_inputs(self): # The summary.h5 file needs to be created to read in the tallies self._input_set.settings.output = {'summary': True} # Initialize the tallies file tallies_file = openmc.Tallies() # Initialize the nuclides u235 = openmc.Nuclide('U-235') u238 = openmc.Nuclide('U-238') pu239 = openmc.Nuclide('Pu-239') # Initialize Mesh mesh = openmc.Mesh(mesh_id=1) mesh.type = 'regular' mesh.dimension = [2, 2, 2] mesh.lower_left = [-160.0, -160.0, -183.0] mesh.upper_right = [160.0, 160.0, 183.0] # Initialize the filters energy_filter = openmc.Filter(type='energy', bins=(0.0, 0.253e-6, 1.0e-3, 1.0, 20.0)) material_filter = openmc.Filter(type='material', bins=(1, 3)) distrib_filter = openmc.Filter(type='distribcell', bins=(60)) mesh_filter = openmc.Filter(type='mesh') mesh_filter.mesh = mesh # Initialized the tallies tally = openmc.Tally(name='tally 1') tally.filters = [material_filter, energy_filter, distrib_filter] tally.scores = ['nu-fission', 'total'] tally.nuclides = [u235, pu239] tallies_file.append(tally) tally = openmc.Tally(name='tally 2') tally.filters = [energy_filter, mesh_filter] tally.scores = ['total', 'fission'] tally.nuclides = [u238, u235] tallies_file.append(tally) # Export tallies to file self._input_set.tallies = tallies_file super(TallyArithmeticTestHarness, self)._build_inputs()
def _build_inputs(self): filt = openmc.Filter(type='energyout', bins=(0.0, 0.253e-6, 1.0e-3, 1.0, 20.0)) tally = openmc.Tally(tally_id=1) tally.add_filter(filt) tally.add_score('scatter') self._input_set.tallies = openmc.TalliesFile() self._input_set.tallies.add_tally(tally) super(FilterEnergyoutTestHarness, self)._build_inputs()
def buildTallies(cell_filter): ###################################Tallies####################### #tallies over 2 energy groups with 4 eV being thermal bound energy_filter = openmc.EnergyFilter([0., 4.0, 20.0e6]) t = openmc.Tally(1) t.filters = [cell_filter, energy_filter] # these are the main reaction rates you should need t.scores = ['absorption','nu-fission','fission'] tallies = openmc.Tallies([t]) tallies.export_to_xml()
def generate_tallies(fuelcelllist, total_fuel_cell, porder, flag): tallies_file = openmc.Tallies() cell_filter = openmc.CellFilter(fuelcelllist) total_fuel_cell_filter = openmc.CellFilter([total_fuel_cell]) zmin = -100 zmax = 100 if flag == 1: # choose flag 1, we use tradiational estimators tally3 = openmc.Tally(name='tracklength') tally3.filters.append(cell_filter) tally3.scores = ['nu-fission', 'absorption'] tally3.nuclides = ['U238'] tally3.estimator = 'tracklength' tallies_file.append(tally3) tally3 = openmc.Tally(name='collision') tally3.filters.append(cell_filter) tally3.scores = ['nu-fission', 'absorption'] tally3.nuclides = ['U238'] tally3.estimator = 'collision' tallies_file.append(tally3) # tally3 = openmc.Tally(name='analog') # tally3.filters.append(cell_filter) # tally3.scores = ['flux'] # tally3.nuclides = ['U238'] # tally3.estimator = 'analog' # tallies_file.append(tally3) elif flag == 2: # we tally FET str1 = 'fet' strorder = str(porder) name = str1 + strorder fet_tally = openmc.Tally(name=name) fet_tally.filters.append(total_fuel_cell_filter) fet_tally.scores = ['nu-fission', 'absorption'] fet_tally.nuclides = ['U238'] expand_filter = openmc.SpatialLegendreFilter(porder, 'z', zmin, zmax) fet_tally.filters.append(expand_filter) tallies_file.append(fet_tally) tallies_file.export_to_xml()