Example #1
0
import openmc

# Geometry
ground_sphere = openmc.Sphere(0, -100.5, 0, 100, boundary_type='vacuum')

cyl = openmc.YCylinder(0, -1, 0.5, boundary_type='vacuum')
ymax = openmc.YPlane(1.0, boundary_type='vacuum')
ymin = openmc.YPlane(0.3, boundary_type='vacuum')
top_cap = openmc.Sphere(0, 1.0, -1, 0.5, boundary_type='vacuum')
bottom_cap = openmc.Sphere(0, 0.3, -1, 0.5, boundary_type='vacuum')
ground_cell = openmc.Cell(region=-ground_sphere)

pill = openmc.Cell(region=((-cyl & -ymax & +ymin) | -top_cap | -bottom_cap))
another_sphere = openmc.Sphere(-1.5, 0.5, -1.0, 0.5, boundary_type='vacuum')
another_sphere_cell = openmc.Cell(region=-another_sphere)

ycone = openmc.YCone(1.5, 1.0, -1, 0.5, boundary_type='vacuum')
cone_cell = openmc.Cell(region=(-ycone & -ymax & +ymin))

geometry = openmc.Geometry([ground_cell, pill, another_sphere_cell, cone_cell])
geometry.export_to_xml()

# Placeholder materials file
openmc.Materials().export_to_xml()

# Minimal settings
settings = openmc.Settings()
settings.particles = 500
settings.batches = 10
settings.inactive = 1
Example #2
0
# Instantiate a Materials collection and export to XML
materials_file = openmc.Materials([uo2, helium, zircaloy, borated_water,normal_water,heavy_water])
materials_file.export_to_xml()

###############################################################################
#                 Exporting to OpenMC geometry.xml file
###############################################################################

# Instantiate ZCylinder surfaces
fuel_or = openmc.ZCylinder(surface_id=1, x0=0, y0=0, r=0.39218, name='Fuel OR')
clad_ir = openmc.ZCylinder(surface_id=2, x0=0, y0=0, r=0.40005, name='Clad IR')
clad_or = openmc.ZCylinder(surface_id=3, x0=0, y0=0, r=0.45720, name='Clad OR')
left = openmc.XPlane(surface_id=4, x0=-0.62992, name='left')
right = openmc.XPlane(surface_id=5, x0=0.62992, name='right')
bottom = openmc.YPlane(surface_id=6, y0=-0.62992, name='bottom')
top = openmc.YPlane(surface_id=7, y0=0.62992, name='top')

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

# Instantiate Cells
fuel = openmc.Cell(cell_id=1, name='cell 1')
gap = openmc.Cell(cell_id=2, name='cell 2')
clad = openmc.Cell(cell_id=3, name='cell 3')
water = openmc.Cell(cell_id=4, name='cell 4')

# Use surface half-spaces to define regions
fuel.region = -fuel_or
acrylic.add_nuclide('H1', 5.6642e-2)
acrylic.add_nuclide('O16', 1.4273e-2)
acrylic.add_nuclide('C0', 3.5648e-2)
acrylic.add_s_alpha_beta('c_H_in_CH2')
acrylic.set_density('g/cm3', 1.185)

mats = openmc.Materials([fuel, water, clad6061, rubber, acrylic])
mats.cross_sections = '/home/tang/nndc_hdf5/cross_sections.xml'
mats.export_to_xml()

#fuel cylinder
zc1 = openmc.ZCylinder(x0=0, y0=0, R=0.6325)
zc2 = openmc.ZCylinder(x0=0, y0=0, R=0.6415)
xp3 = openmc.XPlane(x0=-1.27)
xp4 = openmc.XPlane(x0=1.27)
yp5 = openmc.YPlane(y0=-1.27)
yp6 = openmc.YPlane(y0=1.27)
zp7 = openmc.ZPlane(z0=0.0)
zp8 = openmc.ZPlane(z0=92.075)
zp9 = openmc.ZPlane(z0=94.2975)  #top 0f clad

xp10 = openmc.XPlane(x0=25.4)
xp11 = openmc.XPlane(x0=0.)
zc12 = openmc.ZCylinder(x0=0, y0=0, R=0.7075)  #clad outer surface
xp13 = openmc.XPlane(x0=12.7)

yp19 = openmc.YPlane(y0=0.0)
yp20 = openmc.YPlane(y0=30.48)
yp21 = openmc.YPlane(y0=2.54)

zp23 = openmc.ZPlane(z0=-2.2225)
Example #4
0
zc2=openmc.ZCylinder(x0=0,y0=0,R=0.635)
zp7=openmc.ZPlane(z0= 0.0)
zp8=openmc.ZPlane(z0=91.44)
zp9=openmc.ZPlane(z0=91.92) #top 0f clad


xp10=openmc.XPlane(x0=40.64 )
xp11=openmc.XPlane(x0= 0.0)#first

xp12=openmc.XPlane(x0= 52.56) #second boundary
xp13=openmc.XPlane(x0= 93.2)

xp14=openmc.XPlane(x0= 105.12)#third
xp15=openmc.XPlane(x0= 145.76)

yp20=openmc.YPlane(y0=34.544 )
yp21=openmc.YPlane(y0=0 )
zp22=openmc.ZPlane(z0= 96.52)
zp23=openmc.ZPlane(z0= -1.27)

#side of water reflector
xp24=openmc.XPlane(x0=175.76 ,boundary_type='vacuum')
xp25=openmc.XPlane(x0=-30,boundary_type='vacuum')
yp26=openmc.YPlane(y0=64.544,boundary_type='vacuum' )
yp27=openmc.YPlane(y0=-30,boundary_type='vacuum')
zp28=openmc.ZPlane(z0=106.44,boundary_type='vacuum') #top of water
zp29=openmc.ZPlane(z0=-3.81)
zp30=openmc.ZPlane(z0=-19.11,boundary_type='vacuum' ) #bottom of water


Example #5
0
def slab_mg(reps=None, as_macro=True):
    """Create a one-group, 1D slab model.

    Parameters
    ----------
    reps : list, optional
        List of angular representations. Each item corresponds to materials and
        dictates the angular representation of the multi-group cross
        sections---isotropic ('iso') or angle-dependent ('ang'), and if Legendre
        scattering or tabular scattering ('mu') is used. Thus, items can be
        'ang', 'ang_mu', 'iso', or 'iso_mu'.

    as_macro : bool, optional
        Whether :class:`openmc.Macroscopic` is used

    Returns
    -------
    model : openmc.model.Model
        One-group, 1D slab model

    """
    model = openmc.model.Model()

    # Define materials needed for 1D/1G slab problem
    mat_names = ['uo2', 'clad', 'lwtr']
    mgxs_reps = ['ang', 'ang_mu', 'iso', 'iso_mu']

    if reps is None:
        reps = mgxs_reps

    xs = []
    i = 0
    for mat in mat_names:
        for rep in reps:
            i += 1
            name = mat + '_' + rep
            xs.append(name)
            if as_macro:
                m = openmc.Material(name=str(i))
                m.set_density('macro', 1.)
                m.add_macroscopic(name)
            else:
                m = openmc.Material(name=str(i))
                m.set_density('atom/b-cm', 1.)
                m.add_nuclide(name, 1.0, 'ao')
            model.materials.append(m)

    # Define the materials file
    model.xs_data = xs
    model.materials.cross_sections = "../1d_mgxs.h5"

    # Define surfaces.
    # Assembly/Problem Boundary
    left = openmc.XPlane(x0=0.0, boundary_type='reflective')
    right = openmc.XPlane(x0=10.0, boundary_type='reflective')
    bottom = openmc.YPlane(y0=0.0, boundary_type='reflective')
    top = openmc.YPlane(y0=10.0, boundary_type='reflective')

    # for each material add a plane
    planes = [openmc.ZPlane(z0=0.0, boundary_type='reflective')]
    dz = round(5. / float(len(model.materials)), 4)
    for i in range(len(model.materials) - 1):
        planes.append(openmc.ZPlane(z0=dz * float(i + 1)))
    planes.append(openmc.ZPlane(z0=5.0, boundary_type='reflective'))

    # Define cells for each material
    model.geometry.root_universe = openmc.Universe(name='root universe')
    xy = +left & -right & +bottom & -top
    for i, mat in enumerate(model.materials):
        c = openmc.Cell(fill=mat, region=xy & +planes[i] & -planes[i + 1])
        model.geometry.root_universe.add_cell(c)

    model.settings.batches = 10
    model.settings.inactive = 5
    model.settings.particles = 100
    model.settings.source = openmc.Source(space=openmc.stats.Box(
        [0.0, 0.0, 0.0], [10.0, 10.0, 5.]))
    model.settings.energy_mode = "multi-group"

    plot = openmc.Plot()
    plot.filename = 'mat'
    plot.origin = (5.0, 5.0, 2.5)
    plot.width = (2.5, 2.5)
    plot.basis = 'xz'
    plot.pixels = (3000, 3000)
    plot.color_by = 'material'
    model.plots.append(plot)

    return model
Example #6
0
materials = openmc.Materials([uo2, water])
materials.export_to_xml()

L = pitch

fCylinders = [
    openmc.ZCylinder(R=radius_fuel, x0=0.5 * L + i * L, y0=0.5 * L + j * L)
    for j in range(3) for i in range(3)
]

