Beispiel #1
0
def createMaterials(directory, assembly_name):

    log.py_printf('NORMAL', 'Importing materials data from HDF5...')

    materials = materialize.materialize(directory + assembly_name + '-materials.hdf5')
    
    return materials
Beispiel #2
0
    def exportAvgXSToHDF5(self, assembly_name, directory='casmo-data'):

        #check if cross sections have been computed
        if len(self._average_cross_sections) == 0:
            log.py_printf(
                'WARNING', 'Average Cross Sections do not exist. Call'
                ' averageXSGenerator to compute them.')

        else:

            #create/set directory in which to store hdf5 file
            if not os.path.exists(directory):
                os.makedirs(directory)
            f = h5py.File(
                directory + '/' + assembly_name + '-avg-materials.hdf5', 'w')
            f.attrs['Energy Groups'] = self._energy_groups

            #create an hdf5 dataset to store each average cross section
            for material in self._average_cross_sections.keys():
                material_group = f.create_group(material)
                for xs_type in self._average_cross_sections[material].keys():
                    material_group.create_dataset(
                        xs_type,
                        data=self._average_cross_sections[material][xs_type])
            f.close()
Beispiel #3
0
def createLattice():

    log.py_printf('NORMAL', 'Creating simple pin cell lattice...')

    lattice = Lattice(id=2, width_x=4.0, width_y=4.0)
    lattice.setLatticeCells([[1]])
    
    return lattice
Beispiel #4
0
def createLattice():

    log.py_printf('NORMAL', 'Creating simple pin cell lattice...')

    lattice = Lattice(id=2, width_x=4.0, width_y=4.0)
    lattice.setLatticeCells([[1]])

    return lattice
Beispiel #5
0
def createTrackGen(geometry, num_azim, track_spacing):

    log.py_printf('NORMAL', 'Initializing the track generator...')

    track_generator = TrackGenerator(geometry, num_azim, track_spacing)
    track_generator.generateTracks()

    return track_generator
Beispiel #6
0
def createTrackGen(geometry, num_azim, track_spacing):

    log.py_printf('NORMAL', 'Initializing the track generator...')

    track_generator = TrackGenerator(geometry, num_azim, track_spacing)
    track_generator.generateTracks()

    return track_generator
Beispiel #7
0
def createLattice():

    log.py_printf('NORMAL', 'Creating simple 4x4 lattice...')

    lattice = Lattice(id=3, width_x=1.6, width_y=1.6)

    lattice.setLatticeCells([[1, 1, 1, 1],
                             [1, 2, 1, 1],
                             [1, 1, 2, 1],
                             [1, 1, 1, 1]])
    return lattice
Beispiel #8
0
def createGeometry(materials, cells, lattice):
    
    log.py_printf('NORMAL', 'Creating geometry...')

    geometry = Geometry()
    for material in materials.values(): geometry.addMaterial(material)
    for cell in cells: geometry.addCell(cell)
    geometry.addLattice(lattice)

    geometry.initializeFlatSourceRegions()
    
    return geometry
Beispiel #9
0
def createGeometry(materials, cells, lattice):

    log.py_printf('NORMAL', 'Creating geometry...')

    geometry = Geometry()
    for material in materials.values():
        geometry.addMaterial(material)
    for cell in cells:
        geometry.addCell(cell)
    geometry.addLattice(lattice)

    geometry.initializeFlatSourceRegions()

    return geometry
Beispiel #10
0
def createCells(r, s, circles, planes, uo2_id, clad_id, moderator_id, gd2o3_id):

    log.py_printf("Normal", "Creating cells...")

    #creates cells that contain materials (square, ring, circle cells)
    cells = []
    cells.append(CellBasic(universe=1, material=uo2_id, rings=r, sectors=s))
    cells.append(CellBasic(universe=1, material=clad_id, sectors=s))
    cells.append(CellBasic(universe=1, material=moderator_id, sectors=s))
    cells.append(CellBasic(universe=2, material=gd2o3_id, rings=r, sectors=s)) 
    cells.append(CellBasic(universe=2, material=clad_id, sectors=s))
    cells.append(CellBasic(universe=2, material=moderator_id, sectors=s))

    #creates cells that are filled by the lattice universe
    cells.append(CellFill(universe=0, universe_fill=3))

    ## Fuel Type: UO2: Universe=1 ##

    #first cell, region within small circle
    cells[0].addSurface(halfspace=-1, surface=circles[1])

    #second cell, region inside big and outside small circle
    cells[1].addSurface(halfspace=-1, surface=circles[0])
    cells[1].addSurface(halfspace=+1, surface=circles[1])

    #third cell
    cells[2].addSurface(halfspace=+1, surface=circles[0])

    ## Fuel Type: UO2 + GD2O3: Universe=2 ##


    #fourth cell, region within small circle
    cells[3].addSurface(halfspace=-1, surface=circles[1])

    #fifth cell, region inside big and outside small circle
    cells[4].addSurface(halfspace=-1, surface=circles[0])
    cells[4].addSurface(halfspace=+1, surface=circles[1])

    #sixth cell, region outside the big circle; the square formed by the four planes
    cells[5].addSurface(halfspace=+1, surface=circles[0])

    #seventh cell, giant cell
    #this takes care of the big square surrounding the entire system
    cells[6].addSurface(halfspace=+1, surface=planes[0])
    cells[6].addSurface(halfspace=+1, surface=planes[2])
    cells[6].addSurface(halfspace=-1, surface=planes[1])
    cells[6].addSurface(halfspace=-1, surface=planes[3])

    return cells
Beispiel #11
0
def createCells(uo2_id, water_id, circle, left, right, bottom, top):

    log.py_printf('NORMAL', 'Creating cells...')

    cells = []
    cells.append(CellBasic(universe=1, material=uo2_id))
    cells.append(CellBasic(universe=1, material=water_id))
    cells.append(CellFill(universe=0, universe_fill=2))

    cells[0].addSurface(halfspace=-1, surface=circle)
    cells[1].addSurface(halfspace=+1, surface=circle)
    cells[2].addSurface(halfspace=+1, surface=left)
    cells[2].addSurface(halfspace=-1, surface=right)
    cells[2].addSurface(halfspace=+1, surface=bottom)
    cells[2].addSurface(halfspace=-1, surface=top)

    return cells
Beispiel #12
0
  def stringCellTypeArray(self):

    #id of 1 corresponds to fuel (string of fuel)
    #id of 2 corresponds to guide tube (string of gt)
    #id of 3 corresponds to burnable poison (string of bp)
    string_cell_type_array = numpy.zeros((self._width,self._width), dtype=numpy.str)


    for i, row in enumerate(self._cell_type_array):
      for j, cell in enumerate(row):
        if self._cell_type_array[i,j] in self._cell_types.keys():
          string_cell_type_array[i,j] = self._cell_types[self._cell_type_array[i,j]]
        else:
          log.py_printf('WARNING', 'Cell type id %d does not exist. Call'
          ' setCellTypes to set cell name for id.', self._cell_type_array[i,j])

    return string_cell_type_array
