def _get_results(self, num_iters=True, keff=True, fluxes=True, num_fsrs=True, num_tracks=True, num_segments=True, hash_output=True): """Digest info from the mesh tallies and return as a string.""" # Create OpenMOC Mesh on which to tally reaction rates mesh = process.Mesh() mesh.dimension = [4, 4] mesh.lower_left = [-2., -2.] mesh.upper_right = [2., 2.] mesh.width = [1., 1.] outstr = "" for rxn in ('fission', 'flux', 'total', 'nu-fission', 'scatter'): # Tally OpenMOC reaction rates on the Mesh rxn_rates = mesh.tally_reaction_rates_on_mesh(self.solver, rxn, volume='integrated') # Append reaction rates to the output string outstr += rxn.title() + ' Rate Mesh Tally\n' rates = ['{0:12.6E}'.format(rate) for rate in rxn_rates.ravel()] outstr += '\n'.join(rates) + '\n' return outstr
def _get_results(self, num_iters=True, keff=True, fluxes=True, num_fsrs=True, num_tracks=True, num_segments=True, hash_output=True): """Digest info from the mesh tallies and return as a string.""" # Create OpenMOC Mesh on which to tally fission rates mesh = process.Mesh() mesh.dimension = [4, 4] mesh.lower_left = [-2., -2.] mesh.upper_right = [2., 2.] mesh.width = [1., 1.] # Tally OpenMOC fission rates on the Mesh fiss_rates = mesh.tally_fission_rates(self.solver) # Append fission rates to the output string outstr = 'Fission Rate Mesh Tally\n' rates = ['{0:12.6E}'.format(rate) for rate in fiss_rates.ravel()] outstr += '\n'.join(rates) + '\n' # Retrieve the Materials and number of groups from the geometry materials = self.input_set.geometry.getAllMaterials() num_groups = self.input_set.geometry.getNumEnergyGroups() # Aggregate the total cross sections for each Material # into a dictionary to pass to the mesh tally domains_to_coeffs = {} for material_id in materials: domains_to_coeffs[material_id] = np.zeros(num_groups) for group in range(num_groups): domains_to_coeffs[material_id][group] = \ materials[material_id].getSigmaTByGroup(group+1) # Tally volume-averaged OpenMOC total rates on the Mesh tot_rates = mesh.tally_on_mesh(self.solver, domains_to_coeffs, domain_type='material', volume='integrated') # Append total rates to the output string outstr += 'Total Rate Mesh Tally\n' rates = ['{0:12.6E}'.format(rate) for rate in tot_rates.ravel()] outstr += '\n'.join(rates) + '\n' return outstr
def _get_results(self, num_iters=True, keff=True, fluxes=True, num_fsrs=True, num_tracks=True, num_segments=True, hash_output=True): """Digest info from the mesh tallies and return as a string.""" # Create OpenMOC Mesh on which to tally fission rates mesh = process.Mesh() mesh.dimension = [4, 4] mesh.lower_left = [-2., -2.] mesh.upper_right = [2., 2.] mesh.width = [1., 1.] # Tally OpenMOC fission rates on the Mesh fiss_rates = mesh.tally_fission_rates(self.solver) # Append fission rates to the output string outstr = 'Fission Rate Mesh Tally\n' rates = ['{0:12.6E}'.format(rate) for rate in fiss_rates.ravel()] outstr += '\n'.join(rates) + '\n' # Retrieve the Materials and number of groups from the geometry materials = self.input_set.geometry.getAllMaterials() num_groups = self.input_set.geometry.getNumEnergyGroups() # Aggregate the total cross sections for each Material # into a dictionary to pass to the mesh tally domains_to_coeffs = OrderedDict( {'flux' : {}, 'total' : {}, 'nu-fission': {}, 'scatter' : {}}) for material_id in materials: for rxn in domains_to_coeffs: domains_to_coeffs[rxn][material_id] = np.zeros(num_groups) for group in range(num_groups): domains_to_coeffs['flux'][material_id][group] = 1. domains_to_coeffs['total'][material_id][group] = \ materials[material_id].getSigmaTByGroup(group+1) domains_to_coeffs['nu-fission'][material_id][group] = \ materials[material_id].getNuSigmaFByGroup(group+1) # Add up reaction rates for scattering to all energy groups scatter = 0 for gprime in range(num_groups): scatter += materials[material_id].getSigmaSByGroup( group + 1, gprime + 1) domains_to_coeffs['scatter'][material_id][group] = scatter # Tally volume-averaged OpenMOC rates on the Mesh tallies = OrderedDict() for rxn, coeffs in domains_to_coeffs.items(): tallies[rxn] = mesh.tally_on_mesh(self.solver, coeffs, domain_type='material', volume='integrated') # Append reaction rates to the output string for rxn, rates in tallies.items(): outstr += rxn.title() + ' Rate Mesh Tally\n' rates = ['{0:12.6E}'.format(rate) for rate in rates.ravel()] outstr += '\n'.join(rates) + '\n' return outstr
track_generator.setNumThreads(num_threads) track_generator.setSegmentFormation(openmoc.OTF_STACKS) track_generator.setSegmentationZones([-32.13, -10.71, 10.71, 32.13]) track_generator.generateTracks() ############################################################################### ########################### Running a Simulation ########################## ############################################################################### solver = openmoc.CPUSolver(track_generator) solver.setConvergenceThreshold(tolerance) solver.setNumThreads(num_threads) solver.computeEigenvalue(max_iters) solver.printTimerReport() mesh = process.Mesh() mesh.dimension = [34, 34, 3] mesh.lower_left = [-32.13, -10.71, -32.13] mesh.upper_right = [10.71, 32.13, 10.71] mesh.width = [1.26, 1.26, 14.28] fission_rates = mesh.tally_fission_rates(solver, volume='integrated') for k in range(3): print('Z = ' + str(k)) for i in range(34): msg = '' for j in range(34): msg += str(fission_rates[i][j][k]) msg += ' ' print(msg) print('...')