Example #1
0
def test_from_expression(reset):
    # Create surface dictionary
    s1 = openmc.ZCylinder(surface_id=1)
    s2 = openmc.ZPlane(-10., surface_id=2)
    s3 = openmc.ZPlane(10., surface_id=3)
    surfs = {1: s1, 2: s2, 3: s3}

    r = openmc.Region.from_expression('-1 2 -3', surfs)
    assert isinstance(r, openmc.Intersection)
    assert r[:] == [-s1, +s2, -s3]

    r = openmc.Region.from_expression('+1 | -2 | +3', surfs)
    assert isinstance(r, openmc.Union)
    assert r[:] == [+s1, -s2, +s3]

    r = openmc.Region.from_expression('~(-1)', surfs)
    assert r == +s1

    # Since & has higher precendence than |, the resulting region should be an
    # instance of Union
    r = openmc.Region.from_expression('1 -2 | 3', surfs)
    assert isinstance(r, openmc.Union)
    assert isinstance(r[0], openmc.Intersection)
    assert r[0][:] == [+s1, -s2]

    # ...but not if we use parentheses
    r = openmc.Region.from_expression('1 (-2 | 3)', surfs)
    assert isinstance(r, openmc.Intersection)
    assert isinstance(r[1], openmc.Union)
    assert r[1][:] == [-s2, +s3]
def test_complement(reset):
    zcyl = openmc.ZCylinder(r=1., surface_id=1)
    z0 = openmc.ZPlane(-5., surface_id=2)
    z1 = openmc.ZPlane(5., surface_id=3)
    outside = +zcyl | -z0 | +z1
    inside = ~outside
    outside_equiv = ~(-zcyl & +z0 & -z1)
    inside_equiv = ~outside_equiv

    # Check bounding box
    for region in (inside, inside_equiv):
        ll, ur = region.bounding_box
        assert ll == pytest.approx((-1., -1., -5.))
        assert ur == pytest.approx((1., 1., 5.))
    assert_unbounded(outside)
    assert_unbounded(outside_equiv)

    # string represention
    assert str(inside) == '~(1 | -2 | 3)'

    # evaluate method
    assert (0, 0, 0) in inside
    assert (0, 0, 0) not in outside
    assert (0, 0, 6) not in inside
    assert (0, 0, 6) in outside

    # translate method
    inside_t = inside.translate((1.0, 1.0, 1.0))
    ll, ur = inside_t.bounding_box
    assert ll == pytest.approx((0., 0., -4.))
    assert ur == pytest.approx((2., 2., 6.))
Example #3
0
    def build_default_materials_and_geometry(self):
        # Define materials needed for 1D/1G slab problem
        uo2_data = openmc.Macroscopic('uo2_iso', '71c')
        uo2 = openmc.Material(name='UO2', material_id=1)
        uo2.set_density('macro', 1.0)
        uo2.add_macroscopic(uo2_data)

        clad_data = openmc.Macroscopic('clad_ang_mu', '71c')
        clad = openmc.Material(name='Clad', material_id=2)
        clad.set_density('macro', 1.0)
        clad.add_macroscopic(clad_data)

        water_data = openmc.Macroscopic('lwtr_iso_mu', '71c')
        water = openmc.Material(name='LWTR', material_id=3)
        water.set_density('macro', 1.0)
        water.add_macroscopic(water_data)

        # 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))

        # Assign root universe to geometry
        self.geometry.root_universe = root
Example #4
0
    def _add_outer_rings(self):
        """ Adds BEAVRS RPV, liner, and downcomer """

        self.s_upperBound = openmc.ZPlane(name='Highest Extent',
                                          z0=c.struct_HighestExtent,
                                          boundary_type='vacuum')
        self.s_lowerBound = openmc.ZPlane(name='Lowest Extent',
                                          z0=c.struct_LowestExtent,
                                          boundary_type='vacuum')

        # RPV

        self.s_RPVOR = openmc.ZCylinder(name='RPV OR',
                                        R=c.rpvOR,
                                        boundary_type='vacuum')
        self.s_RPVIR = openmc.ZCylinder(name='RPV IR', R=c.rpvIR)
        self.c_RPV = openmc.Cell(name="RPV", fill=self.mats['Carbon Steel'])
        self.c_RPV.region = (-self.s_RPVOR & +self.s_RPVIR & -self.s_upperBound
                             & +self.s_lowerBound)

        # RPV liner

        self.s_linerIR = openmc.ZCylinder(name='RPV Liner IR', R=c.linerIR)
        self.c_liner = openmc.Cell(name="RPV Liner", fill=self.mats['SS304'])
        self.c_liner.region = (-self.s_RPVIR & +self.s_linerIR
                               & -self.s_upperBound & +self.s_lowerBound)

        # Downcomer

        self.s_neutronShieldOR = openmc.ZCylinder(name='Shield Panel OR',
                                                  R=c.neutronShieldOR)
        self.c_downcomer = openmc.Cell(name="Downcomer",
                                       fill=self.mats['Borated Water'])
        self.c_downcomer.region = (-self.s_linerIR & +self.s_neutronShieldOR
                                   & -self.s_upperBound & +self.s_lowerBound)
