コード例 #1
0
def pincell_model():
    """Set up a model to test with and delete files when done"""
    pincell = openmc.examples.pwr_pin_cell()

    # Add a tally
    filter1 = openmc.MaterialFilter(pincell.materials)
    filter2 = openmc.EnergyFilter([0.0, 1.0, 1.0e3, 20.0e6])
    mat_tally = openmc.Tally()
    mat_tally.filters = [filter1, filter2]
    mat_tally.nuclides = ['U235', 'U238']
    mat_tally.scores = ['total', 'elastic', '(n,gamma)']
    pincell.tallies.append(mat_tally)

    # Write XML files
    pincell.export_to_xml()

    yield

    # Delete generated files
    files = [
        'geometry.xml', 'materials.xml', 'settings.xml', 'tallies.xml',
        'statepoint.10.h5', 'summary.h5', 'test_sp.h5'
    ]
    for f in files:
        if os.path.exists(f):
            os.remove(f)
コード例 #2
0
ファイル: test_lib.py プロジェクト: NavalNuclearLab/openmc
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
コード例 #3
0
    def __init__(self, *args, **kwargs):
        super(TallyArithmeticTestHarness, self).__init__(*args, **kwargs)

        # Initialize Mesh
        mesh = openmc.Mesh(mesh_id=1)
        mesh.type = 'regular'
        mesh.dimension = [2, 2, 2]
        mesh.lower_left = [-160.0, -160.0, -183.0]
        mesh.upper_right = [160.0, 160.0, 183.0]

        # Initialize the filters
        energy_filter = openmc.EnergyFilter((0.0, 0.253e-6, 1.0e-3, 1.0, 20.0))
        material_filter = openmc.MaterialFilter((1, 3))
        distrib_filter = openmc.DistribcellFilter(60)
        mesh_filter = openmc.MeshFilter(mesh)

        # Initialized the tallies
        tally = openmc.Tally(name='tally 1')
        tally.filters = [material_filter, energy_filter, distrib_filter]
        tally.scores = ['nu-fission', 'total']
        tally.nuclides = ['U234', 'U235']
        self._model.tallies.append(tally)

        tally = openmc.Tally(name='tally 2')
        tally.filters = [energy_filter, mesh_filter]
        tally.scores = ['total', 'fission']
        tally.nuclides = ['U238', 'U235']
        self._model.tallies.append(tally)
コード例 #4
0
    def generate_tally_xml(self):
        """ Generates tally.xml.

        Using information from self.depletion_chain as well as the nuclides
        currently in the problem, this function automatically generates a
        tally.xml for the simulation.
        """

        nuc_set = set()

        # Create the set of all nuclides in the decay chain in cells marked for
        # burning in which the number density is greater than zero.
        for nuc in self.number.nuc_to_ind:
            if nuc in self.participating_nuclides:
                if np.sum(self.number[:, nuc]) > 0.0:
                    nuc_set.add(nuc)

        # Communicate which nuclides have nonzeros to rank 0
        if self.rank == 0:
            for i in range(1, self.size):
                nuc_newset = self.comm.recv(source=i, tag=i)
                for nuc in nuc_newset:
                    nuc_set.add(nuc)

            # Sort them in the same order as self.number
            nuc_list = []
            for nuc in self.number.nuc_to_ind:
                if nuc in nuc_set:
                    nuc_list.append(nuc)
        else:
            self.comm.send(nuc_set, dest=0, tag=self.rank)

        if self.rank == 0:
            # Create tallies for depleting regions
            tally_ind = 1
            mat_filter_dep = openmc.MaterialFilter(
                [int(i) for i in self.mat_tally_ind], filter_id=1)
            tallies_file = openmc.Tallies()

            # For each reaction in the chain, for each nuclide, and for each
            # cell, make a tally
            tally_dep = openmc.Tally(tally_id=tally_ind)
            for key in nuc_list:
                if key in self.chain.nuclide_dict:
                    tally_dep.nuclides.append(key)

            for reaction in self.chain.react_to_ind:
                tally_dep.scores.append(reaction)

            tallies_file.append(tally_dep)

            tally_dep.filters.append(mat_filter_dep)
            tallies_file.export_to_xml()