Beispiel #13
0
def createCells(uo2_id, water_id, circle, left, right, bottom, top):

    log.py_printf('NORMAL', 'Creating cells...')

    cells = []
    cells.append(CellBasic(universe=1, material=uo2_id))
    cells.append(CellBasic(universe=1, material=water_id))
    cells.append(CellFill(universe=0, universe_fill=2))

    cells[0].addSurface(halfspace=-1, surface=circle)
    cells[1].addSurface(halfspace=+1, surface=circle)
    cells[2].addSurface(halfspace=+1, surface=left)
    cells[2].addSurface(halfspace=-1, surface=right)
    cells[2].addSurface(halfspace=+1, surface=bottom)
    cells[2].addSurface(halfspace=-1, surface=top)

    return cells
    def _get_results(self,
                     num_iters=False,
                     keff=False,
                     fluxes=False,
                     num_fsrs=False,
                     num_tracks=False,
                     num_segments=False,
                     hash_output=False):
        """Compare the two geometry files."""

        # Assert that both files are the same
        if (os.system("cmp geometry_file.geo geometry_file_second.geo") != 0):
            py_printf(openmoc.ERROR,
                      "Geometry files are not dumped and loaded "
                      "properly")

        # Python2 and 3 binaries differ, cannot compare the file to a reference.
        outstr = 'dummy'
        return outstr
Beispiel #15
0
def createGeometry(geoDirectory, assembly_name, dummy, materials, cells, pinCellArray, lattice):

    log.py_printf('NORMAL', 'Creating geometry...')
    geometry = Geometry() 
    geometry.addMaterial(dummy)

    for material in materials.values(): geometry.addMaterial(material)
    for cell in cells: geometry.addCell(cell)
    
    #extracts microregion ranges
    f = h5py.File(geoDirectory + assembly_name + '-minmax.hdf5', "r")
    min_values = f['minregions'][...]
    max_values = f['maxregions'][...]
    f.close()

    #finds microregions, clones universe, adds materials to cells in universes
    for i, row in enumerate(pinCellArray):
        for j, col in enumerate(row):
            current_UID = pinCellArray[i,j]
            current_min_max = [y for y in range(min_values[i,j], max_values[i,j]+1)]
            current_universe = geometry.getUniverse(int(current_UID))
            cloned_universe = current_universe.clone()
            pinCellArray [i,j] = cloned_universe.getId()
            num_cells = cloned_universe.getNumCells()
            current_cell_ids = current_universe.getCellIds(num_cells)
            cell_ids = cloned_universe.getCellIds(num_cells)
            current_material_ids = []
            for k in range(len(current_min_max)):
                if 'microregion-%d' % (current_min_max[k]) in materials.keys():
                    current_material_ids.append(materials['microregion-%d' % (current_min_max[k])].getId())
            for k, cell_id in enumerate(cell_ids):
                cloned_cell = cloned_universe.getCellBasic(int(cell_id))
                cloned_cell.setMaterial(current_material_ids[k])
                geometry.addCell(cloned_cell)

    #lattice.printString()
    lattice.setLatticeCells(pinCellArray)
    geometry.addLattice(lattice)

    geometry.initializeFlatSourceRegions()

    return geometry
Beispiel #16
0
    def stringCellTypeArray(self):

        #id of 1 corresponds to fuel (string of fuel)
        #id of 2 corresponds to guide tube (string of gt)
        #id of 3 corresponds to burnable poison (string of bp)
        string_cell_type_array = numpy.zeros((self._width, self._width),
                                             dtype=numpy.str)

        for i, row in enumerate(self._cell_type_array):
            for j, cell in enumerate(row):
                if self._cell_type_array[i, j] in self._cell_types.keys():
                    string_cell_type_array[i, j] = self._cell_types[
                        self._cell_type_array[i, j]]
                else:
                    log.py_printf(
                        'WARNING', 'Cell type id %d does not exist. Call'
                        ' setCellTypes to set cell name for id.',
                        self._cell_type_array[i, j])

        return string_cell_type_array
Beispiel #17
0
 def exportAvgXSToHDF5(self, assembly_name, directory = 'casmo-data'):
 
   #check if cross sections have been computed
   if len(self._average_cross_sections) == 0: 
     log.py_printf('WARNING', 'Average Cross Sections do not exist. Call'
     ' averageXSGenerator to compute them.')
     
   else:
   
     #create/set directory in which to store hdf5 file
     if not os.path.exists(directory):
       os.makedirs(directory)
     f = h5py.File(directory + '/' + assembly_name + '-avg-materials.hdf5','w')
     f.attrs['Energy Groups'] = self._energy_groups
     
     #create an hdf5 dataset to store each average cross section
     for material in self._average_cross_sections.keys():
       material_group = f.create_group(material)
       for xs_type in self._average_cross_sections[material].keys():
         material_group.create_dataset(xs_type,data=self._average_cross_sections[material][xs_type])
     f.close()
Beispiel #18
0
###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

options = Options()

num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()

log.set_log_level("NORMAL")

log.py_printf("TITLE", "Simulating the BEAVRS 1.6 pct enriched 0 BP assembly...")

group = "8"
assembly = CellFill(universe=0, universe_fill=lattices[group]["3.1-15tBP"].getId())

###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################

log.py_printf("NORMAL", "Creating surfaces...")

# create surfaces
left = openmoc.XPlane(x=-pin_pitch * 17 / 2.0)
right = openmoc.XPlane(x=pin_pitch * 17 / 2.0)
bottom = openmoc.YPlane(y=-pin_pitch * 17 / 2.0)
top = openmoc.YPlane(y=pin_pitch * 17 / 2.0)
Beispiel #19
0
options = Options()

num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()

log.set_log_level('NORMAL')


###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from HDF5...')

materials = materialize.materialize('../c5g7-materials.h5')

uo2_id = materials['UO2'].getId()
water_id = materials['Water'].getId()


###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################

log.py_printf('NORMAL', 'Creating surfaces...')

circles = []
planes = []
Beispiel #20
0
options = Options()

num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()

log.set_log_level('NORMAL')

###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from HDF5...')

materials = materialize.materialize('../c5g7-materials.h5')

uo2_id = materials['UO2'].getId()
water_id = materials['Water'].getId()

###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################

log.py_printf('NORMAL', 'Creating surfaces...')

circles = []
planes = []
radii = [0.15, 0.2, 0.25, 0.3, 0.35, 0.4]
Beispiel #21
0
rr = universes['Reflector Rodded Assembly']
ri = universes['Reflector Right Assembly']
rb = universes['Reflector Bottom Assembly']
rc = universes['Reflector Corner Assembly']

# 3 x 3 x 9 core to represent 3D core
lattices['Root'].setWidth(width_x=21.42, width_y=21.42)
lattices['Root'].setUniverses([[[uu, mu, ri], [mu, uu, ri], [rb, rb, rc]]])

cells['Root'].setFill(lattices['Root'])

###############################################################################
##########################     Creating Cmfd mesh    ##########################
###############################################################################

log.py_printf('NORMAL', 'Creating Cmfd mesh...')

cmfd = openmoc.Cmfd()
cmfd.setSORRelaxationFactor(1.5)
cmfd.setLatticeStructure(51, 51)
cmfd.setGroupStructure([[1, 2, 3], [4, 5, 6, 7]])
cmfd.setCentroidUpdateOn(True)
cmfd.setKNearest(3)

###############################################################################
##########################   Creating the Geometry   ##########################
###############################################################################

log.py_printf('NORMAL', 'Creating geometry...')

geometry = openmoc.Geometry()
###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

options = Options()

num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()

log.set_log_level('NORMAL')

log.py_printf('TITLE', 'Simulating a two group homogeneous infinite medium...')
log.py_printf('HEADER', 'The reference keff = 1.72...')

###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Creating materials...')