Example #5
0
    def _build_inputs(self):
        # Define materials
        water = openmc.Material(1)
        water.add_nuclide('H1', 2.0)
        water.add_nuclide('O16', 1.0)
        water.add_nuclide('B10', 0.0001)
        water.add_s_alpha_beta('c_H_in_H2O')
        water.set_density('g/cc', 1.0)

        fuel = openmc.Material(2)
        fuel.add_nuclide('U235', 1.0)
        fuel.add_nuclide('Mo99', 0.1)
        fuel.set_density('g/cc', 4.5)

        materials = openmc.Materials((water, fuel))
        materials.export_to_xml()

        cyl = openmc.ZCylinder(surface_id=1, r=1.0, boundary_type='vacuum')
        top_sphere = openmc.Sphere(surface_id=2,
                                   z0=5.,
                                   r=1.,
                                   boundary_type='vacuum')
        top_plane = openmc.ZPlane(surface_id=3, z0=5.)
        bottom_sphere = openmc.Sphere(surface_id=4,
                                      z0=-5.,
                                      r=1.,
                                      boundary_type='vacuum')
        bottom_plane = openmc.ZPlane(surface_id=5, z0=-5.)

        # Define geometry
        inside_cyl = openmc.Cell(1,
                                 fill=fuel,
                                 region=-cyl & -top_plane & +bottom_plane)
        top_hemisphere = openmc.Cell(2,
                                     fill=water,
                                     region=-top_sphere & +top_plane)
        bottom_hemisphere = openmc.Cell(3,
                                        fill=water,
                                        region=-bottom_sphere & -top_plane)
        root = openmc.Universe(0,
                               cells=(inside_cyl, top_hemisphere,
                                      bottom_hemisphere))

        geometry = openmc.Geometry(root)
        geometry.export_to_xml()

        # Set up stochastic volume calculation
        ll, ur = root.bounding_box
        vol_calcs = [
            openmc.VolumeCalculation(list(root.cells.values()), 100000),
            openmc.VolumeCalculation([water, fuel], 100000, ll, ur),
            openmc.VolumeCalculation([root], 100000, ll, ur)
        ]

        # Define settings
        settings = openmc.Settings()
        settings.run_mode = 'volume'
        settings.volume_calculations = vol_calcs
        settings.export_to_xml()
Example #6
0
    def _make_openmc_input(self):
        """Generate the OpenMC input XML

        """
        # Define material
        mat = openmc.Material()
        mat.add_nuclide(self.nuclide, 1.0)
        if self.thermal is not None:
            name, suffix = self.thermal.split('.')
            thermal_name = openmc.data.thermal.get_thermal_name(name)
            mat.add_s_alpha_beta(thermal_name)
        mat.set_density('g/cm3', self.density)
        materials = openmc.Materials([mat])
        if self.xsdir is not None:
            xs_path = (self.openmc_dir / 'cross_sections.xml').resolve()
            materials.cross_sections = str(xs_path)
        materials.export_to_xml(self.openmc_dir / 'materials.xml')

        # Set up geometry
        x1 = openmc.XPlane(x0=-1.e9, boundary_type='reflective')
        x2 = openmc.XPlane(x0=+1.e9, boundary_type='reflective')
        y1 = openmc.YPlane(y0=-1.e9, boundary_type='reflective')
        y2 = openmc.YPlane(y0=+1.e9, boundary_type='reflective')
        z1 = openmc.ZPlane(z0=-1.e9, boundary_type='reflective')
        z2 = openmc.ZPlane(z0=+1.e9, boundary_type='reflective')
        cell = openmc.Cell(fill=materials)
        cell.region = +x1 & -x2 & +y1 & -y2 & +z1 & -z2
        geometry = openmc.Geometry([cell])
        geometry.export_to_xml(self.openmc_dir / 'geometry.xml')

        # Define source
        source = openmc.Source()
        source.space = openmc.stats.Point((0, 0, 0))
        source.angle = openmc.stats.Isotropic()
        source.energy = openmc.stats.Discrete([self.energy], [1.])

        # Settings
        settings = openmc.Settings()
        if self._temperature is not None:
            settings.temperature = {'default': self._temperature}
        settings.source = source
        settings.particles = self.particles // self._batches
        settings.run_mode = 'fixed source'
        settings.batches = self._batches
        settings.create_fission_neutrons = False
        settings.export_to_xml(self.openmc_dir / 'settings.xml')

        # Define tallies
        energy_bins = np.logspace(np.log10(self._min_energy),
                                  np.log10(1.0001 * self.energy),
                                  self._bins + 1)
        energy_filter = openmc.EnergyFilter(energy_bins)
        tally = openmc.Tally(name='tally')
        tally.filters = [energy_filter]
        tally.scores = ['flux']
        tallies = openmc.Tallies([tally])
        tallies.export_to_xml(self.openmc_dir / 'tallies.xml')
def centers_z_cylinder():
    cylinder = openmc.ZCylinder(r=1, x0=1, y0=2)
    min_z = openmc.ZPlane(0)
    max_z = openmc.ZPlane(1)
    region = +min_z & -max_z & -cylinder
    return openmc.model.pack_spheres(radius=_RADIUS,
                                     region=region,
                                     pf=_PACKING_FRACTION,
                                     initial_pf=0.2)
