# Plot yz slices plotter.plotSlice(geometry, plane='YZ', lim1=[-1., 1.], lim2=[-1., 1.], \ filename='fuel', gridsize=50) plotter.plotSlice(geometry, plane='YZ', lim1=[-1., 1.], lim2=[-1., 1.], \ filename='moderator', gridsize=50) py_printf('INFO', 'Plotting the fission site source distribution...') plotter.plotFissionSourceDist(geometry) py_printf('INFO', 'Plotting neutron tracks...') plotter.trackANeutron(geometry, num_moves=100, plane='xy', \ lim1=[-0.75, 0.75], lim2=[-0.75,0.75]) plotter.trackANeutron(geometry, num_moves=100, plane='yz', \ lim1=[-0.75, 0.75], lim2=[-3., 3.]) plotter.trackANeutron(geometry, num_moves=100, plane='xz', \ lim1=[-0.75, 0.75], lim2=[-3.,3.]) # Plot the fluxes plotter.plotFlux([total_flux, moderator_flux, fuel_flux], uselegend=True) # Compute k-infinity using tally arithmetic operators and print to screen k_inf = tot_fiss_rate * nu / tot_abs_rate k_inf.setTallyName('k-infinity') k_inf.printTallies(uncertainties=True) py_printf('TITLE', 'Finished')
elastic_xs = process.GroupXS(total_flux_xs, elastic_rate) capture_xs = process.GroupXS(total_flux_xs, capture_rate) fission_xs = process.GroupXS(total_flux_xs, fission_rate) absorb_xs = process.GroupXS(total_flux_xs, absorb_rate) transport_xs = process.GroupXS(total_flux_xs, transport_rate) diffusion_coeff = process.GroupXS(total_flux_xs, diffusion_rate) total_xs = process.GroupXS(total_flux_xs, total_rate) elastic_xs.printXS(uncertainties=True) capture_xs.printXS(uncertainties=True) fission_xs.printXS(uncertainties=True) absorb_xs.printXS(uncertainties=True) transport_xs.printXS(uncertainties=True) diffusion_coeff.printXS(uncertainties=True) total_xs.printXS(uncertainties=True) # Compute k-infinity using tally arithmetic operators and print to screen k_inf = tot_fiss_rate * nu / tot_abs_rate k_inf.setTallyName('k-infinity') k_inf.printTallies(uncertainties=True) # Compute moderator-to-fuel flux ratios and print to screen flux_ratio = moderator_flux_ratio / fuel_flux_ratio flux_ratio.setTallyName('Moderator-to-Fuel Flux Ratios') flux_ratio.printTallies(uncertainties=True) # Plot the fluxes plotter.plotFlux([total_flux, moderator_flux, fuel_flux]) py_printf('TITLE', 'Finished')
################################ Create Tallies ############################## ############################################################################### py_printf('NORMAL', 'Initializing flux tally...') flux = TallyFactory.createTally(region_mix, FLUX) flux.generateBinEdges(1E-2, 1E7, 10000, LOGARITHMIC) TallyBank.registerTally(flux) ############################################################################### ######################### Run Monte Carlo Simulation ######################### ############################################################################### # Run Monte Carlo simulation geometry.runMonteCarloSimulation() ############################################################################### ############################ Process Output Data ############################# ############################################################################### py_printf('INFO', 'Plotting flux...') plotter.plotFlux(flux, uselegend=False, filename='flux', \ title='Infinite medium flux') py_printf('INFO', 'Writing tally batch statistics to output file...') TallyBank.outputBatchStatistics() py_printf('TITLE', 'Finished')
RI = process.RIEff(abs_rate_flux, u238_abs_rate) RI.setName('Effective RI (U/H=%1.0E)' % u_h_ratios[u_h_ratio]) Eff_RIs[temp].append(RI) # Compute absorption rate ratios abs_rate_ratio = u238_abs_rate / tot_abs_rate abs_rate_ratio.setTallyName('U238 / Tot for U/H=%1.0E' \ % u_h_ratios[u_h_ratio]) abs_rate_ratios[temp].append(abs_rate_ratio) # Append flux for this simulation to an array and deregister it # for next simulation fluxes[u_h_ratio].normalizeBatchMu() TallyBank.deregisterTally(fluxes[u_h_ratio]) # Plot fluxes plotter.plotFlux(fluxes,title='Flux for Temp = ' + str(temps[temp]) \ + 'K', filename='flux-temp-'+str(temps[temp])+'K', \ uselegend=True) # print the reaction rate ratios and resonance integrals to the shell process.printTallies(abs_rate_ratios[temp], header='U238 Abs. / Tot. Abs.') process.printRIs(Eff_RIs[temp], header='Temp=%dK'%temps[temp]) process.printRIs(True_RIs, header='T=300-1200K') py_printf('TITLE', 'Finished')
h1.collideNeutron(neutron) h1_fluxes[j].tally(neutron) py_printf('INFO', 'Simulating generational flux from C-12...') for i in range(num_neutrons): neutron._energy = max_energy # initialize energy to 2 MeV for j in range(num_generations): c12.collideNeutron(neutron) c12_fluxes[j].tally(neutron) py_printf('INFO', 'Plotting the generational fluxes...') plotter.plotFlux(h1_fluxes[1:], loglog=False, uselegend=False, \ filename='h1-generational-flux', title='H1 Generational Flux') plotter.plotFlux(c12_fluxes[1:], loglog=False, uselegend=False, filename='c12-generational-flux', title='C12 Generational Flux') ############################################################################### ########################### Problems 3 and 4 ############################## ############################################################################### num_generations = 50 py_printf('HEADER', 'Problems 3 and 4') py_printf('INFO', 'Initializing lethargy and energy flux tallies...') lethargy_flux = TallyFactory.createTally(c12, COLLISION_RATE)
reached_one_ev = False # Simulate neutron until it is absorbed in H-1 while(neutron._alive): h1_material.collideNeutron(neutron) flux.tally(neutron) times.tally(neutron) coll_rate.tally(neutron) if neutron._energy < 1.0: reached_one_ev = True if not reached_one_ev: coll_rate_1eV.tally(neutron) py_printf('INFO', 'Plotting the flux...') plotter.plotFlux(flux, title='H-1 Flux', filename='h-1-flux') num_collisions = process.computeMeanNumCollisions(coll_rate_1eV, num_neutrons) py_printf('RESULT', 'Mean # of collisions to 1 eV: %f', num_collisions) num_collisions = process.computeMeanNumCollisions(coll_rate, num_neutrons) py_printf('RESULT', 'Mean # of collisions to death: %f', num_collisions) mean_lifetime = process.computeMeanNeutronLifetime(times, num_neutrons) py_printf('RESULT', 'Avg neutron lifetime: %1.2E seconds', mean_lifetime) py_printf('TITLE', 'Finished')
neutron._energy = fissioner.emitNeutroneV() neutron._alive = True reached_one_ev = False # Simulate neutron until it is absorbed in H-1 while (neutron._alive): h1_material.collideNeutron(neutron) flux.tally(neutron) times.tally(neutron) coll_rate.tally(neutron) if neutron._energy < 1.0: reached_one_ev = True if not reached_one_ev: coll_rate_1eV.tally(neutron) py_printf('INFO', 'Plotting the flux...') plotter.plotFlux(flux, title='H-1 Flux', filename='h-1-flux') num_collisions = process.computeMeanNumCollisions(coll_rate_1eV, num_neutrons) py_printf('RESULT', 'Mean # of collisions to 1 eV: %f', num_collisions) num_collisions = process.computeMeanNumCollisions(coll_rate, num_neutrons) py_printf('RESULT', 'Mean # of collisions to death: %f', num_collisions) mean_lifetime = process.computeMeanNeutronLifetime(times, num_neutrons) py_printf('RESULT', 'Avg neutron lifetime: %1.2E seconds', mean_lifetime) py_printf('TITLE', 'Finished')
geometry.addRegion(region_mix) ############################################################################### ################################ Create Tallies ############################## ############################################################################### py_printf('NORMAL', 'Initializing flux tally...') flux = TallyFactory.createTally(region_mix, FLUX) flux.generateBinEdges(1E-2, 1E7, 10000, LOGARITHMIC) TallyBank.registerTally(flux) ############################################################################### ######################### Run Monte Carlo Simulation ######################### ############################################################################### # Run Monte Carlo simulation geometry.runMonteCarloSimulation() ############################################################################### ############################ Process Output Data ############################# ############################################################################### py_printf('INFO', 'Plotting flux...') plotter.plotFlux(flux, uselegend=False, filename='flux', \ title='Infinite medium flux') py_printf('INFO', 'Writing tally batch statistics to output file...') TallyBank.outputBatchStatistics() py_printf('TITLE', 'Finished')