infinite_medium = Material(1)
infinite_medium.setNumEnergyGroups(2)
infinite_medium.setSigmaA(numpy.array([0.0038, 0.184]))
infinite_medium.setSigmaF(numpy.array([0.000625, 0.135416667]))
infinite_medium.setNuSigmaF(numpy.array([0.0015, 0.325]))
infinite_medium.setSigmaS(numpy.array([0.1, 0.117, 0.0, 1.42]))
infinite_medium.setChi(numpy.array([1.0, 0.0]))
Beispiel #23
0
###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

options = Options()

num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()

log.set_log_level("NORMAL")

log.py_printf("TITLE", "Simulating a one group homogeneous infinite medium...")
log.py_printf("HEADER", "The reference keff = 1.43...")


###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

log.py_printf("NORMAL", "Creating materials...")

infinite_medium = Material(1)
infinite_medium.setNumEnergyGroups(1)
infinite_medium.setSigmaA(numpy.array([0.069389522]))
infinite_medium.setSigmaF(numpy.array([0.0414198575]))
infinite_medium.setNuSigmaF(numpy.array([0.0994076580]))
infinite_medium.setSigmaS(numpy.array([0.383259177]))
###############################################################################

options = Options()
num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()
acceleration = options.getCmfdAcceleration()
relax_factor = options.getCmfdRelaxationFactor()
mesh_level = options.getCmfdMeshLevel()


log.set_log_level('NORMAL')

log.py_printf('TITLE', 'Simulating a Design-a-Critical Reactor Problem...')


###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from HDF5...')

materials = materialize.materialize('design-a-reactor-materials.hdf5')

uo2_id = materials['UO2'].getId()
mox43_id = materials['MOX-4.3%'].getId()
mox7_id = materials['MOX-7%'].getId()
mox87_id = materials['MOX-8.7%'].getId()
guide_tube_id = materials['Guide Tube'].getId()
Beispiel #25
0
    def _run_openmoc(self):
        """Instantiate a complex region Geometry."""
        #                                ----------------
        #                              /                 \
        #             --------------- c2 (p22,p23) - u2 - c2a (p11)
        #           /               /
        #  u_r <- c_r (p1,p2) - u1 - c1 (p11,p12,p13)
        #           \             \
        #            ------------- c3
        root_universe = openmoc.Universe(name='root universe')
        root_cell = openmoc.Cell(name='root cell')
        u1 = openmoc.Universe(name='universe 1')
        u2 = openmoc.Universe(name='universe 2 in c2')
        root_cell.setFill(u1)

        # Z-bounds at root level
        p1 = openmoc.ZPlane(z=-2.0, name='zmin')
        p1.setBoundaryType(openmoc.REFLECTIVE)
        p2 = openmoc.ZPlane(z=+2.0, name='zmax')
        p2.setBoundaryType(openmoc.INTERFACE)
        root_cell.addSurface(halfspace=+1, surface=p1)
        root_cell.addSurface(halfspace=-1, surface=p2)

        # Cells in the root cell
        c1 = openmoc.Cell(name='intersection cell')
        c2 = openmoc.Cell(name='union cell')
        c2a = openmoc.Cell(name='union cell 2')
        c3 = openmoc.Cell(name='unbound cell')
        u1.addCell(c1)
        u1.addCell(c2)
        u1.addCell(c3)
        # Setting the parent cell helps to find boundaries (in Z here)
        c3.setParent(root_cell)

        # Cell c2a in c2, to further test arborescence
        c2.setFill(u2)
        u2.addCell(c2a)
        c2.setParent(root_cell)
        c2a.setParent(c2)  # to test transitivity

        # Bounds for cell 1 : intersection region cell
        p11 = openmoc.XPlane(x=-2.0, name='xmin')
        p11.setBoundaryType(openmoc.REFLECTIVE)
        p12 = openmoc.YPlane(y=-2.0, name='ymin')
        p12.setBoundaryType(openmoc.VACUUM)
        p13 = openmoc.ZCylinder(x=0, y=0, radius=2.5, name='cylinder')
        p13.setBoundaryType(openmoc.INTERFACE)

        # addSurface assumes an intersection, which is what we want here
        c1.addSurface(halfspace=+1, surface=p11)
        c1.addSurface(halfspace=+1, surface=p12)
        c1.addSurface(halfspace=-1, surface=p13)

        # Bounds for cell 2 : union region cell
        p22 = openmoc.ZCylinder(x=4, y=4, radius=2.5, name='cylinder')
        p22.setBoundaryType(openmoc.INTERFACE)
        p23 = openmoc.ZCylinder(x=-2, y=-8, radius=3, name='cylinder')
        p23.setBoundaryType(openmoc.VACUUM)

        # To have a union, we need to use addLogicalNode and addSurfaceInRegion
        c2.addLogicalNode(1)
        c2.addSurfaceInRegion(halfspace=-1, surface=p22)
        c2.addSurfaceInRegion(halfspace=-1, surface=p23)

        # Plane limits area even more
        c2a.addLogicalNode(1)
        c2a.addSurfaceInRegion(halfspace=+1, surface=p11)

        openmoc.set_log_level('NORMAL')
        for cell in [root_cell, c1, c2, c2a, c3]:
            py_printf('NORMAL', 'Cell: %s', cell.getName())
            py_printf('NORMAL', 'MinX: %f', cell.getMinX())
            py_printf('NORMAL', 'MinXBoundaryType: %s',
                      cell.getMinXBoundaryType())
            py_printf('NORMAL', 'MinY: %f', cell.getMinY())
            py_printf('NORMAL', 'MinYBoundaryType: %s',
                      cell.getMinYBoundaryType())
            py_printf('NORMAL', 'MinZ: %f', cell.getMinZ())
            py_printf('NORMAL', 'MinZBoundaryType: %s',
                      cell.getMinZBoundaryType())
            py_printf('NORMAL', 'MaxX: %f', cell.getMaxX())
            py_printf('NORMAL', 'MaxXBoundaryType: %s',
                      cell.getMaxXBoundaryType())
            py_printf('NORMAL', 'MaxY: %f', cell.getMaxY())
            py_printf('NORMAL', 'MaxYBoundaryType: %s',
                      cell.getMaxYBoundaryType())
            py_printf('NORMAL', 'MaxZ: %f', cell.getMaxZ())
            py_printf('NORMAL', 'MaxZBoundaryType: %s',
                      cell.getMaxZBoundaryType())
            py_printf('NORMAL', '')