Example #8
0
    def _add_fuel_pincells(self):
        """ Adds BEAVRS fuel pincells """

        self.enrichments = ['1.6%', '2.4%', '3.1%', '3.2%', '3.4%']

        # Fuel radial surfaces

        self.s_fuel_pellet_OR = openmc.ZCylinder(name='Fuel pellet OR', R=c.pelletOR)
        self.s_fuel_clad_IR = openmc.ZCylinder(name='Fuel clad IR', R=c.cladIR)
        self.s_fuel_clad_OR = openmc.ZCylinder(name='Fuel clad OR', R=c.cladOR)
        self.s_fuel_plenumSpring_OR = openmc.ZCylinder(name='Fuel rod plenum spring OR', R=c.plenumSpringOR)

        # Fuel axial surfaces

        self.s_fuel_rod_bot = openmc.ZPlane(name='Fuel rod bottom', z0=c.fuel_Rod_bot)
        self.s_fuel_lowerFitting_bot = self.s_fuel_rod_bot
        self.s_fuel_lowerFitting_top = openmc.ZPlane(name='Fuel lower fitting top', z0=c.fuel_LowerFitting_top)
        self.s_fuel_activeFuel_bot = self.s_fuel_lowerFitting_top
        self.s_fuel_activeFuel_top = openmc.ZPlane(name='Fuel active region top', z0=c.fuel_ActiveFuel_top)
        self.s_fuel_plenum_bot = self.s_fuel_activeFuel_top
        self.s_fuel_plenum_top = openmc.ZPlane(name='Fuel plenum top', z0=c.fuel_Plenum_top)
        self.s_fuel_upperFitting_bot = self.s_fuel_plenum_top
        self.s_fuel_upperFitting_top = openmc.ZPlane(name='Fuel upper fitting top', z0=c.fuel_UpperFitting_top)

        # Fuel pincell universes
    
        self.u_fuel_active_pin = {}
        for enr in self.enrichments:
            self.u_fuel_active_pin[enr] = InfinitePinCell(name='Fuel rod active region - {0} enr'.format(enr))
            self.u_fuel_active_pin[enr].add_ring(self.mats['Fuel {0}'.format(enr)], self.s_fuel_pellet_OR)
            self.u_fuel_active_pin[enr].add_ring(self.mats['Helium'], self.s_fuel_clad_IR)
            self.u_fuel_active_pin[enr].add_last_ring(self.mats['Zircaloy 4'])
            self.u_fuel_active_pin[enr].finalize()

        self.u_fuel_plenum = InfinitePinCell(name='Fuel rod plenum')
        self.u_fuel_plenum.add_ring(self.mats['Inconel 718'], self.s_fuel_plenumSpring_OR)
        self.u_fuel_plenum.add_ring(self.mats['Helium'], self.s_fuel_clad_IR)
        self.u_fuel_plenum.add_last_ring(self.mats['Zircaloy 4'])
        self.u_fuel_plenum.finalize()

        # Fuel axial stack universes

        self.u_fuel_p = {}
        for enr in self.enrichments:
            self.u_fuel_p[enr] = AxialPinCell(name='Fuel rod - {0} enr'.format(enr))
            self.u_fuel_p[enr].add_axial_section(self.s_struct_supportPlate_bot, self.mats['Borated Water'])
            self.u_fuel_p[enr].add_axial_section(self.s_fuel_rod_bot, self.mats['SS304 SPN'])
            self.u_fuel_p[enr].add_axial_section(self.s_fuel_lowerFitting_top, self.mats['Zircaloy 4'])
            self.u_fuel_p[enr].add_axial_section(self.s_fuel_activeFuel_top, self.u_fuel_active_pin[enr])
            self.u_fuel_p[enr].add_axial_section(self.s_fuel_plenum_top, self.u_fuel_plenum)
            self.u_fuel_p[enr].add_axial_section(self.s_fuel_upperFitting_top, self.mats['Zircaloy 4'])
            self.u_fuel_p[enr].add_axial_section(self.s_struct_upperNozzle_bot, self.mats['Borated Water'])
            self.u_fuel_p[enr].add_axial_section(self.s_struct_upperNozzle_top, self.mats['SS304 SPN'])
            self.u_fuel_p[enr].add_last_axial_section(self.mats['Borated Water'])
            self.u_fuel_p[enr] = self.u_fuel_p[enr].add_wrapper(self.u_grids, self.s_fuel_clad_OR)
            self.u_fuel_p[enr].finalize()
Example #9
0
    def _make_openmc_input(self):
        """Generate the OpenMC input XML

        """
        # Define material
        mat = openmc.Material()
        for element, fraction in self.elements:
            mat.add_element(element, fraction)
        mat.set_density('g/cm3', self.density)
        materials = openmc.Materials([mat])
        if self.xsdir is not None:
            xs_path = (self.openmc_dir / 'cross_sections.xml').resolve()
            materials.cross_sections = str(xs_path)
        materials.export_to_xml(self.openmc_dir / 'materials.xml')

        # Set up geometry
        x1 = openmc.XPlane(x0=-1.e9, boundary_type='reflective')
        x2 = openmc.XPlane(x0=+1.e9, boundary_type='reflective')
        y1 = openmc.YPlane(y0=-1.e9, boundary_type='reflective')
        y2 = openmc.YPlane(y0=+1.e9, boundary_type='reflective')
        z1 = openmc.ZPlane(z0=-1.e9, boundary_type='reflective')
        z2 = openmc.ZPlane(z0=+1.e9, boundary_type='reflective')
        cell = openmc.Cell(fill=materials)
        cell.region = +x1 & -x2 & +y1 & -y2 & +z1 & -z2
        geometry = openmc.Geometry([cell])
        geometry.export_to_xml(self.openmc_dir / 'geometry.xml')

        # Define source
        source = openmc.Source()
        source.space = openmc.stats.Point((0,0,0))
        source.angle = openmc.stats.Isotropic()
        source.energy = openmc.stats.Discrete([self.energy], [1.])
        source.particle = 'photon'

        # Settings
        settings = openmc.Settings()
        settings.source = source
        settings.particles = self.particles // self._batches
        settings.run_mode = 'fixed source'
        settings.batches = self._batches
        settings.photon_transport = True
        settings.electron_treatment = self.electron_treatment
        settings.cutoff = {'energy_photon' : self._cutoff_energy}
        settings.export_to_xml(self.openmc_dir / 'settings.xml')
 
        # Define tallies
        energy_bins = np.logspace(np.log10(self._cutoff_energy),
                                  np.log10(1.0001*self.energy), self._bins+1)
        energy_filter = openmc.EnergyFilter(energy_bins)
        particle_filter = openmc.ParticleFilter('photon')
        tally = openmc.Tally(name='tally')
        tally.filters = [energy_filter, particle_filter]
        tally.scores = ['flux']
        tallies = openmc.Tallies([tally])
        tallies.export_to_xml(self.openmc_dir / 'tallies.xml')