コード例 #5
0
def model():
    model = openmc.model.Model()

    fuel = openmc.Material()
    fuel.set_density('g/cm3', 10.0)
    fuel.add_nuclide('U234', 1.0)
    fuel.add_nuclide('U235', 4.0)
    fuel.add_nuclide('U238', 95.0)
    water = openmc.Material(name='light water')
    water.add_nuclide('H1', 2.0)
    water.add_nuclide('O16', 1.0)
    water.set_density('g/cm3', 1.0)
    water.add_s_alpha_beta('c_H_in_H2O')
    model.materials.extend([fuel, water])

    cyl1 = openmc.ZCylinder(r=5.0)
    cyl2 = openmc.ZCylinder(r=10.0, boundary_type='vacuum')
    cell1 = openmc.Cell(fill=fuel, region=-cyl1)
    cell2 = openmc.Cell(fill=water, region=+cyl1 & -cyl2)
    model.geometry = openmc.Geometry([cell1, cell2])

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

    mesh = openmc.RegularMesh()
    mesh.dimension = (2, 2)
    mesh.lower_left = (-10.0, -10.0)
    mesh.upper_right = (10.0, 10.0)
    energy_filter = openmc.EnergyFilter((0.0, 10.0, 20.0e6))
    material_filter = openmc.MaterialFilter((fuel, water))
    mesh_filter = openmc.MeshFilter(mesh)

    tally = openmc.Tally(name='tally 1')
    tally.filters = [material_filter, energy_filter]
    tally.scores = ['nu-fission', 'total']
    tally.nuclides = ['U234', 'U235']
    model.tallies.append(tally)
    tally = openmc.Tally(name='tally 2')
    tally.filters = [energy_filter, mesh_filter]
    tally.scores = ['total', 'fission']
    tally.nuclides = ['U238', 'U235']
    model.tallies.append(tally)

    return model
コード例 #6
0
    def _add_tally_for_every_material(self, sufix: str, score: str,
                                      additional_filters: List = None) -> None:
        """Adds a tally to self.tallies for every material.

        Arguments:
            sufix: the string to append to the end of the tally name to help
                identify the tally later.
            score: the openmc.Tally().scores value that contribute to the tally
        """
        if additional_filters is None:
            additional_filters = []
        for key, value in self.openmc_materials.items():
            if key != 'DT_plasma':
                material_filter = openmc.MaterialFilter(value)
                tally = openmc.Tally(name=key + '_' + sufix)
                tally.filters = [material_filter] + additional_filters
                tally.scores = [score]
                self.tallies.append(tally)