Beispiel #26
0
located within the OpenMOC folder.This could potentially also accept user input,
but there should also be a default value."""

num_threads = options.num_omp_threads
track_spacing = options.track_spacing
num_azim = options.num_azim
tolerance = options.tolerance
max_iters = options.max_iters

log.setLogLevel('NORMAL')

###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from HDF5...')

#The following assigns the dictionary returned by the materialize function in 
#the materialize python file to the variable materials
materials = materialize.materialize('BWR_materials.hdf5')

#finds the identification number for each material
uo2_id = materials['UO2'].getId()
moderator_id = materials['MODERATOR'].getId()
clad_id = materials['CLAD'].getId()
gd2o3_id = materials['UO2 + GD2O3'].getId() 


###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################
Beispiel #27
0
    def _run_openmoc(self):
        """Print a variety of log messages to a log file."""

        # Set a log level which precludes some messages from being printed
        openmoc.set_log_level('NORMAL')

        # Print messages using the pure C implementation
        openmoc.log_printf(openmoc.DEBUG, 'This is a debug message')
        openmoc.log_printf(openmoc.INFO, 'This is an info message')
        openmoc.log_printf(openmoc.NORMAL, 'This is a normal message')
        openmoc.log_printf(openmoc.SEPARATOR, 'This is a separator message')
        openmoc.log_printf(openmoc.HEADER, 'This is a header message')
        openmoc.log_printf(openmoc.TITLE, 'This is a title message')
        openmoc.log_printf(openmoc.WARNING, 'This is a warning message')
        openmoc.log_printf(openmoc.CRITICAL, 'This is a critical message')
        openmoc.log_printf(openmoc.RESULT, 'This is a result message')

        # Print messages using the Python-wrapped version
        py_printf('DEBUG', 'This is a debug message')
        py_printf('INFO', 'This is an info message')
        py_printf('NORMAL', 'This is a normal message')
        py_printf('SEPARATOR', 'This is a separator message')
        py_printf('HEADER', 'This is a header message')
        py_printf('TITLE', 'This is a title message')
        py_printf('WARNING', 'This is a warning message')
        py_printf('CRITICAL', 'This is a critical message')
        py_printf('RESULT', 'This is a result message: %d', 5)
Beispiel #28
0
import openmoc
import openmoc.log as log
import openmoc.plotter as plotter
import openmoc.materialize as materialize

log.set_log_level('NORMAL')


###############################################################################
#                            Creating Materials
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from HDF5...')

materials = openmoc.materialize.load_from_hdf5('c5g7-mgxs.h5', '../')


###############################################################################
#                            Creating Surfaces
###############################################################################

log.py_printf('NORMAL', 'Creating surfaces...')

xmin = openmoc.XPlane(x=-34.0, name='xmin')
xmax = openmoc.XPlane(x= 34.0, name='xmax')
ymin = openmoc.YPlane(y=-34.0, name='ymin')
ymax = openmoc.YPlane(y= 34.0, name='ymax')
zmin = openmoc.ZPlane(z=-0.5, name='zmin')
zmax = openmoc.ZPlane(z= 0.5, name='zmax')

xmin.setBoundaryType(openmoc.REFLECTIVE)
Beispiel #29
0
from openmoc import *
import openmoc.log as log
import openmoc.plotter as plotter
import openmoc.materialize as materialize

###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

log.set_log_level('INFO')

###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from py...')

materials = materialize.materialize('LRA-materials.py')

region1 = materials['region_1'].getId()
region2 = materials['region_2'].getId()
region3 = materials['region_3'].getId()
region4 = materials['region_4'].getId()
region5 = materials['region_5'].getId()
region6 = materials['region_6'].getId()

###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################

log.py_printf('NORMAL', 'Creating surfaces...')
Beispiel #30
0
###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

options = Options()

num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()

log.set_log_level('NORMAL')

log.py_printf('TITLE', 'Simulating the OECD\'s C5G7 Benchmark Problem...')


###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from py...')

materials = materialize.materialize('../../c5g7-materials.h5')

uo2_id = materials['UO2'].getId()
mox43_id = materials['MOX-4.3%'].getId()
mox7_id = materials['MOX-7%'].getId()
mox87_id = materials['MOX-8.7%'].getId()
guide_tube_id = materials['Guide Tube'].getId()
Beispiel #31
0
###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

options = Options()

num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()

log.set_log_level('NORMAL')

log.py_printf('TITLE', 'Simulating the BEAVRS 3.1 pct enriched 16 BP assembly...')
  
group = '8'
assembly = CellFill(universe=0, universe_fill= lattices[group]['3.1-16BP'].getId())

###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################

log.py_printf('NORMAL', 'Creating surfaces...')

#create surfaces
left = openmoc.XPlane(x=-pin_pitch*17/2.0)
right = openmoc.XPlane(x=pin_pitch*17/2.0)
bottom = openmoc.YPlane(y=-pin_pitch*17/2.0)
top = openmoc.YPlane(y=pin_pitch*17/2.0)
###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

options = Options()

num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()

log.set_log_level('NORMAL')

log.py_printf('TITLE', 'Simulating a one group homogeneous infinite medium...')
log.py_printf('HEADER', 'The reference keff = 1.43...')


###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

log.py_printf('NORMAL', 'Creating materials...')

infinite_medium = Material(1)
infinite_medium.setNumEnergyGroups(1)
infinite_medium.setSigmaA(numpy.array([0.069389522]))
infinite_medium.setSigmaF(numpy.array([0.0414198575]))
infinite_medium.setNuSigmaF(numpy.array([0.0994076580]))
infinite_medium.setSigmaS(numpy.array([0.383259177]))
Beispiel #33
0
###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

options = Options()

num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()

log.set_log_level("NORMAL")

log.py_printf("TITLE", "Simulating the OECD's C5G7 Benchmark Problem...")


###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf("NORMAL", "Importing materials data from HDF5...")

materials = materialize.materialize("../../c5g7-materials.h5")

uo2_id = materials["UO2"].getId()
mox43_id = materials["MOX-4.3%"].getId()
mox7_id = materials["MOX-7%"].getId()
mox87_id = materials["MOX-8.7%"].getId()
guide_tube_id = materials["Guide Tube"].getId()
Beispiel #34
0
    def _run_openmoc(self):
        """Print a variety of log messages to a log file."""

        # Set a log level which precludes some messages from being printed
        openmoc.set_log_level('NORMAL')

        # Print messages using the pure C implementation
        openmoc.log_printf(openmoc.DEBUG, 'This is a debug message')
        openmoc.log_printf(openmoc.INFO, 'This is an info message')
        openmoc.log_printf(openmoc.NORMAL, 'This is a normal message')
        openmoc.log_printf(openmoc.SEPARATOR, 'This is a separator message')
        openmoc.log_printf(openmoc.HEADER, 'This is a header message')
        openmoc.log_printf(openmoc.TITLE, 'This is a title message')
        openmoc.log_printf(openmoc.WARNING, 'This is a warning message')
        openmoc.log_printf(openmoc.CRITICAL, 'This is a critical message')
        openmoc.log_printf(openmoc.RESULT, 'This is a result message')

        # Print messages using the Python-wrapped version
        py_printf('DEBUG', 'This is a debug message')
        py_printf('INFO', 'This is an info message')
        py_printf('NORMAL', 'This is a normal message')
        py_printf('SEPARATOR', 'This is a separator message')
        py_printf('HEADER', 'This is a header message')
        py_printf('TITLE', 'This is a title message')
        py_printf('WARNING', 'This is a warning message')
        py_printf('CRITICAL', 'This is a critical message')
        py_printf('RESULT', 'This is a result message: %d', 5)
Beispiel #35
0
located within the OpenMOC folder.This could potentially also accept user input,
but there should also be a default value."""

num_threads = options.num_omp_threads
track_spacing = options.track_spacing
num_azim = options.num_azim
tolerance = options.tolerance
max_iters = options.max_iters

log.setLogLevel('NORMAL')

###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from HDF5...')

#The following assigns the dictionary returned by the materialize function in
#the materialize python file to the variable materials
materials = materialize.materialize('BWR_materials.hdf5')

#finds the identification number for each material
uo2_id = materials['UO2'].getId()
moderator_id = materials['MODERATOR'].getId()
clad_id = materials['CLAD'].getId()
gd2o3_id = materials['UO2 + GD2O3'].getId()

###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################
Beispiel #36
0
import openmoc
import openmoc.log as log
import openmoc.plotter as plotter

log.set_log_level('NORMAL')

###############################################################################
#                            Creating Materials
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from HDF5...')

materials = openmoc.materialize.load_from_hdf5('c5g7-mgxs.h5', '../')

###############################################################################
#                            Creating Surfaces
###############################################################################

log.py_printf('NORMAL', 'Creating surfaces...')