Example #10
0
    def _add_bpra_pincells(self):
        """ Adds BEAVRS BPRA pincells """

        # BP radial surfaces

        self.s_bp_innerclad_IR = openmc.ZCylinder(name='BPRA rod radius 1', R=c.burnabs1)
        self.s_bp_innerclad_OR = openmc.ZCylinder(name='BPRA rod radius 2', R=c.burnabs2)
        self.s_bp_poison_IR = openmc.ZCylinder(name='BPRA rod radius 3', R=c.burnabs3)
        self.s_bp_poison_OR = openmc.ZCylinder(name='BPRA rod radius 4', R=c.burnabs4)
        self.s_bp_outerclad_IR = openmc.ZCylinder(name='BPRA rod radius 5', R=c.burnabs5)
        self.s_bp_outerclad_OR = openmc.ZCylinder(name='BPRA rod radius 6', R=c.burnabs6)

        # BP axial surfaces

        self.s_bp_rod_bot = openmc.ZPlane(name='Bottom of BPRA rod', z0=c.bpra_Rod_bot)
        self.s_bp_lowerFitting_bot = self.s_bp_rod_bot
        self.s_bp_lowerFitting_top = openmc.ZPlane(name='Top of lower fitting in BPRA rod', z0=c.bpra_LowerFitting_top)
        self.s_bp_active_bot = self.s_bp_lowerFitting_top
        self.s_bp_active_top = openmc.ZPlane(name='Top of active poison in BPRA rod', z0=c.bpra_Active_top)
        self.s_bp_plenum_bot = self.s_bp_active_top
        self.s_bp_plenum_top = openmc.ZPlane(name='Top of plenum in BPRA rod', z0=c.bpra_Plenum_top)
        self.s_bp_rod_top = openmc.ZPlane(name='Top of BPRA rod', z0=c.bpra_Rod_top)

        # BP pincell universes

        self.u_bp_activePoison = InfinitePinCell(name='BPRA rod active poison')
        self.u_bp_activePoison.add_ring(self.mats['Air'], self.s_bp_innerclad_IR)
        self.u_bp_activePoison.add_ring(self.mats['SS304'], self.s_bp_innerclad_OR)
        self.u_bp_activePoison.add_ring(self.mats['Air'], self.s_bp_poison_IR)
        self.u_bp_activePoison.add_ring(self.mats['Borosilicate Glass'], self.s_bp_poison_OR)
        self.u_bp_activePoison.add_ring(self.mats['Air'], self.s_bp_outerclad_IR)
        self.u_bp_activePoison.add_last_ring(self.mats['SS304'])
        self.u_bp_activePoison.finalize()

        self.u_bp_plenum = InfinitePinCell(name='BPRA rod plenum')
        self.u_bp_plenum.add_ring(self.mats['Air'], self.s_bp_innerclad_IR)
        self.u_bp_plenum.add_ring(self.mats['SS304'], self.s_bp_innerclad_OR)
        self.u_bp_plenum.add_ring(self.mats['Air'], self.s_bp_outerclad_IR)
        self.u_bp_plenum.add_last_ring(self.mats['SS304'])
        self.u_bp_plenum.finalize()

        # BP axial stack universe

        self.u_bp = AxialPinCell(name='BPRA rod')
        self.u_bp.add_axial_section(self.s_struct_supportPlate_bot, self.mats['Borated Water'])
        self.u_bp.add_axial_section(self.s_struct_lowerNozzle_top, self.mats['Water SPN'])
        self.u_bp.add_axial_section(self.s_bp_rod_bot, self.mats['Borated Water'])
        self.u_bp.add_axial_section(self.s_bp_lowerFitting_top, self.mats['SS304'])
        self.u_bp.add_axial_section(self.s_bp_active_top, self.u_bp_activePoison)
        self.u_bp.add_axial_section(self.s_bp_plenum_top, self.u_bp_plenum)
        self.u_bp.add_axial_section(self.s_bp_rod_top, self.mats['SS304'])
        self.u_bp.add_last_axial_section(self.mats['Borated Water'])
        self.u_bp = self.u_bp.add_wrapper(self.u_gt, self.s_bp_outerclad_OR)
        self.u_bp.finalize()
Example #11
0
def model():
    model = openmc.model.Model()

    fuel = openmc.Material()
    fuel.set_density('g/cm3', 10.0)
    fuel.add_nuclide('U235', 1.0)
    zr = openmc.Material()
    zr.set_density('g/cm3', 1.0)
    zr.add_nuclide('Zr90', 1.0)
    model.materials.extend([fuel, zr])

    box1 = openmc.model.rectangular_prism(10.0, 10.0)
    box2 = openmc.model.rectangular_prism(20.0,
                                          20.0,
                                          boundary_type='reflective')
    top = openmc.ZPlane(z0=10.0, boundary_type='vacuum')
    bottom = openmc.ZPlane(z0=-10.0, boundary_type='vacuum')
    cell1 = openmc.Cell(fill=fuel, region=box1 & +bottom & -top)
    cell2 = openmc.Cell(fill=zr, region=~box1 & box2 & +bottom & -top)
    model.geometry = openmc.Geometry([cell1, cell2])

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

    # Initialize a one-group structure
    energy_groups = openmc.mgxs.EnergyGroups([0, 20.e6])

    # Initialize MGXS Library for a few cross section types
    # for one material-filled cell in the geometry
    model.mgxs_lib = openmc.mgxs.Library(model.geometry)
    model.mgxs_lib.by_nuclide = False

    # Test all MGXS types
    model.mgxs_lib.mgxs_types = openmc.mgxs.MGXS_TYPES + openmc.mgxs.MDGXS_TYPES
    model.mgxs_lib.energy_groups = energy_groups
    model.mgxs_lib.num_delayed_groups = 6
    model.mgxs_lib.correction = None  # Avoid warning about P0 correction
    model.mgxs_lib.legendre_order = 3
    model.mgxs_lib.domain_type = 'mesh'

    # Instantiate a tally mesh
    mesh = openmc.RegularMesh(mesh_id=1)
    mesh.dimension = [2, 2]
    mesh.lower_left = [-100., -100.]
    mesh.width = [100., 100.]

    model.mgxs_lib.domains = [mesh]
    model.mgxs_lib.build_library()

    # Add tallies
    model.mgxs_lib.add_to_tallies_file(model.tallies, merge=False)

    return model
def centers_rectangular_prism():
    min_x = openmc.XPlane(0)
    max_x = openmc.XPlane(1)
    min_y = openmc.YPlane(0)
    max_y = openmc.YPlane(1)
    min_z = openmc.ZPlane(0)
    max_z = openmc.ZPlane(1)
    region = +min_x & -max_x & +min_y & -max_y & +min_z & -max_z
    return openmc.model.pack_spheres(radius=_RADIUS,
                                     region=region,
                                     pf=_PACKING_FRACTION,
                                     initial_pf=0.2)
Example #13
0
 def __init__(self, xmin, xmax, ymin, ymax, zmin, zmax, **kwargs):
     if xmin >= xmax:
         raise ValueError('xmin must be less than xmax')
     if ymin >= ymax:
         raise ValueError('ymin must be less than ymax')
     if zmin >= zmax:
         raise ValueError('zmin must be less than zmax')
     self.xmin = openmc.XPlane(x0=xmin, **kwargs)
     self.xmax = openmc.XPlane(x0=xmax, **kwargs)
     self.ymin = openmc.YPlane(y0=ymin, **kwargs)
     self.ymax = openmc.YPlane(y0=ymax, **kwargs)
     self.zmin = openmc.ZPlane(z0=zmin, **kwargs)
     self.zmax = openmc.ZPlane(z0=zmax, **kwargs)
