Beispiel #1
0
def make_load(name, outer, assemblies, number, hpitch, lenz, load_dict = {}):
    """Parametres:
       ----------
       name : str
           - load called
       outer : openmc.Universe
           - outer universe
       assemblies : dictionary
           - loaded type of assembly
       load_dict : dictionary
           - a pairs 'name of lattice3d' : a 'list of spiral numbers'
       Return:
       ----------
       openmc.Lattice
    """
    lattice = openmc.HexLattice(lattice_id=1001, name=name)
    lattice.center = (0, 0, 0)
    lattice.orientation = "x"
    lattice.pitch = (hpitch, lenz)
    lattice.outer = outer
    univs = []
    univs.append(init_openmc_spiral(outer, number))
    lattice.universes = univs
    for k,v in load_dict.items():
        #
        for g in v:
            zz = get_hex_num_by_spiral(g, number)
            i = zz[0]
            j = zz[1]
            lattice.universes[0][i][j] = assemblies[k]
    return lattice
Beispiel #2
0
def hlat3(pincell1, pincell2, uo2, water, zr):
    """3D Hexagonal lattice for testing."""

    # Create another universe for top layer
    hydrogen = openmc.Material()
    hydrogen.add_element('H', 1.0)
    hydrogen.set_density('g/cm3', 0.09)
    h_cell = openmc.Cell(fill=hydrogen)
    u3 = openmc.Universe(cells=[h_cell])

    all_zr = openmc.Cell(fill=zr)
    pitch = 1.2
    u1, u2 = pincell1, pincell2
    lattice = openmc.HexLattice()
    lattice.center = (0., 0., 0.)
    lattice.pitch = (pitch, 10.0)
    lattice.outer = openmc.Universe(cells=[all_zr])
    lattice.universes = [[[u2, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1],
                          [u2, u1, u1, u1, u1, u1], [u2]],
                         [[u1, u1, u1, u1, u1, u1, u3, u1, u1, u1, u1, u1],
                          [u1, u1, u1, u3, u1, u1], [u3]]]

    # Add extra attributes for comparison purpose
    lattice.cells = [
        u1.fuel, u1.moderator, u2.fuel, u2.moderator, h_cell, all_zr
    ]
    lattice.mats = [uo2, water, zr, hydrogen]
    lattice.univs = [u1, u2, u3, lattice.outer]
    return lattice
Beispiel #3
0
    def get_lattice(self):
        upin = self.pincell.build()
        ugtb = self.gtube.build()
        hlat = openmc.HexLattice()
        hlat.pitch = [self.pitch] * 2

        unis = [[upin] * 78, [upin] * 72, [upin] * 66, [upin] * 60,
                [upin] * 54, [upin] * 48, [upin] * 42, [upin] * 36,
                [upin] * 30, [upin] * 24, [upin] * 18, [upin] * 12, [upin] * 6,
                [ugtb]]
        hlat.center = (0, -self.pitch * (len(unis) - 1), 0)
        # Center row
        unis[0][39] = ugtb
        unis[4][27] = ugtb
        unis[8][15] = ugtb
        unis[9][0] = ugtb
        unis[4][0] = ugtb
        unis[0][0] = ugtb
        # Next row
        unis[0][35] = ugtb
        unis[4][23] = ugtb
        unis[9][4] = ugtb
        unis[8][11] = ugtb
        unis[4][4] = ugtb
        # Another row
        unis[0][31] = ugtb
        unis[4][19] = ugtb
        unis[5][13] = ugtb
        # Corner
        unis[0][26] = ugtb

        hlat.universes = [unis]
        hlat.outer = upin
        print(hlat.show_indices(hlat.num_rings))
        return hlat