xmin = openmoc.XPlane(x=-20.0, name='xmin')
xmax = openmoc.XPlane(x=20.0, name='xmax')
ymin = openmoc.YPlane(y=-20.0, name='ymin')
ymax = openmoc.YPlane(y=20.0, name='ymax')
zmin = openmoc.ZPlane(z=-20.0, name='zmin')
zmax = openmoc.ZPlane(z=20.0, name='zmax')

xmin.setBoundaryType(openmoc.VACUUM)
xmax.setBoundaryType(openmoc.VACUUM)
ymin.setBoundaryType(openmoc.VACUUM)
ymax.setBoundaryType(openmoc.VACUUM)
Beispiel #37
0
###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

options = Options()

num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()

log.set_log_level("NORMAL")

log.py_printf("TITLE", "Simulating the LRA Benchmark Problem...")


###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf("NORMAL", "Importing materials data from py...")

materials = materialize.materialize("LRA-materials.py")


###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################
Beispiel #38
0
#######################   Main Simulation Parameters   ########################
###############################################################################

num_threads = options.num_omp_threads
track_spacing = options.track_spacing
num_azim = options.num_azim
tolerance = options.tolerance
max_iters = options.max_iters

log.setLogLevel('DEBUG')

###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from HDF5...')

materials = materialize.materialize('BWR_materials.hdf5')

uo2_id = materials['UO2'].getId()
moderator_id = materials['MODERATOR'].getId()
clad_id = materials['CLAD'].getId()
gd2o3_id = materials['UO2 + GD2O3'].getId() 


###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################

log.py_printf('NORMAL', 'Creating Surfaces...')
Beispiel #39
0
import openmoc
import openmoc.log as log
import openmoc.plotter as plotter
import openmoc.materialize as materialize

log.set_log_level('NORMAL')

###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from HDF5...')

materials = materialize.load_from_hdf5('c5g7-mgxs.h5', '../')

###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################

log.py_printf('NORMAL', 'Creating surfaces...')

xmin = openmoc.XPlane(x=-2.0, name='xmin')
xmax = openmoc.XPlane(x=2.0, name='xmax')
ymin = openmoc.YPlane(y=-2.0, name='ymin')
ymax = openmoc.YPlane(y=2.0, name='ymax')
zmin = openmoc.ZPlane(z=-10.0, name='zmin')
zmax = openmoc.ZPlane(z=10.0, name='zmax')

xmin.setBoundaryType(openmoc.REFLECTIVE)
xmax.setBoundaryType(openmoc.REFLECTIVE)
ymin.setBoundaryType(openmoc.REFLECTIVE)
Beispiel #40
0
options = Options()

num_threads = options.num_omp_threads
track_spacing = options.track_spacing
num_azim = options.num_azim
tolerance = options.tolerance
max_iters = options.max_iters

log.setLogLevel('NORMAL')


###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from HDF5...')

materials = materialize.materialize('../c5g7-materials.h5')

uo2_id = materials['UO2'].getId()
water_id = materials['Water'].getId()


###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################

log.py_printf('NORMAL', 'Creating surfaces...')

circle = Circle(x=0.0, y=0.0, radius=1.0)
left = XPlane(x=-2.0)
Beispiel #41
0
###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

options = Options()

num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()

log.set_log_level('NORMAL')

log.py_printf('TITLE', 'Simulating a BEAVRS 3x3 small core...')

group = '8'

###############################################################################
###########################   Creating Lattices   #############################
###############################################################################

log.py_printf('NORMAL', 'Creating lattices...')

assembly16 = CellFill(universe=universe_id(), universe_fill= lattices[group]['1.6-0BP'].getId())
assembly24 = CellFill(universe=universe_id(), universe_fill= lattices[group]['2.4-16BP'].getId())
id16 = assembly16.getUniverseId()
id24 = assembly24.getUniverseId()

smallcore = Lattice(universe_id(), pin_pitch*17, pin_pitch*17)
#                          Main Simulation Parameters
###############################################################################

options = Options()

num_threads = options.num_omp_threads
azim_spacing = options.azim_spacing
num_azim = options.num_azim
polar_spacing = options.polar_spacing
num_polar = options.num_polar
tolerance = options.tolerance
max_iters = options.max_iters

log.set_log_level('NORMAL')

log.py_printf('TITLE', 'Simulating a one group homogeneous infinite medium...')
log.py_printf('HEADER', 'The reference keff = 1.43...')

###############################################################################
#                            Creating Materials
###############################################################################

log.py_printf('NORMAL', 'Creating materials...')

infinite_medium = Material(name='1-group infinite medium')
infinite_medium.setNumEnergyGroups(1)
infinite_medium.setSigmaF(numpy.array([0.0414198575]))
infinite_medium.setNuSigmaF(numpy.array([0.0994076580]))
infinite_medium.setSigmaS(numpy.array([0.383259177]))
infinite_medium.setChi(numpy.array([1.0]))
infinite_medium.setSigmaT(numpy.array([0.452648699]))
Beispiel #43
0
num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()
acceleration = options.getCmfdAcceleration()
relax_factor = options.getCmfdRelaxationFactor()
mesh_level = options.getCmfdMeshLevel()

log.set_log_level('NORMAL')

###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from HDF5...')

materials = materialize.materialize('../c5g7-materials.h5')

uo2_id = materials['UO2'].getId()
water_id = materials['Water'].getId()

###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################

log.py_printf('NORMAL', 'Creating surfaces...')