Example #14
0
    def build(self):
        x0 = openmc.XPlane(x0=0, boundary_type="reflective")

        right_inner_wall = openmc.Plane(A=cos(pi / 3),
                                        B=-cos(pi / 6),
                                        D=(RAD_MAJ - STEEL_THICK) *
                                        cos(pi / 6))
        right_outer_wall = openmc.Plane(A=cos(pi / 3),
                                        B=-cos(pi / 6),
                                        D=RAD_MAJ * cos(pi / 6))
        right_refl_edge = openmc.Plane(boundary_type="reflective",
                                       A=cos(pi / 6),
                                       B=cos(pi / 3),
                                       D=-GAP / 2 * cos(pi / 6) * 0)
        ymin = openmc.YPlane(y0=-RAD_MAJ, boundary_type="vacuum", name="YMIN")
        zmin = openmc.ZPlane(z0=-10, boundary_type="periodic", name="ZMIN")
        zmax = openmc.ZPlane(z0=+10, boundary_type="periodic", name="ZMAX")

        ru = openmc.Universe(name="root universe")
        radialu = openmc.Universe(name="radial universe")
        lattice = self.get_lattice()
        dist = RAD_MAJ - STEEL_THICK - sqrt(3) / 2 * self.pitch
        right_inner_water = openmc.Plane(A=cos(pi / 3),
                                         B=-cos(pi / 6),
                                         D=dist * cos(pi / 6))
        # Fueled area
        inner = openmc.Cell()
        inner.region = -right_inner_water
        inner.fill = lattice
        radialu.add_cell(inner)
        # Water buffer
        buffer = openmc.Cell()
        buffer.region = +right_inner_water & -right_inner_wall
        buffer.fill = all_materials["Mod"]
        radialu.add_cell(buffer)
        # Reactor pressure vessel
        rpv = openmc.Cell()
        rpv.region = +right_inner_wall & -right_outer_wall
        rpv.fill = all_materials["SS316"]
        radialu.add_cell(rpv)
        outside = openmc.Cell()
        outside.region = +right_outer_wall
        outside.fill = all_materials["Air"]
        radialu.add_cell(outside)
        # Root Universe
        root_cell = openmc.Cell(name="root cell")
        root_cell.fill = radialu
        root_cell.region = +x0 & +ymin & +zmin & -zmax & -right_refl_edge
        ru.add_cell(root_cell)
        self._geometry = openmc.Geometry()
        self._geometry.root_universe = ru
Example #15
0
    def _add_guide_tube_pincells(self):
        """ Adds BEAVRS guide tube pincells """
    
        # GT radial surfaces

        self.s_gt_IR = openmc.ZCylinder(name='Guide tube IR', R=c.guideTubeIR)
        self.s_gt_OR = openmc.ZCylinder(name='Guide tube OR', R=c.guideTubeOR)
        self.s_gt_dashpot_IR = openmc.ZCylinder(name='Guide tube IR below dashpot', R=c.guideTubeDashIR)
        self.s_gt_dashpot_OR = openmc.ZCylinder(name='Guide tube OR below dashpot', R=c.guideTubeDashOR)

        # GT axial surfaces

        self.s_gt_rod_bot = openmc.ZPlane(name='Bottom of GT rod', z0=c.gt_Rod_bot)
        self.s_gt_dashpot_bot = self.s_gt_rod_bot
        self.s_gt_dashpot_top = openmc.ZPlane(name='GT Dashpot plane', z0=c.gt_Dashpot_top)
        self.s_gt_rod_top = openmc.ZPlane(name='Top of GT rod', z0=c.gt_Rod_top)

        # GT pincell universes

        self.u_gt_dashpot = InfinitePinCell(name='Empty GT below the dashpot')
        self.u_gt_dashpot.add_ring(self.mats['Borated Water'], self.s_gt_dashpot_IR)
        self.u_gt_dashpot.add_ring(self.mats['Zircaloy 4'], self.s_gt_dashpot_OR)
        self.u_gt_dashpot.add_last_ring(self.mats['Borated Water'])
        self.u_gt_dashpot.finalize()

        self.u_gt_nodashpot_p = InfinitePinCell(name='Empty GT above the dashpot')
        self.u_gt_nodashpot_p.add_ring(self.mats['Borated Water'], self.s_gt_IR)
        self.u_gt_nodashpot_p.add_last_ring(self.mats['Zircaloy 4'])
        self.u_gt_nodashpot_p.finalize()

        # GT axial stack

        self.u_gt = AxialPinCell(name='Empty Guide Tube')
        self.u_gt.add_axial_section(self.s_struct_supportPlate_bot, self.mats['Borated Water'])
        self.u_gt.add_axial_section(self.s_gt_rod_bot, self.mats['Water SPN'])
        self.u_gt.add_axial_section(self.s_gt_dashpot_top, self.u_gt_dashpot)
        self.u_gt.add_axial_section(self.s_gt_rod_top, self.u_gt_nodashpot_p)
        self.u_gt.add_axial_section(self.s_struct_upperNozzle_top, self.mats['Water SPN'])
        self.u_gt.add_last_axial_section(self.mats['Borated Water'])
        self.u_gt = self.u_gt.add_wrapper(self.u_grids, self.s_gt_OR)
        self.u_gt.finalize()

        self.u_gt_nodashpot = AxialPinCell(name='Empty Guide Tube in Center Position')
        self.u_gt_nodashpot.add_axial_section(self.s_struct_supportPlate_bot, self.mats['Borated Water'])
        self.u_gt_nodashpot.add_axial_section(self.s_gt_rod_bot, self.mats['Water SPN'])
        self.u_gt_nodashpot.add_axial_section(self.s_gt_rod_top, self.u_gt_nodashpot_p)
        self.u_gt_nodashpot.add_axial_section(self.s_struct_upperNozzle_top, self.mats['Water SPN'])
        self.u_gt_nodashpot.add_last_axial_section(self.mats['Borated Water'])
        self.u_gt_nodashpot = self.u_gt_nodashpot.add_wrapper(self.u_grids, self.s_gt_OR)
        self.u_gt_nodashpot.finalize()