Beispiel #4
0
def mixed_lattice_model(uo2, water):
    cyl = openmc.ZCylinder(r=0.4)
    c1 = openmc.Cell(fill=uo2, region=-cyl)
    c1.temperature = 600.0
    c2 = openmc.Cell(fill=water, region=+cyl)
    pin = openmc.Universe(cells=[c1, c2])

    empty = openmc.Cell()
    empty_univ = openmc.Universe(cells=[empty])

    hex_lattice = openmc.HexLattice()
    hex_lattice.center = (0.0, 0.0)
    hex_lattice.pitch = (1.2, 10.0)
    outer_ring = [pin]*6
    inner_ring = [empty_univ]
    axial_level = [outer_ring, inner_ring]
    hex_lattice.universes = [axial_level]*3
    hex_lattice.outer = empty_univ

    cell_hex = openmc.Cell(fill=hex_lattice)
    u = openmc.Universe(cells=[cell_hex])
    rotated_cell_hex = openmc.Cell(fill=u)
    rotated_cell_hex.rotation = (0., 0., 30.)
    ur = openmc.Universe(cells=[rotated_cell_hex])

    d = 6.0
    rect_lattice = openmc.RectLattice()
    rect_lattice.lower_left = (-d, -d)
    rect_lattice.pitch = (d, d)
    rect_lattice.outer = empty_univ
    rect_lattice.universes = [
        [ur, empty_univ],
        [empty_univ, u]
    ]

    xmin = openmc.XPlane(-d, boundary_type='periodic')
    xmax = openmc.XPlane(d, boundary_type='periodic')
    xmin.periodic_surface = xmax
    ymin = openmc.YPlane(-d, boundary_type='periodic')
    ymax = openmc.YPlane(d, boundary_type='periodic')
    main_cell = openmc.Cell(fill=rect_lattice,
                            region=+xmin & -xmax & +ymin & -ymax)

    # Create geometry and use unique material in each fuel cell
    geometry = openmc.Geometry([main_cell])
    geometry.determine_paths()
    c1.fill = [water.clone() for i in range(c1.num_instances)]

    return openmc.model.Model(geometry)
Beispiel #5
0
def hlat2(pincell1, pincell2, uo2, water, zr):
    """2D Hexagonal lattice for testing."""
    all_zr = openmc.Cell(fill=zr)
    pitch = 1.2
    u1, u2 = pincell1, pincell2
    lattice = openmc.HexLattice()
    lattice.center = (0., 0.)
    lattice.pitch = (pitch, )
    lattice.outer = openmc.Universe(cells=[all_zr])
    lattice.universes = [[u2, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1, u1],
                         [u2, u1, u1, u1, u1, u1], [u2]]

    # Add extra attributes for comparison purpose
    lattice.cells = [u1.fuel, u1.moderator, u2.fuel, u2.moderator, all_zr]
    lattice.mats = [uo2, water, zr]
    lattice.univs = [u1, u2, lattice.outer]
    return lattice