circles = []
planes = []
planes.append(XPlane(x=-2.0))
Beispiel #44
0
    def _run_openmoc(self):

        runtime = openmoc.RuntimeParameters()

        string_input = [
            '-debug', '1', '-log_level', 'NORMAL', '-domain_decompose',
            '2,2,2', '-num_domain_modules', '1,1,1', '-num_threads', '1',
            '-log_filename', 'test_problem.log', '-geo_filename',
            'geometry_file.geo', '-azim_spacing', '0.22 ', '-num_azim', '4',
            '-polar_spacing', '0.8', '-num_polar', '6', '-seg_zones',
            '-5.0,5.0', '-segmentation_type', '3', '-quadraturetype', '2',
            '-CMFD_group_structure', '1/2,3,4/5,6,7', '-CMFD_lattice', '2,3,3',
            '-widths_x', '1,2*1,1', '-widths_y', '1,2*1,1', '-widths_z',
            '3.5,2.5*2,1.5', '-CMFD_flux_update_on', '1', '-knearest', '2',
            '-CMFD_centroid_update_on', '1', '-use_axial_interpolation', '2',
            '-SOR_factor', '1.5', '-CMFD_relaxation_factor', '0.7',
            '-ls_solver', '1', '-max_iters', '15', '-MOC_src_residual_type',
            '1', '-MOC_src_tolerance', '1.0E-2', '-output_mesh_lattice',
            '-output_mesh_lattice', ' 5,5,9', ' -output_type', ' 0',
            '-output_mesh_lattice', '-output_mesh_lattice', ' 5,5,9',
            ' -output_type', ' 1', '-non_uniform_output',
            '1.26*3/1*3/4.*3/-1.,1.,-1.', ' -output_type 1  ',
            '-verbose_report', '1', '-time_report', '1'
        ]
        string_input = [s.encode('utf8') for s in string_input]

        runtime.setRuntimeParameters(string_input)
        print(string_input)

        # Define simulation parameters
        num_threads = runtime._num_threads

        # Set logging information
        if (runtime._log_filename):
            openmoc.set_log_filename(runtime._log_filename)
        openmoc.set_log_level(runtime._log_level)
        openmoc.set_line_length(120)

        py_printf('NORMAL', 'Geometry file = %s', runtime._geo_filename)
        py_printf('NORMAL', 'Azimuthal spacing = %f', runtime._azim_spacing)
        py_printf('NORMAL', 'Azimuthal angles = %d', runtime._num_azim)
        py_printf('NORMAL', 'Polar spacing = %f', runtime._polar_spacing)
        py_printf('NORMAL', 'Polar angles = %d', runtime._num_polar)

        # Create the geometry
        py_printf('NORMAL', 'Creating geometry...')
        geometry = openmoc.Geometry()
        self.input_set.geometry = geometry
        if (not runtime._geo_filename):
            py_printf('ERROR', 'No geometry file is provided')
        geometry.loadFromFile(runtime._geo_filename)
        if False:  #FIXME
            geometry.setDomainDecomposition(runtime._NDx, runtime._NDy,
                                            runtime._NDz, MPI_COMM_WORLD)

        geometry.setNumDomainModules(runtime._NMx, runtime._NMy, runtime._NMz)

        if ((runtime._NCx > 0 and runtime._NCy > 0 and runtime._NCz > 0)
                or (not runtime._cell_widths_x.empty()
                    and not runtime._cell_widths_y.empty()
                    and not runtime._cell_widths_z.empty())):

            # Create CMFD mesh
            py_printf('NORMAL', 'Creating CMFD mesh...')
            cmfd = openmoc.Cmfd()
            cmfd.setSORRelaxationFactor(runtime._SOR_factor)
            cmfd.setCMFDRelaxationFactor(runtime._CMFD_relaxation_factor)
            if (runtime._cell_widths_x.empty()
                    or runtime._cell_widths_y.empty()
                    or runtime._cell_widths_z.empty()):
                cmfd.setLatticeStructure(runtime._NCx, runtime._NCy,
                                         runtime._NCz)
            else:
                cmfd_widths = [
                    runtime._cell_widths_x, runtime._cell_widths_y,
                    runtime._cell_widths_z
                ]
                cmfd.setWidths(cmfd_widths)

            if (not runtime._CMFD_group_structure.empty()):
                cmfd.setGroupStructure(runtime._CMFD_group_structure)
            cmfd.setKNearest(runtime._knearest)
            cmfd.setCentroidUpdateOn(runtime._CMFD_centroid_update_on)
            cmfd.useAxialInterpolation(runtime._use_axial_interpolation)

            geometry.setCmfd(cmfd)

        geometry.initializeFlatSourceRegions()

        # Initialize track generator and generate tracks
        py_printf('NORMAL', 'Initializing the track generator...')
        if runtime._quadraturetype == 0:
            quad = openmoc.TYPolarQuad()
        if runtime._quadraturetype == 1:
            quad = openmoc.LeonardPolarQuad()
        if runtime._quadraturetype == 2:
            quad = openmoc.GLPolarQuad()
        if runtime._quadraturetype == 3:
            quad = openmoc.EqualWeightPolarQuad()
        if runtime._quadraturetype == 4:
            quad = openmoc.EqualAnglePolarQuad()

        quad.setNumAzimAngles(runtime._num_azim)
        quad.setNumPolarAngles(runtime._num_polar)
        track_generator = openmoc.TrackGenerator3D(geometry, runtime._num_azim,
                                                   runtime._num_polar,
                                                   runtime._azim_spacing,
                                                   runtime._polar_spacing)
        track_generator.setNumThreads(num_threads)
        track_generator.setQuadrature(quad)
        track_generator.setSegmentFormation(runtime._segmentation_type)
        if (len(runtime._seg_zones) > 0):
            track_generator.setSegmentationZones(runtime._seg_zones)
        track_generator.generateTracks()
        self.track_generator = track_generator

        # Initialize solver and run simulation
        if (runtime._linear_solver):
            self.solver = openmoc.CPULSSolver(track_generator)
        else:
            self.solver = openmoc.CPUSolver(track_generator)
        if (runtime._verbose_report):
            self.solver.setVerboseIterationReport()
        self.solver.setNumThreads(num_threads)
        self.solver.setConvergenceThreshold(runtime._tolerance)
        self.solver.computeEigenvalue(runtime._max_iters,
                                      runtime._MOC_src_residual_type)

        if (runtime._time_report):
            self.solver.printTimerReport()

        # Extract reaction rates
        my_rank = 0
        #if False: #FIXME
        #MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
        rxtype = {'FISSION_RX', 'TOTAL_RX', 'ABSORPTION_RX', 'FLUX_RX'}
Beispiel #45
0
def createLattice(assembly):
    log.py_printf('NORMAL', 'Creating simple 4x4 lattice...')
    lattice = Lattice(id=100, width_x=0.62992*2, width_y=0.62992*2)

    return lattice
Beispiel #46
0
options = Options()

num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()

log.set_log_level('NORMAL')


###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from HDF5...')

materials = materialize.materialize('../c5g7-materials.h5')

uo2_id = materials['UO2'].getId()
water_id = materials['Water'].getId()


###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################

log.py_printf('NORMAL', 'Creating surfaces...')

circles = []
planes = []
Beispiel #47
0
import openmoc.log as log
import openmoc.plotter as plotter
import openmoc.materialize as materialize


###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

log.set_log_level('INFO')

###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from py...')

materials = materialize.materialize('LRA-materials.py')

region1 = materials['region_1'].getId()
region2 = materials['region_2'].getId()
region3 = materials['region_3'].getId()
region4 = materials['region_4'].getId()
region5 = materials['region_5'].getId()
region6 = materials['region_6'].getId()

###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################

log.py_printf('NORMAL', 'Creating surfaces...')
Beispiel #48
0
options = Options()

num_threads = options.num_omp_threads
azim_spacing = options.azim_spacing
num_azim = options.num_azim
polar_spacing = options.polar_spacing
num_polar = options.num_polar
tolerance = options.tolerance
max_iters = options.max_iters


###############################################################################
########################   Creating the TrackGenerator   ######################
###############################################################################

log.py_printf('NORMAL', 'Initializing the track generator...')

track_generator = openmoc.TrackGenerator3D(geometry, num_azim, num_polar,
                                           azim_spacing, polar_spacing)
track_generator.setNumThreads(num_threads)
track_generator.setSegmentFormation(openmoc.OTF_STACKS)
track_generator.generateTracks()


###############################################################################
###########################   Running a Simulation   ##########################
###############################################################################