コード例 #7
0
def make_neutronics_model(
    reactor,
    firstwall_radial_thickness,
    firstwall_armour_material,
    firstwall_coolant_material,
    firstwall_structural_material,
    firstwall_armour_fraction,
    firstwall_coolant_fraction,
    firstwall_coolant_temperature_C,
    firstwall_coolant_pressure_Pa,
    firstwall_structural_fraction,
    blanket_rear_wall_coolant_material,
    blanket_rear_wall_structural_material,
    blanket_rear_wall_coolant_fraction,
    blanket_rear_wall_structural_fraction,
    blanket_rear_wall_coolant_temperature_C,
    blanket_rear_wall_coolant_pressure_Pa,
    blanket_lithium6_enrichment_percent,
    blanket_breeder_material,
    blanket_coolant_material,
    blanket_multiplier_material,
    blanket_structural_material,
    blanket_breeder_fraction,
    blanket_coolant_fraction,
    blanket_multiplier_fraction,
    blanket_structural_fraction,
    blanket_breeder_packing_fraction,
    blanket_multiplier_packing_fraction,
    blanket_coolant_temperature_C,
    blanket_coolant_pressure_Pa,
    blanket_breeder_temperature_C,
    blanket_breeder_pressure_Pa,
    divertor_coolant_fraction,
    divertor_structural_fraction,
    divertor_coolant_material,
    divertor_structural_material,
    divertor_coolant_temperature_C,
    divertor_coolant_pressure_Pa,
    center_column_shield_coolant_fraction,
    center_column_shield_structural_fraction,
    center_column_shield_coolant_material,
    center_column_shield_structural_material,
    center_column_shield_coolant_temperature_C,
    center_column_shield_coolant_pressure_Pa,
    inboard_tf_coils_conductor_fraction,
    inboard_tf_coils_coolant_fraction,
    inboard_tf_coils_structure_fraction,
    inboard_tf_coils_conductor_material,
    inboard_tf_coils_coolant_material,
    inboard_tf_coils_structure_material,
    inboard_tf_coils_coolant_temperature_C,
    inboard_tf_coils_coolant_pressure_Pa,
):
    """
    Makes and runs a simple OpenMC neutronics model with
    the materials with the same tags as the DAGMC neutronics
    geometry. The model also specifies the computational
    intensity (particles and batches) and the tally to record
    """
    input_parameters = locals()

    # this is the underlying geometry container that is filled with the faceteted CAD model
    universe = openmc.Universe()
    geom = openmc.Geometry(universe)

    center_column_shield_material = MultiMaterial(
        material_tag='center_column_shield_mat',
        materials=[
            Material(
                material_name=center_column_shield_coolant_material,
                temperature_in_C=center_column_shield_coolant_temperature_C,
                pressure_in_Pa=center_column_shield_coolant_pressure_Pa),
            Material(material_name=center_column_shield_structural_material)
        ],
        fracs=[
            center_column_shield_coolant_fraction,
            center_column_shield_structural_fraction
        ],
        percent_type='vo',
        packing_fraction=1.0).openmc_material

    firstwall_material = MultiMaterial(
        material_tag='firstwall_mat',
        materials=[
            Material(material_name=firstwall_coolant_material,
                     temperature_in_C=firstwall_coolant_temperature_C,
                     pressure_in_Pa=firstwall_coolant_pressure_Pa),
            Material(material_name=firstwall_structural_material),
            Material(material_name=firstwall_armour_material)
        ],
        fracs=[
            firstwall_coolant_fraction, firstwall_structural_fraction,
            firstwall_armour_fraction
        ],
        percent_type='vo',
        packing_fraction=1.0).openmc_material

    if blanket_multiplier_material == None and blanket_multiplier_fraction == None and blanket_multiplier_packing_fraction == None:

        blanket_material = MultiMaterial(
            material_tag='blanket_mat',
            materials=[
                Material(material_name=blanket_coolant_material,
                         temperature_in_C=blanket_coolant_temperature_C,
                         pressure_in_Pa=blanket_coolant_pressure_Pa),
                Material(material_name=blanket_structural_material),
                Material(material_name=blanket_breeder_material,
                         enrichment=blanket_lithium6_enrichment_percent,
                         packing_fraction=blanket_breeder_packing_fraction,
                         temperature_in_C=blanket_breeder_temperature_C,
                         pressure_in_Pa=blanket_breeder_pressure_Pa)
            ],
            fracs=[
                blanket_coolant_fraction, blanket_structural_fraction,
                blanket_breeder_fraction
            ],
            percent_type='vo',
            packing_fraction=1.0).openmc_material
    else:
        blanket_material = MultiMaterial(
            material_tag='blanket_mat',
            materials=[
                Material(material_name=blanket_coolant_material,
                         temperature_in_C=blanket_coolant_temperature_C,
                         pressure_in_Pa=blanket_coolant_pressure_Pa),
                Material(material_name=blanket_structural_material),
                Material(material_name=blanket_multiplier_material,
                         packing_fraction=blanket_multiplier_packing_fraction),
                Material(material_name=blanket_breeder_material,
                         enrichment=blanket_lithium6_enrichment_percent,
                         packing_fraction=blanket_breeder_packing_fraction,
                         temperature_in_C=blanket_breeder_temperature_C,
                         pressure_in_Pa=blanket_breeder_pressure_Pa)
            ],
            fracs=[
                blanket_coolant_fraction, blanket_structural_fraction,
                blanket_multiplier_fraction, blanket_breeder_fraction
            ],
            percent_type='vo',
            packing_fraction=1.0).openmc_material

    divertor_material = MultiMaterial(
        material_tag='divertor_mat',
        materials=[
            Material(material_name=divertor_coolant_material,
                     temperature_in_C=divertor_coolant_temperature_C,
                     pressure_in_Pa=divertor_coolant_pressure_Pa),
            Material(material_name=divertor_structural_material)
        ],
        fracs=[divertor_coolant_fraction, divertor_structural_fraction],
        percent_type='vo',
        packing_fraction=1.0).openmc_material

    inboard_tf_coils_material = MultiMaterial(
        material_tag='inboard_tf_coils_mat',
        materials=[
            Material(material_name=inboard_tf_coils_coolant_material,
                     temperature_in_C=inboard_tf_coils_coolant_temperature_C,
                     pressure_in_Pa=inboard_tf_coils_coolant_pressure_Pa),
            Material(material_name=inboard_tf_coils_conductor_material),
            Material(material_name=inboard_tf_coils_structure_material)
        ],
        fracs=[
            inboard_tf_coils_coolant_fraction,
            inboard_tf_coils_conductor_fraction,
            inboard_tf_coils_structure_fraction
        ],
        percent_type='vo',
        packing_fraction=1.0).openmc_material

    blanket_rear_wall_material = MultiMaterial(
        material_tag='blanket_rear_wall_mat',
        materials=[
            Material(material_name=blanket_rear_wall_coolant_material,
                     temperature_in_C=blanket_rear_wall_coolant_temperature_C,
                     pressure_in_Pa=blanket_rear_wall_coolant_pressure_Pa),
            Material(material_name=blanket_rear_wall_structural_material)
        ],
        fracs=[
            blanket_rear_wall_coolant_fraction,
            blanket_rear_wall_structural_fraction
        ],
        percent_type='vo',
        packing_fraction=1.0).openmc_material

    mats = openmc.Materials([
        center_column_shield_material, firstwall_material, blanket_material,
        divertor_material, inboard_tf_coils_material,
        blanket_rear_wall_material
    ])

    # settings for the number of neutrons to simulate
    settings = openmc.Settings()
    settings.batches = 10
    settings.inactive = 0
    settings.particles = 1000
    settings.run_mode = 'fixed source'
    settings.dagmc = True

    # details of the birth locations and energy of the neutronis
    source = openmc.Source()
    source.space = openmc.stats.Point((reactor['major_radius'], 0, 0))
    source.angle = openmc.stats.Isotropic()
    source.energy = openmc.stats.Discrete([14e6], [1])
    settings.source = source
    settings.photon_transport = True  # This line is required to switch on photons tracking

    # details about what neutrons interactions to keep track of (called a tally)
    tallies = openmc.Tallies()
    material_filter = openmc.MaterialFilter(blanket_material)
    tbr_tally = openmc.Tally(name='TBR')
    tbr_tally.filters = [material_filter]
    tbr_tally.scores = ['(n,Xt)']  # where X is a wild card
    tallies.append(tbr_tally)

    material_filter = openmc.MaterialFilter(
        [blanket_material, firstwall_material, blanket_rear_wall_material])
    blanket_heating_tally = openmc.Tally(name='blanket_heating')
    blanket_heating_tally.filters = [material_filter]
    blanket_heating_tally.scores = ['heating']
    tallies.append(blanket_heating_tally)

    # make the model from gemonetry, materials, settings and tallies
    model = openmc.model.Model(geom, mats, settings, tallies)

    # run the simulation
    output_filename = model.run()
    """
    Reads the output file from the neutronics simulation
    and prints the TBR tally result to screen
    """

    # open the results file
    sp = openmc.StatePoint(output_filename)

    # access TBR tally
    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()

    # access heating tally
    blanket_heating_tally = sp.get_tally(name='blanket_heating')
    df = blanket_heating_tally.get_pandas_dataframe()
    blanket_heating_tally_result = df['mean'].sum() / 1e6
    blanket_heating_tally_std_dev = df['std. dev.'].sum() / 1e6

    # returns all the inputs and some extra reactor attributes, merged into a single dictionary
    return {
        **input_parameters,
        **{
            'tbr': tbr_tally_result,
            'tbr_std_dev': tbr_tally_std_dev,
            'blanket_heating': blanket_heating_tally_result,
            'blanket_heating_std_dev': blanket_heating_tally_std_dev,
        }
    }