Beispiel #6
0
    def _build_inputs(self):
        materials = openmc.Materials()

        fuel_mat = openmc.Material()
        fuel_mat.add_nuclide('U235', 4.9817E-03, 'ao')
        materials.append(fuel_mat)

        matrix = openmc.Material()
        matrix.set_density('atom/b-cm', 1.7742E-02)
        matrix.add_element('C', 1.0, 'ao')
        matrix.add_s_alpha_beta('c_Graphite')
        materials.append(matrix)

        lead = openmc.Material(name="Lead")
        lead.set_density('g/cm3', 10.32)
        lead.add_nuclide('Pb204', 0.014, 'ao')
        lead.add_nuclide('Pb206', 0.241, 'ao')
        lead.add_nuclide('Pb207', 0.221, 'ao')
        lead.add_nuclide('Pb208', 0.524, 'ao')
        materials.append(lead)

        coolant = openmc.Material()
        coolant.set_density('atom/b-cm', 5.4464E-04)
        coolant.add_nuclide('He4', 1.0, 'ao')
        materials.append(coolant)

        zirc = openmc.Material(name="Zirc4")
        zirc.add_nuclide('Zr90', 2.217E-02, 'ao')
        zirc.add_nuclide('Zr91', 4.781E-03, 'ao')
        zirc.add_nuclide('Zr92', 7.228E-03, 'ao')
        zirc.add_nuclide('Zr94', 7.169E-03, 'ao')
        zirc.add_nuclide('Zr96', 1.131E-03, 'ao')
        materials.append(zirc)

        materials.export_to_xml()

        ### Geometry ###
        pin_rad = 0.7  # cm
        assembly_pitch = 1.4  # cm

        cool_rad = 0.293  # cm
        zirc_clad_thickness = 0.057  # cm
        zirc_ir = cool_rad  # cm
        zirc_or = cool_rad + zirc_clad_thickness  # cm
        lead_thickness = 0.002  # cm
        lead_ir = zirc_or  # cm
        lead_or = zirc_or + lead_thickness  # cm

        cyl = openmc.ZCylinder(x0=0., y0=0., r=pin_rad)
        fuel_btm = openmc.ZPlane(z0=0.0, boundary_type='reflective')
        fuel_top = openmc.ZPlane(z0=10.0, boundary_type='reflective')
        region = -cyl & +fuel_btm & -fuel_top

        container = openmc.Cell(region=region)
        container.fill = fuel_mat

        fuel_outside = openmc.Cell()
        fuel_outside.region = +cyl
        fuel_outside.fill = matrix

        fuel_ch_univ = openmc.Universe(cells=[container, fuel_outside])

        # Coolant Channel
        cool_outer = openmc.ZCylinder(x0=0.0, y0=0.0, r=cool_rad)
        zirc_outer = openmc.ZCylinder(x0=0.0, y0=0.0, r=zirc_or)
        lead_outer = openmc.ZCylinder(x0=0.0, y0=0.0, r=lead_or)

        coolant_ch = openmc.Cell(name="coolant")
        coolant_ch.region = -cool_outer & +fuel_btm & -fuel_top
        coolant_ch.fill = coolant

        zirc_shell = openmc.Cell(name="zirconium_shell")
        zirc_shell.region = +cool_outer & -zirc_outer & +fuel_btm & -fuel_top
        zirc_shell.fill = zirc

        lead_shell = openmc.Cell(name="lead_shell")
        lead_shell.region = +zirc_outer & -lead_outer & +fuel_btm & -fuel_top
        lead_shell.fill = lead

        coolant_matrix = openmc.Cell(name="matrix coolant surround")
        coolant_matrix.region = +lead_outer & +fuel_btm & -fuel_top
        coolant_matrix.fill = matrix

        coolant_channel = [coolant_ch, zirc_shell, lead_shell, coolant_matrix]

        coolant_univ = openmc.Universe(name="coolant universe")
        coolant_univ.add_cells(coolant_channel)

        half_width = assembly_pitch  # cm
        edge_length = (2. / sqrt(3.0)) * half_width

        inf_mat = openmc.Cell()
        inf_mat.fill = matrix

        inf_mat_univ = openmc.Universe(cells=[
            inf_mat,
        ])

        # a hex surface for the core to go inside of
        hexprism = openmc.model.hexagonal_prism(edge_length=edge_length,
                                                origin=(0.0, 0.0),
                                                boundary_type='reflective',
                                                orientation='x')

        pincell_only_lattice = openmc.HexLattice(name="regular fuel assembly")
        pincell_only_lattice.center = (0., 0.)
        pincell_only_lattice.pitch = (assembly_pitch, )
        pincell_only_lattice.outer = inf_mat_univ

        # setup hex rings
        ring0 = [fuel_ch_univ]
        ring1 = [coolant_univ] * 6
        pincell_only_lattice.universes = [ring1, ring0]

        pincell_only_cell = openmc.Cell(name="container cell")
        pincell_only_cell.region = hexprism & +fuel_btm & -fuel_top
        pincell_only_cell.fill = pincell_only_lattice

        root_univ = openmc.Universe(name="root universe",
                                    cells=[
                                        pincell_only_cell,
                                    ])

        geom = openmc.Geometry(root_univ)
        geom.export_to_xml()

        ### Settings ###

        settings = openmc.Settings()
        settings.run_mode = 'eigenvalue'

        source = openmc.Source()
        corner_dist = sqrt(2) * pin_rad
        ll = [-corner_dist, -corner_dist, 0.0]
        ur = [corner_dist, corner_dist, 10.0]
        source.space = openmc.stats.Box(ll, ur)
        source.strength = 1.0
        settings.source = source
        settings.output = {'summary': False}
        settings.batches = 5
        settings.inactive = 2
        settings.particles = 1000
        settings.seed = 22
        settings.export_to_xml()