solver = openmoc.CPUSolver(track_generator)
solver.setNumThreads(num_threads)
solver.setConvergenceThreshold(tolerance)
Beispiel #49
0
def createSurfaces(numgroups, bp=False):
    
    if bp == False:
        log.py_printf('NORMAL', 'Creating Surfaces...')

        #creates list of circle and plane surfaces
        circles = [] 
        planes = []

        #creates empty Material object as a dummy to fill the fuel cells
        dummy_id = material_id()
        dummy = Material(dummy_id)

        #gives dummy material stupid cross sections
        dummy.setNumEnergyGroups(int(numgroups))
        dummyxs = numpy.zeros(int(numgroups))
        dummyscatter = numpy.zeros((int(numgroups))**2)
        dummy.setSigmaT(dummyxs)
        dummy.setSigmaS(dummyscatter)
        dummy.setSigmaF(dummyxs)
        dummy.setSigmaA(dummyxs)
        dummy.setNuSigmaF(dummyxs)
        dummy.setChi(dummyxs)

        #appends surfaces to lists
        planes.append(XPlane(x=-0.62992*17))
        planes.append(XPlane(x=0.62992*17))
        planes.append(YPlane(y=-0.62992*17))
        planes.append(YPlane(y=0.62992*17))
        #Radii for fuel cells
        circles.append(Circle(x=0.0, y=0.0, radius=0.39218))
        circles.append(Circle(x=0.0, y=0.0, radius=0.40005))
        circles.append(Circle(x=0.0, y=0.0, radius=0.45720))
        #Radii for guide tubes (also use for instrument tube)
        circles.append(Circle(x=0.0, y=0.0, radius=0.56134))
        circles.append(Circle(x=0.0, y=0.0, radius=0.60198))

        for plane in planes:plane.setBoundaryType(REFLECTIVE)

        return dummy, dummy_id, circles, planes
    
    elif bp == True:

        log.py_printf('NORMAL', 'Creating Surfaces...')

        #creates list of circle and plane surfaces
        circles = []
        planes = []

        #creates empty Material object as a dummy to fill the fuel cells
        dummy_id = material_id()
        dummy = Material(dummy_id)

        #gives dummy material stupid cross sections
        dummy.setNumEnergyGroups(int(numgroups))
        dummyxs = numpy.zeros(int(numgroups))
        dummyscatter = numpy.zeros((int(numgroups))**2)
        dummy.setSigmaT(dummyxs)
        dummy.setSigmaS(dummyscatter)
        dummy.setSigmaF(dummyxs)
        dummy.setSigmaA(dummyxs)
        dummy.setNuSigmaF(dummyxs)
        dummy.setChi(dummyxs)

        #appends surfaces to lists
        planes.append(XPlane(x=-0.62992*17))
        planes.append(XPlane(x=0.62992*17))
        planes.append(YPlane(y=-0.62992*17))
        planes.append(YPlane(y=0.62992*17))
        #Radii for fuel cells
        circles.append(Circle(x=0.0, y=0.0, radius=0.39218))
        circles.append(Circle(x=0.0, y=0.0, radius=0.40005))
        circles.append(Circle(x=0.0, y=0.0, radius=0.45720))
        #Radii for guide tubes (also use for instrument tube)
        circles.append(Circle(x=0.0, y=0.0, radius=0.56134))
        circles.append(Circle(x=0.0, y=0.0, radius=0.60198))
        #Radii for burnable poisons
        circles.append(Circle(x=0.0, y=0.0, radius=0.21400))
        circles.append(Circle(x=0.0, y=0.0, radius=0.23051))
        circles.append(Circle(x=0.0, y=0.0, radius=0.24130))
        circles.append(Circle(x=0.0, y=0.0, radius=0.42672))
        circles.append(Circle(x=0.0, y=0.0, radius=0.43688))
        circles.append(Circle(x=0.0, y=0.0, radius=0.48387))
        circles.append(Circle(x=0.0, y=0.0, radius=0.56134))
        circles.append(Circle(x=0.0, y=0.0, radius=0.60198))

        for plane in planes:plane.setBoundaryType(REFLECTIVE)

        return dummy, dummy_id, circles, planes
Beispiel #50
0
###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

options = Options()

num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()

log.set_log_level('NORMAL')

log.py_printf('TITLE', 'Simulating HW3 from Fall 2010 22.212...')


###############################################################################
###########################   Creating Materials   ############################
###############################################################################

log.py_printf('NORMAL', 'Creating materials...')

fuel = Material(1)
moderator = Material(2)

fuel.setNumEnergyGroups(1)
moderator.setNumEnergyGroups(1)

fuel.setSigmaA(numpy.array([0.069389522]))
###############################################################################
#######################   Main Simulation Parameters   ########################
###############################################################################

options = Options()

num_threads = options.getNumThreads()
track_spacing = options.getTrackSpacing()
num_azim = options.getNumAzimAngles()
tolerance = options.getTolerance()
max_iters = options.getMaxIterations()
group = '8'

log.set_log_level('NORMAL')

log.py_printf('TITLE', 'Simulating the BEAVRS full core benchmark...')

###############################################################################
###########################   Creating Surfaces   #############################
###############################################################################

log.py_printf('NORMAL', 'Creating surfaces...')

left = openmoc.XPlane(x=-267.716)
right = openmoc.XPlane(x=267.716)
bottom = openmoc.YPlane(y=-267.716)
top = openmoc.YPlane(y=267.716)