コード例 #8
0
ファイル: test_model.py プロジェクト: yardasol/openmc
def pin_model_attributes():
    uo2 = openmc.Material(material_id=1, name='UO2')
    uo2.set_density('g/cm3', 10.29769)
    uo2.add_element('U', 1., enrichment=2.4)
    uo2.add_element('O', 2.)
    uo2.depletable = True

    zirc = openmc.Material(material_id=2, name='Zirc')
    zirc.set_density('g/cm3', 6.55)
    zirc.add_element('Zr', 1.)
    zirc.depletable = False

    borated_water = openmc.Material(material_id=3, name='Borated water')
    borated_water.set_density('g/cm3', 0.740582)
    borated_water.add_element('B', 4.0e-5)
    borated_water.add_element('H', 5.0e-2)
    borated_water.add_element('O', 2.4e-2)
    borated_water.add_s_alpha_beta('c_H_in_H2O')
    borated_water.depletable = False

    mats = openmc.Materials([uo2, zirc, borated_water])

    pitch = 1.25984
    fuel_or = openmc.ZCylinder(r=0.39218, name='Fuel OR')
    clad_or = openmc.ZCylinder(r=0.45720, name='Clad OR')
    box = openmc.model.rectangular_prism(pitch,
                                         pitch,
                                         boundary_type='reflective')

    # Define cells
    fuel_inf_cell = openmc.Cell(cell_id=1, name='inf fuel', fill=uo2)
    fuel_inf_univ = openmc.Universe(universe_id=1, cells=[fuel_inf_cell])
    fuel = openmc.Cell(cell_id=2,
                       name='fuel',
                       fill=fuel_inf_univ,
                       region=-fuel_or)
    clad = openmc.Cell(cell_id=3, fill=zirc, region=+fuel_or & -clad_or)
    water = openmc.Cell(cell_id=4, fill=borated_water, region=+clad_or & box)

    # Define overall geometry
    geom = openmc.Geometry([fuel, clad, water])
    uo2.volume = pi * fuel_or.r**2

    settings = openmc.Settings()
    settings.batches = 100
    settings.inactive = 10
    settings.particles = 1000

    # Create a uniform spatial source distribution over fissionable zones
    bounds = [-0.62992, -0.62992, -1, 0.62992, 0.62992, 1]
    uniform_dist = openmc.stats.Box(bounds[:3],
                                    bounds[3:],
                                    only_fissionable=True)
    settings.source = openmc.source.Source(space=uniform_dist)

    entropy_mesh = openmc.RegularMesh()
    entropy_mesh.lower_left = [-0.39218, -0.39218, -1.e50]
    entropy_mesh.upper_right = [0.39218, 0.39218, 1.e50]
    entropy_mesh.dimension = [10, 10, 1]
    settings.entropy_mesh = entropy_mesh

    tals = openmc.Tallies()
    tal = openmc.Tally(tally_id=1, name='test')
    tal.filters = [openmc.MaterialFilter(bins=[uo2])]
    tal.scores = ['flux', 'fission']
    tals.append(tal)

    plot1 = openmc.Plot(plot_id=1)
    plot1.origin = (0., 0., 0.)
    plot1.width = (pitch, pitch)
    plot1.pixels = (300, 300)
    plot1.color_by = 'material'
    plot1.filename = 'test'
    plot2 = openmc.Plot(plot_id=2)
    plot2.origin = (0., 0., 0.)
    plot2.width = (pitch, pitch)
    plot2.pixels = (300, 300)
    plot2.color_by = 'cell'
    plots = openmc.Plots((plot1, plot2))

    chain = './test_chain.xml'

    chain_file_xml = """<?xml version="1.0"?>
<depletion_chain>
  <nuclide name="Xe136" decay_modes="0" reactions="0" />
  <nuclide name="U235" decay_modes="0" reactions="1">
    <reaction type="fission" Q="200000000."/>
    <neutron_fission_yields>
      <energies>2.53000e-02</energies>
      <fission_yields energy="2.53000e-02">
        <products>Xe136</products>
        <data>1.0</data>
      </fission_yields>
    </neutron_fission_yields>
  </nuclide>
</depletion_chain>
"""
    operator_kwargs = {'chain_file': chain}

    return (mats, geom, settings, tals, plots, operator_kwargs, chain_file_xml)
