def test_n_nuclides(self): """ Test depletion chain n_nuclides parameter. """ dep = depletion_chain.DepletionChain() dep.nuclides = ["NucA", "NucB", "NucC"] self.assertEqual(dep.n_nuclides, 3)
def test__init__(self): """ Test depletion chain initialization.""" dep = depletion_chain.DepletionChain() self.assertIsInstance(dep.nuclides, list) self.assertIsInstance(dep.nuclide_dict, OrderedDict) self.assertIsInstance(dep.react_to_ind, OrderedDict)
def test_nuc_by_ind(self): """ Test nuc_by_ind converter function. """ dep = depletion_chain.DepletionChain() dep.nuclides = ["NucA", "NucB", "NucC"] dep.nuclide_dict = {"NucA": 0, "NucB": 1, "NucC": 2} self.assertEqual("NucA", dep.nuc_by_ind("NucA")) self.assertEqual("NucB", dep.nuc_by_ind("NucB")) self.assertEqual("NucC", dep.nuc_by_ind("NucC"))
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)