Exemple #1
0
    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()
Exemple #2
0
def buildTriangUni(modSetting,pitch,diameter,boron,modT,fuelT,DyFrac,enrich):
    uo2=getU(fuelT,DyFrac,enrich)
    mod=getMod(modSetting,boron,modT) #loads the moderator
    mats = openmc.Materials([uo2, mod])
    mats.export_to_xml()
       
    ####################build the surfaces################################
    fuel_or1 = openmc.ZCylinder(R=diameter/2)
    box = openmc.get_hexagonal_prism(edge_length=pitch/math.sqrt(3.0),boundary_type='reflective')
        
    #################Build the Cells #######################################
    fuel_region = -fuel_or1   #beautiful abuse of operator overloading
    mod_region = box & +fuel_or1
    # c
    # c Fuel 
    # c
    # c throwback to MCNP
    fuel = openmc.Cell(1, 'fuel')
    fuel.fill = uo2
    fuel.region = fuel_region
    #
    # Moderator 
    #
    moderator = openmc.Cell(4, 'moderator')
    moderator.fill = mod
    moderator.region = mod_region
       
    #I am groot!
    groot = openmc.Universe(cells=(fuel, moderator))
    geom = openmc.Geometry(groot)
    geom.export_to_xml()
    cell_filter = openmc.CellFilter([fuel, moderator])
    # tallies
    buildTallies(cell_filter)
    return (fuel,moderator)
Exemple #3
0
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
Exemple #4
0
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
Exemple #5
0
	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
Exemple #6
0
	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
Exemple #7
0
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()
Exemple #8
0
    def update(self, Tf, Tclad, Tbulk, Mesh, RhoBulk):  #T.gap

        # Update temperatures in OpenMC

        self.settings_file.batches = 1100
        self.settings_file.inactive = 100
        self.settings_file.particles = 20000
        self.settings_file.generations_per_batch = 5
        # self.settings_file.seed = np.random.randint(1,100) #for correlation calculation
        self.settings_file.export_to_xml()
        shutil.move('settings.xml', 'PinGeo/settings.xml')

        #START removed for uncoupled correlation
        self.materials_file.export_to_xml()
        shutil.move('materials.xml', 'PinGeo/materials.xml')

        self.reflectTOP.temperature = Tbulk[-1]
        self.reflectBOT.temperature = Tbulk[0]
        j = 0
        for fuels in self.fuel_list:
            fuels.temperature = (Tf[j] + Tf[j + 1]) / 2
            j = j + 1
        # j = 0
        # for gaps in self.gap_list:
        # 	gaps.temperature = (Tgap[j]+Tgap[j])/2.
        # 	j = j+1
        j = 0
        for clads in self.clad_list:
            clads.temperature = (Tclad[j] + Tclad[j + 1]) / 2.
            j = j + 1
        #Update temperature of extraclad_list?
        j = 0
        for waters in self.water_list:
            waters.temperature = (Tbulk[j] + Tbulk[j + 1]) / 2
            j = j + 1

        self.root.add_cells(self.fuel_list)
        # self.root.add_cells(self.gap_list)
        self.root.add_cells(self.clad_list)
        self.root.add_cells(self.water_list)
        self.geometry_file = openmc.Geometry(self.root)
        self.geometry_file.export_to_xml()
        shutil.move('geometry.xml', 'PinGeo/geometry.xml')
        #END removed for uncoupled correlation

        # Tallies
        # power distribution: fission q recoverable (starts 0, might be data pb)
        # openmc accounts for incoming neutron energy and isotope
        cell_filter = openmc.CellFilter(self.fuel_list)
        t = openmc.Tally(tally_id=2)
        t.filters.append(cell_filter)
        t.scores = ['fission-q-recoverable']
        self.tallies = openmc.Tallies([t])
        self.tallies.export_to_xml()
        shutil.move('tallies.xml', 'PinGeo/tallies.xml')
Exemple #9
0
def generate_tallies(fuelcelllist, total_fuel_cell, zerk_order, flag):
    tallies_file = openmc.Tallies()
    cell_filter = openmc.CellFilter(fuelcelllist)
    total_fuel_cell_filter = openmc.CellFilter([total_fuel_cell])

    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 = ['nu-fission', 'absorption']
        tally3.nuclides = ['U238']
        tally3.estimator = 'analog'
        tallies_file.append(tally3)

    elif flag == 2:
        # we tally FET
        str1 = 'fet'
        strorder = str(zerk_order)
        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.ZernikeFilter(zerk_order, x=0.0, y=0.0, r=0.392)
        fet_tally.filters.append(expand_filter)
        tallies_file.append(fet_tally)

    tallies_file.export_to_xml()
Exemple #10
0
def model(request):
    openmc.reset_auto_ids()
    marker = request.node.get_closest_marker("surf_source_op")
    surf_source_op = marker.args[0]

    openmc_model = openmc.model.Model()

    # Materials
    # None

    # Geometry
    # Concentric void spheres
    # - Innermost sphere to bank surface sources
    # - Second shell to tally cell flux
    # - Outermost sphere as vacuum boundary
    sph_1 = openmc.Sphere(r=1.0)  # Surface to bank/write sources.
    sph_2 = openmc.Sphere(r=2.0)
    sph_3 = openmc.Sphere(r=2.5)
    sph_4 = openmc.Sphere(r=4.0, boundary_type='vacuum')
    cell_1 = openmc.Cell(region=-sph_1)
    cell_2 = openmc.Cell(region=+sph_1 & -sph_2)
    cell_3 = openmc.Cell(region=+sph_2 & -sph_3)  # Cell to tally flux.
    cell_4 = openmc.Cell(region=+sph_3 & -sph_4)
    root = openmc.Universe(cells=[cell_1, cell_2, cell_3, cell_4])
    openmc_model.geometry = openmc.Geometry(root)

    # Settings
    openmc_model.settings.run_mode = 'fixed source'
    openmc_model.settings.particles = 1000
    openmc_model.settings.batches = 10
    openmc_model.settings.seed = 1

    if surf_source_op == 'write':
        point = openmc.stats.Point((0, 0, 0))
        pt_src = openmc.Source(space=point)
        openmc_model.settings.source = pt_src

        openmc_model.settings.surf_source_write = {
            'surface_ids': [1],
            'max_particles': 1000
        }
    elif surf_source_op == 'read':
        openmc_model.settings.surf_source_read = {
            'path': 'surface_source_true.h5'
        }

    # Tallies
    tal = openmc.Tally()
    cell_filter = openmc.CellFilter(cell_3)
    tal.filters = [cell_filter]
    tal.scores = ['flux']
    openmc_model.tallies.append(tal)

    return openmc_model
Exemple #11
0
def dagmc_model(request):

    model = openmc.model.Model()

    # settings
    model.settings.batches = 5
    model.settings.inactive = 0
    model.settings.particles = 100
    model.settings.temperature = {'tolerance': 50.0}
    model.settings.verbosity = 1
    source_box = openmc.stats.Box([-4, -4, -4], [4, 4, 4])
    source = openmc.Source(space=source_box)
    model.settings.source = source

    # geometry
    dagmc_universe = openmc.DAGMCUniverse('dagmc.h5m')
    model.geometry = openmc.Geometry(dagmc_universe)

    # tally
    tally = openmc.Tally()
    tally.scores = ['total']
    tally.filters = [openmc.CellFilter(1)]
    model.tallies = [tally]

    # materials
    u235 = openmc.Material(name="no-void fuel")
    u235.add_nuclide('U235', 1.0, 'ao')
    u235.set_density('g/cc', 11)
    u235.id = 40
    u235.temperature = 320

    water = openmc.Material(name="water")
    water.add_nuclide('H1', 2.0, 'ao')
    water.add_nuclide('O16', 1.0, 'ao')
    water.set_density('g/cc', 1.0)
    water.add_s_alpha_beta('c_H_in_H2O')
    water.id = 41

    mats = openmc.Materials([u235, water])
    model.materials = mats

    # location of  dagmc file in test directory
    dagmc_file = request.fspath.dirpath() + "/dagmc.h5m"
    # move to a temporary directory
    with cdtemp():
        shutil.copyfile(dagmc_file, "./dagmc.h5m")
        model.export_to_xml()
        openmc.lib.init()
        yield

    openmc.lib.finalize()