コード例 #9
0
ファイル: test_mg_tallies.py プロジェクト: zzdbirdsfly/openmc
    # Instantiate a tally mesh
    mesh = openmc.Mesh(mesh_id=1)
    mesh.type = 'regular'
    mesh.dimension = [1, 1, 10]
    mesh.lower_left = [0.0, 0.0, 0.0]
    mesh.upper_right = [10, 10, 5]

    # Instantiate some tally filters
    energy_filter = openmc.EnergyFilter([0.0, 20.0e6])
    energyout_filter = openmc.EnergyoutFilter([0.0, 20.0e6])
    energies = [1e-5, 0.0635, 10.0, 1.0e2, 1.0e3, 0.5e6, 1.0e6, 20.0e6]
    matching_energy_filter = openmc.EnergyFilter(energies)
    matching_eout_filter = openmc.EnergyoutFilter(energies)
    mesh_filter = openmc.MeshFilter(mesh)

    mat_filter = openmc.MaterialFilter(model.materials)

    nuclides = model.xs_data

    scores = {False: ['total', 'absorption', 'flux', 'fission', 'nu-fission'],
              True: ['total', 'absorption', 'fission', 'nu-fission']}

    for do_nuclides in [False, True]:
        t = openmc.Tally()
        t.filters = [mesh_filter]
        t.estimator = 'analog'
        t.scores = scores[do_nuclides]
        if do_nuclides:
            t.nuclides = nuclides
        model.tallies.append(t)