x1 = openmc.XPlane(x0=0.0, boundary_type='reflective')
x2 = openmc.XPlane(x0=1 * L)
x3 = openmc.XPlane(x0=2 * L)
x4 = openmc.XPlane(x0=3 * L, boundary_type='reflective')

y1 = openmc.YPlane(y0=0.0, boundary_type='reflective')
y2 = openmc.YPlane(y0=1 * L)
y3 = openmc.YPlane(y0=2 * L)
y4 = openmc.YPlane(y0=3 * L, boundary_type='reflective')

xP = [x1, x2, x3, x4]
yP = [y1, y2, y3, y4]



waterReg = +x1 & -x4 & +y1 & -y4 &                              \
           +fCylinders[0] &  +fCylinders[1] &  +fCylinders[2] & \
           +fCylinders[3] &  +fCylinders[4] &  +fCylinders[5] & \
           +fCylinders[6] &  +fCylinders[7] &  +fCylinders[8]

fCells = [
Example #7
0
def generate_mat_and_geom(pln_num):
    # 1.6 enriched fuel
    fuel = openmc.Material(name='1.6% Fuel')
    fuel.set_density('g/cm3', 10.31341)
    fuel.add_nuclide('U235', 3.7503e-4)
    fuel.add_nuclide('U238', 2.2625e-2)
    fuel.add_nuclide('O16', 4.6007e-2)
    # borated water
    water = openmc.Material(name='Borated Water')
    water.set_density('g/cm3', 0.740582)
    water.add_nuclide('H1', 4.9457e-2)
    water.add_nuclide('O16', 2.4732e-2)
    water.add_nuclide('B10', 8.0042e-6)
    # zircaloy
    zircaloy = openmc.Material(name='Zircaloy')
    zircaloy.set_density('g/cm3', 6.55)
    zircaloy.add_nuclide('Zr90', 7.2758e-3)

    # Instantiate a Materials collection
    materials_file = openmc.Materials([fuel, water, zircaloy])
    # Export to "materials.xml"
    materials_file.export_to_xml()

    # Create cylinders for the fuel and clad
    NumPln = pln_num
    fuel_radius = []
    Rout = 0.392
    Cout = 0.457
    # darea = np.pi*Rout**2/NumRad
    # area = 0
    # Rlist = []
    # for i in range(0,NumRad):
    #     area += darea
    #     r = np.sqrt(area/np.pi)
    #     Rlist.append(r)
    #     fuel_radius.append(openmc.ZCylinder(x0=0.0, y0=0.0, R=r))

    clad_outer_radius = openmc.ZCylinder(x0=0.0, y0=0.0, R=Cout)
    fuel_outer_radius = openmc.ZCylinder(x0=0.0, y0=0.0, R=Rout)
    # Create a Universe to encapsulate a fuel pin
    min_x = openmc.XPlane(x0=-0.63, boundary_type='reflective')
    max_x = openmc.XPlane(x0=+0.63, boundary_type='reflective')
    min_y = openmc.YPlane(y0=-0.63, boundary_type='reflective')
    max_y = openmc.YPlane(y0=+0.63, boundary_type='reflective')
    min_z = openmc.ZPlane(z0=-100., boundary_type='vacuum')
    max_z = openmc.ZPlane(z0=+100., boundary_type='vacuum')

    zmin = -100
    zmax = 100
    dx = (zmax - zmin) / pln_num
    planes = []
    for i in range(1, NumPln):
        planes.append(openmc.ZPlane(z0=dx * i - 100))
    # top = openmc.ZPlane(z0=zmax, boundary_type='reflective')

    fuelcelllist = []
    for i in range(0, len(planes) + 1):
        if i == 0:
            fuel_cell = openmc.Cell(name='fuel',
                                    fill=fuel,
                                    region=-fuel_outer_radius & +min_z
                                    & -planes[0])
        elif i == pln_num - 1:
            fuel_cell = openmc.Cell(name='fuel',
                                    fill=fuel,
                                    region=-fuel_outer_radius
                                    & +planes[pln_num - 2] & -max_z)
        else:
            fuel_cell = openmc.Cell(name='fuel',
                                    fill=fuel,
                                    region=-fuel_outer_radius & +planes[i - 1]
                                    & -planes[i])
        fuelcelllist.append(fuel_cell)

    fuel_cell_universe = openmc.Universe(name='Total Fuel Cell')
    for j in range(0, len(fuelcelllist)):
        fuel_cell_universe.add_cell(fuelcelllist[j])

    #Create total fuel cell
    total_fuel_cell = openmc.Cell(name='totalfuelcell')
    total_fuel_cell.fill = fuel_cell_universe
    total_fuel_cell.region = -fuel_outer_radius & +min_z & -max_z

    # Create a clad Cell
    clad_cell = openmc.Cell(name='1.6% Clad')
    clad_cell.fill = zircaloy
    clad_cell.region = +fuel_outer_radius & -clad_outer_radius & +min_x & -max_x & +min_y & -max_y & +min_z & -max_z

    # Create a moderator Cell
    moderator_cell = openmc.Cell(name='1.6% Moderator')
    moderator_cell.fill = water
    moderator_cell.region = +clad_outer_radius & +min_x & -max_x & +min_y & -max_y & +min_z & -max_z

    # Create root Universe
    root_universe = openmc.Universe(universe_id=0, name='root universe')
    root_universe.add_cell(total_fuel_cell)
    root_universe.add_cell(moderator_cell)
    root_universe.add_cell(clad_cell)

    # Create Geometry and set root Universe
    geometry = openmc.Geometry(root_universe)

    # Export to "geometry.xml"
    geometry.export_to_xml()
    # openmc.plot_geometry(output=False)
    return fuelcelllist, total_fuel_cell
Example #8
0
    def build_default_materials_and_geometry(self):
        # Define materials needed for 1D/1G slab problem
        # This time do using nuclide, not macroscopic
        uo2 = openmc.Material(name='UO2', material_id=1)
        uo2.set_density('sum', 1.0)
        uo2.add_nuclide("uo2_iso", 1.0)

        clad = openmc.Material(name='Clad', material_id=2)
        clad.set_density('sum', 1.0)
        clad.add_nuclide("clad_ang_mu", 1.0)

        # water_data = openmc.Nuclide('lwtr_iso_mu', '71c')
        water = openmc.Material(name='LWTR', material_id=3)
        water.set_density('sum', 1.0)
        water.add_nuclide("lwtr_iso_mu", 1.0)

        # Define the materials file.
        self.materials.default_xs = '71c'
        self.materials += (uo2, clad, water)

        # Define surfaces.

        # Assembly/Problem Boundary
        left = openmc.XPlane(x0=0.0,
                             surface_id=200,
                             boundary_type='reflective')
        right = openmc.XPlane(x0=10.0,
                              surface_id=201,
                              boundary_type='reflective')
        bottom = openmc.YPlane(y0=0.0,
                               surface_id=300,
                               boundary_type='reflective')
        top = openmc.YPlane(y0=10.0,
                            surface_id=301,
                            boundary_type='reflective')

        down = openmc.ZPlane(z0=0.0, surface_id=0, boundary_type='reflective')
        fuel_clad_intfc = openmc.ZPlane(z0=2.0, surface_id=1)
        clad_lwtr_intfc = openmc.ZPlane(z0=2.4, surface_id=2)
        up = openmc.ZPlane(z0=5.0, surface_id=3, boundary_type='reflective')

        # Define cells
        c1 = openmc.Cell(cell_id=1)
        c1.region = +left & -right & +bottom & -top & +down & -fuel_clad_intfc
        c1.fill = uo2
        c2 = openmc.Cell(cell_id=2)
        c2.region = +left & -right & +bottom & -top & +fuel_clad_intfc & -clad_lwtr_intfc
        c2.fill = clad
        c3 = openmc.Cell(cell_id=3)
        c3.region = +left & -right & +bottom & -top & +clad_lwtr_intfc & -up
        c3.fill = water

        # Define root universe.
        root = openmc.Universe(universe_id=0, name='root universe')

        root.add_cells((c1, c2, c3))

        # Define the geometry file.
        geometry = openmc.Geometry()
        geometry.root_universe = root

        self.geometry = geometry
Example #9
0
    def _read_surfaces(self):
        self.n_surfaces = self._f['geometry/n_surfaces'].value

        # Initialize dictionary for each Surface
        # Keys     - Surface keys
        # Values   - Surfacee objects
        self.surfaces = {}

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

            surface_id = int(key.lstrip('surface '))
            index = self._f['geometry/surfaces'][key]['index'].value
            name = self._f['geometry/surfaces'][key]['name'].value.decode()
            surf_type = self._f['geometry/surfaces'][key]['type'].value.decode(
            )
            bc = self._f['geometry/surfaces'][key][
                'boundary_condition'].value.decode()
            coeffs = self._f['geometry/surfaces'][key]['coefficients'][...]

            # Create the Surface based on its type
            if surf_type == 'x-plane':
                x0 = coeffs[0]
                surface = openmc.XPlane(surface_id, bc, x0, name)

            elif surf_type == 'y-plane':
                y0 = coeffs[0]
                surface = openmc.YPlane(surface_id, bc, y0, name)

            elif surf_type == 'z-plane':
                z0 = coeffs[0]
                surface = openmc.ZPlane(surface_id, bc, z0, name)

            elif surf_type == 'plane':
                A = coeffs[0]
                B = coeffs[1]
                C = coeffs[2]
                D = coeffs[3]
                surface = openmc.Plane(surface_id, bc, A, B, C, D, name)

            elif surf_type == 'x-cylinder':
                y0 = coeffs[0]
                z0 = coeffs[1]
                R = coeffs[2]
                surface = openmc.XCylinder(surface_id, bc, y0, z0, R, name)

            elif surf_type == 'y-cylinder':
                x0 = coeffs[0]
                z0 = coeffs[1]
                R = coeffs[2]
                surface = openmc.YCylinder(surface_id, bc, x0, z0, R, name)

            elif surf_type == 'z-cylinder':
                x0 = coeffs[0]
                y0 = coeffs[1]
                R = coeffs[2]
                surface = openmc.ZCylinder(surface_id, bc, x0, y0, R, name)

            elif surf_type == 'sphere':
                x0 = coeffs[0]
                y0 = coeffs[1]
                z0 = coeffs[2]
                R = coeffs[3]
                surface = openmc.Sphere(surface_id, bc, x0, y0, z0, R, name)

            elif surf_type in ['x-cone', 'y-cone', 'z-cone']:
                x0 = coeffs[0]
                y0 = coeffs[1]
                z0 = coeffs[2]
                R2 = coeffs[3]

                if surf_type == 'x-cone':
                    surface = openmc.XCone(surface_id, bc, x0, y0, z0, R2,
                                           name)
                if surf_type == 'y-cone':
                    surface = openmc.YCone(surface_id, bc, x0, y0, z0, R2,
                                           name)
                if surf_type == 'z-cone':
                    surface = openmc.ZCone(surface_id, bc, x0, y0, z0, R2,
                                           name)

            elif surf_type == 'quadric':
                a, b, c, d, e, f, g, h, j, k = coeffs
                surface = openmc.Quadric(surface_id, bc, a, b, c, d, e, f, g,
                                         h, j, k, name)

            # Add Surface to global dictionary of all Surfaces
            self.surfaces[index] = surface
Example #10
0
    def make_geometry(self, mats):
        # Instantiate Universe
        root = openmc.Universe(universe_id=0, name='root universe')
        cells = []

        if self.geom == 'IN':
            left = openmc.XPlane(x0=-INF, boundary_type='reflective')
            right = openmc.XPlane(x0=INF, boundary_type='reflective')
            bottom = openmc.YPlane(y0=-INF, boundary_type='reflective')
            top = openmc.YPlane(y0=INF, boundary_type='reflective')
            down = openmc.ZPlane(z0=-INF, boundary_type='reflective')
            up = openmc.ZPlane(z0=INF, boundary_type='reflective')

            # Instantiate Cells
            cells = []
            cells.append(openmc.Cell(name='fissile'))
            yz = (+bottom & -top) & (+down & -up)
            cells[-1].region = (+left & -right) & yz

            # Register Materials with Cells
            cells[-1].fill = mats[0]

        elif self.geom == 'SL':
            surfs = []
            surfs.append(openmc.XPlane(x0=0., boundary_type='reflective'))
            for r, rad in enumerate(self.rad):
                if r == len(self.rad) - 1:
                    surfs.append(openmc.XPlane(x0=rad, boundary_type='vacuum'))
                else:
                    surfs.append(openmc.XPlane(x0=rad))
            bottom = openmc.YPlane(y0=-INF, boundary_type='reflective')
            top = openmc.YPlane(y0=INF, boundary_type='reflective')
            down = openmc.ZPlane(z0=-INF, boundary_type='reflective')
            up = openmc.ZPlane(z0=INF, boundary_type='reflective')

            # Instantiate Cells
            yz = (+bottom & -top) & (+down & -up)
            cells = []
            for c in range(len(surfs) - 1):
                cells.append(openmc.Cell())
                cells[-1].region = (+surfs[c] & -surfs[c + 1]) & yz
                cells[-1].fill = mats[c]

        elif self.geom == 'SL-NS':
            surfs = []
            surfs.append(openmc.XPlane(x0=-self.rad[0],
                                       boundary_type='vacuum'))
            for r, rad in enumerate(self.rad):
                if r == len(self.rad) - 1:
                    surfs.append(openmc.XPlane(x0=rad, boundary_type='vacuum'))
                else:
                    surfs.append(openmc.XPlane(x0=rad))
            bottom = openmc.YPlane(y0=-INF, boundary_type='reflective')
            top = openmc.YPlane(y0=INF, boundary_type='reflective')
            down = openmc.ZPlane(z0=-INF, boundary_type='reflective')
            up = openmc.ZPlane(z0=INF, boundary_type='reflective')

            # Instantiate Cells
            yz = (+bottom & -top) & (+down & -up)
            cells = []
            for c in range(len(surfs) - 1):
                cells.append(openmc.Cell())
                cells[-1].region = (+surfs[c] & -surfs[c + 1]) & yz
                cells[-1].fill = mats[c]

        elif self.geom == 'FENA':
            surfs = []
            surfs.append(openmc.XPlane(x0=0.0, boundary_type='vacuum'))
            for c in range(len(mats) - 1):
                surfs.append(openmc.XPlane(x0=self.rad[c]))
            surfs.append(openmc.XPlane(x0=self.rad[-1],
                                       boundary_type='vacuum'))

            bottom = openmc.YPlane(y0=-INF, boundary_type='reflective')
            top = openmc.YPlane(y0=INF, boundary_type='reflective')
            down = openmc.ZPlane(z0=-INF, boundary_type='reflective')
            up = openmc.ZPlane(z0=INF, boundary_type='reflective')

            # Instantiate Cells
            yz = (+bottom & -top) & (+down & -up)
            cells = []
            for c in range(len(mats)):
                cells.append(openmc.Cell())
                cells[-1].region = (+surfs[c] & -surfs[c + 1]) & yz
                cells[-1].fill = mats[c]

        elif self.geom == 'CY':
            surfs = []
            for r, rad in enumerate(self.rad):
                if r == len(self.rad) - 1:
                    surfs.append(
                        openmc.ZCylinder(R=rad, boundary_type='vacuum'))
                else:
                    surfs.append(openmc.ZCylinder(R=rad))

            # Instantiate Cells
            cells = []
            cells.append(openmc.Cell())
            cells[-1].region = -surfs[0]
            cells[-1].fill = mats[0]
            for c in range(1, len(surfs)):
                cells.append(openmc.Cell())
                cells[-1].region = (+surfs[c - 1] & -surfs[c])
                cells[-1].fill = mats[c]

        elif self.geom == 'SP':
            surfs = []
            for r, rad in enumerate(self.rad):
                if r == len(self.rad) - 1:
                    surfs.append(openmc.Sphere(R=rad, boundary_type='vacuum'))
                else:
                    surfs.append(openmc.Sphere(R=rad))

            # Instantiate Cells
            cells = []
            cells.append(openmc.Cell())
            cells[-1].region = -surfs[0]
            cells[-1].fill = mats[0]
            for c in range(1, len(surfs)):
                cells.append(openmc.Cell())
                cells[-1].region = (+surfs[c - 1] & -surfs[c])
                cells[-1].fill = mats[c]

        elif self.geom == 'ISLC':
            surfs = []
            surfs.append(openmc.XPlane(x0=0., boundary_type='reflective'))
            for r, rad in enumerate(self.rad):
                if r == len(self.rad) - 1:
                    surfs.append(
                        openmc.XPlane(x0=rad, boundary_type='reflective'))
                else:
                    surfs.append(openmc.XPlane(x0=rad))
            bottom = openmc.YPlane(y0=-INF, boundary_type='reflective')
            top = openmc.YPlane(y0=INF, boundary_type='reflective')
            down = openmc.ZPlane(z0=-INF, boundary_type='reflective')
            up = openmc.ZPlane(z0=INF, boundary_type='reflective')

            # Instantiate Cells
            yz = (+bottom & -top) & (+down & -up)
            cells = []
            for c in range(len(surfs) - 1):
                cells.append(openmc.Cell())
                cells[-1].region = (+surfs[c] & -surfs[c + 1]) & yz
                cells[-1].fill = mats[c]

        # Register Cells with Universe
        root.add_cells(cells)

        # Instantiate a Geometry, register the root Universe, and export to XML
        geometry = openmc.Geometry(root)

        return geometry
Example #11
0
nxsurfs = nxbins + 1
nysurfs = nybins + 1
nzsurfs = nzbins + 1

XPLANES = []
YPLANES = []
ZPLANES = []
for i in range(nxsurfs):
    if (i == 0) or (i == nxsurfs - 1):
        XPLANES.append(openmc.XPlane(x0 = i*dx, boundary_type='vacuum'))
    else:
        XPLANES.append(openmc.XPlane(x0 = i*dx))

for j in range(nysurfs):
    if (j == 0) or (j == nysurfs - 1):
        YPLANES.append(openmc.YPlane(y0 = j*dy, boundary_type='vacuum'))
    else:
        YPLANES.append(openmc.YPlane(y0 = j*dy))

for k in range(nzsurfs):
    if (k == 0) or (k == nzsurfs - 1):
        ZPLANES.append(openmc.ZPlane(z0 = k*dz, boundary_type='vacuum'))
    else:
        ZPLANES.append(openmc.ZPlane(z0 = k*dz))

CELLS = []
for i in range(nxbins):
    for j in range(nybins):
        for k in range(nzbins):
            xsname = str(i)+"."+str(j)+"."+str(k)
            CELLS.append(openmc.Cell())
Example #12
0
def generate_geometry(n_rings, n_wedges):
    """ Generates example geometry.

    This function creates the initial geometry, a 9 pin reflective problem.
    One pin, containing gadolinium, is discretized into sectors.

    In addition to what one would do with the general OpenMC geometry code, it
    is necessary to create a dictionary, volume, that maps a cell ID to a
    volume. Further, by naming cells the same as the above materials, the code
    can automatically handle the mapping.

    Parameters
    ----------
    n_rings : int
        Number of rings to generate for the geometry
    n_wedges : int
        Number of wedges to generate for the geometry
    """

    pitch = 1.26197
    r_fuel = 0.412275
    r_gap = 0.418987
    r_clad = 0.476121

    n_pin = 3

    # This table describes the 'fuel' to actual type mapping
    # It's not necessary to do it this way.  Just adjust the initial conditions
    # below.
    mapping = [
        'fuel', 'fuel', 'fuel', 'fuel', 'fuel_gd', 'fuel', 'fuel', 'fuel',
        'fuel'
    ]

    # Form pin cell
    fuel_u, v_segment, v_gap, v_clad = segment_pin(n_rings, n_wedges, r_fuel,
                                                   r_gap, r_clad)

    # Form lattice
    all_water_c = openmc.Cell(name='cool')
    all_water_u = openmc.Universe(cells=(all_water_c, ))

    lattice = openmc.RectLattice()
    lattice.pitch = [pitch] * 2
    lattice.lower_left = [-pitch * n_pin / 2, -pitch * n_pin / 2]
    lattice_array = [[fuel_u for i in range(n_pin)] for j in range(n_pin)]
    lattice.universes = lattice_array
    lattice.outer = all_water_u

    # Bound universe
    x_low = openmc.XPlane(-pitch * n_pin / 2, boundary_type='reflective')
    x_high = openmc.XPlane(pitch * n_pin / 2, boundary_type='reflective')
    y_low = openmc.YPlane(-pitch * n_pin / 2, boundary_type='reflective')
    y_high = openmc.YPlane(pitch * n_pin / 2, boundary_type='reflective')
    z_low = openmc.ZPlane(-10, boundary_type='reflective')
    z_high = openmc.ZPlane(10, boundary_type='reflective')

    # Compute bounding box
    lower_left = [-pitch * n_pin / 2, -pitch * n_pin / 2, -10]
    upper_right = [pitch * n_pin / 2, pitch * n_pin / 2, 10]

    root_c = openmc.Cell(fill=lattice)
    root_c.region = (+x_low & -x_high & +y_low & -y_high & +z_low & -z_high)
    root_u = openmc.Universe(universe_id=0, cells=(root_c, ))
    geometry = openmc.Geometry(root_u)

    v_cool = pitch**2 - (v_gap + v_clad + n_rings * n_wedges * v_segment)

    # Store volumes for later usage
    volume = {'fuel': v_segment, 'gap': v_gap, 'clad': v_clad, 'cool': v_cool}

    return geometry, volume, mapping, lower_left, upper_right
Example #13
0
    def _build_inputs(self):
        # Define TRISO matrials
        fuel = openmc.Material()
        fuel.set_density('g/cm3', 10.5)
        fuel.add_nuclide('U235', 0.14154)
        fuel.add_nuclide('U238', 0.85846)
        fuel.add_nuclide('C0', 0.5)
        fuel.add_nuclide('O16', 1.5)

        porous_carbon = openmc.Material()
        porous_carbon.set_density('g/cm3', 1.0)
        porous_carbon.add_nuclide('C0', 1.0)
        porous_carbon.add_s_alpha_beta('c_Graphite')

        ipyc = openmc.Material()
        ipyc.set_density('g/cm3', 1.90)
        ipyc.add_nuclide('C0', 1.0)
        ipyc.add_s_alpha_beta('c_Graphite')

        sic = openmc.Material()
        sic.set_density('g/cm3', 3.20)
        sic.add_element('Si', 1.0)
        sic.add_nuclide('C0', 1.0)

        opyc = openmc.Material()
        opyc.set_density('g/cm3', 1.87)
        opyc.add_nuclide('C0', 1.0)
        opyc.add_s_alpha_beta('c_Graphite')

        graphite = openmc.Material()
        graphite.set_density('g/cm3', 1.1995)
        graphite.add_nuclide('C0', 1.0)
        graphite.add_s_alpha_beta('c_Graphite')

        # Create TRISO particles
        spheres = [
            openmc.Sphere(R=r * 1e-4) for r in [212.5, 312.5, 347.5, 382.5]
        ]
        c1 = openmc.Cell(fill=fuel, region=-spheres[0])
        c2 = openmc.Cell(fill=porous_carbon, region=+spheres[0] & -spheres[1])
        c3 = openmc.Cell(fill=ipyc, region=+spheres[1] & -spheres[2])
        c4 = openmc.Cell(fill=sic, region=+spheres[2] & -spheres[3])
        c5 = openmc.Cell(fill=opyc, region=+spheres[3])
        inner_univ = openmc.Universe(cells=[c1, c2, c3, c4, c5])

        outer_radius = 422.5 * 1e-4
        trisos = openmc.model.pack_trisos(radius=outer_radius,
                                          fill=inner_univ,
                                          domain_shape='cube',
                                          domain_length=1.,
                                          domain_center=(0., 0., 0.),
                                          n_particles=100)

        # Define box to contain lattice
        min_x = openmc.XPlane(x0=-0.5, boundary_type='reflective')
        max_x = openmc.XPlane(x0=0.5, boundary_type='reflective')
        min_y = openmc.YPlane(y0=-0.5, boundary_type='reflective')
        max_y = openmc.YPlane(y0=0.5, boundary_type='reflective')
        min_z = openmc.ZPlane(z0=-0.5, boundary_type='reflective')
        max_z = openmc.ZPlane(z0=0.5, boundary_type='reflective')
        box = openmc.Cell(region=+min_x & -max_x & +min_y & -max_y & +min_z
                          & -max_z)

        # Create lattice
        ll, ur = box.region.bounding_box
        shape = (3, 3, 3)
        pitch = (ur - ll) / shape
        lattice = openmc.model.create_triso_lattice(trisos, ll, pitch, shape,
                                                    graphite)
        box.fill = lattice

        root = openmc.Universe(0, cells=[box])
        geom = openmc.Geometry(root)
        geom.export_to_xml()

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

        mats = openmc.Materials(
            [fuel, porous_carbon, ipyc, sic, opyc, graphite])
        mats.export_to_xml()
Example #14
0
mats = openmc.Materials([fuel, clad, water])
mats.cross_sections = '/home/tang/nndc_hdf5/cross_sections.xml'
mats.export_to_xml()

#fuel
zc1 = openmc.ZCylinder(x0=0, y0=0, R=0.625)  #fuel
zc2 = openmc.ZCylinder(x0=0, y0=0, R=0.7085)  #clad

zp8 = openmc.ZPlane(z0=144.15)  #top fuel
zp7 = openmc.ZPlane(z0=0.0)  #bottom of fuel

#lattice
xp10 = openmc.XPlane(x0=36.98)
xp11 = openmc.XPlane(x0=0.)
yp20 = openmc.YPlane(y0=36.98)
yp19 = openmc.YPlane(y0=0.)

sph9 = openmc.Sphere(x0=18.49,
                     y0=18.49,
                     z0=72.075,
                     R=150.0,
                     boundary_type='vacuum')

zp11 = openmc.ZPlane(z0=73.73)  #critical water level=73.73

#water reflector=30.0 cm

xp31 = openmc.XPlane(x0=66.98)
xp32 = openmc.XPlane(x0=-30.)
yp33 = openmc.YPlane(y0=66.98)
Example #15
0
###############################################################################
#                 Exporting to OpenMC geometry.xml file
###############################################################################

# top and bottom surfaces (dz)
top_surface = openmc.ZPlane(z0=T_pitch / 2 + (z_thickness - 1) / 2 * T_pitch,
                            boundary_type='reflective')
bot_surface = openmc.ZPlane(z0=-(T_pitch / 2 +
                                 (z_thickness - 1) / 2 * T_pitch),
                            boundary_type='reflective')

# Outermost Hexagon

H_m = 1 / tan(pi / 6)
H_1 = openmc.YPlane(0.5 * H_side / tan(pi / 6), 'periodic')
H_2 = plane(-H_m, 0.5 * H_side, 0.5 * H_side / tan(pi / 6), 'periodic')
H_3 = plane(H_m, 0.5 * H_side, -0.5 * H_side / tan(pi / 6), 'periodic')
H_4 = openmc.YPlane(-0.5 * H_side / tan(pi / 6), 'periodic')
H_5 = plane(-H_m, -0.5 * H_side, -0.5 * H_side / tan(pi / 6), 'periodic')
H_6 = plane(H_m, -0.5 * H_side, 0.5 * H_side / tan(pi / 6), 'periodic')
H_1.periodic_surface = H_4
H_2.periodic_surface = H_5
H_3.periodic_surface = H_6
H_region = -H_1 & +H_4 & -H_2 & +H_3 & +H_5 & -H_6
H_cell = openmc.Cell(fill=graphite)
H_cell.region = H_region & -top_surface & +bot_surface

# Diamond Plank Area
A1_D_cell = openmc.Cell(fill=flibe)
A1_D_cell.region = region_maker('A1', 'D') & -top_surface & +bot_surface
Example #16
0
fuel = openmc.Cell(1, 'fuel')
fuel.fill = uo2
fuel.region = fuel_region

gap = openmc.Cell(2, 'air gap')
gap.region = gap_region

clad = openmc.Cell(3, 'clad')
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
Example #17
0
# Define water and zircaloy materials (always at 600 K)
water = openmc.Material(name='H2O', temperature=600.0)
water.set_density(units='sum')
for nuc, density in water_comp[600]:
    water.add_nuclide(nuc, density)
water.add_s_alpha_beta('c_H_in_H2O')

zircaloy = openmc.Material(name='Zircaloy', temperature=600.0)
zircaloy.set_density('atom/b-cm', clad_density[600])
zircaloy.add_element('Zr', 1.0)

for T in 600, 900:
    # Create box to bound pin-cell -- dimensions depend on T
    x_min = openmc.XPlane(x0=-pitch[T]/2, boundary_type='reflective')
    x_max = openmc.XPlane(x0=+pitch[T]/2, boundary_type='reflective')
    y_min = openmc.YPlane(y0=-pitch[T]/2, boundary_type='reflective')
    y_max = openmc.YPlane(y0=+pitch[T]/2, boundary_type='reflective')
    z_min = openmc.ZPlane(z0=-10.0, boundary_type='reflective')
    z_max = openmc.ZPlane(z0=+10.0, boundary_type='reflective')
    box = +x_min & -x_max & +y_min & -y_max & +z_min & -z_max

    # Define source as box
    settings.source = openmc.Source(space=openmc.stats.Box(
        *box.bounding_box))

    # Surfaces for fuel/clad
    fuel_outer = openmc.ZCylinder(R=fuel_or[T])
    clad_inner = openmc.ZCylinder(R=clad_ir[T])
    clad_outer = openmc.ZCylinder(R=clad_or[T])

    # Define cells within pin-cell
Example #18
0
    def build_cells(self, bc=None):
        """Generates a lattice of universes with the same dimensionality
        as the mesh object.  The individual cells/universes produced
        will not have material definitions applied and so downstream code
        will have to apply that information.

        Parameters
        ----------
        bc : iterable of {'reflective', 'periodic', 'transmission', 'vacuum', or 'white'}
            Boundary conditions for each of the four faces of a rectangle
            (if applying to a 2D mesh) or six faces of a parallelepiped
            (if applying to a 3D mesh) provided in the following order:
            [x min, x max, y min, y max, z min, z max].  2-D cells do not
            contain the z min and z max entries. Defaults to 'reflective' for
            all faces.

        Returns
        -------
        root_cell : openmc.Cell
            The cell containing the lattice representing the mesh geometry;
            this cell is a single parallelepiped with boundaries matching
            the outermost mesh boundary with the boundary conditions from bc
            applied.
        cells : iterable of openmc.Cell
            The list of cells within each lattice position mimicking the mesh
            geometry.

        """
        if bc is None:
            bc = ['reflective'] * 6
        if len(bc) not in (4, 6):
            raise ValueError('Boundary condition must be of length 4 or 6')
        for entry in bc:
            cv.check_value('bc', entry, _BOUNDARY_TYPES)

        n_dim = len(self.dimension)

        # Build the cell which will contain the lattice
        xplanes = [
            openmc.XPlane(self.lower_left[0], boundary_type=bc[0]),
            openmc.XPlane(self.upper_right[0], boundary_type=bc[1])
        ]
        if n_dim == 1:
            yplanes = [
                openmc.YPlane(-1e10, boundary_type='reflective'),
                openmc.YPlane(1e10, boundary_type='reflective')
            ]
        else:
            yplanes = [
                openmc.YPlane(self.lower_left[1], boundary_type=bc[2]),
                openmc.YPlane(self.upper_right[1], boundary_type=bc[3])
            ]

        if n_dim <= 2:
            # Would prefer to have the z ranges be the max supported float, but
            # these values are apparently different between python and Fortran.
            # Choosing a safe and sane default.
            # Values of +/-1e10 are used here as there seems to be an
            # inconsistency between what numpy uses as the max float and what
            # Fortran expects for a real(8), so this avoids code complication
            # and achieves the same goal.
            zplanes = [
                openmc.ZPlane(-1e10, boundary_type='reflective'),
                openmc.ZPlane(1e10, boundary_type='reflective')
            ]
        else:
            zplanes = [
                openmc.ZPlane(self.lower_left[2], boundary_type=bc[4]),
                openmc.ZPlane(self.upper_right[2], boundary_type=bc[5])
            ]
        root_cell = openmc.Cell()
        root_cell.region = ((+xplanes[0] & -xplanes[1]) &
                            (+yplanes[0] & -yplanes[1]) &
                            (+zplanes[0] & -zplanes[1]))

        # Build the universes which will be used for each of the (i,j,k)
        # locations within the mesh.
        # We will concurrently build cells to assign to these universes
        cells = []
        universes = []
        for _ in self.indices:
            cells.append(openmc.Cell())
            universes.append(openmc.Universe())
            universes[-1].add_cell(cells[-1])

        lattice = openmc.RectLattice()
        lattice.lower_left = self.lower_left

        # Assign the universe and rotate to match the indexing expected for
        # the lattice
        if n_dim == 1:
            universe_array = np.array([universes])
        elif n_dim == 2:
            universe_array = np.empty(self.dimension[::-1],
                                      dtype=openmc.Universe)
            i = 0
            for y in range(self.dimension[1] - 1, -1, -1):
                for x in range(self.dimension[0]):
                    universe_array[y][x] = universes[i]
                    i += 1
        else:
            universe_array = np.empty(self.dimension[::-1],
                                      dtype=openmc.Universe)
            i = 0
            for z in range(self.dimension[2]):
                for y in range(self.dimension[1] - 1, -1, -1):
                    for x in range(self.dimension[0]):
                        universe_array[z][y][x] = universes[i]
                        i += 1
        lattice.universes = universe_array

        if self.width is not None:
            lattice.pitch = self.width
        else:
            dx = ((self.upper_right[0] - self.lower_left[0]) /
                  self.dimension[0])

            if n_dim == 1:
                lattice.pitch = [dx]
            elif n_dim == 2:
                dy = ((self.upper_right[1] - self.lower_left[1]) /
                      self.dimension[1])
                lattice.pitch = [dx, dy]
            else:
                dy = ((self.upper_right[1] - self.lower_left[1]) /
                      self.dimension[1])
                dz = ((self.upper_right[2] - self.lower_left[2]) /
                      self.dimension[2])
                lattice.pitch = [dx, dy, dz]

        # Fill Cell with the Lattice
        root_cell.fill = lattice

        return root_cell, cells
Example #19
0
zp7 = openmc.ZPlane(z0=0.0)
zp8 = openmc.ZPlane(z0=92.075)
zp9 = openmc.ZPlane(z0=94.2975)  #top 0f clad

xp10 = openmc.XPlane(x0=38.1)  #first cluster
xp11 = openmc.XPlane(x0=0.0)
zc12 = openmc.ZCylinder(x0=0, y0=0, R=0.7075)  #clad outer surface

xp14 = openmc.XPlane(x0=84.1)  #second cluster
xp15 = openmc.XPlane(x0=46)  #second cluster

xp16 = openmc.XPlane(x0=130.1)  #third cluster
xp17 = openmc.XPlane(x0=92)  #third cluster

yp19 = openmc.YPlane(y0=0.0)
yp20 = openmc.YPlane(y0=20.32)

zp23 = openmc.ZPlane(z0=-2.2225)

#side of water reflector
xp24 = openmc.XPlane(x0=160.6, boundary_type='vacuum')
xp25 = openmc.XPlane(x0=-30.5, boundary_type='vacuum')
yp26 = openmc.YPlane(y0=50.82, boundary_type='vacuum')
yp27 = openmc.YPlane(y0=-30.5, boundary_type='vacuum')
zp28 = openmc.ZPlane(z0=107.075, boundary_type='vacuum')  #top of water
zp29 = openmc.ZPlane(z0=-4.7625)
zp35 = openmc.ZPlane(z0=-20.0625, boundary_type='vacuum')  #bottom of water

##ss plate
yp41 = openmc.YPlane(y0=-7.64)
Example #20
0
def get_openmc_surface(opencg_surface):
    """Return an OpenMC surface corresponding to an OpenCG surface.

    Parameters
    ----------
    opencg_surface : opencg.Surface
        OpenCG surface

    Returns
    -------
    openmc_surface : openmc.surface.Surface
        Equivalent OpenMC surface

    """

    if not isinstance(opencg_surface, opencg.Surface):
        msg = 'Unable to create an OpenMC Surface from "{0}" which ' \
              'is not an OpenCG Surface'.format(opencg_surface)
        raise ValueError(msg)

    global openmc_surface
    surface_id = opencg_surface.id

    # If this Surface was already created, use it
    if surface_id in OPENMC_SURFACES:
        return OPENMC_SURFACES[surface_id]

    # Create an OpenMC Surface to represent this OpenCG Surface
    name = opencg_surface.name

    # Correct for OpenMC's syntax for Surfaces dividing Cells
    boundary = opencg_surface.boundary_type
    if boundary == 'interface':
        boundary = 'transmission'

    if opencg_surface.type == 'plane':
        A = opencg_surface.a
        B = opencg_surface.b
        C = opencg_surface.c
        D = opencg_surface.d
        openmc_surface = openmc.Plane(surface_id, boundary, A, B, C, D, name)

    elif opencg_surface.type == 'x-plane':
        x0 = opencg_surface.x0
        openmc_surface = openmc.XPlane(surface_id, boundary, x0, name)

    elif opencg_surface.type == 'y-plane':
        y0 = opencg_surface.y0
        openmc_surface = openmc.YPlane(surface_id, boundary, y0, name)

    elif opencg_surface.type == 'z-plane':
        z0 = opencg_surface.z0
        openmc_surface = openmc.ZPlane(surface_id, boundary, z0, name)

    elif opencg_surface.type == 'x-cylinder':
        y0 = opencg_surface.y0
        z0 = opencg_surface.z0
        R = opencg_surface.r
        openmc_surface = openmc.XCylinder(surface_id, boundary, y0, z0, R,
                                          name)

    elif opencg_surface.type == 'y-cylinder':
        x0 = opencg_surface.x0
        z0 = opencg_surface.z0
        R = opencg_surface.r
        openmc_surface = openmc.YCylinder(surface_id, boundary, x0, z0, R,
                                          name)

    elif opencg_surface.type == 'z-cylinder':
        x0 = opencg_surface.x0
        y0 = opencg_surface.y0
        R = opencg_surface.r
        openmc_surface = openmc.ZCylinder(surface_id, boundary, x0, y0, R,
                                          name)

    else:
        msg = 'Unable to create an OpenMC Surface from an OpenCG ' \
              'Surface of type "{0}" since it is not a compatible ' \
              'Surface type in OpenMC'.format(opencg_surface.type)
        raise ValueError(msg)

    # Add the OpenMC Surface to the global collection of all OpenMC Surfaces
    OPENMC_SURFACES[surface_id] = openmc_surface

    # Add the OpenCG Surface to the global collection of all OpenCG Surfaces
    OPENCG_SURFACES[surface_id] = opencg_surface

    return openmc_surface
Example #21
0
# Instantiate a Materials collection and export to XML
materials_file = openmc.Materials([fuel1, fuel2, moderator])
materials_file.export_to_xml()

###############################################################################
#                 Exporting to OpenMC geometry.xml file
###############################################################################

# Instantiate planar surfaces
x1 = openmc.XPlane(surface_id=1, x0=-10)
x2 = openmc.XPlane(surface_id=2, x0=-7)
x3 = openmc.XPlane(surface_id=3, x0=-4)
x4 = openmc.XPlane(surface_id=4, x0=4)
x5 = openmc.XPlane(surface_id=5, x0=7)
x6 = openmc.XPlane(surface_id=6, x0=10)
y1 = openmc.YPlane(surface_id=11, y0=-10)
y2 = openmc.YPlane(surface_id=12, y0=-7)
y3 = openmc.YPlane(surface_id=13, y0=-4)
y4 = openmc.YPlane(surface_id=14, y0=4)
y5 = openmc.YPlane(surface_id=15, y0=7)
y6 = openmc.YPlane(surface_id=16, y0=10)
z1 = openmc.ZPlane(surface_id=21, z0=-10)
z2 = openmc.ZPlane(surface_id=22, z0=-7)
z3 = openmc.ZPlane(surface_id=23, z0=-4)
z4 = openmc.ZPlane(surface_id=24, z0=4)
z5 = openmc.ZPlane(surface_id=25, z0=7)
z6 = openmc.ZPlane(surface_id=26, z0=10)

# Set vacuum boundary conditions on outside
for surface in [x1, x6, y1, y6, z1, z6]:
    surface.boundary_type = 'vacuum'
def get_openmc_surface(openmoc_surface):
    """Return an OpenMC surface corresponding to an OpenMOC surface.

    Parameters
    ----------
    openmoc_surface : openmoc.Surface
        OpenMOC surface

    Returns
    -------
    openmc_surface : openmc.Surface
        Equivalent OpenMC surface

    """

    cv.check_type('openmoc_surface', openmoc_surface, openmoc.Surface)

    surface_id = openmoc_surface.getId()

    # If this Surface was already created, use it
    if surface_id in OPENMC_SURFACES:
        return OPENMC_SURFACES[surface_id]

    # Create an OpenMC Surface to represent this OpenMOC Surface
    name = openmoc_surface.getName()

    # Correct for OpenMC's syntax for Surfaces dividing Cells
    boundary = openmoc_surface.getBoundaryType()
    if boundary == openmoc.VACUUM:
        boundary = 'vacuum'
    elif boundary == openmoc.REFLECTIVE:
        boundary = 'reflective'
    elif boundary == openmoc.PERIODIC:
        boundary = 'periodic'
    else:
        boundary = 'transmission'

    if openmoc_surface.getSurfaceType() == openmoc.PLANE:
        openmoc_surface = openmoc.castSurfaceToPlane(openmoc_surface)
        A = openmoc_surface.getA()
        B = openmoc_surface.getB()
        C = openmoc_surface.getC()
        D = openmoc_surface.getD()

        # OpenMOC uses the opposite sign on D
        openmc_surface = openmc.Plane(surface_id, boundary, A, B, C, -D, name)

    elif openmoc_surface.getSurfaceType() == openmoc.XPLANE:
        openmoc_surface = openmoc.castSurfaceToXPlane(openmoc_surface)
        x0 = openmoc_surface.getX()
        openmc_surface = openmc.XPlane(surface_id, boundary, x0, name)

    elif openmoc_surface.getSurfaceType() == openmoc.YPLANE:
        openmoc_surface = openmoc.castSurfaceToYPlane(openmoc_surface)
        y0 = openmoc_surface.getY()
        openmc_surface = openmc.YPlane(surface_id, boundary, y0, name)

    elif openmoc_surface.getSurfaceType() == openmoc.ZPLANE:
        openmoc_surface = openmoc.castSurfaceToZPlane(openmoc_surface)
        z0 = openmoc_surface.getZ()
        openmc_surface = openmc.ZPlane(surface_id, boundary, z0, name)

    elif openmoc_surface.getSurfaceType() == openmoc.ZCYLINDER:
        openmoc_surface = openmoc.castSurfaceToZCylinder(openmoc_surface)
        x0 = openmoc_surface.getX0()
        y0 = openmoc_surface.getY0()
        R = openmoc_surface.getRadius()
        openmc_surface = openmc.ZCylinder(surface_id, boundary, x0, y0, R, name)

    # Add the OpenMC Surface to the global collection of all OpenMC Surfaces
    OPENMC_SURFACES[surface_id] = openmc_surface

    # Add the OpenMOC Surface to the global collection of all OpenMOC Surfaces
    OPENMOC_SURFACES[surface_id] = openmoc_surface

    return openmc_surface
Example #23
0
def pwr_assembly():
    """Create a PWR assembly model.

    This model is a reflected 17x17 fuel assembly from the the `BEAVRS
    <http://crpg.mit.edu/research/beavrs>`_ benchmark. The fuel is 2.4 w/o
    enriched UO2 corresponding to a beginning-of-cycle condition. Note that the
    number of particles/batches is initially set very low for testing purposes.

    Returns
    -------
    model : openmc.model.Model
        A PWR assembly model

    """

    model = openmc.model.Model()

    # Define materials.
    fuel = openmc.Material(name='Fuel')
    fuel.set_density('g/cm3', 10.29769)
    fuel.add_nuclide("U234", 4.4843e-6)
    fuel.add_nuclide("U235", 5.5815e-4)
    fuel.add_nuclide("U238", 2.2408e-2)
    fuel.add_nuclide("O16", 4.5829e-2)

    clad = openmc.Material(name='Cladding')
    clad.set_density('g/cm3', 6.55)
    clad.add_nuclide("Zr90", 2.1827e-2)
    clad.add_nuclide("Zr91", 4.7600e-3)
    clad.add_nuclide("Zr92", 7.2758e-3)
    clad.add_nuclide("Zr94", 7.3734e-3)
    clad.add_nuclide("Zr96", 1.1879e-3)

    hot_water = openmc.Material(name='Hot borated water')
    hot_water.set_density('g/cm3', 0.740582)
    hot_water.add_nuclide("H1", 4.9457e-2)
    hot_water.add_nuclide("O16", 2.4672e-2)
    hot_water.add_nuclide("B10", 8.0042e-6)
    hot_water.add_nuclide("B11", 3.2218e-5)
    hot_water.add_s_alpha_beta('c_H_in_H2O')

    # Define the materials file.
    model.materials = (fuel, clad, hot_water)

    # Instantiate ZCylinder surfaces
    fuel_or = openmc.ZCylinder(x0=0, y0=0, R=0.39218, name='Fuel OR')
    clad_or = openmc.ZCylinder(x0=0, y0=0, R=0.45720, name='Clad OR')

    # Create boundary planes to surround the geometry
    pitch = 21.42
    min_x = openmc.XPlane(x0=-pitch/2, boundary_type='reflective')
    max_x = openmc.XPlane(x0=+pitch/2, boundary_type='reflective')
    min_y = openmc.YPlane(y0=-pitch/2, boundary_type='reflective')
    max_y = openmc.YPlane(y0=+pitch/2, boundary_type='reflective')

    # Create a fuel pin universe
    fuel_pin_universe = openmc.Universe(name='Fuel Pin')
    fuel_cell = openmc.Cell(name='fuel', fill=fuel, region=-fuel_or)
    clad_cell = openmc.Cell(name='clad', fill=clad, region=+fuel_or & -clad_or)
    hot_water_cell = openmc.Cell(name='hot water', fill=hot_water, region=+clad_or)
    fuel_pin_universe.add_cells([fuel_cell, clad_cell, hot_water_cell])


    # Create a control rod guide tube universe
    guide_tube_universe = openmc.Universe(name='Guide Tube')
    gt_inner_cell = openmc.Cell(name='guide tube inner water', fill=hot_water,
                                region=-fuel_or)
    gt_clad_cell = openmc.Cell(name='guide tube clad', fill=clad,
                               region=+fuel_or & -clad_or)
    gt_outer_cell = openmc.Cell(name='guide tube outer water', fill=hot_water,
                                region=+clad_or)
    guide_tube_universe.add_cells([gt_inner_cell, gt_clad_cell, gt_outer_cell])

    # Create fuel assembly Lattice
    assembly = openmc.RectLattice(name='Fuel Assembly')
    assembly.pitch = (pitch/17, pitch/17)
    assembly.lower_left = (-pitch/2, -pitch/2)

    # Create array indices for guide tube locations in lattice
    template_x = np.array([5, 8, 11, 3, 13, 2, 5, 8, 11, 14, 2, 5, 8,
                           11, 14, 2, 5, 8, 11, 14, 3, 13, 5, 8, 11])
    template_y = np.array([2, 2, 2, 3, 3, 5, 5, 5, 5, 5, 8, 8, 8, 8,
                           8, 11, 11, 11, 11, 11, 13, 13, 14, 14, 14])

    # Create 17x17 array of universes
    assembly.universes = np.tile(fuel_pin_universe, (17, 17))
    assembly.universes[template_x, template_y] = guide_tube_universe

    # Create root Cell
    root_cell = openmc.Cell(name='root cell', fill=assembly)
    root_cell.region = +min_x & -max_x & +min_y & -max_y

    # Create root Universe
    model.geometry.root_universe = openmc.Universe(name='root universe')
    model.geometry.root_universe.add_cell(root_cell)

    model.settings.batches = 10
    model.settings.inactive = 5
    model.settings.particles = 100
    model.settings.source = openmc.Source(space=openmc.stats.Box(
        [-pitch/2, -pitch/2, -1], [pitch/2, pitch/2, 1], only_fissionable=True))

    plot = openmc.Plot()
    plot.origin = (0.0, 0.0, 0)
    plot.width = (21.42, 21.42)
    plot.pixels = (300, 300)
    plot.color_by = 'material'
    model.plots.append(plot)

    return model
#fuel cylinder
zc1 = openmc.ZCylinder(x0=0, y0=0, R=0.5588)
zc2 = openmc.ZCylinder(x0=0, y0=0, R=0.635)

zp7 = openmc.ZPlane(z0=0.0)
zp8 = openmc.ZPlane(z0=91.44)
zp9 = openmc.ZPlane(z0=91.92)  #top 0f clad

xp10 = openmc.XPlane(x0=38.608)
xp11 = openmc.XPlane(x0=0.0)
xp15 = openmc.XPlane(x0=51.708)
xp14 = openmc.XPlane(x0=90.316)
xp17 = openmc.XPlane(x0=103.416)
xp16 = openmc.XPlane(x0=142.024)

yp20 = openmc.YPlane(y0=32.512)
yp21 = openmc.YPlane(y0=0.0)
zp22 = openmc.ZPlane(z0=96.52)
zp23 = openmc.ZPlane(z0=-1.27)

#side of water reflector
xp24 = openmc.XPlane(x0=183.512, boundary_type='vacuum')
xp25 = openmc.XPlane(x0=-41.488, boundary_type='vacuum')
yp26 = openmc.YPlane(y0=63.012, boundary_type='vacuum')
yp27 = openmc.YPlane(y0=-30.5, boundary_type='vacuum')
zp28 = openmc.ZPlane(z0=111.72, boundary_type='vacuum')  #top of water
zp29 = openmc.ZPlane(z0=-3.81)

yp31 = openmc.YPlane(y0=-10.2)
yp32 = openmc.YPlane(y0=42.712)
xp33 = openmc.XPlane(x0=-10.988)
Example #25
0
def pwr_pin_cell():
    """Create a PWR pin-cell model.

    This model is a single fuel pin with 2.4 w/o enriched UO2 corresponding to a
    beginning-of-cycle condition and borated water. The specifications are from
    the `BEAVRS <http://crpg.mit.edu/research/beavrs>`_ benchmark. Note that the
    number of particles/batches is initially set very low for testing purposes.

    Returns
    -------
    model : openmc.model.Model
        A PWR pin-cell model

    """
    model = openmc.model.Model()

    # Define materials.
    fuel = openmc.Material(name='UO2 (2.4%)')
    fuel.set_density('g/cm3', 10.29769)
    fuel.add_nuclide("U234", 4.4843e-6)
    fuel.add_nuclide("U235", 5.5815e-4)
    fuel.add_nuclide("U238", 2.2408e-2)
    fuel.add_nuclide("O16", 4.5829e-2)

    clad = openmc.Material(name='Zircaloy')
    clad.set_density('g/cm3', 6.55)
    clad.add_nuclide("Zr90", 2.1827e-2)
    clad.add_nuclide("Zr91", 4.7600e-3)
    clad.add_nuclide("Zr92", 7.2758e-3)
    clad.add_nuclide("Zr94", 7.3734e-3)
    clad.add_nuclide("Zr96", 1.1879e-3)

    hot_water = openmc.Material(name='Hot borated water')
    hot_water.set_density('g/cm3', 0.740582)
    hot_water.add_nuclide("H1", 4.9457e-2)
    hot_water.add_nuclide("O16", 2.4672e-2)
    hot_water.add_nuclide("B10", 8.0042e-6)
    hot_water.add_nuclide("B11", 3.2218e-5)
    hot_water.add_s_alpha_beta('c_H_in_H2O')

    # Define the materials file.
    model.materials = (fuel, clad, hot_water)

    # Instantiate ZCylinder surfaces
    pitch = 1.26
    fuel_or = openmc.ZCylinder(x0=0, y0=0, R=0.39218, name='Fuel OR')
    clad_or = openmc.ZCylinder(x0=0, y0=0, R=0.45720, name='Clad OR')
    left = openmc.XPlane(x0=-pitch/2, name='left', boundary_type='reflective')
    right = openmc.XPlane(x0=pitch/2, name='right', boundary_type='reflective')
    bottom = openmc.YPlane(y0=-pitch/2, name='bottom',
                           boundary_type='reflective')
    top = openmc.YPlane(y0=pitch/2, name='top', boundary_type='reflective')

    # Instantiate Cells
    fuel_pin = openmc.Cell(name='Fuel', fill=fuel)
    cladding = openmc.Cell(name='Cladding', fill=clad)
    water = openmc.Cell(name='Water', fill=hot_water)

    # Use surface half-spaces to define regions
    fuel_pin.region = -fuel_or
    cladding.region = +fuel_or & -clad_or
    water.region = +clad_or & +left & -right & +bottom & -top

    # Create root universe
    model.geometry.root_universe = openmc.Universe(0, name='root universe')
    model.geometry.root_universe.add_cells([fuel_pin, cladding, water])

    model.settings.batches = 10
    model.settings.inactive = 5
    model.settings.particles = 100
    model.settings.source = openmc.Source(space=openmc.stats.Box(
        [-pitch/2, -pitch/2, -1], [pitch/2, pitch/2, 1], only_fissionable=True))

    plot = openmc.Plot.from_geometry(model.geometry)
    plot.pixels = (300, 300)
    plot.color_by = 'material'
    model.plots.append(plot)

    return model
Example #26
0
###############################################################################
# Geometry

# Instantiate zCylinder surfaces
fuel_or = openmc.ZCylinder(r=0.4096, name='Fuel OR')
clad_ir = openmc.ZCylinder(r=0.4180, name='Clad IR')
clad_or = openmc.ZCylinder(r=0.4750, name='Clad OR')
gt_ir = openmc.ZCylinder(r=0.5610, name='Guide Tube IR')
gt_or = openmc.ZCylinder(r=0.6020, name='Guide Tube OR')
aic_ir = openmc.ZCylinder(r=0.3820, name='AIC Radius')
aic_clad_ir = openmc.ZCylinder(r=0.3860, name='AIC Clad IR')
aic_clad_or = openmc.ZCylinder(r=0.4840, name='AIC Clad OR')

assembly_left = openmc.XPlane(x0=-10.75, boundary_type='reflective')
assembly_right = openmc.XPlane(x0=10.75, boundary_type='reflective')
assembly_back = openmc.YPlane(y0=-10.75, boundary_type='reflective')
assembly_front = openmc.YPlane(y0=10.75, boundary_type='reflective')
assembly_bottom = openmc.ZPlane(z0=-200.0, boundary_type='reflective')
assembly_top = openmc.ZPlane(z0=200.0, boundary_type='reflective')

lattice_left = openmc.XPlane(x0=-10.71)
lattice_right = openmc.XPlane(x0=10.71)
lattice_back = openmc.YPlane(y0=-10.71)
lattice_front = openmc.YPlane(y0=10.71)
lattice_bottom = openmc.ZPlane(z0=-200.0)
lattice_top = openmc.ZPlane(z0=200.0)

# fuel rod cell with 3.6 w/o
u_fuel = openmc.model.pin([fuel_or, clad_ir, clad_or],
                          [fuel_31, helium, zirc4, water_600])
Example #27
0
 def __init__(self, x0=0., y0=0., z0=0., r2=1., up=True, **kwargs):
     check_greater_than('cone R^2', r2, 0.0)
     self.cone = openmc.YCone(x0, y0, z0, r2, **kwargs)
     self.plane = openmc.YPlane(y0)
     self.up = up
Example #28
0
def generate_geometry():
    """ Generates example geometry.

    This function creates the initial geometry, a 4 pin reflective problem.
    One pin, containing gadolinium, is discretized into 5 radial cells of
    equal volume.  Reflections go through the center of this pin.

    In addition to what one would do with the general OpenMC geometry code, it
    is necessary to create a dictionary, volume, that maps a cell ID to a
    volume. Further, by naming cells the same as the above materials, the code
    can automatically handle the mapping.
    """

    import math
    import numpy as np

    pitch = 1.2600
    r_fuel = 0.4096
    r_gap = 0.4180
    r_clad = 0.4750
    n_rings = 1

    # Calculate all the volumes of interest ahead of time
    v_fuel = math.pi * r_fuel**2
    v_gap = math.pi * r_gap**2 - v_fuel
    v_clad = math.pi * r_clad**2 - v_fuel - v_gap
    v_ring = v_fuel / n_rings

    # Form dictionaries for later use.
    volume = OrderedDict()

    # Calculate pin discretization radii
    r_rings = np.zeros(n_rings)

    # Remaining rings
    for i in range(n_rings):
        r_rings[i] = math.sqrt(1.0 / (math.pi) * v_ring * (i + 1))

    # Form bounding box
    left = openmc.XPlane(x0=-3.0 / 2.0 * pitch, name='left')
    right = openmc.XPlane(x0=3.0 / 2.0 * pitch, name='right')
    bottom = openmc.YPlane(y0=-3.0 / 2.0 * pitch, name='bottom')
    top = openmc.YPlane(y0=3.0 / 2.0 * pitch, name='top')

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

    # ----------------------------------------------------------------------
    # Fill pin 1 (the one with gadolinium)

    gd_fuel_r = [
        openmc.ZCylinder(x0=0, y0=0, R=r_rings[i]) for i in range(n_rings)
    ]
    gd_clad_ir = openmc.ZCylinder(x0=0, y0=0, R=r_gap)
    gd_clad_or = openmc.ZCylinder(x0=0, y0=0, R=r_clad)

    gd_fuel_cell = openmc.Cell(name='fuel_gd')
    gd_fuel_cell.region = -gd_fuel_r[0]
    volume[gd_fuel_cell.id] = v_ring

    # Gap
    gd_fuel_gap = openmc.Cell(name='gap')
    gd_fuel_gap.region = +gd_fuel_r[n_rings - 1] & -gd_clad_ir
    volume[gd_fuel_gap.id] = v_gap

    # Clad
    gd_fuel_clad = openmc.Cell(name='clad')
    gd_fuel_clad.region = +gd_clad_ir & -gd_clad_or
    volume[gd_fuel_clad.id] = v_clad

    # ----------------------------------------------------------------------
    # Fill pin 2, 3 and 4 (without gadolinium)
    coords = [[pitch, 0], [pitch, pitch], [0, pitch], [-pitch, pitch],
              [-pitch, 0], [-pitch, -pitch], [0, -pitch], [pitch, -pitch]]

    fuel_s = []
    clad_ir_s = []
    clad_or_s = []

    fuel_cell = []
    clad_cell = []
    gap_cell = []

    ind = 0

    for x in coords:
        fuel_s.append(openmc.ZCylinder(x0=x[0], y0=x[1], R=r_fuel))
        clad_ir_s.append(openmc.ZCylinder(x0=x[0], y0=x[1], R=r_gap))
        clad_or_s.append(openmc.ZCylinder(x0=x[0], y0=x[1], R=r_clad))

        fs = openmc.Cell(name='fuel')
        cs = openmc.Cell(name='clad')
        gs = openmc.Cell(name='gap')

        fs.region = -fuel_s[ind]
        gs.region = +fuel_s[ind] & -clad_ir_s[ind]
        cs.region = +clad_ir_s[ind] & -clad_or_s[ind]

        volume[fs.id] = v_fuel
        volume[cs.id] = v_clad
        volume[gs.id] = v_gap

        fuel_cell.append(fs)
        clad_cell.append(cs)
        gap_cell.append(gs)
        ind += 1

    # ----------------------------------------------------------------------
    # Fill coolant

    cool_cell = openmc.Cell(name='cool')
    cool_cell.region = +clad_or_s[0] & +clad_or_s[1] & +clad_or_s[2] &\
                       +clad_or_s[3] & +clad_or_s[4] & +clad_or_s[5] &\
                       +clad_or_s[6] & +clad_or_s[7] &\
                       +gd_clad_or & +left & -right & +bottom & -top
    volume[cool_cell.id] = (3 * pitch)**2 - 9 * v_fuel - \
        9 * v_gap - 9 * v_clad

    # ----------------------------------------------------------------------
    # Finalize geometry
    root = openmc.Universe(universe_id=0, name='root universe')

    root.add_cells([cool_cell] + clad_cell + gap_cell + fuel_cell +
                   [gd_fuel_cell] + [gd_fuel_clad] + [gd_fuel_gap])

    geometry = openmc.Geometry()
    geometry.root_universe = root
    return geometry, volume
Example #29
0
iron.add_nuclide(fe56, 1.)

# Instantiate a MaterialsFile, register all Materials, and export to XML
materials_file = openmc.MaterialsFile()
materials_file.default_xs = '71c'
materials_file.add_materials([moderator, fuel, iron])
materials_file.export_to_xml()

###############################################################################
#                 Exporting to OpenMC geometry.xml File
###############################################################################

# Instantiate Surfaces
left = openmc.XPlane(surface_id=1, x0=-3, name='left')
right = openmc.XPlane(surface_id=2, x0=3, name='right')
bottom = openmc.YPlane(surface_id=3, y0=-4, name='bottom')
top = openmc.YPlane(surface_id=4, y0=4, name='top')
fuel_surf = openmc.ZCylinder(surface_id=5, x0=0, y0=0, R=0.4)

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

# Instantiate Cells
cell1 = openmc.Cell(cell_id=1, name='Cell 1')
cell2 = openmc.Cell(cell_id=101, name='cell 2')
cell3 = openmc.Cell(cell_id=102, name='cell 3')
cell4 = openmc.Cell(cell_id=500, name='cell 4')
cell5 = openmc.Cell(cell_id=600, name='cell 5')
cell6 = openmc.Cell(cell_id=601, name='cell 6')
Example #30
0
zc2 = openmc.ZCylinder(x0=0, y0=0, R=0.6415)

zp7 = openmc.ZPlane(z0=0.0)
zp8 = openmc.ZPlane(z0=92.075)
zp9 = openmc.ZPlane(z0=94.2975)  #top 0f clad

xp10 = openmc.XPlane(x0=33.02)
xp11 = openmc.XPlane(x0=0.0)
zc12 = openmc.ZCylinder(x0=0, y0=0, R=0.7075)  #clad outer surface

xp14 = openmc.XPlane(x0=85.535)
xp15 = openmc.XPlane(x0=52.515)
xp16 = openmc.XPlane(x0=138.05)
xp17 = openmc.XPlane(x0=105.03)

yp19 = openmc.YPlane(y0=0.0)
yp20 = openmc.YPlane(y0=20.32)

zp23 = openmc.ZPlane(z0=-2.2225)

#side of water reflector
xp24 = openmc.XPlane(x0=181.525, boundary_type='vacuum')
xp25 = openmc.XPlane(x0=-43.475, boundary_type='vacuum')
yp26 = openmc.YPlane(y0=50.82, boundary_type='vacuum')
yp27 = openmc.YPlane(y0=-30.5, boundary_type='vacuum')
zp28 = openmc.ZPlane(z0=109.4975, boundary_type='vacuum')  #top of water
zp35 = openmc.ZPlane(z0=-20.0625, boundary_type='vacuum')  #bottom of lead

##lead pb
zp29 = openmc.ZPlane(z0=-4.7625)  #bottom of acrylic support plate