left.setBoundaryType(VACUUM)
right.setBoundaryType(VACUUM)
bottom.setBoundaryType(VACUUM)
Beispiel #52
0
    def _run_openmoc(self):

        openmoc.set_log_level('NORMAL')

        c1 = openmoc.Cell()
        c2 = openmoc.Cell()

        s1 = openmoc.XPlane(-40.)
        s2 = openmoc.XPlane(-50.)
        s3 = openmoc.XPlane(-60.)
        s1.setBoundaryType(openmoc.VACUUM)
        s2.setBoundaryType(openmoc.PERIODIC)
        s3.setBoundaryType(openmoc.REFLECTIVE)

        c1.addSurface(+1, s1)
        c2.addSurface(+1, s2)
        c2.addSurface(+1, s3)

        u = openmoc.Universe()
        u.addCell(c1)
        u.addCell(c2)
        boundary = u.getMinXBoundaryType()
        if boundary == 0:
            boundary = 'VACUUM'
        elif boundary == 1:
            boundary = 'REFLECTIVE'
        elif boundary == 2:
            boundary = 'PERIODIC'
        else:
            boundary = 'BOUNDARY_NONE'

        py_printf('NORMAL', 'MinX: %f', u.getMinX())
        py_printf('NORMAL', 'MinXBoundaryType: %s', boundary)
        py_printf('SEPARATOR', '')

        c1 = openmoc.Cell()
        c2 = openmoc.Cell()

        s1 = openmoc.YPlane(-40.)
        s2 = openmoc.YPlane(-50.)
        s3 = openmoc.YPlane(-60.)
        s1.setBoundaryType(openmoc.VACUUM)
        s2.setBoundaryType(openmoc.PERIODIC)
        s3.setBoundaryType(openmoc.REFLECTIVE)

        c1.addSurface(+1, s1)
        c2.addSurface(+1, s2)
        c2.addSurface(+1, s3)

        u = openmoc.Universe()
        u.addCell(c1)
        u.addCell(c2)
        boundary = u.getMinYBoundaryType()
        if boundary == 0:
            boundary = 'VACUUM'
        elif boundary == 1:
            boundary = 'REFLECTIVE'
        elif boundary == 2:
            boundary = 'PERIODIC'
        else:
            boundary = 'BOUNDARY_NONE'

        py_printf('NORMAL', 'MinY: %f', u.getMinY())
        py_printf('NORMAL', 'MinYBoundaryType: %s', boundary)
        py_printf('SEPARATOR', '')

        c1 = openmoc.Cell()
        c2 = openmoc.Cell()

        s1 = openmoc.ZPlane(-40.)
        s2 = openmoc.ZPlane(-50.)
        s3 = openmoc.ZPlane(-60.)
        s1.setBoundaryType(openmoc.VACUUM)
        s2.setBoundaryType(openmoc.PERIODIC)
        s3.setBoundaryType(openmoc.REFLECTIVE)

        c1.addSurface(+1, s1)
        c2.addSurface(+1, s2)
        c2.addSurface(+1, s3)

        u = openmoc.Universe()
        u.addCell(c1)
        u.addCell(c2)
        boundary = u.getMinZBoundaryType()
        if boundary == 0:
            boundary = 'VACUUM'
        elif boundary == 1:
            boundary = 'REFLECTIVE'
        elif boundary == 2:
            boundary = 'PERIODIC'
        else:
            boundary = 'BOUNDARY_NONE'

        py_printf('NORMAL', 'MinZ: %f', u.getMinZ())
        py_printf('NORMAL', 'MinZBoundaryType: %s', boundary)
        py_printf('SEPARATOR', '')

        c1 = openmoc.Cell()
        c2 = openmoc.Cell()

        s1 = openmoc.XPlane(40.)
        s2 = openmoc.XPlane(50.)
        s3 = openmoc.XPlane(60.)
        s1.setBoundaryType(openmoc.VACUUM)
        s2.setBoundaryType(openmoc.PERIODIC)
        s3.setBoundaryType(openmoc.REFLECTIVE)

        c1.addSurface(-1, s1)
        c2.addSurface(-1, s2)
        c2.addSurface(-1, s3)

        u = openmoc.Universe()
        u.addCell(c1)
        u.addCell(c2)
        boundary = u.getMaxXBoundaryType()
        if boundary == 0:
            boundary = 'VACUUM'
        elif boundary == 1:
            boundary = 'REFLECTIVE'
        elif boundary == 2:
            boundary = 'PERIODIC'
        else:
            boundary = 'BOUNDARY_NONE'

        py_printf('NORMAL', 'MaxX: %f', u.getMaxX())
        py_printf('NORMAL', 'MaxXBoundaryType: %s', boundary)
        py_printf('SEPARATOR', '')

        c1 = openmoc.Cell()
        c2 = openmoc.Cell()

        s1 = openmoc.YPlane(40.)
        s2 = openmoc.YPlane(50.)
        s3 = openmoc.YPlane(60.)
        s1.setBoundaryType(openmoc.VACUUM)
        s2.setBoundaryType(openmoc.PERIODIC)
        s3.setBoundaryType(openmoc.REFLECTIVE)

        c1.addSurface(-1, s1)
        c2.addSurface(-1, s2)
        c2.addSurface(-1, s3)

        u = openmoc.Universe()
        u.addCell(c1)
        u.addCell(c2)
        boundary = u.getMaxYBoundaryType()
        if boundary == 0:
            boundary = 'VACUUM'
        elif boundary == 1:
            boundary = 'REFLECTIVE'
        elif boundary == 2:
            boundary = 'PERIODIC'
        else:
            boundary = 'BOUNDARY_NONE'

        py_printf('NORMAL', 'MaxY: %f', u.getMaxY())
        py_printf('NORMAL', 'MaxYBoundaryType: %s', boundary)
        py_printf('SEPARATOR', '')

        c1 = openmoc.Cell()
        c2 = openmoc.Cell()

        s1 = openmoc.ZPlane(40.)
        s2 = openmoc.ZPlane(50.)
        s3 = openmoc.ZPlane(60.)
        s1.setBoundaryType(openmoc.VACUUM)
        s2.setBoundaryType(openmoc.PERIODIC)
        s3.setBoundaryType(openmoc.REFLECTIVE)

        c1.addSurface(-1, s1)
        c2.addSurface(-1, s2)
        c2.addSurface(-1, s3)

        u = openmoc.Universe()
        u.addCell(c1)
        u.addCell(c2)
        boundary = u.getMaxZBoundaryType()
        if boundary == 0:
            boundary = 'VACUUM'
        elif boundary == 1:
            boundary = 'REFLECTIVE'
        elif boundary == 2:
            boundary = 'PERIODIC'
        else:
            boundary = 'BOUNDARY_NONE'

        py_printf('NORMAL', 'MaxZ: %f', u.getMaxZ())
        py_printf('NORMAL', 'MaxZBoundaryType: %s', boundary)
        py_printf('SEPARATOR', '')

        sW = openmoc.XPlane(10)
        sE = openmoc.XPlane(20)
        sS = openmoc.YPlane(30)
        sN = openmoc.YPlane(40)
        sB = openmoc.ZPlane(50)
        sT = openmoc.ZPlane(60)
        sW.setBoundaryType(openmoc.VACUUM)
        sE.setBoundaryType(openmoc.REFLECTIVE)
        sS.setBoundaryType(openmoc.VACUUM)
        sN.setBoundaryType(openmoc.REFLECTIVE)
        sB.setBoundaryType(openmoc.PERIODIC)
        sT.setBoundaryType(openmoc.REFLECTIVE)

        sX_mid = openmoc.XPlane(15)
        sY_mid = openmoc.YPlane(35)
        sZ_mid = openmoc.ZPlane(55)
        sX_mid.setBoundaryType(openmoc.BOUNDARY_NONE)
        sY_mid.setBoundaryType(openmoc.BOUNDARY_NONE)
        sZ_mid.setBoundaryType(openmoc.BOUNDARY_NONE)

        cell = openmoc.Cell()
        cell.addSurface(+1, sW)
        cell.addSurface(-1, sE)
        cell.addSurface(+1, sS)
        cell.addSurface(-1, sN)
        cell.addSurface(+1, sB)
        cell.addSurface(-1, sT)

        cell.addSurface(+1, sX_mid)
        cell.addSurface(-1, sX_mid)
        cell.addSurface(+1, sY_mid)
        cell.addSurface(-1, sY_mid)
        cell.addSurface(+1, sZ_mid)
        cell.addSurface(-1, sZ_mid)

        univ = openmoc.Universe()
        univ.addCell(cell)

        py_printf('NORMAL', 'MinX: %f', univ.getMinX())
        py_printf('NORMAL', 'MinXBoundaryType: %s', univ.getMinXBoundaryType())
        py_printf('NORMAL', 'MinY: %f', univ.getMinY())
        py_printf('NORMAL', 'MinYBoundaryType: %s', univ.getMinYBoundaryType())
        py_printf('NORMAL', 'MinZ: %f', univ.getMinZ())
        py_printf('NORMAL', 'MinZBoundaryType: %s', univ.getMinZBoundaryType())
        py_printf('NORMAL', 'MaxX: %f', univ.getMaxX())
        py_printf('NORMAL', 'MaxXBoundaryType: %s', univ.getMaxXBoundaryType())
        py_printf('NORMAL', 'MaxY: %f', univ.getMaxY())
        py_printf('NORMAL', 'MaxYBoundaryType: %s', univ.getMaxYBoundaryType())
        py_printf('NORMAL', 'MaxZ: %f', univ.getMaxZ())
        py_printf('NORMAL', 'MaxZBoundaryType: %s', univ.getMaxZBoundaryType())
Beispiel #53
0
import openmoc
import openmoc.log as log
import openmoc.plotter as plotter

log.set_log_level('NORMAL')

###############################################################################
#                            Creating Materials
###############################################################################

log.py_printf('NORMAL', 'Importing materials data from HDF5...')

materials = openmoc.materialize.load_from_hdf5('c5g7-mgxs.h5', '../')

###############################################################################
#                            Creating Surfaces
###############################################################################

log.py_printf('NORMAL', 'Creating surfaces...')

xmin = openmoc.XPlane(x=-2.0, name='xmin')
xmax = openmoc.XPlane(x=2.0, name='xmax')
ymin = openmoc.YPlane(y=-2.0, name='ymin')
ymax = openmoc.YPlane(y=2.0, name='ymax')
zmin = openmoc.ZPlane(z=-0.5, name='zmin')
zmax = openmoc.ZPlane(z=0.5, name='zmax')

xmin.setBoundaryType(openmoc.REFLECTIVE)
xmax.setBoundaryType(openmoc.REFLECTIVE)
ymin.setBoundaryType(openmoc.REFLECTIVE)
ymax.setBoundaryType(openmoc.REFLECTIVE)