コード例 #10
0
def make_other_aspects_of_neutronics_model(my_reactor):
    """
    Makes and runs a simple OpenMC neutronics model with
    the materials with the same tags as the DAGMC neutronics
    geometry. The model also specifies the computational
    intensity (particles and batches) and the tally to record
    """

    # these materials are overly simplified to keep the example short
    firstwall_mat = Material(material_name='eurofer',
                             material_tag='firstwall_mat').openmc_material

    inboard_tf_coils_mat = Material(
        material_name='WC',
        material_tag='inboard_tf_coils_mat').openmc_material

    center_column_mat = Material(
        material_name='WC',
        material_tag='center_column_shield_mat').openmc_material

    divertor_mat = Material(material_name='eurofer',
                            material_tag='divertor_mat').openmc_material

    blanket_mat = Material(material_name='Li4SiO4',
                           enrichment=60,
                           material_tag='blanket_mat').openmc_material

    blanket_rear_wall_mat = Material(
        material_name='eurofer',
        material_tag='blanket_rear_wall_mat').openmc_material

    mats = openmc.Materials([
        firstwall_mat,
        inboard_tf_coils_mat,
        center_column_mat,
        divertor_mat,
        blanket_mat,
        blanket_rear_wall_mat,
    ])

    # this is the underlying geometry container that is filled with the faceteted CAD model
    universe = openmc.Universe()
    geom = openmc.Geometry(universe)

    # settings for the number of neutrons to simulate
    settings = openmc.Settings()
    settings.batches = 10
    settings.inactive = 0
    settings.particles = 100
    settings.run_mode = 'fixed source'
    settings.dagmc = True

    # details of the birth locations and energy of the neutronis
    source = openmc.Source()
    source.space = openmc.stats.Point((my_reactor.major_radius, 0, 0))
    source.angle = openmc.stats.Isotropic()
    source.energy = openmc.stats.Discrete([14e6], [1])
    settings.source = source

    # details about what neutrons interactions to keep track of (called a tally)
    tallies = openmc.Tallies()
    material_filter = openmc.MaterialFilter(blanket_mat)
    tbr_tally = openmc.Tally(name='TBR')
    tbr_tally.filters = [material_filter]
    tbr_tally.scores = ['(n,Xt)']  # where X is a wild card
    tallies.append(tbr_tally)

    # make the model from gemonetry, materials, settings and tallies
    model = openmc.model.Model(geom, mats, settings, tallies)

    # run the simulation
    output_filename = model.run()

    return output_filename
