Esempio n. 1
0
def model_surf(request):
    # Select random distance and source energy
    x = uniform(50., 100.)
    E = uniform(0., 20.0e6)

    # Create model
    model = openmc.Model()
    mat = openmc.Material()
    mat.add_nuclide('Zr90', 1.0)
    mat.set_density('g/cm3', 1.0)
    model.materials.append(mat)
    left = openmc.XPlane(-1., boundary_type='vacuum')
    black_surface = openmc.XPlane(x, boundary_type='vacuum')
    right = openmc.XPlane(x + 1)
    void_cell = openmc.Cell(region=+left & -black_surface)
    black_cell = openmc.Cell(region=+black_surface & -right)
    model.geometry = openmc.Geometry([void_cell, black_cell])
    model.settings = openmc.Settings()
    model.settings.run_mode = 'fixed source'
    model.settings.particles = 1000
    model.settings.batches = 20
    particle = request.param
    model.settings.source = openmc.Source(
        space=openmc.stats.Point((0., 0., 0.)),
        angle=openmc.stats.Monodirectional([1., 0., 0.]),
        energy=openmc.stats.Discrete([E], [1.0]),
        particle=particle)

    # Calculate time it will take neutrons to reach purely-absorbing surface
    t0 = time(particle, x, E)

    # Create tally with surface and time filters
    tally = openmc.Tally()
    tally.filters = [
        openmc.SurfaceFilter([black_surface]),
        openmc.TimeFilter([0.0, t0 * 0.999, t0 * 1.001, 100.0])
    ]
    tally.scores = ['current']
    model.tallies.append(tally)
    return model
Esempio n. 2
0
def shield(rad, bool, outer, m_batches, m_error, neutrons):

    #MATERIALS#

    min = 1
    max = outer

    R1 = rad[0]
    R2 = rad[1]

    mats = openmc.Materials()

    tungsten = openmc.Material(name='Tungsten')
    tungsten.set_density('g/cm3', 19.0)
    tungsten.add_element('W', 1.0)
    mats.append(tungsten)

    water = openmc.Material(name='Water')
    water.set_density('g/cm3', 1.0)
    water.add_element('H', 2.0)
    water.add_element('O', 1.0)
    mats.append(water)

    eurofer = openmc.Material(name='EUROFER97')
    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.append(eurofer)

    boron = openmc.Material(name='Boron')
    boron.set_density('g/cm3', 2.37)
    boron.add_element('B', 1.0)
    mats.append(boron)

    #GEOMETRY#

    sphere1 = openmc.Sphere(R=min)
    sphere2 = openmc.Sphere(R=R1)
    sphere3 = openmc.Sphere(R=R2)
    sphere4 = openmc.Sphere(R=max)
    sphere5 = openmc.Sphere(R=15)
    sphere6 = openmc.Sphere(R=17, boundary_type='vacuum')

    vac1 = -sphere1
    mat1 = +sphere1 & -sphere2
    mat2 = +sphere2 & -sphere3
    mat3 = +sphere3 & -sphere4
    vac2 = +sphere4 & -sphere5
    steel = +sphere5 & -sphere6
    vac3 = +sphere6

    vacuum1 = openmc.Cell(region=vac1)
    first = openmc.Cell(region=mat1)
    first.fill = tungsten
    second = openmc.Cell(region=mat2)
    second.fill = water
    third = openmc.Cell(region=mat3)
    third.fill = tungsten
    vacuum2 = openmc.Cell(region=vac2)
    vessel = openmc.Cell(region=steel)
    vessel.fill = boron
    vacuum3 = openmc.Cell(region=vac3)

    root = openmc.Universe(cells=(vacuum1, first, second, third, vacuum2,
                                  vessel, vacuum3))
    geom = openmc.Geometry(root)

    #SETTINGS#

    batch = 2
    max_batches = m_batches
    inactive = 1
    particles = neutrons

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

    sett = openmc.Settings()
    sett.batches = batch
    sett.trigger_active = True
    sett.trigger_max_batches = m_batches
    sett.inactive = inactive
    sett.particles = particles
    sett.output = {'tallies': False}
    sett.run_mode = 'fixed source'
    sett.source = source

    #TALLIES#

    tallies = openmc.Tallies()

    filter = openmc.SurfaceFilter(sphere6)

    tally = openmc.Tally(name='leakage')
    tally.scores = ['current']
    tally.filters = [filter]
    trigger = openmc.Trigger('rel_err', m_error / 100)
    tally.triggers = [trigger]
    tallies.append(tally)

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

    #RUN#

    model.run(output=bool)

    #PLOT#

    #plots = openmc.Plots()

    #plot = openmc.Plot()
    #plot.basis = 'xz'
    #plot.origin = (0, 0, 0)
    #plot.width = (200, 200)
    #plot.pixels = (400, 400)
    #plot.color_by = 'material'
    #plot.colors = {tungsten: 'black', water: 'blue'}
    #plots.append(plot)

    #plots.export_to_xml()

    for i in reversed(range(batch, max_batches + 1)):
        filename = 'statepoint.' + str(i).zfill(len(str(max_batches))) + '.h5'
        if os.path.isfile(filename):
            sp = openmc.StatePoint(filename)
            break

    #print('file:',filename)
    leakage = sp.get_tally(name='leakage')
    leakage_mean = leakage.mean[0][0][0]
    leakage_error = leakage.std_dev[0][0][0]
    #print(leakage_mean)
    #print(leakage_error)

    dir = '/home/emiralle/shield_git'
    for zippath in glob.iglob(os.path.join(dir, '*.h5')):
        os.remove(zippath)

    return leakage_mean * 100, leakage_error * 100