Example #16
0
def make_surfaces(zcore, hpitch):
    overall_size = sum(zcore)
    Z = [zcore[0]]
    for i, zz in enumerate(zcore[1:]):
        Z.append(zz + Z[i])
    surfaces = []
    surfaces.append(openmc.ZPlane(z0=0.0 - overall_size/2, boundary_type = 'vacuum'))
    for i,z in enumerate(Z[:-1]):
        surfaces.append(openmc.ZPlane(z0=z - overall_size/2))
    surfaces.append(openmc.ZPlane(z0=Z[-1] - overall_size/2, boundary_type = 'vacuum'))
    edge_length = (1./np.sqrt(3.0)) * hpitch
    hexsurface = openmc.model.get_hexagonal_prism(edge_length=edge_length,
                                                  origin=(0.0, 0.0))
    return hexsurface, surfaces
Example #17
0
    def _build_inputs(self):
        # Set energy cutoff
        energy_cutoff = 4.0

        # Material is composed of H-1
        mat = openmc.Material(material_id=1, name='mat')
        mat.set_density('atom/b-cm', 0.069335)
        mat.add_nuclide('H1', 40.0)
        materials_file = openmc.Materials([mat])
        materials_file.export_to_xml()

        # Cell is box with reflective boundary
        x1 = openmc.XPlane(surface_id=1, x0=-1)
        x2 = openmc.XPlane(surface_id=2, x0=1)
        y1 = openmc.YPlane(surface_id=3, y0=-1)
        y2 = openmc.YPlane(surface_id=4, y0=1)
        z1 = openmc.ZPlane(surface_id=5, z0=-1)
        z2 = openmc.ZPlane(surface_id=6, z0=1)
        for surface in [x1, x2, y1, y2, z1, z2]:
            surface.boundary_type = 'reflective'
        box = openmc.Cell(cell_id=1, name='box')
        box.region = +x1 & -x2 & +y1 & -y2 & +z1 & -z2
        box.fill = mat
        root = openmc.Universe(universe_id=0, name='root universe')
        root.add_cell(box)
        geometry = openmc.Geometry(root)
        geometry.export_to_xml()

        # Set the running parameters
        settings_file = openmc.Settings()
        settings_file.run_mode = 'fixed source'
        settings_file.batches = 10
        settings_file.particles = 100
        settings_file.cutoff = {'energy_neutron': energy_cutoff}
        bounds = [-1, -1, -1, 1, 1, 1]
        uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:])
        watt_dist = openmc.stats.Watt()
        settings_file.source = openmc.source.Source(space=uniform_dist,
                                                    energy=watt_dist)
        settings_file.export_to_xml()

        # Tally flux under energy cutoff
        tallies = openmc.Tallies()
        tally = openmc.Tally(1)
        tally.scores = ['flux']
        energy_filter = openmc.filter.EnergyFilter((0.0, energy_cutoff))
        tally.filters = [energy_filter]
        tallies.append(tally)
        tallies.export_to_xml()
Example #18
0
def test_zplane():
    s = openmc.ZPlane(z0=3.)
    assert s.z0 == 3.

    # Check bounding box
    ll, ur = (+s).bounding_box
    assert ll == pytest.approx((-np.inf, -np.inf, 3.))
    assert np.all(np.isinf(ur))
    ll, ur = (-s).bounding_box
    assert ur == pytest.approx((np.inf, np.inf, 3.))
    assert np.all(np.isinf(ll))

    # __contains__ on associated half-spaces
    assert (0, 0, 5) in +s
    assert (0, 0, 5) not in -s
    assert (-2, 1, -10) in -s
    assert (-2, 1, -10) not in +s

    # evaluate method
    assert s.evaluate((0., 0., 10.)) == pytest.approx(7.)

    # translate method
    st = s.translate((0.0, 0.0, 1.0))
    assert st.z0 == s.z0 + 1

    # rotate method
    # make sure rotating around z axis does nothing to coefficients
    sr = s.rotate((0., 0., 123), order='zxy')
    assert s._get_base_coeffs() == pytest.approx(sr._get_base_coeffs())
    # rotate around x by -90 deg and y by 90 deg should give negative x-plane
    sr = s.rotate((-90, 0., 90.))
    assert (-1., 0., 0., 3.) == pytest.approx(sr._get_base_coeffs())

    # Make sure repr works
    repr(s)
def test_zplane():
    s = openmc.ZPlane(z0=3.)
    assert s.z0 == 3.

    # Check bounding box
    ll, ur = (+s).bounding_box
    assert ll == pytest.approx((-np.inf, -np.inf, 3.))
    assert np.all(np.isinf(ur))
    ll, ur = (-s).bounding_box
    assert ur == pytest.approx((np.inf, np.inf, 3.))
    assert np.all(np.isinf(ll))

    # __contains__ on associated half-spaces
    assert (0, 0, 5) in +s
    assert (0, 0, 5) not in -s
    assert (-2, 1, -10) in -s
    assert (-2, 1, -10) not in +s

    # evaluate method
    assert s.evaluate((0., 0., 10.)) == pytest.approx(7.)

    # translate method
    st = s.translate((0.0, 0.0, 1.0))
    assert st.z0 == s.z0 + 1

    # Make sure repr works
    repr(s)
Example #20
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Extract universes encapsulating fuel and water assemblies
        geometry = self._model.geometry
        water = geometry.get_universes_by_name('water assembly (hot)')[0]
        fuel = geometry.get_universes_by_name('fuel assembly (hot)')[0]

        # Construct a 3x3 lattice of fuel assemblies
        core_lat = openmc.RectLattice(name='3x3 Core Lattice', lattice_id=202)
        core_lat.lower_left = (-32.13, -32.13)
        core_lat.pitch = (21.42, 21.42)
        core_lat.universes = [[fuel, water, water], [fuel, fuel, fuel],
                              [water, water, water]]

        # Create bounding surfaces
        min_x = openmc.XPlane(-32.13, boundary_type='reflective')
        max_x = openmc.XPlane(+32.13, boundary_type='reflective')
        min_y = openmc.YPlane(-32.13, boundary_type='reflective')
        max_y = openmc.YPlane(+32.13, boundary_type='reflective')
        min_z = openmc.ZPlane(0, boundary_type='reflective')
        max_z = openmc.ZPlane(+32.13, boundary_type='reflective')

        # Define root universe
        root_univ = openmc.Universe(universe_id=0, name='root universe')
        root_cell = openmc.Cell(cell_id=1)
        root_cell.region = +min_x & -max_x & +min_y & -max_y & +min_z & -max_z
        root_cell.fill = core_lat
        root_univ.add_cell(root_cell)

        # Over-ride geometry in the input set with this 3x3 lattice
        self._model.geometry.root_universe = root_univ

        # Initialize a "distribcell" filter for the fuel pin cell
        distrib_filter = openmc.DistribcellFilter(27)

        # Initialize the tallies
        tally = openmc.Tally(name='distribcell tally', tally_id=27)
        tally.filters.append(distrib_filter)
        tally.scores.append('nu-fission')

        # Assign the tallies file to the input set
        self._model.tallies.append(tally)

        # Specify summary output and correct source sampling box
        self._model.settings.source = openmc.Source(space=openmc.stats.Box(
            [-32, -32, 0], [32, 32, 32], only_fissionable=True))