コード例 #11
0
ファイル: test.py プロジェクト: MauriDeb/Desarrollo_OpenMC
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Set settings explicitly
        self._model.settings.batches = 3
        self._model.settings.inactive = 0
        self._model.settings.particles = 100
        self._model.settings.source = openmc.Source(
            space=openmc.stats.Box([-160, -160, -183], [160, 160, 183]))
        self._model.settings.temperature['multipole'] = True

        filt_mats = openmc.MaterialFilter((1, 3))
        filt_eout = openmc.EnergyoutFilter((0.0, 0.625, 20.0e6))

        # We want density derivatives for both water and fuel to get coverage
        # for both fissile and non-fissile materials.
        d1 = openmc.TallyDerivative(derivative_id=1)
        d1.variable = 'density'
        d1.material = 3
        d2 = openmc.TallyDerivative(derivative_id=2)
        d2.variable = 'density'
        d2.material = 1

        # O-16 is a good nuclide to test against because it is present in both
        # water and fuel.  Some routines need to recognize that they have the
        # perturbed nuclide but not the perturbed material.
        d3 = openmc.TallyDerivative(derivative_id=3)
        d3.variable = 'nuclide_density'
        d3.material = 1
        d3.nuclide = 'O16'

        # A fissile nuclide, just for good measure.
        d4 = openmc.TallyDerivative(derivative_id=4)
        d4.variable = 'nuclide_density'
        d4.material = 1
        d4.nuclide = 'U235'

        # Temperature derivatives.
        d5 = openmc.TallyDerivative(derivative_id=5)
        d5.variable = 'temperature'
        d5.material = 1

        derivs = [d1, d2, d3, d4, d5]

        # Cover the flux score.
        for i in range(5):
            t = openmc.Tally()
            t.scores = ['flux']
            t.filters = [filt_mats]
            t.derivative = derivs[i]
            self._model.tallies.append(t)

        # Cover supported scores with a collision estimator.
        for i in range(5):
            t = openmc.Tally()
            t.scores = [
                'total', 'absorption', 'scatter', 'fission', 'nu-fission'
            ]
            t.filters = [filt_mats]
            t.nuclides = ['total', 'U235']
            t.derivative = derivs[i]
            self._model.tallies.append(t)

        # Cover an analog estimator.
        for i in range(5):
            t = openmc.Tally()
            t.scores = ['absorption']
            t.filters = [filt_mats]
            t.estimator = 'analog'
            t.derivative = derivs[i]
            self._model.tallies.append(t)

        # Energyout filter and total nuclide for the density derivatives.
        for i in range(2):
            t = openmc.Tally()
            t.scores = ['nu-fission', 'scatter']
            t.filters = [filt_mats, filt_eout]
            t.nuclides = ['total', 'U235']
            t.derivative = derivs[i]
            self._model.tallies.append(t)

        # Energyout filter without total nuclide for other derivatives.
        for i in range(2, 5):
            t = openmc.Tally()
            t.scores = ['nu-fission', 'scatter']
            t.filters = [filt_mats, filt_eout]
            t.nuclides = ['U235']
            t.derivative = derivs[i]
            self._model.tallies.append(t)
