def test_n_reaction_paths(self): """ Test the reaction path count parameter. """ nuc = nuclide.Nuclide() nuc.reactions = [ nuclide.ReactionTuple("(n,2n)", "a", 0.0, 1.0), nuclide.ReactionTuple("(n,3n)", "b", 0.0, 1.0), nuclide.ReactionTuple("(n,4n)", "c", 0.0, 1.0) ] self.assertEqual(nuc.n_reaction_paths, 3)
def test_n_decay_modes(self): """ Test the decay mode count parameter. """ nuc = nuclide.Nuclide() nuc.decay_modes = [ nuclide.DecayTuple("beta1", "a", 0.5), nuclide.DecayTuple("beta2", "b", 0.3), nuclide.DecayTuple("beta3", "c", 0.2) ] self.assertEqual(nuc.n_decay_modes, 3)
def test_xml_write(self): """Test writing a depletion chain to XML.""" # Prevent different MPI ranks from conflicting filename = 'test%u.xml' % MPI.COMM_WORLD.rank A = nuclide.Nuclide() A.name = "A" A.half_life = 2.36520e4 A.decay_modes = [ nuclide.DecayTuple("beta1", "B", 0.6), nuclide.DecayTuple("beta2", "C", 0.4) ] A.reactions = [nuclide.ReactionTuple("(n,gamma)", "C", 0.0, 1.0)] B = nuclide.Nuclide() B.name = "B" B.half_life = 3.29040e4 B.decay_modes = [nuclide.DecayTuple("beta", "A", 1.0)] B.reactions = [nuclide.ReactionTuple("(n,gamma)", "C", 0.0, 1.0)] C = nuclide.Nuclide() C.name = "C" C.reactions = [ nuclide.ReactionTuple("fission", None, 2.0e8, 1.0), nuclide.ReactionTuple("(n,gamma)", "A", 0.0, 0.7), nuclide.ReactionTuple("(n,gamma)", "B", 0.0, 0.3) ] C.yield_energies = [0.0253] C.yield_data = {0.0253: [("A", 0.0292737), ("B", 0.002566345)]} chain = depletion_chain.DepletionChain() chain.nuclides = [A, B, C] chain.xml_write(filename) original = open('chains/chain_test.xml', 'r').read() chain_xml = open(filename, 'r').read() self.assertEqual(original, chain_xml) os.remove(filename)
def test_xml_write(self): """Test writing nuclide data to an XML element.""" C = nuclide.Nuclide() C.name = "C" C.half_life = 0.123 C.decay_modes = [ nuclide.DecayTuple('beta-', 'B', 0.99), nuclide.DecayTuple('alpha', 'D', 0.01) ] C.reactions = [ nuclide.ReactionTuple('fission', None, 2.0e8, 1.0), nuclide.ReactionTuple('(n,gamma)', 'A', 0.0, 1.0) ] C.yield_energies = [0.0253] C.yield_data = {0.0253: [("A", 0.0292737), ("B", 0.002566345)]} element = C.xml_write() self.assertEqual(element.get("half_life"), "0.123") decay_elems = element.findall("decay_type") self.assertEqual(len(decay_elems), 2) self.assertEqual(decay_elems[0].get("type"), "beta-") self.assertEqual(decay_elems[0].get("target"), "B") self.assertEqual(decay_elems[0].get("branching_ratio"), "0.99") self.assertEqual(decay_elems[1].get("type"), "alpha") self.assertEqual(decay_elems[1].get("target"), "D") self.assertEqual(decay_elems[1].get("branching_ratio"), "0.01") rx_elems = element.findall("reaction_type") self.assertEqual(len(rx_elems), 2) self.assertEqual(rx_elems[0].get("type"), "fission") self.assertEqual(float(rx_elems[0].get("Q")), 2.0e8) self.assertEqual(rx_elems[1].get("type"), "(n,gamma)") self.assertEqual(rx_elems[1].get("target"), "A") self.assertEqual(float(rx_elems[1].get("Q")), 0.0) self.assertIsNotNone(element.find('neutron_fission_yields'))