def testMeanLifetime(self): py_printf('UNITTEST', 'Testing HW2 mean lifetime') mean_lifetime = process.computeMeanNeutronLifetime(self.times, self.num_neutrons) self.assertGreater(.10, abs(1.40E-5 - mean_lifetime) / 1.40E-5)
def testMeanLifetime(self): py_printf('UNITTEST', 'Testing HW2 mean lifetime') mean_lifetime = process.computeMeanNeutronLifetime( self.times, self.num_neutrons) self.assertGreater(.10, abs(1.40E-5 - mean_lifetime) / 1.40E-5)
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')