Exemple #12
0
    def _build_openmc(self):
        """Generate the OpenMC input XML

        """
        # Directory from which openmc is run
        os.makedirs('openmc', exist_ok=True)

        # Define material
        mat = openmc.Material()
        for element, fraction in self.elements:
            mat.add_element(element, fraction)
        mat.set_density('g/cm3', self.density)
        materials = openmc.Materials([mat])
        materials.export_to_xml(os.path.join('openmc', 'materials.xml'))

        # Set up geometry
        sphere = openmc.Sphere(boundary_type='reflective', R=1.e9)
        cell = openmc.Cell()
        cell.fill = mat
        cell.region = -sphere
        geometry = openmc.Geometry([cell])
        geometry.export_to_xml(os.path.join('openmc', '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.])
        source.particle = 'photon'

        # Settings
        settings = openmc.Settings()
        settings.source = source
        settings.particles = self.particles
        settings.run_mode = 'fixed source'
        settings.batches = 1
        settings.photon_transport = True
        settings.electron_treatment = self.electron_treatment
        settings.cutoff = {'energy_photon': 1000.}
        settings.export_to_xml(os.path.join('openmc', 'settings.xml'))

        # Define tallies
        cell_filter = openmc.CellFilter(cell)
        energy_bins = np.logspace(3, np.log10(self.energy), 500)
        energy_filter = openmc.EnergyFilter(energy_bins)
        particle_filter = openmc.ParticleFilter('photon')
        tally = openmc.Tally(name='photon flux')
        tally.filters = [cell_filter, energy_filter, particle_filter]
        tally.scores = ['flux']
        tallies = openmc.Tallies([tally])
        tallies.export_to_xml(os.path.join('openmc', 'tallies.xml'))
Exemple #13
0
def parse4Factor(batch,fuel,mod):
        #read in the tallies
    sp = openmc.StatePoint('statepoint.'+str(batch)+'.h5')
    
    uniFilter = openmc.CellFilter([fuel, mod])
    fuelFilter=openmc.CellFilter([fuel])
    # this reads the tally with all reaction rates, not just absorption
    tally = sp.get_tally(scores=['absorption'])
    data=tally.get_pandas_dataframe()
    #data=dat.set_index("cell",drop=False)
    
    #parse dem data (gotta use proper plural grammar)
    nuFiss= data.iloc[1,5]+data.iloc[4,5]   #sum all fission neutrons produced
    absorbFuel=data.iloc[3,5]+data.iloc[0,5] #all absorptions in the fuel
    absorbTotal=absorbFuel+data.iloc[6,5]+data.iloc[9,5] #all absorptions
    thermalized=data.iloc[0,5]+data.iloc[2,5]+data.iloc[6,5]   #all absorptions and fissions below thermal (since no leakage)
    thermalFiss=data.iloc[2,5]
    
    eta=nuFiss/absorbFuel
    f=absorbFuel/absorbTotal
    p=thermalized/nuFiss
    eps=nuFiss/thermalFiss
    
    return np.array([eta,f,p,eps])
Exemple #14
0
	def get_all_nucl_rxn_tally(self, bucell):

		nucl_list = self.get_nucl_to_be_tallied(bucell)
		print ('bucell name',bucell.name)
		print ('nucl list when set to tally',nucl_list)
		nucl_list = utils.bu_namelist_to_mc_namelist(nucl_list)
		rxn = openmc.Tally(name='{} rxn rate'.format(bucell.name))
		rxn.filters = [openmc.CellFilter(bucell.id)]
		rxn.filters.append(self.energy_bin)
		rxn.scores = ['fission', '(n,gamma)', '(n,2n)', '(n,3n)', '(n,p)', '(n,a)']
		#rxn.scores = ['fission', '(n,gamma)']
		#rxn.scores = ['fission', '(n,gamma)', '(n,2n)']
		rxn.nuclides = nucl_list
		
		return rxn
Exemple #15
0
def model():

    model = openmc.model.Model()

    # settings
    model.settings.batches = 5
    model.settings.inactive = 0
    model.settings.particles = 100

    source_box = openmc.stats.Box([-4, -4, -4], [4, 4, 4])
    source = openmc.Source(space=source_box)

    model.settings.source = source

    model.settings.dagmc = True

    # geometry
    dag_univ = openmc.DAGMCUniverse("dagmc.h5m")
    model.geometry = openmc.Geometry(dag_univ)

    # tally
    tally = openmc.Tally()
    tally.scores = ['total']
    tally.filters = [openmc.CellFilter(1)]
    model.tallies = [tally]

    # materials
    u235 = openmc.Material(name="no-void fuel")
    u235.add_nuclide('U235', 1.0, 'ao')
    u235.set_density('g/cc', 11)
    u235.id = 40

    water = openmc.Material(name="water")
    water.add_nuclide('H1', 2.0, 'ao')
    water.add_nuclide('O16', 1.0, 'ao')
    water.set_density('g/cc', 1.0)
    water.add_s_alpha_beta('c_H_in_H2O')
    water.id = 41

    mats = openmc.Materials([u235, water])
    model.materials = mats

    return model
Exemple #16
0
    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()

        # tally
        tally = openmc.Tally()
        tally.scores = ['total']
        tally.filters = [openmc.CellFilter(1)]
        model.tallies = [tally]

        model.tallies.export_to_xml()
Exemple #17
0
def test_dagmc():
    model = openmc.model.Model()

    # settings
    model.settings.batches = 5
    model.settings.inactive = 0
    model.settings.particles = 100

    source_box = openmc.stats.Box([-4, -4, -4], [4, 4, 4])
    source = openmc.Source(space=source_box)

    model.settings.source = source

    model.settings.dagmc = True

    # tally
    tally = openmc.Tally()
    tally.scores = ['total']
    tally.filters = [openmc.CellFilter(1)]
    model.tallies = [tally]

    # materials
    u235 = openmc.Material(name="fuel")
    u235.add_nuclide('U235', 1.0, 'ao')
    u235.set_density('g/cc', 11)
    u235.id = 40

    water = openmc.Material(name="water")
    water.add_nuclide('H1', 2.0, 'ao')
    water.add_nuclide('O16', 1.0, 'ao')
    water.set_density('g/cc', 1.0)
    water.add_s_alpha_beta('c_H_in_H2O')
    water.id = 41

    mats = openmc.Materials([u235, water])
    model.materials = mats

    model.export_to_xml()
Exemple #18
0
sett.inactive = 0
sett.particles = 10000
sett.run_mode = 'fixed source'

# Create a DT point source
source = openmc.Source()
source.space = openmc.stats.Point((0, 0, 0))
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([14e6], [1])
sett.source = source


tallies = openmc.Tallies()

# added a cell tally for tritium production
cell_filter = openmc.CellFilter(first_wall_cell)
reaction_tally = openmc.Tally(name='DPA')
reaction_tally.filters = [cell_filter]
reaction_tally.scores = ['444']
tallies.append(reaction_tally)


# Run OpenMC!
model = openmc.model.Model(geom, mats, sett, tallies)
model.run()

# open the results file
sp = openmc.StatePoint('statepoint.'+str(batches)+'.h5')

# access the tally
tally = sp.get_tally(name='DPA')
def make_materials_geometry_tallies(enrichment):

    # MATERIALS

    breeder_material = openmc.Material(1, "PbLi")  # Pb84.2Li15.8
    breeder_material.add_element('Pb', 84.2, percent_type='ao')
    breeder_material.add_element('Li',
                                 15.8,
                                 percent_type='ao',
                                 enrichment=enrichment,
                                 enrichment_target='Li6',
                                 enrichment_type='ao')
    breeder_material.set_density('atom/b-cm', 3.2720171e-2)  # around 11 g/cm3

    steel = openmc.Material(name='steel')
    steel.set_density('g/cm3', 7.75)
    steel.add_element('Fe', 0.95, percent_type='wo')
    steel.add_element('C', 0.05, percent_type='wo')

    mats = openmc.Materials([breeder_material, steel])

    # GEOMETRY

    # surfaces
    vessel_inner = openmc.Sphere(r=500)
    first_wall_outer_surface = openmc.Sphere(r=510)
    breeder_blanket_outer_surface = openmc.Sphere(r=610,
                                                  boundary_type='vacuum')

    # cells
    inner_vessel_region = -vessel_inner
    inner_vessel_cell = openmc.Cell(region=inner_vessel_region)

    first_wall_region = -first_wall_outer_surface & +vessel_inner
    first_wall_cell = openmc.Cell(region=first_wall_region)
    first_wall_cell.fill = steel

    breeder_blanket_region = +first_wall_outer_surface & -breeder_blanket_outer_surface
    breeder_blanket_cell = openmc.Cell(region=breeder_blanket_region)
    breeder_blanket_cell.fill = breeder_material

    universe = openmc.Universe(
        cells=[inner_vessel_cell, first_wall_cell, breeder_blanket_cell])
    geom = openmc.Geometry(universe)

    # SIMULATION SETTINGS
    sett = openmc.Settings()
    sett.batches = 2  # this is minimum number of batches that will be run
    sett.trigger_active = True
    sett.trigger_max_batches = 200  # this is maximum number of batches that will be run
    sett.inactive = 0
    sett.particles = 1000
    sett.run_mode = 'fixed source'

    source = openmc.Source()
    source.space = openmc.stats.Point((0, 0, 0))
    source.angle = openmc.stats.Isotropic()
    source.energy = openmc.stats.Discrete([14e6], [1])
    sett.source = source

    # TALLIES

    tallies = openmc.Tallies()

    cell_filter = openmc.CellFilter(breeder_blanket_cell)
    tbr_tally = openmc.Tally(name='TBR')
    tbr_tally.filters = [cell_filter]
    tbr_tally.scores = [
        '(n,Xt)'
    ]  # MT 205 is the (n,Xt) reaction where X is a wildcard, if MT 105 or (n,t) then some tritium production will be missed, for example (n,nt) which happens in Li7 would be missed
    tbr_tally.triggers = [
        openmc.Trigger(trigger_type='std_dev', threshold=0.01)
    ]  # This stops the simulation if the threshold is meet
    tallies.append(tbr_tally)

    # RUN OPENMC
    model = openmc.model.Model(geom, mats, sett, tallies)
    sp_filename = model.run()

    # OPEN OUPUT FILE
    sp = openmc.StatePoint(sp_filename)

    tbr_tally = sp.get_tally(name='TBR')

    df = tbr_tally.get_pandas_dataframe()

    tbr_tally_result = df['mean'].sum()
    tbr_tally_std_dev = df['std. dev.'].sum()

    return {
        'enrichment': enrichment,
        'tbr_tally_result': tbr_tally_result,
        'tbr_tally_std_dev': tbr_tally_std_dev
    }
Exemple #20
0
def simulate_model(enrichment,
                   blanket_thickness=200,
                   firstwall_thickness=5,
                   breeder_material_name="Li4SiO4",
                   temperature_in_C=500,
                   threshold=0.0005,
                   inner_radius=500):

    # MATERIALS from library of materials in neutronics_material_maker package
    breeder_material = Material(
        material_name=breeder_material_name,
        enrichment=enrichment,
        temperature_in_C=temperature_in_C,
    ).neutronics_material

    SS316 = Material(material_name="SS316").neutronics_material
    copper = Material(material_name="copper").neutronics_material

    mats = openmc.Materials([breeder_material, SS316, copper])
    mats.export_to_xml("materials.xml")

    # GEOMETRY#

    first_wall_inner_surface = openmc.Sphere(r=inner_radius)
    first_wall_outer_surface = openmc.Sphere(r=inner_radius +
                                             firstwall_thickness)
    breeder_blanket_outer_surface = openmc.Sphere(
        r=inner_radius + firstwall_thickness + blanket_thickness)
    vessel_outer_surface = openmc.Sphere(r=inner_radius + firstwall_thickness +
                                         blanket_thickness + 10.,
                                         boundary_type="vacuum")

    inner_void_region = -first_wall_inner_surface
    inner_void_cell = openmc.Cell(region=inner_void_region)
    inner_void_cell.name = "inner_void"

    first_wall_region = (-first_wall_outer_surface & +first_wall_inner_surface)
    first_wall_cell = openmc.Cell(region=first_wall_region)
    first_wall_cell.fill = SS316

    breeder_blanket_region = (+first_wall_outer_surface
                              & -breeder_blanket_outer_surface)
    breeder_blanket_cell = openmc.Cell(region=breeder_blanket_region)
    breeder_blanket_cell.fill = breeder_material

    vessel_region = +breeder_blanket_outer_surface & -vessel_outer_surface
    vessel_cell = openmc.Cell(region=vessel_region)
    vessel_cell.name = "vessel"
    vessel_cell.fill = SS316

    universe = openmc.Universe(cells=[
        inner_void_cell, first_wall_cell, breeder_blanket_cell, vessel_cell
    ])

    geom = openmc.Geometry(universe)

    # SIMULATION SETTINGS#

    sett = openmc.Settings()
    sett.batches = 2  # this is minimum number of batches that will be run
    sett.trigger_active = True
    sett.trigger_max_batches = 2000  # this is maximum number of batches that will be run
    sett.inactive = 0
    sett.particles = 1000
    sett.run_mode = "fixed source"

    source = openmc.Source()
    source.space = openmc.stats.Point((150, 0, 0))
    source.angle = openmc.stats.Isotropic()
    source.energy = openmc.stats.Discrete([14.08e6], [1])
    sett.source = source

    # sett.export_to_xml("settings.xml")

    # tally filters
    particle_filter = openmc.ParticleFilter("neutron")
    cell_filter_breeder = openmc.CellFilter(breeder_blanket_cell)

    # TALLIES#
    tallies = openmc.Tallies()

    tally = openmc.Tally(name="TBR")
    tally.filters = [cell_filter_breeder, particle_filter]
    tally.scores = ["(n,Xt)"]
    tally.triggers = [
        openmc.Trigger(trigger_type='rel_err', threshold=threshold)
    ]  # This stops the simulation if the threshold is meet
    tallies.append(tally)

    # RUN OPENMC #
    model = openmc.model.Model(geom, mats, sett, tallies)
    sp_filename = model.run(output=False)

    # RETRIEVING TALLY RESULTS

    sp = openmc.StatePoint(sp_filename)

    json_output = {
        "enrichment": enrichment,
        "inner_radius": inner_radius,
        "firstwall_thickness": firstwall_thickness,
        "blanket_thickness": blanket_thickness,
        "breeder_material_name": breeder_material_name,
        "temperature_in_C": temperature_in_C,
    }

    tally = sp.get_tally(name="TBR")

    df = tally.get_pandas_dataframe()

    json_output["TBR"] = df["mean"].sum()
    json_output["TBR_std_dev"] = df["std. dev."].sum()

    os.system('rm *.h5')

    return json_output
sett.batches = batches
sett.inactive = 0
sett.particles = 50
sett.run_mode = 'fixed source'

# Create a DT point source
source = openmc.Source()
source.space = openmc.stats.Point((300, 0, 0))
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([14e6], [1])
sett.source = source

tallies = openmc.Tallies()

#added a cell tally for tritium production
cell_filter = openmc.CellFilter(breeder_blanket_cell)
tbr_tally = openmc.Tally(2, name='TBR')
tbr_tally.filters = [cell_filter]
tbr_tally.scores = [
    '205'
]  # MT 205 is the (n,Xt) reaction where X is a wildcard, if MT 105 or (n,t) then some tritium production will be missed, for example (n,nt) which happens in Li7 would be missed
tallies.append(tbr_tally)

# Run OpenMC!
model = openmc.model.Model(geom, mats, sett, tallies)
model.run()

# open the results file
sp = openmc.StatePoint('statepoint.' + str(batches) + '.h5')

# access the tally
Exemple #22
0
def pincellfunction(pitch, enrichment):

    settings = openmc.Settings()
    # Set high tolerance to allow use of lower temperature xs
    settings.temperature['tolerance'] = 10000
    settings.temperature['method'] = 'nearest'
    settings.temperature['multipole'] = True
    settings.cutoff = {'energy': 1e-8}  #energy cutoff in eV

    #############################
    ###       MATERIALS       ###
    #############################
    uo2 = openmc.Material(1, "uo2")
    uo2.add_element('U', 1.0, enrichment=enrichment)
    uo2.add_element('O', 2.0)
    uo2.set_density('g/cm3', 10.97)
    uo2.temperature = 900  #kelvin

    graphite = openmc.Material(2, "graphite")
    graphite.set_density('g/cm3', 1.1995)
    graphite.add_element('C', 1.0)
    graphite.add_s_alpha_beta('c_Graphite')
    graphite.temperature = 600  #kelvin

    mats = openmc.Materials([uo2, graphite])
    mats.export_to_xml()

    #############################
    ###       GEOMETRY        ###
    #############################
    universe = openmc.Universe()

    fuel_or = openmc.ZCylinder(R=0.5)
    fuel_region = -fuel_or
    fuel_cell = openmc.Cell(1, 'fuel')
    fuel_cell.fill = uo2
    fuel_cell.region = fuel_region

    box = openmc.get_rectangular_prism(width=pitch,
                                       height=pitch,
                                       boundary_type='reflective')
    water_region = box & +fuel_or
    moderator = openmc.Cell(2, 'moderator')
    moderator.fill = graphite
    moderator.region = water_region

    root = openmc.Universe(cells=(fuel_cell, moderator))
    geom = openmc.Geometry(root)
    geom.export_to_xml()

    #####################################
    ###        SOURCE/BATCHES         ###
    #####################################
    point = openmc.stats.Point((0, 0, 0))
    src = openmc.Source(space=point)

    settings.source = src
    settings.batches = 100
    settings.inactive = 10
    settings.particles = 1000

    settings.export_to_xml()

    #############################
    ###       TALLIES         ###
    #############################
    # Instantiate an empty Tallies object
    tallies_file = openmc.Tallies()

    # K-Eigenvalue (infinity) tallies
    fiss_rate = openmc.Tally(name='fiss. rate')
    fiss_rate.scores = ['nu-fission']
    tallies_file.append(fiss_rate)

    abs_rate = openmc.Tally(name='abs. rate')
    abs_rate.scores = ['absorption']
    tallies_file.append(abs_rate)

    # Resonance Escape Probability tallies
    therm_abs_rate = openmc.Tally(name='therm. abs. rate')
    therm_abs_rate.scores = ['absorption']
    therm_abs_rate.filters = [openmc.EnergyFilter([0., 0.625])]
    tallies_file.append(therm_abs_rate)

    # Thermal Flux Utilization tallies
    fuel_therm_abs_rate = openmc.Tally(name='fuel therm. abs. rate')
    fuel_therm_abs_rate.scores = ['absorption']
    fuel_therm_abs_rate.filters = [
        openmc.EnergyFilter([0., 0.625]),
        openmc.CellFilter([fuel_cell])
    ]
    tallies_file.append(fuel_therm_abs_rate)

    # Fast Fission Factor tallies
    therm_fiss_rate = openmc.Tally(name='therm. fiss. rate')
    therm_fiss_rate.scores = ['nu-fission']
    therm_fiss_rate.filters = [openmc.EnergyFilter([0., 0.625])]
    tallies_file.append(therm_fiss_rate)

    tallies_file.export_to_xml()

    #############################
    ###       PLOTTING        ###
    #############################
    p = openmc.Plot()
    p.filename = 'pinplot'
    p.width = (pitch, pitch)
    p.pixels = (200, 200)
    p.color_by = 'material'
    p.colors = {uo2: 'yellow', graphite: 'grey'}

    plots = openmc.Plots([p])
    plots.export_to_xml()

    openmc.plot_geometry(output=False)
    pngstring = 'pinplot{}.png'.format(str(pitch))
    subprocess.call(['convert', 'pinplot.ppm', pngstring])
    subprocess.call(['mv', pngstring, 'figures/' + pngstring])

    #############################
    ###       EXECUTION       ###
    #############################
    openmc.run(output=False)
    sp = openmc.StatePoint('statepoint.{}.h5'.format(settings.batches))
    # Collect all the tallies
    fiss_rate = sp.get_tally(name='fiss. rate')
    fiss_rate_df = fiss_rate.get_pandas_dataframe()
    abs_rate = sp.get_tally(name='abs. rate')
    abs_rate_df = abs_rate.get_pandas_dataframe()
    therm_abs_rate = sp.get_tally(name='therm. abs. rate')
    therm_abs_rate_df = therm_abs_rate.get_pandas_dataframe()
    fuel_therm_abs_rate = sp.get_tally(name='fuel therm. abs. rate')
    fuel_therm_abs_rate_df = fuel_therm_abs_rate.get_pandas_dataframe()
    therm_fiss_rate = sp.get_tally(name='therm. fiss. rate')
    therm_fiss_rate_df = therm_fiss_rate.get_pandas_dataframe()

    # Compute k-infinity
    kinf = fiss_rate / abs_rate
    kinf_df = kinf.get_pandas_dataframe()

    # Compute resonance escape probability
    res_esc = (therm_abs_rate) / (abs_rate)
    res_esc_df = res_esc.get_pandas_dataframe()

    # Compute fast fission factor
    fast_fiss = fiss_rate / therm_fiss_rate
    fast_fiss_df = fast_fiss.get_pandas_dataframe()

    # Compute thermal flux utilization
    therm_util = fuel_therm_abs_rate / therm_abs_rate
    therm_util_df = therm_util.get_pandas_dataframe()

    # Compute neutrons produced per absorption
    eta = therm_fiss_rate / fuel_therm_abs_rate
    eta_df = eta.get_pandas_dataframe()

    columns = [
        'pitch', 'enrichment', 'kinf mean', 'kinf sd', 'res_esc mean',
        'res_esc sd', 'fast_fiss mean', 'fast_fiss sd', 'therm_util mean',
        'therm_util sd', 'eta mean', 'eta sd'
    ]
    data = [[
        pitch, enrichment, kinf_df['mean'][0], kinf_df['std. dev.'][0],
        res_esc_df['mean'][0], res_esc_df['std. dev.'][0],
        fast_fiss_df['mean'][0], fast_fiss_df['std. dev.'][0],
        therm_util_df['mean'][0], therm_util_df['std. dev.'][0],
        eta_df['mean'][0], eta_df['std. dev.'][0]
    ]]
    all_tallies = pd.DataFrame(data, columns=columns)

    return all_tallies
def make_materials_geometry_tallies(enrichment):

    # MATERIALS#

    breeder_material = openmc.Material(name="breeder_material")  # Pb84.2Li15.8
    breeder_material.add_element('Pb', 84.2, percent_type='ao')
    breeder_material.add_element(
        'Li',
        15.8,
        percent_type='ao',
        enrichment=enrichment,
        enrichment_target='Li6',
        enrichment_type='ao')  # enrichment defined by function call
    breeder_material.set_density('atom/b-cm', 3.2720171e-2)  # around 11 g/cm3

    copper = openmc.Material(name='copper')
    copper.set_density('g/cm3', 8.5)
    copper.add_element('Cu', 1.0)

    eurofer = openmc.Material(name='eurofer')
    eurofer.set_density('g/cm3', 7.75)
    eurofer.add_element('Fe', 89.067, percent_type='wo')
    eurofer.add_element('C', 0.11, percent_type='wo')
    eurofer.add_element('Mn', 0.4, percent_type='wo')
    eurofer.add_element('Cr', 9.0, percent_type='wo')
    eurofer.add_element('Ta', 0.12, percent_type='wo')
    eurofer.add_element('W', 1.1, percent_type='wo')
    eurofer.add_element('N', 0.003, percent_type='wo')
    eurofer.add_element('V', 0.2, percent_type='wo')

    mats = openmc.Materials([breeder_material, eurofer, copper])

    # GEOMETRY

    central_sol_surface = openmc.ZCylinder(r=100)
    central_shield_outer_surface = openmc.ZCylinder(r=110)
    vessel_inner = openmc.Sphere(r=500)
    first_wall_outer_surface = openmc.Sphere(r=510)
    breeder_blanket_outer_surface = openmc.Sphere(r=610,
                                                  boundary_type='vacuum')

    central_sol_region = -central_sol_surface & -vessel_inner
    central_sol_cell = openmc.Cell(region=central_sol_region)
    central_sol_cell.fill = copper

    central_shield_region = +central_sol_surface & -central_shield_outer_surface & -vessel_inner
    central_shield_cell = openmc.Cell(region=central_shield_region)
    central_shield_cell.fill = eurofer

    inner_vessel_region = -vessel_inner & +central_shield_outer_surface
    inner_vessel_cell = openmc.Cell(region=inner_vessel_region)

    first_wall_region = -first_wall_outer_surface & +vessel_inner
    first_wall_cell = openmc.Cell(region=first_wall_region)
    first_wall_cell.fill = eurofer

    breeder_blanket_region = +first_wall_outer_surface & -breeder_blanket_outer_surface
    breeder_blanket_cell = openmc.Cell(region=breeder_blanket_region)
    breeder_blanket_cell.fill = breeder_material
    breeder_blanket_cell.name = 'breeder_blanket'

    universe = openmc.Universe(cells=[
        central_sol_cell, central_shield_cell, inner_vessel_cell,
        first_wall_cell, breeder_blanket_cell
    ])
    geom = openmc.Geometry(universe)

    # SIMULATION SETTINGS

    sett = openmc.Settings()
    batches = 3
    sett.batches = batches
    sett.inactive = 0
    sett.particles = 5000
    sett.run_mode = 'fixed source'

    source = openmc.Source()
    source.space = openmc.stats.Point((350, 0, 0))
    source.angle = openmc.stats.Isotropic()
    source.energy = openmc.stats.Discrete([14e6], [1])
    sett.source = source

    # TALLIES

    tallies = openmc.Tallies()

    cell_filter = openmc.CellFilter(breeder_blanket_cell)
    tbr_tally = openmc.Tally(2, name='TBR')
    tbr_tally.filters = [cell_filter]
    tbr_tally.scores = [
        '(n,Xt)'
    ]  # MT 205 is the (n,Xt) reaction where X is a wildcard, if MT 105 or (n,t) then some tritium production will be missed, for example (n,nt) which happens in Li7 would be missed
    tallies.append(tbr_tally)

    # RUN OPENMC
    model = openmc.model.Model(geom, mats, sett, tallies)
    model.run()
    sp = openmc.StatePoint('statepoint.' + str(batches) + '.h5')

    tbr_tally = sp.get_tally(name='TBR')

    df = tbr_tally.get_pandas_dataframe()

    tbr_tally_result = df['mean'].sum()
    tbr_tally_std_dev = df['std. dev.'].sum()

    return {
        'enrichment': enrichment,
        'tbr_tally_result': tbr_tally_result,
        'tbr_tally_std_dev': tbr_tally_std_dev
    }
Exemple #24
0
def make_materials_geometry_tallies(v):
    enrichment_fraction_list, thickness = v
    batches = 2
    inner_radius = 500
    breeder_material_name = 'Li'
    temperature_in_C = 500

    if isinstance(enrichment_fraction_list, list):
        enrichment_fraction = enrichment_fraction_list[0]
    else:
        enrichment_fraction = enrichment_fraction_list
    print('simulating ', batches, enrichment_fraction, inner_radius, thickness,
          breeder_material_name)

    #MATERIALS#

    breeder_material = make_breeder_material(enrichment_fraction,
                                             breeder_material_name,
                                             temperature_in_C)
    eurofer = make_eurofer()
    mats = openmc.Materials([breeder_material, eurofer])

    #GEOMETRY#

    breeder_blanket_inner_surface = openmc.Sphere(r=inner_radius)
    breeder_blanket_outer_surface = openmc.Sphere(r=inner_radius + thickness)

    vessel_inner_surface = openmc.Sphere(r=inner_radius + thickness + 10)
    vessel_outer_surface = openmc.Sphere(r=inner_radius + thickness + 20,
                                         boundary_type='vacuum')

    breeder_blanket_region = -breeder_blanket_outer_surface & +breeder_blanket_inner_surface
    breeder_blanket_cell = openmc.Cell(region=breeder_blanket_region)
    breeder_blanket_cell.fill = breeder_material
    breeder_blanket_cell.name = 'breeder_blanket'

    inner_void_region = -breeder_blanket_inner_surface
    inner_void_cell = openmc.Cell(region=inner_void_region)
    inner_void_cell.name = 'inner_void'

    vessel_region = +vessel_inner_surface & -vessel_outer_surface
    vessel_cell = openmc.Cell(region=vessel_region)
    vessel_cell.name = 'vessel'
    vessel_cell.fill = eurofer

    blanket_vessel_gap_region = -vessel_inner_surface & +breeder_blanket_outer_surface
    blanket_vessel_gap_cell = openmc.Cell(region=blanket_vessel_gap_region)
    blanket_vessel_gap_cell.name = 'blanket_vessel_gap'

    universe = openmc.Universe(cells=[
        inner_void_cell, breeder_blanket_cell, blanket_vessel_gap_cell,
        vessel_cell
    ])

    geom = openmc.Geometry(universe)

    #SIMULATION SETTINGS#

    sett = openmc.Settings()
    # batches = 3 # this is parsed as an argument
    sett.batches = batches
    sett.inactive = 10
    sett.particles = 500
    sett.run_mode = 'fixed source'

    source = openmc.Source()
    source.space = openmc.stats.Point((0, 0, 0))
    source.angle = openmc.stats.Isotropic()
    source.energy = openmc.stats.Muir(
        e0=14080000.0, m_rat=5.0, kt=20000.0
    )  #neutron energy = 14.08MeV, AMU for D + T = 5, temperature is 20KeV
    sett.source = source

    #TALLIES#

    tallies = openmc.Tallies()

    # define filters
    cell_filter_breeder = openmc.CellFilter(breeder_blanket_cell)
    cell_filter_vessel = openmc.CellFilter(vessel_cell)
    particle_filter = openmc.ParticleFilter([1])  #1 is neutron, 2 is photon
    surface_filter_rear_blanket = openmc.SurfaceFilter(
        breeder_blanket_outer_surface)
    surface_filter_rear_vessel = openmc.SurfaceFilter(vessel_outer_surface)
    energy_bins = openmc.mgxs.GROUP_STRUCTURES['VITAMIN-J-175']
    energy_filter = openmc.EnergyFilter(energy_bins)

    tally = openmc.Tally(name='TBR')
    tally.filters = [cell_filter_breeder, particle_filter]
    tally.scores = [
        '205'
    ]  # MT 205 is the (n,Xt) reaction where X is a wildcard, if MT 105 or (n,t) then some tritium production will be missed, for example (n,nt) which happens in Li7 would be missed
    tallies.append(tally)

    tally = openmc.Tally(name='blanket_leakage')
    tally.filters = [surface_filter_rear_blanket, particle_filter]
    tally.scores = ['current']
    tallies.append(tally)

    tally = openmc.Tally(name='vessel_leakage')
    tally.filters = [surface_filter_rear_vessel, particle_filter]
    tally.scores = ['current']
    tallies.append(tally)

    tally = openmc.Tally(name='breeder_blanket_spectra')
    tally.filters = [cell_filter_breeder, particle_filter, energy_filter]
    tally.scores = ['flux']
    tallies.append(tally)

    tally = openmc.Tally(name='vacuum_vessel_spectra')
    tally.filters = [cell_filter_vessel, particle_filter, energy_filter]
    tally.scores = ['flux']
    tallies.append(tally)

    tally = openmc.Tally(name='DPA')
    tally.filters = [cell_filter_vessel, particle_filter]
    tally.scores = ['444']
    tallies.append(tally)

    #RUN OPENMC #
    model = openmc.model.Model(geom, mats, sett, tallies)
    model.run()

    sp = openmc.StatePoint('statepoint.' + str(batches) + '.h5')

    json_output = {
        'enrichment_fraction': enrichment_fraction,
        'inner_radius': inner_radius,
        'thickness': thickness,
        'breeder_material_name': breeder_material_name,
        'temperature_in_C': temperature_in_C
    }

    tallies_to_retrieve = ['TBR', 'DPA', 'blanket_leakage', 'vessel_leakage']
    for tally_name in tallies_to_retrieve:
        tally = sp.get_tally(name=tally_name)

        df = tally.get_pandas_dataframe()

        tally_result = df['mean'].sum()
        tally_std_dev = df['std. dev.'].sum()

        json_output[tally_name] = {
            'value': tally_result,
            'std_dev': tally_std_dev
        }

    spectra_tallies_to_retrieve = [
        'breeder_blanket_spectra', 'vacuum_vessel_spectra'
    ]
    for spectra_name in spectra_tallies_to_retrieve:
        spectra_tally = sp.get_tally(name=spectra_name)
        spectra_tally_result = [entry[0][0] for entry in spectra_tally.mean]
        spectra_tally_std_dev = [
            entry[0][0] for entry in spectra_tally.std_dev
        ]

        json_output[spectra_name] = {
            'value': spectra_tally_result,
            'std_dev': spectra_tally_std_dev,
            'energy_groups': list(energy_bins)
        }

    return json_output
Exemple #25
0
mgxs_lib = openmc.mgxs.Library(geometry)
mgxs_lib.energy_groups = openmc.mgxs.EnergyGroups(groups)
mgxs_lib.correction = None
mgxs_lib.mgxs_types = ('total','absorption','nu-fission',\
                       'fission','consistent nu-scatter matrix','chi')
mgxs_lib.domain_type = 'cell'
mgxs_lib.domains = geometry.get_all_material_cells().values()
mgxs_lib.build_library()

tallies = openmc.Tallies()
mgxs_lib.add_to_tallies_file(tallies)

flux_tally = openmc.Tally(name='flux')
energy_filter = openmc.EnergyFilter(groups)
flux_tally.filters = [
    openmc.CellFilter(mCells + fCells),
    openmc.EnergyFilter(groups)
]
#flux_tally.scores = ['flux','nu-fission']
flux_tally.scores = ['flux']
tallies.append(flux_tally)

###############################################################################
###############################################################################
# Extract all Cells filled by Materials
openmc_cells = geometry.get_all_material_cells().values()

# Create dictionary to store multi-group cross sections for all cells
xs_library = {}

# Instantiate 8-group cross sections for each cell
def make_materials_geometry_tallies(v):
    enrichment_fraction, thickness = v
    inner_radius = 500
    breeder_material_name = 'Li'
    temperature_in_C = 500

    print('simulating enrichment,', enrichment_fraction, 'thickness ',
          thickness)

    # MATERIALS from library of materials in neutronics_material_maker package
    breeder_material = Material(
        material_name=breeder_material_name,
        enrichment_fraction=enrichment_fraction,
        temperature_in_C=temperature_in_C).neutronics_material

    eurofer = Material(material_name='eurofer').neutronics_material

    mats = openmc.Materials([breeder_material, eurofer])

    # GEOMETRY

    breeder_blanket_inner_surface = openmc.Sphere(r=inner_radius)
    breeder_blanket_outer_surface = openmc.Sphere(r=inner_radius + thickness)

    vessel_inner_surface = openmc.Sphere(r=inner_radius + thickness + 10)
    vessel_outer_surface = openmc.Sphere(r=inner_radius + thickness + 20,
                                         boundary_type='vacuum')

    breeder_blanket_region = -breeder_blanket_outer_surface & +breeder_blanket_inner_surface
    breeder_blanket_cell = openmc.Cell(region=breeder_blanket_region)
    breeder_blanket_cell.fill = breeder_material
    breeder_blanket_cell.name = 'breeder_blanket'

    inner_void_region = -breeder_blanket_inner_surface
    inner_void_cell = openmc.Cell(region=inner_void_region)
    inner_void_cell.name = 'inner_void'

    vessel_region = +vessel_inner_surface & -vessel_outer_surface
    vessel_cell = openmc.Cell(region=vessel_region)
    vessel_cell.name = 'vessel'
    vessel_cell.fill = eurofer

    blanket_vessel_gap_region = -vessel_inner_surface & +breeder_blanket_outer_surface
    blanket_vessel_gap_cell = openmc.Cell(region=blanket_vessel_gap_region)
    blanket_vessel_gap_cell.name = 'blanket_vessel_gap'

    universe = openmc.Universe(cells=[
        inner_void_cell, breeder_blanket_cell, blanket_vessel_gap_cell,
        vessel_cell
    ])

    geom = openmc.Geometry(universe)

    # SIMULATION SETTINGS

    sett = openmc.Settings()
    # batches = 3 # this is parsed as an argument
    sett.batches = batches
    sett.inactive = 0
    sett.particles = 500
    sett.run_mode = 'fixed source'

    source = openmc.Source()
    source.space = openmc.stats.Point((0, 0, 0))
    source.angle = openmc.stats.Isotropic()
    source.energy = openmc.stats.Muir(
        e0=14080000.0, m_rat=5.0, kt=20000.0
    )  # neutron energy = 14.08MeV, AMU for D + T = 5, temperature is 20KeV
    sett.source = source

    # TALLIES

    tallies = openmc.Tallies()

    # define filters
    cell_filter_breeder = openmc.CellFilter(breeder_blanket_cell)
    cell_filter_vessel = openmc.CellFilter(vessel_cell)
    particle_filter = openmc.ParticleFilter([1])  # 1 is neutron, 2 is photon
    surface_filter_rear_blanket = openmc.SurfaceFilter(
        breeder_blanket_outer_surface)
    surface_filter_rear_vessel = openmc.SurfaceFilter(vessel_outer_surface)
    energy_bins = openmc.mgxs.GROUP_STRUCTURES['VITAMIN-J-175']
    energy_filter = openmc.EnergyFilter(energy_bins)

    tally = openmc.Tally(name='TBR')
    tally.filters = [cell_filter_breeder, particle_filter]
    tally.scores = [
        '(n,Xt)'
    ]  # MT 205 is the (n,Xt) reaction where X is a wildcard, if MT 105 or (n,t) then some tritium production will be missed, for example (n,nt) which happens in Li7 would be missed
    tallies.append(tally)

    # RUN OPENMC
    model = openmc.model.Model(geom, mats, sett, tallies)
    model.run()

    sp = openmc.StatePoint('statepoint.' + str(batches) + '.h5')

    json_output = {
        'enrichment_fraction': enrichment_fraction,
        'inner_radius': inner_radius,
        'thickness': thickness,
        'breeder_material_name': breeder_material_name,
        'temperature_in_C': temperature_in_C
    }

    tally = sp.get_tally(name='TBR')

    df = tally.get_pandas_dataframe()

    json_output['TBR'] = df['mean'].sum()
    json_output['TBR_std_dev'] = df['std. dev.'].sum()

    return json_output
Exemple #27
0
def generate_model(sol_temp=303., sol_conc=0.299, U_enrch=0.1467, cr_wd=0.1):
    sol_atom_densities = BoilerAtomDensities(enrich=U_enrch,
                                             temp=sol_temp,
                                             conc=sol_conc)

    sol = openmc.Material(name='sol')
    sol.add_element('H', sol_atom_densities['H'], percent_type='ao')
    sol.add_element('O', sol_atom_densities['O'], percent_type='ao')
    sol.add_element('S', sol_atom_densities['S'], percent_type='ao')
    sol.add_nuclide('U234', sol_atom_densities['U234'], percent_type='ao')
    sol.add_nuclide('U235', sol_atom_densities['U235'], percent_type='ao')
    sol.add_nuclide('U238', sol_atom_densities['U238'], percent_type='ao')
    sol.add_s_alpha_beta('c_H_in_H2O')

    ad_tot = 0.
    for key in sol_atom_densities:
        ad_tot += sol_atom_densities[key]

    sol.set_density('atom/b-cm', ad_tot)

    brass = openmc.Material(name='brass')
    brass.add_element('Fe', 0.001002)
    brass.add_element('Cu', 0.674918)
    brass.add_element('Zn', 0.320956)
    brass.add_element('Sn', 0.001451)
    brass.add_element('Pb', 0.001673)
    brass.set_density('g/cc', 8.070)

    cadmium = openmc.Material(name='cadmium')
    cadmium.add_element('Cd', 1.0)
    cadmium.set_density('g/cc', 8.65)

    shell = openmc.Material(name='shell')
    shell.add_element('C', 0.003659)
    shell.add_element('Si', 0.019559)
    shell.add_element('P', 0.000798)
    shell.add_element('S', 0.000514)
    shell.add_element('Cr', 0.179602)
    shell.add_element('Mn', 0.019998)
    shell.add_element('Fe', 0.669338)
    shell.add_element('Ni', 0.102952)
    shell.add_element('Nb', 0.002365)
    shell.add_element('Ta', 0.001214)
    shell.set_density('g/cc', 8.0)

    beryl_ref = openmc.Material(name='beryl_ref')
    beryl_ref.add_element('O', 6.6210e-2)
    beryl_ref.add_element('Be', 6.6210e-2)
    beryl_ref.add_element('B', 3.0637e-7)
    beryl_ref.add_element('Co', 5.6202e-7)
    beryl_ref.add_element('Ag', 3.0706e-8)
    beryl_ref.add_element('Cd', 7.3662e-8)
    beryl_ref.add_element('In', 1.4423e-8)
    beryl_ref.add_s_alpha_beta('c_Be_in_BeO')
    beryl_ref.set_density('g/cc', 2.75)

    grph = openmc.Material(name='grph')
    grph.add_element('C', 0.999999)
    grph.add_element('B', 0.000001)
    grph.set_density('g/cc', 1.7)
    grph.add_s_alpha_beta('c_Graphite')

    air = openmc.Material(name='air')
    air.add_element('C', 0.000150)
    air.add_element('N', 0.784431)
    air.add_element('O', 0.210748)
    air.add_element('Ar', 0.004671)
    air.set_density('g/cc', 0.001205)

    materials = openmc.Materials(
        [sol, shell, beryl_ref, grph, air, brass, cadmium])

    rx_origin = [0., 76.3214, 0.]
    ref_sphere = openmc.Sphere(y0=rx_origin[1], r=47.4210)
    tank_o = openmc.Sphere(y0=rx_origin[1], r=15.3614)
    tank_i = openmc.Sphere(y0=rx_origin[1], r=15.282)
    graph_base_cyl = openmc.YCylinder(r=47.4210)
    #fill_drain_cav = openmc.YCylinder(r=4.445/2.);
    fill_drain_o = openmc.YCylinder(r=2.06375)
    fill_drain_i = openmc.YCylinder(r=1.905)
    plate_plane = openmc.YPlane(y0=0.)
    base_plane = openmc.YPlane(y0=34.4114)
    sphere_center_plane = openmc.YPlane(y0=rx_origin[1])
    upper_plane = openmc.YPlane(y0=118.2314)
    bbox = openmc.model.RightCircularCylinder([0., -10., 0.],
                                              230.,
                                              60.,
                                              axis='y',
                                              boundary_type='vacuum')

    # surfaces for the control rod
    rod_channel_bottom = 118.2314 - 76.20

    cr_cyl = openmc.YCylinder(x0=-18.891, z0=0., r=1.42875)
    cr_cyl_bottom = openmc.YPlane(y0=rod_channel_bottom)

    # surfaces for the safety rod
    sr_right = openmc.XPlane(x0=17.3664)
    sr_left = openmc.XPlane(x0=15.4614)
    sr_front = openmc.ZPlane(z0=7.62 / 2.)
    sr_back = openmc.ZPlane(z0=-7.62 / 2.)

    # top plane for cr/sr
    rod_channel_top = openmc.YPlane(y0=200.)
    rod_length = 76.20

    #sr_wd = 76.20;# cm, distance from fully inserted

    cr_bottom = openmc.YPlane(y0=(rod_channel_bottom + cr_wd))
    cr_top = openmc.YPlane(y0=(rod_channel_bottom + cr_wd + rod_length))

    #sr_bottom = openmc.YPlane(y0=(rod_channel_bottom+sr_wd));
    #sr_top = openmc.YPlane(y0=(rod_channel_bottom+sr_wd+rod_length));

    cr_brass_o = openmc.YCylinder(x0=-18.891, z0=0., r=0.9525)
    cr_brass_i = openmc.YCylinder(x0=-18.891, z0=0., r=0.7000)
    cr_cd_o = openmc.YCylinder(x0=-18.891, z0=0.0, r=1.03375)

    core = openmc.Cell()
    core.fill = sol
    core.region = (-tank_i) | (-fill_drain_i) & -bbox

    steel_tank_and_pipe = openmc.Cell()
    steel_tank_and_pipe.fill = shell
    #steel_tank_and_pipe.region = (+tank_i & -tank_o & ~(-fill_drain_i)) | \
    #                             (+fill_drain_i & -fill_drain_o & +tank_i) & -bbox
    steel_tank_and_pipe.region = (+tank_i & -tank_o & ~(-fill_drain_i)) | \
                                 (+fill_drain_i & -fill_drain_o & +tank_i) & -bbox

    # make a universe for the control rod
    cr_brass = openmc.Cell()
    cr_brass.fill = brass
    cr_brass.region = +cr_brass_i & -cr_brass_o & +cr_bottom & -cr_top

    cr_cd = openmc.Cell()
    cr_cd.fill = cadmium
    cr_cd.region = +cr_brass_o & -cr_cd_o & +cr_bottom & -cr_top

    cr_air = openmc.Cell()
    cr_air.fill = air
    cr_air.region = +cr_cyl_bottom & -rod_channel_top & -cr_cyl & ~cr_cd.region & ~cr_brass.region

    cr_univ = openmc.Universe()
    cr_univ.add_cells([cr_brass, cr_cd, cr_air])

    cr = openmc.Cell()
    cr.fill = cr_univ
    cr.region = -cr_cyl & +cr_cyl_bottom & -rod_channel_top

    sr = openmc.Cell()
    sr.fill = air
    sr.region = +sr_left & -sr_right & +cr_cyl_bottom & -upper_plane & -sr_front & +sr_back

    ref = openmc.Cell()
    ref.fill = beryl_ref
    ref.region = ((+tank_o & +fill_drain_o) & -ref_sphere & +base_plane
                  & -upper_plane) & ~cr.region & ~sr.region

    outside = openmc.Cell()
    outside.fill = air
    outside.region = -bbox & (+graph_base_cyl | (+ref_sphere & -upper_plane) |
                              (+upper_plane & +fill_drain_o & ~cr.region))

    graph_base = openmc.Cell()
    graph_base.fill = grph
    graph_base.region = (
        (-graph_base_cyl & +plate_plane & -base_plane & +fill_drain_o) |
        (-graph_base_cyl & +ref_sphere & +base_plane & -sphere_center_plane))
    root = openmc.Universe()
    root.add_cells(
        [graph_base, ref, core, steel_tank_and_pipe, outside, cr, sr])

    geometry = openmc.Geometry()
    geometry.root_universe = root

    cell_filter = openmc.CellFilter(core)
    N = 1001
    energy_bins = np.logspace(-3, 7, num=N)
    energy_filter = openmc.EnergyFilter(values=energy_bins)

    abs_core = openmc.Tally(name='abs_core')
    abs_core.scores = ['absorption']
    abs_core.filters = [cell_filter, energy_filter]

    fission = openmc.Tally(name='fission')
    fission.scores = ['fission']
    fission.filters = [cell_filter, energy_filter]

    fission_by_nuclide = openmc.Tally(name='fission_by_nuclide')
    fission_by_nuclide.scores = ['fission']
    fission_by_nuclide.nuclides = ['U234', 'U235', 'U238']
    fission_by_nuclide.filters = [cell_filter, energy_filter]

    capture = openmc.Tally(name='capture')
    capture.scores = ['(n,gamma)']
    capture.filters = [cell_filter, energy_filter]

    capture_by_nuclide = openmc.Tally(name='capture_by_nuclide')
    capture_by_nuclide.scores = ['(n,gamma)']
    capture_by_nuclide.nuclides = ['U234', 'U238', 'H1', 'O16', 'S32']
    capture_by_nuclide.filters = [cell_filter, energy_filter]

    flux = openmc.Tally(name='flux')
    flux.scores = ['flux']
    flux.filters = [cell_filter, energy_filter]

    tallies = openmc.Tallies([
        abs_core, flux, fission, capture, fission_by_nuclide,
        capture_by_nuclide
    ])

    settings = openmc.Settings()
    settings.batches = 100
    settings.inactive = 20
    settings.particles = 5000

    R = 15.
    y_org = 76.3214

    bounds = [-R, -R + y_org, -R, R, R + y_org, R]
    uniform_dist = openmc.stats.Box(bounds[:3],
                                    bounds[3:],
                                    only_fissionable=True)
    settings.source = openmc.source.Source(space=uniform_dist)

    #settings.temperature['method']='interpolation';

    return materials, geometry, tallies, settings
sett.batches = batches
sett.inactive = 1
sett.particles = 5000
sett.run_mode = 'fixed source'

# Create a DT point source
source = openmc.Source()
source.space = openmc.stats.Point((300, 0, 0))
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([14e6], [1])
sett.source = source

tallies = openmc.Tallies()

#added a cell tally for tritium production
cell_filter = openmc.CellFilter(central_shield_cell)
reaction_tally = openmc.Tally(2, name='DPA')
reaction_tally.filters = [cell_filter]
reaction_tally.scores = ['444']
tallies.append(reaction_tally)

# Run OpenMC!
model = openmc.model.Model(geom, mats, sett, tallies)
model.run()

# open the results file
sp = openmc.StatePoint('statepoint.' + str(batches) + '.h5')

# access the tally
tally = sp.get_tally(name='DPA')
tally_result = tally.sum[0][0][
Exemple #29
0
def make_materials_geometry_tallies(
        enrichment_fractions, breeder_material_name, temperature_in_C, batches,
        nps, include_first_wall,
        seed):  #thickness fixed to 100cm and inner radius to 500cm
    os.system('rm *.h5')
    os.system('rm *.xml')
    print('simulating ', ' batches =', batches, 'seed = ', seed, 'nps', nps,
          'enrichment_fractions', enrichment_fractions, 'inner radius = 500',
          'thickness = 100 breeder_material_name =', breeder_material_name)

    number_of_materials = len(enrichment_fractions)

    print(enrichment_fractions)

    #MATERIALS#

    list_of_breeder_materials = []

    for counter, e in enumerate(enrichment_fractions):
        breeder_material = make_breeder_material(e, breeder_material_name,
                                                 temperature_in_C, counter + 3)
        list_of_breeder_materials.append(breeder_material)

    print('len(list_of_breeder_materials)', len(list_of_breeder_materials))
    mats = openmc.Materials(list_of_breeder_materials)
    eurofer = make_eurofer()
    mats.append(eurofer)
    mats.export_to_xml()

    # #GEOMETRY#
    list_of_breeder_blanket_region = []
    list_of_breeder_blanket_cell = []

    if include_first_wall == True:
        breeder_blanket_inner_surface_wall = openmc.Sphere(
            r=498)  #inner radius
        first_wall_outer_surface = openmc.Sphere(r=500)

        inner_void_region_wall = -breeder_blanket_inner_surface_wall  #inner radius
        inner_void_cell_wall = openmc.Cell(region=inner_void_region_wall)
        inner_void_cell_wall.name = 'inner_void'

        first_wall_region = -first_wall_outer_surface & +breeder_blanket_inner_surface_wall
        first_wall_cell = openmc.Cell(region=first_wall_region)
        first_wall_cell.name = 'first_wall'
        first_wall_cell.fill = eurofer
        for k in range(1, number_of_materials + 1):
            if k == number_of_materials:
                breeder_blanket_outer_surface = openmc.Sphere(
                    r=500 + 100, boundary_type='vacuum')
            else:
                breeder_blanket_outer_surface = openmc.Sphere(
                    r=500 + k * (100 / number_of_materials)
                )  #inner radius + thickness of each breeder material

            list_of_breeder_blanket_region.append(
                -breeder_blanket_outer_surface & +first_wall_outer_surface)

            breeder_cell = openmc.Cell(region=-breeder_blanket_outer_surface
                                       & +first_wall_outer_surface)
            breeder_cell.fill = list_of_breeder_materials[k - 1]
            breeder_cell.name = 'breeder_blanket'

            list_of_breeder_blanket_cell.append(breeder_cell)

            if k != number_of_materials:
                first_wall_outer_surface = breeder_blanket_outer_surface

        cells = [inner_void_cell_wall, first_wall_cell
                 ] + list_of_breeder_blanket_cell

    else:
        breeder_blanket_inner_surface_no_wall = openmc.Sphere(
            r=500)  #inner radius

        inner_void_region_no_wall = -breeder_blanket_inner_surface_no_wall  #inner radius
        inner_void_cell_no_wall = openmc.Cell(region=inner_void_region_no_wall)
        inner_void_cell_no_wall.name = 'inner_void'

        for k in range(1, number_of_materials + 1):
            if k == number_of_materials:
                breeder_blanket_outer_surface = openmc.Sphere(
                    r=500 + 100, boundary_type='vacuum')
            else:
                breeder_blanket_outer_surface = openmc.Sphere(
                    r=500 + k * (100 / number_of_materials)
                )  #inner radius + thickness of each breeder material

            list_of_breeder_blanket_region.append(
                -breeder_blanket_outer_surface
                & +breeder_blanket_inner_surface_no_wall)

            breeder_cell = openmc.Cell(
                region=-breeder_blanket_outer_surface
                & +breeder_blanket_inner_surface_no_wall)
            breeder_cell.fill = list_of_breeder_materials[k - 1]
            breeder_cell.name = 'breeder_blanket'

            list_of_breeder_blanket_cell.append(breeder_cell)

            if k != number_of_materials:
                breeder_blanket_inner_surface_common = breeder_blanket_outer_surface
            cells = [inner_void_cell_no_wall] + list_of_breeder_blanket_cell

    universe = openmc.Universe(cells=cells)

    geom = openmc.Geometry(universe)

    #openmc color by material

    geom.export_to_xml()
    # p = openmc.Plot()
    # p.basis='xz'
    # p.filename = 'plot'
    # p.width = (1850, 1850) #hint, this might need to be increased to see the new large geometry
    # p.pixels = (1400, 1400)
    # p.color_by = 'material'
    # #p.colors = {natural_lead: 'blue'}
    # plots = openmc.Plots([p])
    # plots.export_to_xml()

    # openmc.plot_geometry()

    # os.system('convert plot.ppm plot.png')
    # os.system('eog plot.png')
    # os.system('xdg-open plot.png')

    #SIMULATION SETTINGS#

    sett = openmc.Settings()
    sett.batches = batches
    sett.inactive = 0
    sett.particles = nps
    sett.seed = seed
    sett.run_mode = 'fixed source'

    source = openmc.Source()
    #source.space = openmc.stats.Point((0,0,0))
    #source.angle = openmc.stats.Isotropic()
    #source.energy = openmc.stats.Muir(e0=14080000.0, m_rat=5.0, kt=20000.0) #neutron energy = 14.08MeV, AMU for D + T = 5, temperature is 20KeV
    sett._source_library = 'parametric_plasma_source/source_sampling.so'
    sett.source = source

    #TALLIES#

    tallies = openmc.Tallies()
    cell_filter_breeder = openmc.CellFilter(list_of_breeder_blanket_cell)

    tally = openmc.Tally(name='TBR')
    tally.filters = [cell_filter_breeder]
    tally.scores = ['205']
    tallies.append(tally)

    #RUN OPENMC #

    model = openmc.model.Model(geom, mats, sett, tallies)
    model.run()

    sp = openmc.StatePoint('statepoint.' + str(batches) + '.h5')

    tally = sp.get_tally(name='TBR')

    tally_result = tally.get_values().sum()

    var = 0
    df = tally.get_pandas_dataframe()
    for sigma in df['std. dev.']:
        var += sigma**2  #independance which is considered between the different layers
    tally_std_dev = (var)**(1 / 2)

    if len(set(enrichment_fractions)) == 1:
        graded = 'uniform'
    else:
        graded = 'graded'

    json_output = {
        'first_wall': include_first_wall,
        'number_of_materials': len(enrichment_fractions),
        'graded': graded,
        'enrichment_value': enrichment_fractions,
        'value': tally_result,
        'std_dev': tally_std_dev,
        'breeder_material_name': breeder_material_name,
        'nps': nps
    }

    print(json_output)
    return json_output
Exemple #30
0
def hexfunction(pitch, pack_frac):

    settings = openmc.Settings()
    # Set high tolerance to allow use of lower temperature xs
    settings.temperature['tolerance'] = 1000
    settings.temperature['method'] = 'nearest'
    settings.temperature['multipole'] = True
    settings.cutoff = {'energy': 1e-8}  #energy cutoff in eV

    #############################
    ###       MATERIALS       ###
    #############################
    enrichment = 20.0

    uo2 = openmc.Material(1, "uo2")
    uo2.add_element('U', 1.0, enrichment=enrichment)
    uo2.add_element('O', 2.0)
    uo2.set_density('g/cm3', 10.97)
    uo2.temperature = 900  #kelvin

    graphite = openmc.Material(2, "graphite")
    graphite.set_density('g/cm3', 1.1995)
    graphite.add_element('C', 1.0)
    graphite.add_s_alpha_beta('c_Graphite')
    graphite.temperature = 900  #kelvin

    sodium = openmc.Material(3, "sodium")
    sodium.set_density('g/cm3', 0.8017)  # 900 K
    sodium.add_element('Na', 1.0)
    # sodium.add_s_alpha_beta('c_Graphite')
    sodium.temperature = 900  #kelvin

    naoh = openmc.Material(6, "naoh")
    naoh.set_density('g/cm3', 1.5)  # 900 K
    naoh.add_element('Na', 1.0)
    naoh.add_element('O', 1.0)
    naoh.add_element('H', 1.0)
    # sodium.add_s_alpha_beta('c_Graphite')
    naoh.temperature = 900  #kelvin

    uo2 = openmc.Material(1, "uo2")
    uo2.add_element('U', 1.0, enrichment=enrichment)
    uo2.add_element('O', 2.0)
    uo2.set_density('g/cm3', 10.97)
    uo2.temperature = 900  #kelvin

    fuel_temp = 900
    homogeneous_fuel = build_fuel_material(4, fuel_temp, pack_frac)

    mats = openmc.Materials([uo2, graphite, sodium, naoh, homogeneous_fuel])
    mats.export_to_xml()

    #############################
    ###       GEOMETRY        ###
    #############################
    universe = openmc.Universe()

    coolant_cyl = openmc.ZCylinder(R=0.5)
    coolant_region = -coolant_cyl
    coolant_cell = openmc.Cell(1, 'coolant')
    coolant_cell.fill = naoh
    coolant_cell.region = coolant_region

    hex_prism = openmc.get_hexagonal_prism(edge_length=pitch / (3**1 / 2),
                                           boundary_type='reflective')
    top = openmc.YPlane(y0=pitch)
    bottom = openmc.YPlane(y0=-pitch)
    fuel_region = hex_prism & -top & +bottom
    fuel_cell = openmc.Cell(2, 'moderator')
    fuel_cell.fill = homogeneous_fuel
    fuel_cell.region = fuel_region

    root = openmc.Universe(cells=(fuel_cell, coolant_cell))
    geom = openmc.Geometry(root)
    geom.export_to_xml()

    #####################################
    ###        SOURCE/BATCHES         ###
    #####################################
    point = openmc.stats.Point((0, 0, 0))
    src = openmc.Source(space=point)

    settings.source = src
    settings.batches = 50
    settings.inactive = 10
    settings.particles = 200

    settings.export_to_xml()

    #############################
    ###       TALLIES         ###
    #############################
    # Instantiate an empty Tallies object
    tallies_file = openmc.Tallies()

    # K-Eigenvalue (infinity) tallies
    fiss_rate = openmc.Tally(name='fiss. rate')
    fiss_rate.scores = ['nu-fission']
    tallies_file.append(fiss_rate)

    abs_rate = openmc.Tally(name='abs. rate')
    abs_rate.scores = ['absorption']
    tallies_file.append(abs_rate)

    # Resonance Escape Probability tallies
    therm_abs_rate = openmc.Tally(name='therm. abs. rate')
    therm_abs_rate.scores = ['absorption']
    therm_abs_rate.filters = [openmc.EnergyFilter([0., 0.625])]
    tallies_file.append(therm_abs_rate)

    # Thermal Flux Utilization tallies
    fuel_therm_abs_rate = openmc.Tally(name='fuel therm. abs. rate')
    fuel_therm_abs_rate.scores = ['absorption']
    fuel_therm_abs_rate.filters = [
        openmc.EnergyFilter([0., 0.625]),
        openmc.CellFilter([fuel_cell])
    ]
    tallies_file.append(fuel_therm_abs_rate)

    # Fast Fission Factor tallies
    therm_fiss_rate = openmc.Tally(name='therm. fiss. rate')
    therm_fiss_rate.scores = ['nu-fission']
    therm_fiss_rate.filters = [openmc.EnergyFilter([0., 0.625])]
    tallies_file.append(therm_fiss_rate)

    tallies_file.export_to_xml()

    #############################
    ###       PLOTTING        ###
    #############################
    p = openmc.Plot()
    p.filename = 'pinplot'
    p.width = (2 * pitch, 2 * pitch)
    p.pixels = (200, 200)
    p.color_by = 'material'
    p.colors = {homogeneous_fuel: 'yellow', sodium: 'grey'}

    plots = openmc.Plots([p])
    plots.export_to_xml()

    # openmc.plot_geometry(output = False)
    openmc.plot_geometry()
    pngstring = 'pinplot{}.png'.format(str(pitch))
    subprocess.call(['convert', 'pinplot.ppm', pngstring])
    subprocess.call(['mv', pngstring, 'figures/' + pngstring])

    #############################
    ###       EXECUTION       ###
    #############################
    # openmc.run(output=False)
    openmc.run()
    sp = openmc.StatePoint('statepoint.{}.h5'.format(settings.batches))
    # Collect all the tallies
    fiss_rate = sp.get_tally(name='fiss. rate')
    fiss_rate_df = fiss_rate.get_pandas_dataframe()
    abs_rate = sp.get_tally(name='abs. rate')
    abs_rate_df = abs_rate.get_pandas_dataframe()
    therm_abs_rate = sp.get_tally(name='therm. abs. rate')
    therm_abs_rate_df = therm_abs_rate.get_pandas_dataframe()
    fuel_therm_abs_rate = sp.get_tally(name='fuel therm. abs. rate')
    fuel_therm_abs_rate_df = fuel_therm_abs_rate.get_pandas_dataframe()
    therm_fiss_rate = sp.get_tally(name='therm. fiss. rate')
    therm_fiss_rate_df = therm_fiss_rate.get_pandas_dataframe()

    # Compute k-infinity
    kinf = fiss_rate / abs_rate
    kinf_df = kinf.get_pandas_dataframe()

    # Compute resonance escape probability
    res_esc = (therm_abs_rate) / (abs_rate)
    res_esc_df = res_esc.get_pandas_dataframe()

    # Compute fast fission factor
    fast_fiss = fiss_rate / therm_fiss_rate
    fast_fiss_df = fast_fiss.get_pandas_dataframe()

    # Compute thermal flux utilization
    therm_util = fuel_therm_abs_rate / therm_abs_rate
    therm_util_df = therm_util.get_pandas_dataframe()

    # Compute neutrons produced per absorption
    eta = therm_fiss_rate / fuel_therm_abs_rate
    eta_df = eta.get_pandas_dataframe()

    columns = [
        'pitch', 'enrichment', 'kinf mean', 'kinf sd', 'res_esc mean',
        'res_esc sd', 'fast_fiss mean', 'fast_fiss sd', 'therm_util mean',
        'therm_util sd', 'eta mean', 'eta sd'
    ]
    data = [[
        pitch, enrichment, kinf_df['mean'][0], kinf_df['std. dev.'][0],
        res_esc_df['mean'][0], res_esc_df['std. dev.'][0],
        fast_fiss_df['mean'][0], fast_fiss_df['std. dev.'][0],
        therm_util_df['mean'][0], therm_util_df['std. dev.'][0],
        eta_df['mean'][0], eta_df['std. dev.'][0]
    ]]
    all_tallies = pd.DataFrame(data, columns=columns)

    return all_tallies