Beispiel #7
0
    def from_hdf5(group, universes):
        """Create lattice from HDF5 group

        Parameters
        ----------
        group : h5py.Group
            Group in HDF5 file
        universes : dict
            Dictionary mapping universe IDs to instances of
            :class:`openmc.Universe`.

        Returns
        -------
        openmc.Lattice
            Instance of lattice subclass

        """
        lattice_id = int(group.name.split('/')[-1].lstrip('lattice '))
        name = group['name'].value.decode() if 'name' in group else ''
        lattice_type = group['type'].value.decode()

        if lattice_type == 'rectangular':
            dimension = group['dimension'][...]
            lower_left = group['lower_left'][...]
            pitch = group['pitch'][...]
            outer = group['outer'].value
            universe_ids = group['universes'][...]

            # Create the Lattice
            lattice = openmc.RectLattice(lattice_id, name)
            lattice.lower_left = lower_left
            lattice.pitch = pitch

            # If the Universe specified outer the Lattice is not void
            if outer >= 0:
                lattice.outer = universes[outer]

            # Build array of Universe pointers for the Lattice
            uarray = np.empty(universe_ids.shape, dtype=openmc.Universe)

            for z in range(universe_ids.shape[0]):
                for y in range(universe_ids.shape[1]):
                    for x in range(universe_ids.shape[2]):
                        uarray[z, y, x] = universes[universe_ids[z, y, x]]

            # Use 2D NumPy array to store lattice universes for 2D lattices
            if len(dimension) == 2:
                uarray = np.squeeze(uarray)
                uarray = np.atleast_2d(uarray)

            # Set the universes for the lattice
            lattice.universes = uarray

        elif lattice_type == 'hexagonal':
            n_rings = group['n_rings'].value
            n_axial = group['n_axial'].value
            center = group['center'][...]
            pitch = group['pitch'][...]
            outer = group['outer'].value

            universe_ids = group['universes'][...]

            # Create the Lattice
            lattice = openmc.HexLattice(lattice_id, name)
            lattice.center = center
            lattice.pitch = pitch

            # If the Universe specified outer the Lattice is not void
            if outer >= 0:
                lattice.outer = universes[outer]

            # Build array of Universe pointers for the Lattice.  Note that
            # we need to convert between the HDF5's square array of
            # (x, alpha, z) to the Python API's format of a ragged nested
            # list of (z, ring, theta).
            uarray = []
            for z in range(n_axial):
                # Add a list for this axial level.
                uarray.append([])
                x = n_rings - 1
                a = 2 * n_rings - 2
                for r in range(n_rings - 1, 0, -1):
                    # Add a list for this ring.
                    uarray[-1].append([])

                    # Climb down the top-right.
                    for i in range(r):
                        uarray[-1][-1].append(universe_ids[z, a, x])
                        x += 1
                        a -= 1

                    # Climb down the right.
                    for i in range(r):
                        uarray[-1][-1].append(universe_ids[z, a, x])
                        a -= 1

                    # Climb down the bottom-right.
                    for i in range(r):
                        uarray[-1][-1].append(universe_ids[z, a, x])
                        x -= 1

                    # Climb up the bottom-left.
                    for i in range(r):
                        uarray[-1][-1].append(universe_ids[z, a, x])
                        x -= 1
                        a += 1

                    # Climb up the left.
                    for i in range(r):
                        uarray[-1][-1].append(universe_ids[z, a, x])
                        a += 1

                    # Climb up the top-left.
                    for i in range(r):
                        uarray[-1][-1].append(universe_ids[z, a, x])
                        x += 1

                    # Move down to the next ring.
                    a -= 1

                    # Convert the ids into Universe objects.
                    uarray[-1][-1] = [
                        universes[u_id] for u_id in uarray[-1][-1]
                    ]

                # Handle the degenerate center ring separately.
                u_id = universe_ids[z, a, x]
                uarray[-1].append([universes[u_id]])

            # Add the universes to the lattice.
            if len(pitch) == 2:
                # Lattice is 3D
                lattice.universes = uarray
            else:
                # Lattice is 2D; extract the only axial level
                lattice.universes = uarray[0]

        return lattice
c3003 = openmc.Cell(fill=fuel, region=+zc301 & -zc300 & -zp200)
c3004 = openmc.Cell(fill=steel, region=+zc300 & -zp200)
c3005 = openmc.Cell(fill=fuel, region=+zc301 & +zp200 & -zp201)
c3006 = openmc.Cell(region=+zp201)

u3 = openmc.Universe(
    universe_id=3,
    cells=[c3000, c3001, c3001, c3002, c3003, c3004, c3005, c3006])

c4000 = openmc.Cell(region=+zp201)
c4001 = openmc.Cell(fill=fuel, region=+zp200 & -zp201)  #fuel
c4002 = openmc.Cell(fill=steel, region=-zp200)  #steel
u4 = openmc.Universe(cells=[c4000, c4001, c4002])

##建立六边形栅格
lattice = openmc.HexLattice(lattice_id=5)
lattice.center = (0, 0)  #六边形以原点为中心
lattice.pitch = [10.6]  #间隔10.6cm
outer_ring = [
    u1, u2, u2, u2, u2
] * 6  #[u1,u2,u2,u2,u2, u1,u2,u2,u2,u2, u1,u2,u2,u2,u2, u1,u2,u2,u2,u2, u1,u2,u2,u2,u2, u1,u2,u2,u2,u2]
m5_ring = [
    u2
] * 24  #[u2,u2,u2,u2, u2,u2,u2,u2, u2,u2,u2,u2, u2,u2,u2,u2, u2,u2,u2,u2, u2,u2,u2,u2]
m4_ring = [u3, u2, u2
           ] * 6  #[u3,u2,u2, u3,u2,u2, u3,u2,u2, u3,u2,u2, u3,u2,u2, u3,u2,u2]
