def graph(nuc): """Returns a graphviz Digraph object for the decay chain starting from nuc.""" i = nucname.name(nuc) name = nucname.name(nuc) dot = Digraph(comment='Decay chain for ' + nuc) dot.node(name) nodes_seen = {name} kids = data.decay_children(i) from_to = {(i, j) for j in kids} edges_seen = set() while len(from_to) != 0: new_from_to = set() for ft in from_to: i, j = ft jname = nucname.name(j) if jname not in nodes_seen: dot.node(jname) nodes_seen.add(jname) if ft not in edges_seen: iname = nucname.name(i) try: label = rxname.name(i, j, 'decay') except RuntimeError: label = 'sf' label = PRETTY_RX.get(label, label) br = data.branch_ratio(i, j) if br < 1.0: label += ', br={0:.3}'.format(br) dot.edge(iname, jname, label=label) edges_seen.add(ft) kids = data.decay_children(j) new_from_to |= {(j, k) for k in kids} from_to = new_from_to return dot
def _build_matrix(N): """This function builds burnup matrix, A. Decay only.""" A = np.zeros((len(N), len(N))) # convert N to id form N_id = [] for i in range(len(N)): if isinstance(N[i], str): ID = nucname.id(N[i]) else: ID = N[i] N_id.append(ID) sds = SimpleDataSource() # Decay for i in range(len(N)): A[i, i] -= decay_const(N_id[i]) # Find decay parents for k in range(len(N)): if N_id[i] in decay_children(N_id[k]): A[i, k] += branch_ratio(N_id[k], N_id[i]) * decay_const(N_id[k]) return A
def test_branch_ratio(): assert_equal(data.branch_ratio('H1', 'H1'), 1.0) assert_equal(data.branch_ratio(922350001, 922350000), 1.0) assert_equal(data.branch_ratio(922350001, 922360000), 0.0) assert_equal(data.branch_ratio(611460000, 621460000), 0.34) children = data.decay_children('U235') for child in children: obs = data.branch_ratio('U235', child) assert_true(obs >= 0.0 and obs <= 1.0)
def genchains(chains, sf=False): chain = chains[-1] children = decay_children(chain[-1]) # filters spontaneous fission if not sf: children = { c for c in children if (0.0 == fpyield(chain[-1], c)) and (c not in chain) } if decay_const(chain[-1]) != 0: for child in children: if child not in chain: chains.append(chain + (child,)) chains = genchains(chains, sf=sf) return chains
def test_branch_ratio(): assert_equal(data.branch_ratio("H1", "H1"), 1.0) assert_equal(data.branch_ratio(922350001, 922350000), 1.0) assert_equal(data.branch_ratio(922350001, 922360000), 0.0) assert_equal(data.branch_ratio(611460000, 621460000), 0.34299999999999997) children = data.decay_children("U235") for child in children: obs = data.branch_ratio("U235", child) assert_true(obs >= 0.0 and obs <= 1.0) # There was a bug with metastable ids being dropped prematurely, # which would then lead to the branch ratio for the ground state being reported # Obviously, this was bad, so here is a test. assert_equal(data.branch_ratio("Se86", "Br86M"), 0.0) # Not all isomeric transitions have a 100% branch ratio assert_equal(data.branch_ratio(932400001, 932400000), 0.0012)
def _decay_branches(self, nuc): """Returns a dictionary that contains the decay children of nuc as keys to the branch ratio of that child's decay process. Parameters ---------- nuc : int Name of parent nuclide to get decay children of. Returns ------- decay_branches : dictionary Keys are decay children of nuc in zzaaam format. Values are the branch ratio of the decay child. """ decay_branches = {} children = data.decay_children(nuc) for child in children: decay_branches[child] = data.branch_ratio(nuc, child) return decay_branches
def test_decay_children(): assert_equal(data.decay_children('H1'), set()) assert_equal(data.decay_children(922350001), set([922350000])) assert_equal(data.decay_children(611460000), set([601460000, 621460000])) assert_equal(data.decay_children('O16'), set()) assert_equal(data.decay_children('80166', False), set([60120000, 80160000])) # Spontaneous fission case assert_equal(data.decay_children('U-235'), set([360830000, 420950000, 430990000, 441010000, 441030000, 441060000, 451030000, 451050000, 461050000, 461070000, 461080000, 471090000, 481130000, 491150000, 511250000, 521270000, 531270000, 531350000, 541310000, 541340000, 541350000, 541360000, 551330000, 551340000, 551350000, 551370000, 601430000, 601450000, 611470000, 611480000, 611480001, 611490000, 621470000, 621480000, 621490000, 621500000, 621510000, 621520000, 631510000, 631520000, 631530000, 631540000, 631550000, 641540000, 641550000, 641560000, 641570000, 641580000, 661600000, 661610000, 661620000, 661630000, 661640000, 671650000, 681660000, 681670000, 902310000]))
def _build_matrix(N): """ This function builds burnup matrix, A. Decay only. """ A = np.zeros((len(N), len(N))) # convert N to id form N_id = [] for i in xrange(len(N)): ID = id(N[i]) N_id.append(ID) sds = SimpleDataSource() # Decay for i in xrange(len(N)): A[i, i] -= decay_const(N_id[i]) # Find decay parents for k in xrange(len(N)): if N_id[i] in decay_children(N_id[k]): A[k, i] += decay_const(N_id[k]) return A
def test_decay_children(): assert_equal(data.decay_children('H1'), set()) assert_equal(data.decay_children(922350001), set([922350000])) assert_equal(data.decay_children(611460000), set([601460000, 621460000])) assert_equal(data.decay_children('O16'), set()) assert_equal(data.decay_children('80166', False), set([60120000, 80160000]))
def get_child(nuc_id): children = data.decay_children(nuc_id) if len(children) != 0: children_set.update(children) for child_nuc_id in children: get_child(child_nuc_id)
from pyne import data, nucname import numpy as np print(data.decay_const('U-235')) print(data.decay_const('922350')) print(data.decay_const('922350000')) print(data.branch_ratio('932390000','942390000', use_metastable=False)) print(data.decay_children('932390000')) print(data.decay_const('942420000')) print(data.decay_children('942420000')) print(np.log(2)/data.decay_const('922340000')/3.15e7) print('-------Np-239 to Pu-239 test--------') print(data.decay_const('932390')) print(data.decay_children('932390')) print(data.decay_const('932390')) print(data.decay_children('932390')) print(data.branch_ratio(932390,942390)) print('-------U-240 decay test--------') print(np.log(2)/data.decay_const('922400')/3600) print(data.branch_ratio('922400','932400', use_metastable=False)) print('-----U234 Capture Test-----') print(float('922350')-float('922340') == 10) print('-----Mass Test-----') print(nucname.anum('922350')) print('-----Name Test-----')