Esempio n. 3
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
Esempio n. 4
0
def make_geometry_tallies(batches, nps, inner_radius, thickness):

    first_wall_inner_surface = openmc.Sphere(r=inner_radius)
    first_wall_outer_surface = openmc.Sphere(r=inner_radius + thickness,
                                             boundary_type='vacuum')

    first_wall = +first_wall_inner_surface & -first_wall_outer_surface
    first_wall = openmc.Cell(region=first_wall)
    first_wall.fill = eurofer

    inner_vac_cell = -first_wall_inner_surface
    inner_vac_cell = openmc.Cell(region=inner_vac_cell)

    universe = openmc.Universe(cells=[first_wall, inner_vac_cell])
    geom = openmc.Geometry(universe)

    geom.export_to_xml('geometry')

    vox_plot = openmc.Plot()
    vox_plot.type = 'voxel'
    vox_plot.width = (15, 15, 15)
    vox_plot.pixels = (200, 200, 200)
    vox_plot.filename = 'plot_3d'
    vox_plot.color_by = 'material'
    vox_plot.colors = {eurofer: 'blue'}
    plots = openmc.Plots([vox_plot])
    plots.export_to_xml()

    openmc.plot_geometry()

    os.system('openmc-voxel-to-vtk plot_3d.h5 -o plot_3d.vti')
    os.system('paraview plot_3d.vti')

    sett = openmc.Settings()
    sett.batches = batches
    sett.inactive = 0
    sett.particles = nps
    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([14.08e6], [1])
    #source.energy = openmc.stats.Muir(e0=14080000.0, m_rat=5.0, kt=20000.0)
    sett.source = source

    sett.export_to_xml('settings.xml')

    #tallies
    particle_filter = openmc.ParticleFilter([1])
    surface_filter_front = openmc.SurfaceFilter(first_wall_inner_surface)
    surface_filter_rear = openmc.SurfaceFilter(first_wall_outer_surface)
    bins = openmc.mgxs.GROUP_STRUCTURES['VITAMIN-J-175']
    #think will need to change this
    energy_filter = openmc.EnergyFilter(bins)

    tallies = openmc.Tallies()

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

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

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

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

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

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

    #we want to retrieve our tallies, but we now want to save them in a .json file
    #therefore, we setup the json file to recieve the tally data
    #for now, we will simply get the json file to get the neutron current
    #first, we specify the 'general' parameters about the setup that we want the .json file to recieve

    json_output = {'inner_radius': inner_radius, 'thickness': thickness}

    #i.e. these are the general parameters about the setup that we want the json file to recieve

    #however, we also want the json file to retrieve the data from the tallies

    #first, we want to retrieve the neutron current at the inner and outer surfaces
    tallies_to_retrieve = [
        'incident_neutron_current', 'leakage_neutron_current'
    ]
    for tally_name in tallies_to_retrieve:
        tally = sp.get_tally(name=tally_name)

        df = tally.get_pandas_dataframe()
        #defining something that stands for dataframe, need to investigate this
        #its basically something that we use to obtain the mean value and the std deviation value of the tally
        tally_result = df['mean'].sum()
        tally_std_dev = df['std. dev.'].sum()

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

    #next we wnat to retrieve the neutron spectra data at the inner and outer surfaces of the shell

    spectra_tallies_to_retrieve = [
        'incident_neutron_spectrum', 'leakage_neutron_spectrum'
    ]
    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
        ]
        #print(spectra_tally_result)

    return json_output
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
sett.inactive = 0  # the default is 10, which would be wasted computing for us
sett.particles = 600
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
sett.photon_transport = True  # This line is required to switch on photons tracking