m3_ring = [u2] * 12  #[u2,u2, u2,u2, u2,u2, u2,u2, u2,u2, u2,u2]
m2_ring = [u2] * 6  #[u2,u2,u2,u2,u2,u2]
inner_ring = [u3]
lattice.universes = [
    outer_ring, m5_ring, m4_ring, m3_ring, m2_ring, inner_ring
Beispiel #9
0
    def _build_inputs(self):
        materials = openmc.Materials()

        fuel_mat = openmc.Material(material_id=1, name="UO2")
        fuel_mat.set_density('sum')
        fuel_mat.add_nuclide('U235', 0.87370e-03)
        fuel_mat.add_nuclide('U238', 1.87440e-02)
        fuel_mat.add_nuclide('O16', 3.92350e-02)
        materials.append(fuel_mat)

        coolant = openmc.Material(material_id=2, name="borated H2O")
        coolant.set_density('sum')
        coolant.add_nuclide('H1', 0.06694)
        coolant.add_nuclide('O16', 0.03347)
        coolant.add_nuclide('B10', 6.6262e-6)
        coolant.add_nuclide('B11', 2.6839e-5)
        materials.append(coolant)

        absorber = openmc.Material(material_id=3, name="pellet B4C")
        absorber.set_density('sum')
        absorber.add_nuclide('C0', 0.01966)
        absorber.add_nuclide('B11', 4.7344e-6)
        absorber.add_nuclide('B10', 1.9177e-5)
        materials.append(absorber)

        zirc = openmc.Material(material_id=4, name="Zirc4")
        zirc.set_density('sum')
        zirc.add_element('Zr', 4.23e-2)
        materials.append(zirc)

        materials.export_to_xml()

        # Geometry #

        pin_rad = 0.7  # cm
        assembly_pitch = 1.235  # cm
        hexagonal_pitch = 23.6  # cm
        length = 10.0  # cm

        # Fuel pin surfaces

        cylfuelin = openmc.ZCylinder(surface_id=1, r=0.386)
        cylfuelout = openmc.ZCylinder(surface_id=2, r=0.4582)

        # Fuel cells

        infcell = openmc.Cell(cell_id=1)
        infcell.region = -cylfuelin
        infcell.fill = fuel_mat

        clfcell = openmc.Cell(cell_id=2)
        clfcell.region = -cylfuelout & +cylfuelin
        clfcell.fill = zirc

        outfcell = openmc.Cell(cell_id=3)
        outfcell.region = +cylfuelout
        outfcell.fill = coolant

        # Fuel universe

        fuel_ch_univ = openmc.Universe(universe_id=1,
                                       name="Fuel channel",
                                       cells=[infcell, clfcell, outfcell])

        # Central tube surfaces

        cyltubein = openmc.ZCylinder(surface_id=3, r=0.45)
        cyltubeout = openmc.ZCylinder(surface_id=4, r=0.5177)

        # Central tube cells

        inctcell = openmc.Cell(cell_id=4)
        inctcell.region = -cyltubein
        inctcell.fill = coolant

        clctcell = openmc.Cell(cell_id=5)
        clctcell.region = -cyltubeout & +cyltubein
        clctcell.fill = zirc

        outctcell = openmc.Cell(cell_id=6)
        outctcell.region = +cyltubeout
        outctcell.fill = coolant

        # Central tubel universe

        tube_ch_univ = openmc.Universe(universe_id=2,
                                       name="Central tube channel",
                                       cells=[inctcell, clctcell, outctcell])

        # Absorber tube surfaces

        cylabsin = openmc.ZCylinder(surface_id=5, r=0.35)
        cylabsout = openmc.ZCylinder(surface_id=6, r=0.41)
        cylabsclin = openmc.ZCylinder(surface_id=7, r=0.545)
        cylabsclout = openmc.ZCylinder(surface_id=8, r=0.6323)

        # Absorber tube cells

        inabscell = openmc.Cell(cell_id=7)
        inabscell.region = -cylabsin
        inabscell.fill = absorber

        clabscell = openmc.Cell(cell_id=8)
        clabscell.region = -cylabsout & +cylabsin
        clabscell.fill = zirc

        interabscell = openmc.Cell(cell_id=9)
        interabscell.region = -cylabsclin & +cylabsout
        interabscell.fill = coolant

        clatcell = openmc.Cell(cell_id=10)
        clatcell.region = -cylabsclout & +cylabsclin
        clatcell.fill = zirc

        outabscell = openmc.Cell(cell_id=11)
        outabscell.region = +cylabsclout
        outabscell.fill = coolant

        # Absorber tube universe

        abs_ch_univ = openmc.Universe(
            universe_id=3,
            name="Central tube channel",
            cells=[inabscell, clabscell, interabscell, clatcell, outabscell])
        # Assembly surfaces

        edge_length = (1. / np.sqrt(3.0)) * hexagonal_pitch
        fuel_bottom = openmc.ZPlane(surface_id=9,
                                    z0=0.0,
                                    boundary_type='reflective')
        fuel_top = openmc.ZPlane(surface_id=10,
                                 z0=length,
                                 boundary_type='reflective')

        # a hex surface for the core to go inside of

        hexprism = openmc.model.hexagonal_prism(edge_length=edge_length,
                                                origin=(0.0, 0.0),
                                                boundary_type='reflective',
                                                orientation='x')
        region = hexprism & +fuel_bottom & -fuel_top

        inf_mat = openmc.Cell(cell_id=12)
        inf_mat.fill = coolant
        inf_mat_univ = openmc.Universe(universe_id=4, cells=[inf_mat])

        # Fill lattice by channels

        nring = 11
        universes = []
        for ring in range(nring - 1, -1, -1):
            arr = []
            arr.append(fuel_ch_univ)
            for cell in range(ring * 6 - 1):
                arr.append(fuel_ch_univ)
            universes.append(arr)
        universes[-1] = [tube_ch_univ]
        channels = [(7, 2), (7, 5), (7, 8), (7, 11), (7, 14), (7, 17), (5, 0),
                    (4, 3), (5, 5), (4, 9), (5, 10), (4, 15), (5, 15), (4, 21),
                    (5, 20), (4, 27), (5, 25), (4, 33)]
        for i, j in channels:
            universes[i][j] = abs_ch_univ
        lattice = openmc.HexLattice(name="regular fuel assembly")
        lattice.orientation = "x"
        lattice.center = (0., 0., length / 2.0)
        lattice.pitch = (assembly_pitch, length / 2.0)
        lattice.universes = 2 * [universes]
        lattice.outer = inf_mat_univ

        assembly_cell = openmc.Cell(cell_id=13, name="container assembly cell")
        assembly_cell.region = region
        assembly_cell.fill = lattice

        root_univ = openmc.Universe(universe_id=5,
                                    name="root universe",
                                    cells=[assembly_cell])

        geom = openmc.Geometry(root_univ)
        geom.export_to_xml()

        # Settings #

        settings = openmc.Settings()
        settings.run_mode = 'eigenvalue'

        source = openmc.Source()
        ll = [-edge_length, -edge_length, 0.0]
        ur = [edge_length, edge_length, 10.0]
        source.space = openmc.stats.Box(ll, ur)
        source.strength = 1.0
        settings.source = source
        settings.batches = 10
        settings.inactive = 5
        settings.particles = 1000
        settings.seed = 22
        settings.export_to_xml()
Beispiel #10
0
breedgap.fill = He
breedgap.region = gap_region

breedclad = openmc.Cell(14, 'breedclad')
breedclad.fill = stainless
breedclad.region = clad_region

#assembly
#assemebly cell
f = openmc.Universe(name='Fuel Pin', cells=[fuel, gap, clad, gas, coolant])
all_coolant = openmc.Universe(cells=[coolant2])
s = openmc.Universe(cells=[steel])
c = openmc.Universe(name='control rod', cells=[control, controlvoid])

#lattice
assembly = openmc.HexLattice()
assembly.center = (0, 0)
assembly.pitch = [1.36]
assembly.outer = all_coolant
assembly.universes = [[f] * 48, [f] * 42, [f] * 36, [f] * 30, [f] * 24,
                      [f] * 18, [s] * 12, [c] * 6, [c]]

# Create boundary planes to surround the geometry
asseouter_sphere = openmc.Sphere(R=300, boundary_type='vacuum')
asseouter_surface = openmc.ZCylinder(R=100, boundary_type='vacuum')
min_z = openmc.ZPlane(z0=-1.4, boundary_type='vacuum')
max_z = openmc.ZPlane(z0=+208.6, boundary_type='vacuum')
max_z2 = openmc.ZPlane(z0=+165.4, boundary_type='vacuum')
min_z2 = openmc.ZPlane(z0=-0.5, boundary_type='vacuum')

# cell for assembly
Beispiel #11
0
def rotated_lattice_model():
    model = openmc.model.Model()

    # Create some materials
    fuel1 = openmc.Material()
    fuel1.set_density('g/cm3', 10.0)
    fuel1.add_nuclide('U235', 1.0)
    fuel2 = openmc.Material()
    fuel2.set_density('g/cm3', 10.0)
    fuel2.add_nuclide('U238', 1.0)
    water = openmc.Material()
    water.set_density('g/cm3', 1.0)
    water.add_nuclide('H1', 2.0)
    water.add_nuclide('O16', 1.0)
    water.add_s_alpha_beta('c_H_in_H2O')
    model.materials.extend([fuel1, fuel2, water])

    # Create universes for lattices
    r_pin = openmc.ZCylinder(r=0.25)
    fuel_cell = openmc.Cell(fill=fuel1, region=-r_pin)
    water_cell = openmc.Cell(fill=water, region=+r_pin)
    pin_universe = openmc.Universe(cells=(fuel_cell, water_cell))
    r_big_pin = openmc.ZCylinder(r=0.5)
    fuel2_cell = openmc.Cell(fill=fuel2, region=-r_big_pin)
    water2_cell = openmc.Cell(fill=water, region=+r_big_pin)
    big_pin_universe = openmc.Universe(cells=(fuel2_cell, water2_cell))
    all_water_cell = openmc.Cell(fill=water)
    outer_universe = openmc.Universe(30, cells=(all_water_cell,))

    # Create hexagonal lattice
    pitch = 1.25
    hexlat = openmc.HexLattice()
    hexlat.center = (0., 0.)
    hexlat.pitch = [pitch]
    hexlat.outer = outer_universe
    outer_ring = [big_pin_universe] + [pin_universe]*11
    middle_ring = [big_pin_universe] + [pin_universe]*5
    inner_ring = [big_pin_universe]
    hexlat.universes = [outer_ring, middle_ring, inner_ring]

    # Create rectangular lattice
    rectlat = openmc.RectLattice()
    rectlat.center = (0., 0.)
    rectlat.pitch = (pitch, pitch)
    rectlat.lower_left = (-2*pitch, -2*pitch)
    rectlat.outer = outer_universe
    rectlat.universes = np.full((4, 4), pin_universe)
    rectlat.universes[0] = big_pin_universe

    # Create cell filled with translated/rotated rectangular lattice on left
    left_cyl = openmc.ZCylinder(x0=-4.0, r=4.0)
    left_cell = openmc.Cell(fill=rectlat, region=-left_cyl)
    left_cell.translation = (-4.0, 0.0, 0.0)
    left_cell.rotation = (0.0, 0.0, 45.0)

    # Create cell filled with translated/rotated hexagonal lattice on right
    right_cyl = openmc.ZCylinder(x0=4.0, r=4.0)
    right_cell = openmc.Cell(fill=hexlat, region=-right_cyl)
    right_cell.translation = (4.0, 0.0, 0.0)
    right_cell.rotation = (0.0, 0.0, 30.0)

    # Finish up with the geometry
    outer_cyl = openmc.ZCylinder(r=8.0, boundary_type='vacuum')
    main_cell = openmc.Cell(fill=water, region=-outer_cyl & +left_cyl & +right_cyl)
    model.geometry = openmc.Geometry([main_cell, left_cell, right_cell])

    model.settings.batches = 5
    model.settings.inactive = 0
    model.settings.particles = 1000
    model.settings.source = openmc.Source(space=openmc.stats.Point())
    model.settings.export_to_xml()

    return model
Beispiel #12
0
    def _read_lattices(self):
        self.n_lattices = self._f['geometry/n_lattices'].value

        # Initialize lattices for each Lattice
        # Keys     - Lattice keys
        # Values   - Lattice objects
        self.lattices = {}

        for key in self._f['geometry/lattices'].keys():
            if key == 'n_lattices':
                continue

            lattice_id = int(key.lstrip('lattice '))
            index = self._f['geometry/lattices'][key]['index'].value
            name = self._f['geometry/lattices'][key]['name'].value.decode()
            lattice_type = self._f['geometry/lattices'][key][
                'type'].value.decode()

            if 'offsets' in self._f['geometry/lattices'][key]:
                offsets = self._f['geometry/lattices'][key]['offsets'][...]
            else:
                offsets = None

            if lattice_type == 'rectangular':
                dimension = self._f['geometry/lattices'][key]['dimension'][...]
                lower_left = \
                     self._f['geometry/lattices'][key]['lower_left'][...]
                pitch = self._f['geometry/lattices'][key]['pitch'][...]
                outer = self._f['geometry/lattices'][key]['outer'].value

                universe_ids = \
                     self._f['geometry/lattices'][key]['universes'][...]
                universe_ids = np.swapaxes(universe_ids, 0, 1)
                universe_ids = np.swapaxes(universe_ids, 1, 2)

                # Create the Lattice
                lattice = openmc.RectLattice(lattice_id=lattice_id, name=name)
                lattice.dimension = tuple(dimension)
                lattice.lower_left = lower_left
                lattice.pitch = pitch

                # If the Universe specified outer the Lattice is not void (-22)
                if outer != -22:
                    lattice.outer = self.universes[outer]

                # Build array of Universe pointers for the Lattice
                universes = \
                    np.ndarray(tuple(universe_ids.shape), dtype=openmc.Universe)

                for x in range(universe_ids.shape[0]):
                    for y in range(universe_ids.shape[1]):
                        for z in range(universe_ids.shape[2]):
                            universes[x, y, z] = \
                                 self.get_universe_by_id(universe_ids[x, y, z])

                # Transpose, reverse y-dimension for appropriate ordering
                shape = universes.shape
                universes = np.transpose(universes, (1, 0, 2))
                universes.shape = shape
                universes = universes[:, ::-1, :]
                lattice.universes = universes

                if offsets is not None:
                    offsets = np.swapaxes(offsets, 0, 1)
                    offsets = np.swapaxes(offsets, 1, 2)
                    lattice.offsets = offsets

                # Add the Lattice to the global dictionary of all Lattices
                self.lattices[index] = lattice

            if lattice_type == 'hexagonal':
                n_rings = self._f['geometry/lattices'][key]['n_rings'][0]
                n_axial = self._f['geometry/lattices'][key]['n_axial'][0]
                center = self._f['geometry/lattices'][key]['center'][...]
                pitch = self._f['geometry/lattices'][key]['pitch'][...]
                outer = self._f['geometry/lattices'][key]['outer'][0]

                universe_ids = self._f['geometry/lattices'][key]['universes'][
                    ...]

                # Create the Lattice
                lattice = openmc.HexLattice(lattice_id=lattice_id, name=name)
                lattice.num_rings = n_rings
                lattice.num_axial = n_axial
                lattice.center = center
                lattice.pitch = pitch

                # If the Universe specified outer the Lattice is not void (-22)
                if outer != -22:
                    lattice.outer = self.universes[outer]

                # Build array of Universe pointers for the Lattice.  Note that
                # we need to convert between the HDF5's square array of
                # (x, alpha, z) to the Python API's format of a ragged nested
                # list of (z, ring, theta).
                universes = []
                for z in range(lattice.num_axial):
                    # Add a list for this axial level.
                    universes.append([])
                    x = lattice.num_rings - 1
                    a = 2 * lattice.num_rings - 2
                    for r in range(lattice.num_rings - 1, 0, -1):
                        # Add a list for this ring.
                        universes[-1].append([])

                        # Climb down the top-right.
                        for i in range(r):
                            universes[-1][-1].append(universe_ids[z, a, x])
                            x += 1
                            a -= 1

                        # Climb down the right.
                        for i in range(r):
                            universes[-1][-1].append(universe_ids[z, a, x])
                            a -= 1

                        # Climb down the bottom-right.
                        for i in range(r):
                            universes[-1][-1].append(universe_ids[z, a, x])
                            x -= 1

                        # Climb up the bottom-left.
                        for i in range(r):
                            universes[-1][-1].append(universe_ids[z, a, x])
                            x -= 1
                            a += 1

                        # Climb up the left.
                        for i in range(r):
                            universes[-1][-1].append(universe_ids[z, a, x])
                            a += 1

                        # Climb up the top-left.
                        for i in range(r):
                            universes[-1][-1].append(universe_ids[z, a, x])
                            x += 1

                        # Move down to the next ring.
                        a -= 1

                        # Convert the ids into Universe objects.
                        universes[-1][-1] = [
                            self.get_universe_by_id(u_id)
                            for u_id in universes[-1][-1]
                        ]

                    # Handle the degenerate center ring separately.
                    u_id = universe_ids[z, a, x]
                    universes[-1].append([self.get_universe_by_id(u_id)])

                # Add the universes to the lattice.
                if len(pitch) == 2:
                    # Lattice is 3D
                    lattice.universes = universes
                else:
                    # Lattice is 2D; extract the only axial level
                    lattice.universes = universes[0]

                if offsets is not None:
                    lattice.offsets = offsets

                # Add the Lattice to the global dictionary of all Lattices
                self.lattices[index] = lattice
Beispiel #13
0
sodium.add_element('Na', 2.2272e-02)

materials = openmc.Materials([fuel, ht9, sodium])
materials.export_to_xml()

################################################################################
# GEOMETRY

fuel_outer = openmc.ZCylinder(r=fuel_radius)
clad_outer = openmc.ZCylinder(r=clad_outer_radius)
pin_universe = openmc.model.pin([fuel_outer, clad_outer], [fuel, ht9, sodium])

na_cell = openmc.Cell(fill=sodium)
na_universe = openmc.Universe(cells=(na_cell, ))

lattice = openmc.HexLattice()
lattice.center = (0., 0.)
lattice.pitch = (pin_pitch, )
lattice.orientation = 'x'
lattice.universes = [[pin_universe]]
lattice.universes = [[pin_universe for _ in range(max(1, 6 * ring_index))]
                     for ring_index in reversed(range(10))]
lattice.outer = na_universe

outer_hex = openmc.model.hexagonal_prism(subassembly_pitch / sqrt(3.),
                                         orientation='x',
                                         boundary_type='periodic')
duct_outer_hex = openmc.model.hexagonal_prism(subassembly_duct_outer /
                                              sqrt(3.),
                                              orientation='x')
duct_inner_hex = openmc.model.hexagonal_prism(subassembly_duct_inner /