Example #21
0
    def _build_inputs(self):
        # Define materials
        water = openmc.Material(1)
        water.add_nuclide('H1', 2.0)
        water.add_nuclide('O16', 1.0)
        water.add_s_alpha_beta('c_H_in_H2O')
        water.set_density('g/cc', 1.0)

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

        materials = openmc.Materials((water, fuel))
        materials.default_temperature = '294K'
        materials.export_to_xml()

        # Define geometry
        x_min = openmc.XPlane(surface_id=1, x0=-5., boundary_type='periodic')
        x_max = openmc.XPlane(surface_id=2, x0=5., boundary_type='periodic')
        x_max.periodic_surface = x_min

        y_min = openmc.YPlane(surface_id=3, y0=-5., boundary_type='periodic')
        y_max = openmc.YPlane(surface_id=4, y0=5., boundary_type='periodic')

        z_min = openmc.ZPlane(surface_id=5, z0=-5., boundary_type='reflective')
        z_max = openmc.ZPlane(surface_id=6, z0=5., boundary_type='reflective')
        z_cyl = openmc.ZCylinder(surface_id=7, x0=-2.5, y0=2.5, r=2.0)

        outside_cyl = openmc.Cell(1,
                                  fill=water,
                                  region=(+x_min & -x_max & +y_min & -y_max
                                          & +z_min & -z_max & +z_cyl))
        inside_cyl = openmc.Cell(2, fill=fuel, region=+z_min & -z_max & -z_cyl)
        root_universe = openmc.Universe(0, cells=(outside_cyl, inside_cyl))

        geometry = openmc.Geometry()
        geometry.root_universe = root_universe
        geometry.export_to_xml()

        # Define settings
        settings = openmc.Settings()
        settings.particles = 1000
        settings.batches = 4
        settings.inactive = 0
        settings.source = openmc.Source(space=openmc.stats.Box(
            *outside_cyl.region.bounding_box))
        settings.export_to_xml()
Example #22
0
 def __init__(self, center_base, height, radius, axis='z', **kwargs):
     cx, cy, cz = center_base
     check_greater_than('cylinder height', height, 0.0)
     check_greater_than('cylinder radius', radius, 0.0)
     check_value('cylinder axis', axis, ('x', 'y', 'z'))
     if axis == 'x':
         self.cyl = openmc.XCylinder(y0=cy, z0=cz, r=radius, **kwargs)
         self.bottom = openmc.XPlane(x0=cx, **kwargs)
         self.top = openmc.XPlane(x0=cx + height, **kwargs)
     elif axis == 'y':
         self.cyl = openmc.YCylinder(x0=cx, z0=cz, r=radius, **kwargs)
         self.bottom = openmc.YPlane(y0=cy, **kwargs)
         self.top = openmc.YPlane(y0=cy + height, **kwargs)
     elif axis == 'z':
         self.cyl = openmc.ZCylinder(x0=cx, y0=cy, r=radius, **kwargs)
         self.bottom = openmc.ZPlane(z0=cz, **kwargs)
         self.top = openmc.ZPlane(z0=cz + height, **kwargs)
def test_get_all_surfaces(uo2):
    planes = [openmc.ZPlane(z0=z) for z in np.linspace(-100., 100.)]
    slabs = []
    for region in openmc.model.subdivide(planes):
        slabs.append(openmc.Cell(fill=uo2, region=region))
    geom = openmc.Geometry(slabs)

    surfs = set(geom.get_all_surfaces().values())
    assert not surfs ^ set(planes)
Example #24
0
    def _add_outer_rings(self):
        """ Adds BEAVRS RPV, liner, and downcomer """

        # Change z-dimension based on whether 2D or 3D problem
        if self.is_2d:
            self.s_upperBound = openmc.ZPlane(name='Highest Extent',
                                              z0=c.struct_HighestExtent_2d,
                                              boundary_type='reflective')
            self.s_lowerBound = openmc.ZPlane(name='Lowest Extent',
                                              z0=c.struct_LowestExtent_2d,
                                              boundary_type='reflective')
        else:
            self.s_upperBound = openmc.ZPlane(name='Highest Extent',
                                              z0=c.struct_HighestExtent,
                                              boundary_type='vacuum')
            self.s_lowerBound = openmc.ZPlane(name='Lowest Extent',
                                              z0=c.struct_LowestExtent,
                                              boundary_type='vacuum')

        # RPV

        self.s_RPVOR = openmc.ZCylinder(name='RPV OR',
                                        r=c.rpvOR,
                                        boundary_type='vacuum')
        self.s_RPVIR = openmc.ZCylinder(name='RPV IR', r=c.rpvIR)
        self.c_RPV = openmc.Cell(name="RPV", fill=self.mats['Carbon Steel'])
        self.c_RPV.region = (-self.s_RPVOR & +self.s_RPVIR & -self.s_upperBound
                             & +self.s_lowerBound)

        # RPV liner

        self.s_linerIR = openmc.ZCylinder(name='RPV Liner IR', r=c.linerIR)
        self.c_liner = openmc.Cell(name="RPV Liner", fill=self.mats['SS304'])
        self.c_liner.region = (-self.s_RPVIR & +self.s_linerIR
                               & -self.s_upperBound & +self.s_lowerBound)

        # Downcomer

        self.s_neutronShieldOR = openmc.ZCylinder(name='Shield Panel OR',
                                                  r=c.neutronShieldOR)
        self.c_downcomer = openmc.Cell(name="Downcomer",
                                       fill=self.mats['Borated Water'])
        self.c_downcomer.region = (-self.s_linerIR & +self.s_neutronShieldOR
                                   & -self.s_upperBound & +self.s_lowerBound)