コード例 #12
0
def test_mg_tallies():
    create_library()
    model = slab_mg()

    # Instantiate a tally mesh
    mesh = openmc.RegularMesh(mesh_id=1)
    mesh.dimension = [10, 1, 1]
    mesh.lower_left = [0.0, 0.0, 0.0]
    mesh.upper_right = [929.45, 1000, 1000]

    # Instantiate some tally filters
    energy_filter = openmc.EnergyFilter([0.0, 20.0e6])
    energyout_filter = openmc.EnergyoutFilter([0.0, 20.0e6])
    energies = [0.0, 0.625, 20.0e6]
    matching_energy_filter = openmc.EnergyFilter(energies)
    matching_eout_filter = openmc.EnergyoutFilter(energies)
    mesh_filter = openmc.MeshFilter(mesh)

    mat_filter = openmc.MaterialFilter(model.materials)

    nuclides = model.xs_data

    scores_with_nuclides = [
        'total', 'absorption', 'fission', 'nu-fission', 'inverse-velocity',
        'prompt-nu-fission', 'delayed-nu-fission', 'kappa-fission', 'events',
        'decay-rate'
    ]
    scores_without_nuclides = scores_with_nuclides + ['flux']

    for do_nuclides, scores in ((False, scores_without_nuclides),
                                (True, scores_with_nuclides)):
        t = openmc.Tally()
        t.filters = [mesh_filter]
        t.estimator = 'analog'
        t.scores = scores
        if do_nuclides:
            t.nuclides = nuclides
        model.tallies.append(t)

        t = openmc.Tally()
        t.filters = [mesh_filter]
        t.estimator = 'tracklength'
        t.scores = scores
        if do_nuclides:
            t.nuclides = nuclides
        model.tallies.append(t)

        # Impose energy bins that dont match the MG structure and those
        # that do
        for match_energy_bins in [False, True]:
            if match_energy_bins:
                e_filter = matching_energy_filter
                eout_filter = matching_eout_filter
            else:
                e_filter = energy_filter
                eout_filter = energyout_filter

            t = openmc.Tally()
            t.filters = [mat_filter, e_filter]
            t.estimator = 'analog'
            t.scores = scores + ['scatter', 'nu-scatter']
            if do_nuclides:
                t.nuclides = nuclides
            model.tallies.append(t)

            t = openmc.Tally()
            t.filters = [mat_filter, e_filter]
            t.estimator = 'collision'
            t.scores = scores
            if do_nuclides:
                t.nuclides = nuclides
            model.tallies.append(t)

            t = openmc.Tally()
            t.filters = [mat_filter, e_filter]
            t.estimator = 'tracklength'
            t.scores = scores
            if do_nuclides:
                t.nuclides = nuclides
            model.tallies.append(t)

            t = openmc.Tally()
            t.filters = [mat_filter, e_filter, eout_filter]
            t.scores = ['scatter', 'nu-scatter', 'nu-fission']
            if do_nuclides:
                t.nuclides = nuclides
            model.tallies.append(t)

    harness = MGXSTestHarness('statepoint.10.h5', model)
    harness.main()
コード例 #13
0
uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True)
model.settings.source = openmc.source.Source(space=uniform_dist)

entropy_mesh = openmc.RegularMesh()
entropy_mesh.lower_left = [-10.71, -10.71]
entropy_mesh.upper_right = [10.71, 10.71]
entropy_mesh.dimension = [10, 10]
model.settings.entropy_mesh = entropy_mesh

###############################################################################
# Analysis

# Get heating in a neutron-only calculation
tally = openmc.Tally(name='heating')
tally.filters = [
    openmc.MaterialFilter([fuel_31, helium, zirc4, ss304, agincd, water_600]),
    openmc.ParticleFilter(['neutron', 'photon', 'electron', 'positron'])
]
tally.scores = ['fission', 'heating-local']

total_tally = openmc.Tally(name='total')
total_tally.scores = ['fission', 'heating-local', 'heating']

model.tallies = openmc.Tallies([tally, total_tally])

sp_path = model.run()
with openmc.StatePoint(sp_path) as sp:
    t = sp.get_tally(name='heating')
    df_neutron = t.get_pandas_dataframe()

# Get heating in a coupled neutron-photon calculation
コード例 #14
0
uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True)
model.settings.source = openmc.source.Source(space=uniform_dist)

entropy_mesh = openmc.RegularMesh()
entropy_mesh.lower_left = [-10.71, -10.71]
entropy_mesh.upper_right = [10.71, 10.71]
entropy_mesh.dimension = [10, 10]
model.settings.entropy_mesh = entropy_mesh

###############################################################################
# Analysis

# Get heating in a neutron-only calculation
tally = openmc.Tally(name='heating')
tally.filters = [
    openmc.MaterialFilter([fuel_31, helium, zirc4, water_600]),
    openmc.ParticleFilter(['neutron', 'photon', 'electron', 'positron'])
]
tally.scores = ['fission', 'heating-local']
model.tallies = openmc.Tallies([tally])

sp_path = model.run()
with openmc.StatePoint(sp_path) as sp:
    t = sp.get_tally(name='heating')
    df_neutron = t.get_pandas_dataframe()

# Get heating in a coupled neutron-photon calculation
model.settings.photon_transport = True
model.settings.delayed_photon_scaling = True
model.tallies[0].scores = ['fission', 'heating']
sp_path = model.run()