# setup the  filters for the tallies
photon_particle_filter = openmc.ParticleFilter(
    ['photon'])  # This line adds a particle filter for photons
surface_filter = openmc.SurfaceFilter(
    vessel_rear_surface)  # detects particles across a surface
cell_filter = openmc.CellFilter(
    blanket_cell)  # detects particles across a cell / volume
energy_bins = openmc.mgxs.GROUP_STRUCTURES['CCFE-709']
energy_filter = openmc.EnergyFilter(energy_bins)
spectra_tally = openmc.Tally(name='energy_spectra')
spectra_tally.scores = ['flux']
spectra_tally.filters = [cell_filter, photon_particle_filter, energy_filter]

tallies = openmc.Tallies()
tallies.append(spectra_tally)

# combine all the required parts to make a model
model = openmc.model.Model(geom, mats, sett, tallies)
# Run OpenMC!
results_filename = model.run()
Esempio n. 7
0
    def _build_inputs(self):
        # Instantiate some Materials and register the appropriate Nuclides
        uo2 = openmc.Material(name='UO2 fuel at 2.4% wt enrichment')
        uo2.set_density('g/cc', 10.0)
        uo2.add_nuclide('U238', 1.0)
        uo2.add_nuclide('U235', 0.02)
        uo2.add_nuclide('O16', 2.0)

        borated_water = openmc.Material(name='Borated water')
        borated_water.set_density('g/cm3', 1)
        borated_water.add_nuclide('B10', 10e-5)
        borated_water.add_nuclide('H1', 2.0)
        borated_water.add_nuclide('O16', 1.0)

        # Instantiate a Materials collection and export to XML
        materials_file = openmc.Materials([uo2, borated_water])
        materials_file.export_to_xml()

        # Instantiate ZCylinder surfaces
        fuel_or = openmc.ZCylinder(surface_id=1,
                                   x0=0,
                                   y0=0,
                                   r=1,
                                   name='Fuel OR')
        left = openmc.XPlane(surface_id=2, x0=-2, name='left')
        right = openmc.XPlane(surface_id=3, x0=2, name='right')
        bottom = openmc.YPlane(y0=-2, name='bottom')
        top = openmc.YPlane(y0=2, name='top')

        left.boundary_type = 'vacuum'
        right.boundary_type = 'reflective'
        top.boundary_type = 'reflective'
        bottom.boundary_type = 'reflective'

        # Instantiate Cells
        fuel = openmc.Cell(name='fuel')
        water = openmc.Cell(name='water')

        # Use surface half-spaces to define regions
        fuel.region = -fuel_or
        water.region = +fuel_or & -right & +bottom & -top

        # Register Materials with Cells
        fuel.fill = uo2
        water.fill = borated_water

        # Instantiate pin cell Universe
        pin_cell = openmc.Universe(name='pin cell')
        pin_cell.add_cells([fuel, water])

        # Instantiate root Cell and Universe
        root_cell = openmc.Cell(name='root cell')
        root_cell.region = +left & -right & +bottom & -top
        root_cell.fill = pin_cell
        root_univ = openmc.Universe(universe_id=0, name='root universe')
        root_univ.add_cell(root_cell)

        # Instantiate a Geometry, register the root Universe
        geometry = openmc.Geometry(root_univ)
        geometry.export_to_xml()

        # Instantiate a Settings object, set all runtime parameters
        settings_file = openmc.Settings()
        settings_file.batches = 10
        settings_file.inactive = 0
        settings_file.particles = 1000
        #settings_file.output = {'tallies': True}

        # Create an initial uniform spatial source distribution
        bounds = [-0.62992, -0.62992, -1, 0.62992, 0.62992, 1]
        uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:],\
             only_fissionable=True)
        settings_file.source = openmc.source.Source(space=uniform_dist)
        settings_file.export_to_xml()

        # Tallies file
        tallies_file = openmc.Tallies()

        # Create partial current tallies from fuel to water
        # Filters
        two_groups = [0., 4e6, 20e6]
        energy_filter = openmc.EnergyFilter(two_groups)
        polar_filter = openmc.PolarFilter([0, np.pi / 4, np.pi])
        azimuthal_filter = openmc.AzimuthalFilter([0, np.pi / 4, np.pi])
        surface_filter = openmc.SurfaceFilter([1])
        cell_from_filter = openmc.CellFromFilter(fuel)
        cell_filter = openmc.CellFilter(water)

        # Use Cell to cell filters for partial current
        cell_to_cell_tally = openmc.Tally(name=str('fuel_to_water_1'))
        cell_to_cell_tally.filters = [cell_from_filter, cell_filter, \
             energy_filter, polar_filter, azimuthal_filter]
        cell_to_cell_tally.scores = ['current']
        tallies_file.append(cell_to_cell_tally)

        # Use a Cell from + surface filters for partial current
        cell_to_cell_tally = openmc.Tally(name=str('fuel_to_water_2'))
        cell_to_cell_tally.filters = [cell_from_filter, surface_filter, \
             energy_filter, polar_filter, azimuthal_filter]
        cell_to_cell_tally.scores = ['current']
        tallies_file.append(cell_to_cell_tally)

        # Create partial current tallies from water to fuel
        # Filters
        cell_from_filter = openmc.CellFromFilter(water)
        cell_filter = openmc.CellFilter(fuel)

        # Cell to cell filters for partial current
        cell_to_cell_tally = openmc.Tally(name=str('water_to_fuel_1'))
        cell_to_cell_tally.filters = [cell_from_filter, cell_filter, \
             energy_filter, polar_filter, azimuthal_filter]
        cell_to_cell_tally.scores = ['current']
        tallies_file.append(cell_to_cell_tally)

        # Cell from + surface filters for partial current
        cell_to_cell_tally = openmc.Tally(name=str('water_to_fuel_2'))
        cell_to_cell_tally.filters = [cell_from_filter, surface_filter, \
             energy_filter, polar_filter, azimuthal_filter]
        cell_to_cell_tally.scores = ['current']
        tallies_file.append(cell_to_cell_tally)

        # Create a net current tally on inner surface using a surface filter
        surface_filter = openmc.SurfaceFilter([1])
        surf_tally1 = openmc.Tally(name='net_cylinder')
        surf_tally1.filters = [surface_filter, energy_filter, polar_filter, \
             azimuthal_filter]
        surf_tally1.scores = ['current']
        tallies_file.append(surf_tally1)

        # Create a net current tally on left surface using a surface filter
        # This surface has a vacuum boundary condition, so leakage is tallied
        surface_filter = openmc.SurfaceFilter([2])
        surf_tally2 = openmc.Tally(name='leakage_left')
        surf_tally2.filters = [surface_filter, energy_filter, polar_filter, \
            azimuthal_filter]
        surf_tally2.scores = ['current']
        tallies_file.append(surf_tally2)

        # Create a net current tally on right surface using a surface filter
        # This surface has a reflective boundary condition, so the net current
        # should be zero.
        surface_filter = openmc.SurfaceFilter([3])
        surf_tally3 = openmc.Tally(name='net_right')
        surf_tally3.filters = [surface_filter, energy_filter]
        surf_tally3.scores = ['current']
        tallies_file.append(surf_tally3)

        surface_filter = openmc.SurfaceFilter([3])
        surf_tally3 = openmc.Tally(name='net_right')
        surf_tally3.filters = [surface_filter, energy_filter]
        surf_tally3.scores = ['current']
        tallies_file.append(surf_tally3)

        tallies_file.export_to_xml()