Example #25
0
def model():
    model = openmc.model.Model()

    fuel = openmc.Material()
    fuel.set_density('g/cm3', 10.0)
    fuel.add_nuclide('U235', 1.0)
    zr = openmc.Material()
    zr.set_density('g/cm3', 1.0)
    zr.add_nuclide('Zr90', 1.0)
    model.materials.extend([fuel, zr])

    box1 = openmc.model.rectangular_prism(10.0, 10.0)
    box2 = openmc.model.rectangular_prism(20.0,
                                          20.0,
                                          boundary_type='reflective')
    top = openmc.ZPlane(z0=10.0, boundary_type='vacuum')
    bottom = openmc.ZPlane(z0=-10.0, boundary_type='vacuum')
    cell1 = openmc.Cell(fill=fuel, region=box1 & +bottom & -top)
    cell2 = openmc.Cell(fill=zr, region=~box1 & box2 & +bottom & -top)
    model.geometry = openmc.Geometry([cell1, cell2])

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

    mesh = openmc.Mesh()
    mesh.lower_left = (-10.0, -10.0, -10.0)
    mesh.upper_right = (10.0, 10.0, 10.0)
    mesh.dimension = (3, 3, 3)

    mesh_surface_filter = openmc.MeshSurfaceFilter(mesh)
    energy_filter = openmc.EnergyFilter([0.0, 0.253, 20.0e6])

    tally1 = openmc.Tally()
    tally1.filters = [mesh_surface_filter]
    tally1.scores = ['current']
    tally2 = openmc.Tally()
    tally2.filters = [mesh_surface_filter, energy_filter]
    tally2.scores = ['current']
    model.tallies.extend([tally1, tally2])

    return model
Example #26
0
def test_get_surfaces():
    s1 = openmc.XPlane()
    s2 = openmc.YPlane()
    s3 = openmc.ZPlane()
    region = (+s1 & -s2) | +s3

    # Make sure get_surfaces() returns all surfaces
    surfs = set(region.get_surfaces().values())
    assert not (surfs ^ {s1, s2, s3})

    inverse = ~region
    surfs = set(inverse.get_surfaces().values())
    assert not (surfs ^ {s1, s2, s3})
Example #27
0
def model():
    model = openmc.model.Model()

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

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

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

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

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

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

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

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

    return model
Example #28
0
    def _add_structural_axials(self):
        """ Adds structure axial surfaces common for most pincells """

        self.s_struct_supportPlate_bot = openmc.ZPlane(name='Support plate bottom', z0=c.struct_SupportPlate_bot)
        self.s_struct_supportPlate_top = openmc.ZPlane(name='Support plate top', z0=c.struct_SupportPlate_top)
        self.s_struct_lowerNozzle_bot = openmc.ZPlane(name='Lower nozzle bottom', z0=c.struct_LowerNozzle_bot)
        self.s_struct_lowerNozzle_top = openmc.ZPlane(name='Lower nozzle top', z0=c.struct_LowerNozzle_top)
        self.s_struct_upperNozzle_bot = openmc.ZPlane(name='Upper nozzle bottom', z0=c.struct_UpperNozzle_bot)
        self.s_struct_upperNozzle_top = openmc.ZPlane(name='Upper nozzle top', z0=c.struct_UpperNozzle_top)
Example #29
0
def create_geom(radius, fuel, air):
    """Create geometry for some radius sphere
    """

    # Create geometry
    sphere = openmc.Sphere(R=radius)
    min_x = openmc.XPlane(x0=-radius, boundary_type='vacuum')
    max_x = openmc.XPlane(x0=+radius, boundary_type='vacuum')
    min_y = openmc.YPlane(y0=-radius, boundary_type='vacuum')
    max_y = openmc.YPlane(y0=+radius, boundary_type='vacuum')
    min_z = openmc.ZPlane(z0=-radius, boundary_type='vacuum')
    max_z = openmc.ZPlane(z0=+radius, boundary_type='vacuum')

    # Create Universe
    universe = openmc.Universe(name='Universe')

    fuel_cell = openmc.Cell(name='fuel')
    fuel_cell.fill = fuel
    fuel_cell.region = -sphere
    universe.add_cell(fuel_cell)

    air_cell = openmc.Cell(name='air')
    air_cell.fill = None
    air_cell.region = +sphere
    universe.add_cell(air_cell)

    # Create root cell
    root_cell = openmc.Cell(name='root_cell')
    root_cell.fill = universe
    root_cell.region = +min_x & -max_x & +min_y & -max_y & +min_z & -max_z
    root_universe = openmc.Universe(universe_id=0, name='root universe')
    root_universe.add_cell(root_cell)

    geometry = openmc.Geometry()
    geometry.root_universe = root_universe
    geometry.export_to_xml()
Example #30
0
def create_cube(x_length,
                y_length,
                z_length,
                start_point,
                boundary_type_set='reflective'):

    x_pos = openmc.XPlane(x0=max(x_length + start_point.x, start_point.x),
                          boundary_type=boundary_type_set)
    x_neg = openmc.XPlane(x0=min(x_length + start_point.x, start_point.x),
                          boundary_type=boundary_type_set)
    y_pos = openmc.YPlane(y0=max(y_length + start_point.y, start_point.y),
                          boundary_type=boundary_type_set)
    y_neg = openmc.YPlane(y0=min(y_length + start_point.y, start_point.y),
                          boundary_type=boundary_type_set)
    z_pos = openmc.ZPlane(z0=max(z_length + start_point.z, start_point.z),
                          boundary_type=boundary_type_set)
    z_neg = openmc.ZPlane(z0=min(z_length + start_point.z, start_point.z),
                          boundary_type=boundary_type_set)

    plane_list = []
    plane_list.append([x_pos, x_neg])
    plane_list.append([y_pos, y_neg])
    plane_list.append([z_pos, z_neg])
    return truncation_create(plane_list)