def _create_geometry(self): """Initialize CMFD and add it to the Geometry.""" super(OTFTransportTestHarness, self)._create_geometry() # Change boundary condition on one side to vacuum cell_id = list(self.input_set.geometry.getRootUniverse().getCells())[0] surface_ids = list(self.input_set.geometry.getRootUniverse().getCells()[ cell_id].getSurfaces())[1:5] del surface_ids[2] for surface_id in surface_ids: self.input_set.geometry.getRootUniverse().getCells()[ cell_id].getSurfaces()[surface_id].getSurface().setBoundaryType( openmoc.VACUUM) # Initialize CMFD cmfd = openmoc.Cmfd() cmfd.setCMFDRelaxationFactor(1.0) cmfd.setSORRelaxationFactor(1.5) cmfd.setLatticeStructure(4,4,4) cmfd.setGroupStructure([[1,2,3], [4,5,6,7]]) cmfd.setKNearest(3) # Add CMFD to the Geometry self.input_set.geometry.setCmfd(cmfd)
def _create_geometry(self): """Initialize CMFD and add it to the Geometry.""" super(CmfdPwrAssemblyTestHarness, self)._create_geometry() # Change boundary condition on one side to vacuum cell_id = list(self.input_set.geometry.getRootUniverse().getCells())[0] surface_id = list(self.input_set.geometry.getRootUniverse().getCells() [cell_id].getSurfaces())[0] self.input_set.geometry.getRootUniverse().getCells( )[cell_id].getSurfaces()[surface_id].getSurface().setBoundaryType( openmoc.PERIODIC) surface_id = list(self.input_set.geometry.getRootUniverse().getCells() [cell_id].getSurfaces())[1] self.input_set.geometry.getRootUniverse().getCells( )[cell_id].getSurfaces()[surface_id].getSurface().setBoundaryType( openmoc.PERIODIC) # Initialize CMFD cmfd = openmoc.Cmfd() cmfd.setCMFDRelaxationFactor(0.7) cmfd.setSORRelaxationFactor(1.0) cmfd.setLatticeStructure(17, 17) cmfd.setGroupStructure([[1, 2, 3], [4, 5, 6, 7]]) cmfd.setKNearest(3) # Add CMFD to the Geometry self.input_set.geometry.setCmfd(cmfd)
def _create_geometry(self): """Initialize CMFD and add it to the Geometry.""" super(MultiSimMaterialsCmfdTestHarness, self)._create_geometry() # Initialize CMFD cmfd = openmoc.Cmfd() cmfd.setSORRelaxationFactor(1.5) cmfd.setLatticeStructure(3,3) # Add CMFD to the Geometry self.input_set.geometry.setCmfd(cmfd)
def _setup(self): """Build materials, geometry, CMFD, and perform ray tracing.""" self._create_geometry() self._create_trackgenerator() # Overlay simple CMFD mesh cmfd = openmoc.Cmfd() cmfd.setLatticeStructure(2, 2) self.input_set.geometry.setCmfd(cmfd) self._generate_tracks() self._create_solver()
def _create_geometry(self): """Initialize CMFD and add it to the Geometry.""" super(TransportStabilizationTestHarness, self)._create_geometry() # Initialize CMFD cmfd = openmoc.Cmfd() cmfd.setCMFDRelaxationFactor(0.7) cmfd.setLatticeStructure(17, 17) cmfd.setGroupStructure([[1, 2, 3], [4, 5, 6, 7]]) cmfd.setKNearest(3) # Add CMFD to the Geometry self.input_set.geometry.setCmfd(cmfd)
def _create_geometry(self): """Initialize CMFD and add it to the Geometry.""" super(PlotCmfdCellsTestHarness, self)._create_geometry() # Initialize CMFD self.cmfd = openmoc.Cmfd() self.cmfd.setSORRelaxationFactor(1.5) self.cmfd.setLatticeStructure(17, 17) self.cmfd.setGroupStructure([1, 4, 8]) self.cmfd.setKNearest(3) # Add CMFD to the Geometry self.input_set.geometry.setCmfd(self.cmfd)
def _create_geometry(self): """Initialize CMFD and add it to the Geometry.""" super(NonUniformLatticeTestHarness, self)._create_geometry() # Initialize CMFD cmfd = openmoc.Cmfd() cmfd.setCMFDRelaxationFactor(0.7) cmfd.setSORRelaxationFactor(1.0) cmfd.setWidths([[0.05, 1.26, 1.26, 0.05], [0.05, 1.26, 1.26, 0.05], [1., 1.5]]) cmfd.setGroupStructure([[1, 2, 3], [4, 5, 6, 7]]) # Add CMFD to the Geometry self.input_set.geometry.setCmfd(cmfd)
def _create_geometry(self): """Initialize CMFD and add it to the Geometry.""" super(SimpleLatticeTestHarness, self)._create_geometry() # Initialize CMFD cmfd = openmoc.Cmfd() cmfd.setSORRelaxationFactor(1.5) cmfd.setCMFDRelaxationFactor(1.0) cmfd.setLatticeStructure(4, 4, 4) cmfd.setGroupStructure([[1, 2, 3], [4, 5, 6, 7]]) cmfd.setKNearest(3) # Add CMFD to the Geometry self.input_set.geometry.setCmfd(cmfd)
def test_cmfd_group_structure(self): cmfd = openmoc.Cmfd() # CMFD number of groups getter test cmfd.setGroupStructure([[1, 2, 3], [4, 5]]) self.assertEqual(cmfd.getNumCmfdGroups(), 2) # Check exception raising for non-monotonic group structure with self.assertRaises(Exception): cmfd.setGroupStructure([[1, 2, 6], [4, 5]]) # Check exception raising for non-continuous group structure with self.assertRaises(Exception): cmfd.setGroupStructure([[1, 2, 3], [6, 7]])
def _run_openmoc(self): """Segment tracks over the geometry and save the result to a string""" # Segmentize over the geometry with a fine and coarse cmfd mesh for m in [3, 51]: # Overlay simple CMFD mesh self._result += '{0} x {0} CMFD mesh\n'.format(m) geometry = self.input_set.geometry cmfd = openmoc.Cmfd() cmfd.setLatticeStructure(m, m) geometry.setCmfd(cmfd) geometry.initializeCmfd() # Track over the composite geometry super(TrackingLatticeGridCMFDTestHarness, self)._run_openmoc()
def _create_geometry(self): """Initialize CMFD and add it to the Geometry. Add symmetries""" super(SimpleLatticeTestHarness, self)._create_geometry() # Declare symmetries to use in computation (domain is not actually # symmetric) self.input_set.geometry.useSymmetry(True, True, True) # Initialize CMFD cmfd = openmoc.Cmfd() cmfd.setLatticeStructure(2, 2, 2) cmfd.setGroupStructure([[1, 2, 3], [4, 5, 6, 7]]) cmfd.setKNearest(3) # Add CMFD to the Geometry self.input_set.geometry.setCmfd(cmfd)
def _create_geometry(self): """Initialize CMFD and add it to the Geometry.""" super(AxialQuadraticCMFDTestHarness, self)._create_geometry() # Initialize CMFD cmfd = openmoc.Cmfd() cmfd.setSORRelaxationFactor(1.5) cmfd.setCMFDRelaxationFactor(0.7) # Use FSR axially average value for CMFD prolongation cmfd.useAxialInterpolation(1) # Set CMFD widths with axially non-uniform cmfd.setWidths([[0.05, 1.26, 1.26, 0.05], [0.05, 1.26, 1.26, 0.05], [1, 2, 3, 4, 1, 2, 3, 4]]) # Add CMFD to the Geometry self.input_set.geometry.setCmfd(cmfd)
def _create_geometry(self): """Initialize CMFD and add it to the Geometry.""" super(ModularDomainsTestHarness, self)._create_geometry() # Initialize CMFD cmfd = openmoc.Cmfd() cmfd.setCMFDRelaxationFactor(1.0) cmfd.setSORRelaxationFactor(1.5) cmfd.setLatticeStructure(4,6,12) cmfd.setGroupStructure([[1,2,3], [4,5,6,7]]) cmfd.setKNearest(3) # Add CMFD to the Geometry self.input_set.geometry.setCmfd(cmfd) # Add modular domain decomposition : has to line up with the CMFD self.input_set.geometry.setNumDomainModules(2, 3, 4)
def test_cmfd_parameters(self): ''' Check default CMFD parameters and getters.''' cmfd = openmoc.Cmfd() # Check flux update self.assertEqual(cmfd.isFluxUpdateOn(), True) cmfd.setFluxUpdateOn(False) self.assertEqual(cmfd.isFluxUpdateOn(), False) # Check sigmaT rebalance self.assertEqual(cmfd.isSigmaTRebalanceOn(), False) cmfd.rebalanceSigmaT(True) self.assertEqual(cmfd.isSigmaTRebalanceOn(), True) # Check centroid update self.assertEqual(cmfd.isCentroidUpdateOn(), False) cmfd.setCentroidUpdateOn(True) self.assertEqual(cmfd.isCentroidUpdateOn(), True)
def _create_geometry(self): """Initialize CMFD and add it to the Geometry.""" self.input_set.geometry = openmoc.Geometry() # load a geometry file with a non-uniform lattice self.input_set.geometry.loadFromFile('non-uniform-lattice.geo') # dump geometry file, to test compatibility with the load operation self.input_set.geometry.dumpToFile('log/dump.geo') # Initialize CMFD cmfd = openmoc.Cmfd() cmfd.setCMFDRelaxationFactor(0.7) cmfd.setSORRelaxationFactor(1.0) cmfd.setWidths([[0.05, 1.26, 1.26, 0.05], [0.05, 1.26, 1.26, 0.05], [1., 1.5]]) cmfd.setGroupStructure([[1, 2, 3], [4, 5, 6, 7]]) cmfd.setCentroidUpdateOn(False) # Add CMFD to the Geometry self.input_set.geometry.setCmfd(cmfd)
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'}
############################################################################### ####################### Main Simulation Parameters ######################## ############################################################################### opts = openmoc.options.Options() openmoc.log.set_log_level('NORMAL') openmoc.log.py_printf('TITLE', \ 'Simulating a one group homogeneous, two directional gradient...') ############################################################################### ########################### Creating CMFD Mesh ########################### ############################################################################### openmoc.log.py_printf('NORMAL', 'Creating Cmfd mesh...') cmfd = openmoc.Cmfd() cmfd.setSORRelaxationFactor(1.5) cmfd.setLatticeStructure(25,1) ############################################################################### ######################### Load the Cubic Geometry ######################### ############################################################################### openmoc.log.py_printf('NORMAL', 'Importing cubic geometry...') left.setBoundaryType(openmoc.VACUUM) right.setBoundaryType(openmoc.VACUUM) top.setBoundaryType(openmoc.REFLECTIVE) bottom.setBoundaryType(openmoc.REFLECTIVE) geometry.setCmfd(cmfd)