Esempio n. 1
0
def materials(tmpdir_factory):
    """Use C API to construct realistic materials for testing tallies"""
    tmpdir = tmpdir_factory.mktemp("lib")
    orig = tmpdir.chdir()
    # Create proxy problem to please openmc
    mfuel = openmc.Material(name="test_fuel")
    mfuel.volume = 1.0
    for nuclide in ["U235", "U238", "Xe135", "Pu239"]:
        mfuel.add_nuclide(nuclide, 1.0)
    openmc.Materials([mfuel]).export_to_xml()
    # Geometry
    box = openmc.rectangular_prism(1.0, 1.0, boundary_type="reflective")
    cell = openmc.Cell(fill=mfuel, region=box)
    root = openmc.Universe(cells=[cell])
    openmc.Geometry(root).export_to_xml()
    # settings
    settings = openmc.Settings()
    settings.particles = 100
    settings.inactive = 0
    settings.batches = 10
    settings.verbosity = 1
    settings.export_to_xml()

    try:
        with lib.run_in_memory():
            yield [lib.Material(), lib.Material()]
    finally:
        # Convert to strings as os.remove in py 3.5 doesn't support Paths
        for file_path in ("settings.xml", "geometry.xml", "materials.xml",
                          "summary.h5"):
            os.remove(str(tmpdir / file_path))
        orig.chdir()
        os.rmdir(str(tmpdir))
Esempio n. 2
0
def model():
    model = openmc.model.Model()

    fuel = openmc.Material()
    fuel.set_density('g/cc', 10.0)
    fuel.add_nuclide('U235', 1.0)

    h1 = openmc.Material()
    h1.set_density('g/cc', 0.1)
    h1.add_nuclide('H1', 0.1)

    inner_sphere = openmc.Sphere(x0=1.0, r=5.0)

    fuel_cell = openmc.Cell(fill=fuel, region=-inner_sphere)
    hydrogen_cell = openmc.Cell(fill=h1, region=+inner_sphere)
    univ = openmc.Universe(cells=[fuel_cell, hydrogen_cell])

    # Create one cell on top of the other. Only one
    # has a rotation
    box = openmc.rectangular_prism(15., 15., 'z', boundary_type='vacuum')
    lower_z = openmc.ZPlane(-7.5, boundary_type='vacuum')
    upper_z = openmc.ZPlane(22.5, boundary_type='vacuum')
    middle_z = openmc.ZPlane(7.5)

    lower_cell = openmc.Cell(fill=univ, region=box & +lower_z & -middle_z)
    lower_cell.rotation = (10, 20, 30)
    upper_cell = openmc.Cell(fill=univ, region=box & +middle_z & -upper_z)
    upper_cell.translation = (0, 0, 15)

    model.geometry = openmc.Geometry(root=[lower_cell, upper_cell])

    model.settings.particles = 10000
    model.settings.inactive = 5
    model.settings.batches = 10
    source_box = openmc.stats.Box((-4., -4., -4.), (4., 4., 4.))
    model.settings.source = openmc.Source(space=source_box)

    return model
Esempio n. 3
0
def test_inf_media():
    # setup and infinite media problem
    model = openmc.model.Model()

    # create a material
    mat = openmc.Material()
    mat.add_nuclide('O16', 1.0, 'ao')

    cell = openmc.Cell(fill=mat)
    cell.region = openmc.rectangular_prism(1E5, 1E5, boundary_type='reflective')

    model.materials = [mat]
    model.materials.cross_sections = str(current_dir / "endfb71_hdf5" / "cross_sections.xml")

    model.geometry = openmc.Geometry([cell])

    model.settings.run_mode = 'fixed source'
    model.settings.particles = 1000
    model.settings.batches = 10
    model.settings.temperature['multipole'] = True
    model.settings.resonance_scattering['enable'] = True

    model.export_to_xml()
    openmc.run()