Esempio n. 8
0
def make_geometry_tallies(batches, nps, enrichment_fraction, inner_radius,
                          thickness, breeder_material_name, temperature_in_C):
    #print('simulating ',batches,enrichment_fraction,inner_radius,thickness,breeder_material_name)

    #MATERIALS#
    breeder_material = make_breeder_materials(enrichment_fraction,
                                              breeder_material_name,
                                              temperature_in_C)
    eurofer = make_eurofer()
    copper = make_copper()
    mats = openmc.Materials([breeder_material, eurofer, copper])
    mats.export_to_xml('materials.xml')

    #GEOMETRY#

    central_sol_surface = openmc.ZCylinder(R=100)
    central_shield_outer_surface = openmc.ZCylinder(R=110)
    first_wall_inner_surface = openmc.Sphere(R=inner_radius)
    first_wall_outer_surface = openmc.Sphere(R=inner_radius + 10)
    breeder_blanket_outer_surface = openmc.Sphere(R=inner_radius + 10.0 +
                                                  thickness)
    vessel_outer_surface = openmc.Sphere(R=inner_radius + 10.0 + thickness +
                                         10.0,
                                         boundary_type='vacuum')

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

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

    inner_void_region = -first_wall_inner_surface & +central_shield_outer_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 & +central_shield_outer_surface
    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 & +central_shield_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 = eurofer

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

    #plt.show(universe.plot(width=(1500,1500),basis='xz'))

    geom = openmc.Geometry(universe)
    # geom.export_to_xml('geometry.xml')

    #SIMULATION SETTINGS#

    sett = openmc.Settings()
    sett.batches = batches
    sett.inactive = 1
    sett.particles = nps
    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])
    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

    sett.export_to_xml('settings.xml')

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

    #TALLIES#
    tallies = openmc.Tallies()

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

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

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

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

    tally = openmc.Tally(name='front_neutron_spectra')
    tally.filters = [surface_filter_front, particle_filter, energy_filter]
    tally.scores = ['flux']
    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()

    #RETRIEVING TALLY RESULTS

    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)
        tally_result = tally.sum[0][0][
            0] / batches  #for some reason the tally sum is a nested list
        tally_std_dev = tally.std_dev[0][0][
            0] / batches  #for some reason the tally std_dev is a nested list

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

    spectra_tallies_to_retrieve = [
        'front_neutron_spectra', 'breeder_blanket_spectra',
        'vacuum_vessel_spectra', 'rear_neutron_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
def get_neutron_spectrum_from_plasma(plasma_temperature=14080000.0):

    # MATERIALS (there are none in this model)

    mats = openmc.Materials([])

    # GEOMETRY

    # surfaces
    inner_surface = openmc.Sphere(r=100)
    outer_surface = openmc.Sphere(r=101, boundary_type='vacuum')

    # cells
    inner_cell = openmc.Cell(region=-inner_surface)
    # this is filled with a void / vauum by default

    outer_cell = openmc.Cell(region=+inner_surface & -outer_surface)
    # this is filled with a void / vauum by default

    universe = openmc.Universe(cells=[inner_cell, outer_cell])
    geom = openmc.Geometry(universe)

    # SIMULATION SETTINGS

    # Instantiate a Settings object
    sett = openmc.Settings()
    sett.batches = 20
    sett.inactive = 0  # the default is 10, which would be wasted computing for us
    sett.particles = 500000
    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.Muir(kt=plasma_temperature)
    sett.source = source

    # setup the  filters for the tallies
    neutron_particle_filter = openmc.ParticleFilter(['neutron'])
    surface_filter = openmc.SurfaceFilter(
        inner_surface)  # detects particles across a surface

    energy_filter = openmc.EnergyFilter(energy_bins)
    spectra_tally = openmc.Tally(name='energy_spectra')
    spectra_tally.scores = ['current']
    spectra_tally.filters = [
        surface_filter, neutron_particle_filter, energy_filter
    ]

    tallies = openmc.Tallies()
    tallies.append(spectra_tally)

    # combine all the required parts to make a model
    model = openmc.model.Model(geom, mats, sett, tallies)
    # Run OpenMC!
    results_filename = model.run()

    # open the results file
    results = openmc.StatePoint(results_filename)

    #extracts the tally values from the simulation results
    surface_tally = results.get_tally(name='energy_spectra')
    surface_tally = surface_tally.get_pandas_dataframe()
    surface_tally_values = surface_tally['mean']

    return surface_tally_values
Esempio n. 10
0
    def _make_openmc_input(self):
        """Generate the OpenMC input XML

        """
        # Define material
        mat = openmc.Material()
        for nuclide, fraction in self.nuclides:
            mat.add_nuclide(nuclide, fraction)
        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')

        # Instantiate surfaces
        cyl = openmc.XCylinder(boundary_type='vacuum', r=1.e-6)
        px1 = openmc.XPlane(boundary_type='vacuum', x0=-1.)
        px2 = openmc.XPlane(boundary_type='transmission', x0=1.)
        px3 = openmc.XPlane(boundary_type='vacuum', x0=1.e9)

        # Instantiate cells
        inner_cyl_left = openmc.Cell()
        inner_cyl_right = openmc.Cell()
        outer_cyl = openmc.Cell()

        # Set cells regions and materials
        inner_cyl_left.region = -cyl & +px1 & -px2
        inner_cyl_right.region = -cyl & +px2 & -px3
        outer_cyl.region = ~(-cyl & +px1 & -px3)
        inner_cyl_right.fill = mat

        # Create root universe and export to XML
        geometry = openmc.Geometry(
            [inner_cyl_left, inner_cyl_right, outer_cyl])
        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.Monodirectional()
        source.energy = openmc.stats.Discrete([self.energy], [1.])
        source.particle = 'neutron'

        # 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.photon_transport = True
        settings.electron_treatment = self.electron_treatment
        settings.cutoff = {'energy_photon': self._cutoff_energy}
        settings.export_to_xml(self.openmc_dir / 'settings.xml')

        # Define filters
        surface_filter = openmc.SurfaceFilter(cyl)
        particle_filter = openmc.ParticleFilter('photon')
        energy_bins = np.logspace(np.log10(self._cutoff_energy),
                                  np.log10(self.max_energy), self._bins + 1)
        energy_filter = openmc.EnergyFilter(energy_bins)

        # Create tallies and export to XML
        tally = openmc.Tally(name='tally')
        tally.filters = [surface_filter, energy_filter, particle_filter]
        tally.scores = ['current']
        tallies = openmc.Tallies([tally])
        tallies.export_to_xml(self.openmc_dir / 'tallies.xml')
Esempio n. 11
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 nuclide, fraction in self.nuclides:
            mat.add_nuclide(nuclide, fraction)
        mat.set_density('g/cm3', self.density)
        materials = openmc.Materials([mat])
        materials.export_to_xml(os.path.join('openmc', 'materials.xml'))

        # Instantiate surfaces
        cyl = openmc.XCylinder(boundary_type='vacuum', R=1.e-6)
        px1 = openmc.XPlane(boundary_type='vacuum', x0=-1.)
        px2 = openmc.XPlane(boundary_type='transmission', x0=1.)
        px3 = openmc.XPlane(boundary_type='vacuum', x0=1.e9)

        # Instantiate cells
        inner_cyl_left = openmc.Cell()
        inner_cyl_right = openmc.Cell()
        outer_cyl = openmc.Cell()

        # Set cells regions and materials
        inner_cyl_left.region = -cyl & +px1 & -px2
        inner_cyl_right.region = -cyl & +px2 & -px3
        outer_cyl.region = ~(-cyl & +px1 & -px3)
        inner_cyl_right.fill = mat

        # Create root universe and export to XML
        geometry = openmc.Geometry(
            [inner_cyl_left, inner_cyl_right, outer_cyl])
        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.Monodirectional()
        source.energy = openmc.stats.Discrete([self.energy], [1.])
        source.particle = 'neutron'

        # 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 filters
        surface_filter = openmc.SurfaceFilter(cyl)
        particle_filter = openmc.ParticleFilter('photon')
        energy_bins = np.logspace(3, np.log10(2 * self.energy), 500)
        energy_filter = openmc.EnergyFilter(energy_bins)

        # Create tallies and export to XML
        tally = openmc.Tally(name='photon current')
        tally.filters = [surface_filter, energy_filter, particle_filter]
        tally.scores = ['current']
        tallies = openmc.Tallies([tally])
        tallies.export_to_xml(os.path.join('openmc', 'tallies.xml'))
Esempio n. 12
0
    def _build_inputs(self):
        mat = openmc.Material()
        mat.set_density('g/cm3', 2.6989)
        mat.add_nuclide('Al27', 1.0)
        materials = openmc.Materials([mat])
        materials.export_to_xml()

        cyl = openmc.XCylinder(r=1.0, boundary_type='vacuum')
        x_plane_left = openmc.XPlane(-1.0, 'vacuum')
        x_plane_center = openmc.XPlane(1.0)
        x_plane_right = openmc.XPlane(1.0e9, 'vacuum')

        inner_cyl_left = openmc.Cell()
        inner_cyl_right = openmc.Cell()
        outer_cyl = openmc.Cell()

        inner_cyl_left.region = -cyl & +x_plane_left & -x_plane_center
        inner_cyl_right.region = -cyl & +x_plane_center & -x_plane_right
        outer_cyl.region = ~(-cyl & +x_plane_left & -x_plane_right)
        inner_cyl_right.fill = mat
        geometry = openmc.Geometry(
            [inner_cyl_left, inner_cyl_right, outer_cyl])
        geometry.export_to_xml()

        source = openmc.Source()
        source.space = openmc.stats.Point((0, 0, 0))
        source.angle = openmc.stats.Monodirectional()
        source.energy = openmc.stats.Discrete([14.0e6], [1.0])
        source.particle = 'neutron'

        settings = openmc.Settings()
        settings.particles = 10000
        settings.run_mode = 'fixed source'
        settings.batches = 1
        settings.photon_transport = True
        settings.electron_treatment = 'ttb'
        settings.cutoff = {'energy_photon': 1000.0}
        settings.source = source
        settings.export_to_xml()

        surface_filter = openmc.SurfaceFilter(cyl)
        particle_filter = openmc.ParticleFilter('photon')
        current_tally = openmc.Tally()
        current_tally.filters = [surface_filter, particle_filter]
        current_tally.scores = ['current']
        tally_tracklength = openmc.Tally()
        tally_tracklength.filters = [particle_filter]
        tally_tracklength.scores = ['total', 'heating']
        tally_tracklength.nuclides = ['Al27', 'total']
        tally_tracklength.estimator = 'tracklength'
        tally_collision = openmc.Tally()
        tally_collision.filters = [particle_filter]
        tally_collision.scores = ['total', 'heating']
        tally_collision.nuclides = ['Al27', 'total']
        tally_collision.estimator = 'collision'
        tally_analog = openmc.Tally()
        tally_analog.filters = [particle_filter]
        tally_analog.scores = ['total', 'heating']
        tally_analog.nuclides = ['Al27', 'total']
        tally_analog.estimator = 'analog'
        tallies = openmc.Tallies(
            [current_tally, tally_tracklength, tally_collision, tally_analog])
        tallies.export_to_xml()
Esempio n. 13
0
g.root_universe = root
g.export_to_xml()

# data/control section
settings = openmc.Settings()
settings.run_mode = 'fixed source'

settings.batches = 50
# even for fixed source problems you need batches
settings.particles = 10000

source = openmc.Source()
source.particle = 'neutron'
source.space = openmc.stats.Point(xyz=(0., 0., 0.))
# default is the origin
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([1.0e6], [1.0])
settings.source = source

settings.export_to_xml()

t = openmc.Tally(name='sphere')
s_filter = openmc.SurfaceFilter(sphere.id)
t.filters = [s_filter]
t.scores = ['flux']

tallies = openmc.Tallies([t])
tallies.export_to_xml()

openmc.run()
Esempio n. 14
0
def model():
    model = openmc.model.Model()
    mat = openmc.Material()
    mat.set_density('g/cm3', 2.6989)
    mat.add_nuclide('Al27', 1.0)
    model.materials.append(mat)

    cyl = openmc.XCylinder(r=1.0, boundary_type='vacuum')
    x_plane_left = openmc.XPlane(-1.0, boundary_type='vacuum')
    x_plane_center = openmc.XPlane(1.0)
    x_plane_right = openmc.XPlane(1.0e9, boundary_type='vacuum')

    inner_cyl_left = openmc.Cell()
    inner_cyl_right = openmc.Cell()
    outer_cyl = openmc.Cell()

    inner_cyl_left.region = -cyl & +x_plane_left & -x_plane_center
    inner_cyl_right.region = -cyl & +x_plane_center & -x_plane_right
    outer_cyl.region = ~(-cyl & +x_plane_left & -x_plane_right)
    inner_cyl_right.fill = mat
    model.geometry = openmc.Geometry(
        [inner_cyl_left, inner_cyl_right, outer_cyl])

    source = openmc.Source()
    source.space = openmc.stats.Point((0, 0, 0))
    source.angle = openmc.stats.Monodirectional()
    source.energy = openmc.stats.Discrete([14.0e6], [1.0])
    source.particle = 'neutron'

    model.settings.particles = 10000
    model.settings.run_mode = 'fixed source'
    model.settings.batches = 1
    model.settings.photon_transport = True
    model.settings.electron_treatment = 'ttb'
    model.settings.cutoff = {'energy_photon': 1000.0}
    model.settings.source = source

    surface_filter = openmc.SurfaceFilter(cyl)
    particle_filter = openmc.ParticleFilter(
        ['neutron', 'photon', 'electron', 'positron'])
    current_tally = openmc.Tally()
    current_tally.filters = [surface_filter, particle_filter]
    current_tally.scores = ['current']
    tally_tracklength = openmc.Tally()
    tally_tracklength.filters = [particle_filter]
    tally_tracklength.scores = ['total', '(n,gamma)'
                                ]  # heating doesn't work with tracklength
    tally_tracklength.nuclides = ['Al27', 'total']
    tally_tracklength.estimator = 'tracklength'
    tally_collision = openmc.Tally()
    tally_collision.filters = [particle_filter]
    tally_collision.scores = ['total', 'heating', '(n,gamma)']
    tally_collision.nuclides = ['Al27', 'total']
    tally_collision.estimator = 'collision'
    tally_analog = openmc.Tally()
    tally_analog.filters = [particle_filter]
    tally_analog.scores = ['total', 'heating', '(n,gamma)']
    tally_analog.nuclides = ['Al27', 'total']
    tally_analog.estimator = 'analog'
    model.tallies.extend(
        [current_tally, tally_tracklength, tally_collision, tally_analog])

    return model