Ejemplo n.º 1
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
Ejemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        super(FilterEnergyFunHarness, self).__init__(*args, **kwargs)

        # Add Am241 to the fuel.
        self._model.materials[1].add_nuclide('Am241', 1e-7)

        # Define Am242m / Am242 branching ratio from ENDF/B-VII.1 data.
        x = [1e-5, 3.69e-1, 1e3, 1e5, 6e5, 1e6, 2e6, 4e6, 3e7]
        y = [0.1, 0.1, 0.1333, 0.158, 0.18467, 0.25618, 0.4297, 0.48, 0.48]

        # Make an EnergyFunctionFilter directly from the x and y lists.
        filt1 = openmc.EnergyFunctionFilter(x, y)

        # Also make a filter with the .from_tabulated1d constructor.  Make sure
        # the filters are identical.
        tab1d = openmc.data.Tabulated1D(x, y)
        filt2 = openmc.EnergyFunctionFilter.from_tabulated1d(tab1d)
        assert filt1 == filt2, 'Error with the .from_tabulated1d constructor'

        # Make tallies.
        tallies = [openmc.Tally(1), openmc.Tally(2)]
        for t in tallies:
            t.scores = ['(n,gamma)']
            t.nuclides = ['Am241']
        tallies[1].filters = [filt1]
        self._model.tallies = tallies
Ejemplo n.º 3
0
def model():
    model = openmc.model.Model()

    m = openmc.Material()
    m.set_density('g/cm3', 10.0)
    m.add_nuclide('Am241', 1.0)
    model.materials.append(m)

    s = openmc.Sphere(r=100.0, boundary_type='vacuum')
    c = openmc.Cell(fill=m, region=-s)
    model.geometry = openmc.Geometry([c])

    model.settings.batches = 5
    model.settings.inactive = 0
    model.settings.particles = 1000

    # Define Am242m / Am242 branching ratio from ENDF/B-VII.1 data.
    x = [1e-5, 3.69e-1, 1e3, 1e5, 6e5, 1e6, 2e6, 4e6, 3e7]
    y = [0.1, 0.1, 0.1333, 0.158, 0.18467, 0.25618, 0.4297, 0.48, 0.48]

    # Make an EnergyFunctionFilter directly from the x and y lists.
    filt1 = openmc.EnergyFunctionFilter(x, y)

    # Also make a filter with the .from_tabulated1d constructor.  Make sure
    # the filters are identical.
    tab1d = openmc.data.Tabulated1D(x, y)
    filt2 = openmc.EnergyFunctionFilter.from_tabulated1d(tab1d)
    assert filt1 == filt2, 'Error with the .from_tabulated1d constructor'

    # Make tallies
    tallies = [openmc.Tally(), openmc.Tally()]
    for t in tallies:
        t.scores = ['(n,gamma)']
        t.nuclides = ['Am241']
    tallies[1].filters = [filt1]
    model.tallies.extend(tallies)

    return model