Esempio n. 4
0
water.add_macroscopic(h2o_data)

# Instantiate a Materials collection and export to XML
materials_file = openmc.Materials([uo2, water])
materials_file.cross_sections = "mgxs.h5"
materials_file.export_to_xml()

###############################################################################
# Define problem geometry

# Create a surface for the fuel outer radius
fuel_or = openmc.ZCylinder(r=0.54, name='Fuel OR')

# Create a region represented as the inside of a rectangular prism
pitch = 1.26
box = openmc.rectangular_prism(pitch, pitch, boundary_type='reflective')

# Instantiate Cells
fuel = openmc.Cell(fill=uo2, region=-fuel_or, name='fuel')
moderator = openmc.Cell(fill=water, region=+fuel_or & box, name='moderator')

# Create a geometry with the two cells and export to XML
geometry = openmc.Geometry([fuel, moderator])
geometry.export_to_xml()

###############################################################################
# Define problem settings

# Instantiate a Settings object, set all runtime parameters, and export to XML
settings = openmc.Settings()
settings.energy_mode = "multi-group"
Esempio n. 5
0
    def _add_assembly_surfs(self):
        """ Adds BEAVRS assebly surfaces - these include the assembly pitch"""

        # Rectangular prism around the edge of the pinlattice
        self.assem_surfs = \
            openmc.rectangular_prism(c.latticePitch, c.latticePitch)
Esempio n. 6
0
    def _add_lattice_surfs(self):
        """ Adds BEAVRS lattice surfaces """

        # Rectangular prism around the edge of the pinlattice
        self.lattice_surfs = \
            openmc.rectangular_prism(17*c.pinPitch, 17*c.pinPitch)
Esempio n. 7
0
clad.fill = zirconium
clad.region = clad_region

pitch = 1.26
left = openmc.XPlane(x0=-pitch/2, boundary_type='reflective')
right = openmc.XPlane(x0=pitch/2, boundary_type='reflective')
bottom = openmc.YPlane(y0=-pitch/2, boundary_type='reflective')
top = openmc.YPlane(y0=pitch/2, boundary_type='reflective')

water_region = +left & -right & +bottom & -top & +clad_or

moderator = openmc.Cell(4, 'moderator')
moderator.fill = water
moderator.region = water_region

box = openmc.rectangular_prism(width=pitch, height=pitch, boundary_type='reflective')
water_region = box & +clad_or

root = openmc.Universe(cells=(fuel, gap, clad, moderator))

geom = openmc.Geometry()
geom.root_universe = root
geom.export_to_xml()

point = openmc.stats.Point((0, 0, 0))
src = openmc.Source(space=point)
settings = openmc.Settings()
settings.source = src
settings.batches = 100
settings.inactive = 10
settings.particles = 1000
Esempio n. 8
0
    def _add_grid_pincells(self):
        """ Adds BEAVRS pincellgrid and assembly gridsleeve pincells """

        # Rectangular prisms for grid spacers
        grid_surfs_tb = \
            openmc.rectangular_prism(c.rodGridSide_tb, c.rodGridSide_tb)
        grid_surfs_i = \
            openmc.rectangular_prism(c.rodGridSide_i, c.rodGridSide_i)

        # Rectangular prisms for lattice grid sleeves
        grid_surfs_ass = \
            openmc.rectangular_prism(c.gridstrapSide, c.gridstrapSide)

        # Grids axial surfaces

        self.s_grid1_bot = openmc.ZPlane(name='Bottom of grid 1',
                                         z0=c.grid1_bot)
        self.s_grid1_top = openmc.ZPlane(name='Top of grid 1', z0=c.grid1_top)
        self.s_grid2_bot = openmc.ZPlane(name='Bottom of grid 2',
                                         z0=c.grid2_bot)
        self.s_grid2_top = openmc.ZPlane(name='Top of grid 2', z0=c.grid2_top)
        self.s_grid3_bot = openmc.ZPlane(name='Bottom of grid 3',
                                         z0=c.grid3_bot)
        self.s_grid3_top = openmc.ZPlane(name='Top of grid 3', z0=c.grid3_top)
        self.s_grid4_bot = openmc.ZPlane(name='Bottom of grid 4',
                                         z0=c.grid4_bot)
        self.s_grid4_top = openmc.ZPlane(name='Top of grid 4', z0=c.grid4_top)
        self.s_grid5_bot = openmc.ZPlane(name='Bottom of grid 5',
                                         z0=c.grid5_bot)
        self.s_grid5_top = openmc.ZPlane(name='Top of grid 5', z0=c.grid5_top)
        self.s_grid6_bot = openmc.ZPlane(name='Bottom of grid 6',
                                         z0=c.grid6_bot)
        self.s_grid6_top = openmc.ZPlane(name='Top of grid 6', z0=c.grid6_top)
        self.s_grid7_bot = openmc.ZPlane(name='Bottom of grid 7',
                                         z0=c.grid7_bot)
        self.s_grid7_top = openmc.ZPlane(name='Top of grid 7', z0=c.grid7_top)
        self.s_grid8_bot = openmc.ZPlane(name='Bottom of grid 8',
                                         z0=c.grid8_bot)
        self.s_grid8_top = openmc.ZPlane(name='Top of grid 8', z0=c.grid8_top)

        # Grids pincell universes

        self.u_grid_i = InfinitePinCell(name='Intermediate grid pincell')
        self.u_grid_i.add_ring(self.mats['Borated Water'],
                               grid_surfs_i,
                               box=True)
        self.u_grid_i.add_last_ring(self.mats['Zircaloy 4'])
        self.u_grid_i.finalize()

        self.u_grid_tb = InfinitePinCell(name='Top/Bottom grid pincell')
        self.u_grid_tb.add_ring(self.mats['Borated Water'],
                                grid_surfs_tb,
                                box=True)
        self.u_grid_tb.add_last_ring(self.mats['Inconel 718'])
        self.u_grid_tb.finalize()

        self.u_grid_sleeve_i = InfinitePinCell(
            name='Intermediate grid sleeve pincell')
        self.u_grid_sleeve_i.add_ring(self.mats['Zircaloy 4'],
                                      grid_surfs_ass,
                                      box=True)
        self.u_grid_sleeve_i.add_last_ring(self.mats['Borated Water'])
        self.u_grid_sleeve_i.finalize()

        self.u_grid_sleeve_tb = InfinitePinCell(
            name='Top/Bottom grid sleeve pincell')
        self.u_grid_sleeve_tb.add_ring(self.mats['Inconel 718'],
                                       grid_surfs_ass,
                                       box=True)
        self.u_grid_sleeve_tb.add_last_ring(self.mats['Borated Water'])
        self.u_grid_sleeve_tb.finalize()

        # Grids axial stack

        self.u_grids = AxialPinCell(name='Grids axial universe')
        self.u_grids.add_axial_section(self.s_struct_supportPlate_bot,
                                       self.mats['Borated Water'])
        self.u_grids.add_axial_section(self.s_struct_lowerNozzle_top,
                                       self.mats['Water SPN'])
        self.u_grids.add_axial_section(self.s_grid1_bot,
                                       self.mats['Borated Water'])
        self.u_grids.add_axial_section(self.s_grid1_top, self.u_grid_tb)
        self.u_grids.add_axial_section(self.s_grid2_bot,
                                       self.mats['Borated Water'])
        self.u_grids.add_axial_section(self.s_grid2_top, self.u_grid_i)
        self.u_grids.add_axial_section(self.s_grid3_bot,
                                       self.mats['Borated Water'])
        self.u_grids.add_axial_section(self.s_grid3_top, self.u_grid_i)
        self.u_grids.add_axial_section(self.s_grid4_bot,
                                       self.mats['Borated Water'])
        self.u_grids.add_axial_section(self.s_grid4_top, self.u_grid_i)
        self.u_grids.add_axial_section(self.s_grid5_bot,
                                       self.mats['Borated Water'])
        self.u_grids.add_axial_section(self.s_grid5_top, self.u_grid_i)
        self.u_grids.add_axial_section(self.s_grid6_bot,
                                       self.mats['Borated Water'])
        self.u_grids.add_axial_section(self.s_grid6_top, self.u_grid_i)
        self.u_grids.add_axial_section(self.s_grid7_bot,
                                       self.mats['Borated Water'])
        self.u_grids.add_axial_section(self.s_grid7_top, self.u_grid_i)
        self.u_grids.add_axial_section(self.s_grid8_bot,
                                       self.mats['Borated Water'])
        self.u_grids.add_axial_section(self.s_grid8_top, self.u_grid_tb)
        self.u_grids.add_axial_section(self.s_struct_upperNozzle_bot,
                                       self.mats['Borated Water'])
        self.u_grids.add_axial_section(self.s_struct_upperNozzle_top,
                                       self.mats['Water SPN'])
        self.u_grids.add_last_axial_section(self.mats['Borated Water'])
        self.u_grids.finalize()

        self.u_gridsleeve = AxialPinCell(name='Grid sleeve axial universe')
        self.u_gridsleeve.add_axial_section(self.s_struct_supportPlate_bot,
                                            self.mats['Borated Water'])
        self.u_gridsleeve.add_axial_section(self.s_struct_lowerNozzle_top,
                                            self.mats['Water SPN'])
        self.u_gridsleeve.add_axial_section(self.s_grid1_bot,
                                            self.mats['Borated Water'])
        self.u_gridsleeve.add_axial_section(self.s_grid1_top,
                                            self.u_grid_sleeve_tb)
        self.u_gridsleeve.add_axial_section(self.s_grid2_bot,
                                            self.mats['Borated Water'])
        self.u_gridsleeve.add_axial_section(self.s_grid2_top,
                                            self.u_grid_sleeve_i)
        self.u_gridsleeve.add_axial_section(self.s_grid3_bot,
                                            self.mats['Borated Water'])
        self.u_gridsleeve.add_axial_section(self.s_grid3_top,
                                            self.u_grid_sleeve_i)
        self.u_gridsleeve.add_axial_section(self.s_grid4_bot,
                                            self.mats['Borated Water'])
        self.u_gridsleeve.add_axial_section(self.s_grid4_top,
                                            self.u_grid_sleeve_i)
        self.u_gridsleeve.add_axial_section(self.s_grid5_bot,
                                            self.mats['Borated Water'])
        self.u_gridsleeve.add_axial_section(self.s_grid5_top,
                                            self.u_grid_sleeve_i)
        self.u_gridsleeve.add_axial_section(self.s_grid6_bot,
                                            self.mats['Borated Water'])
        self.u_gridsleeve.add_axial_section(self.s_grid6_top,
                                            self.u_grid_sleeve_i)
        self.u_gridsleeve.add_axial_section(self.s_grid7_bot,
                                            self.mats['Borated Water'])
        self.u_gridsleeve.add_axial_section(self.s_grid7_top,
                                            self.u_grid_sleeve_i)
        self.u_gridsleeve.add_axial_section(self.s_grid8_bot,
                                            self.mats['Borated Water'])
        self.u_gridsleeve.add_axial_section(self.s_grid8_top,
                                            self.u_grid_sleeve_tb)
        self.u_gridsleeve.add_axial_section(self.s_struct_upperNozzle_bot,
                                            self.mats['Borated Water'])
        self.u_gridsleeve.add_axial_section(self.s_struct_upperNozzle_top,
                                            self.mats['Water SPN'])
        self.u_gridsleeve.add_last_axial_section(self.mats['Borated Water'])
        self.u_gridsleeve.finalize()