def activity(self, time): self._tmp = [[[self.C0._asc_code(), 100]]] self._chain_tree(self.C0._asc_code(), self._tmp[0]) val = {} for tree in self._tmp: key = tree[-1][0] if key in val.keys(): val[key] += self._bateman(time, tree)*_nuc.nuclide(key).info['T'] else: val[key] = self._bateman(time, tree)*_nuc.nuclide(key).info['T'] return val
def activity(self, time): self._tmp = [[[self.C0._asc_code(), 100]]] self._chain_tree(self.C0._asc_code(), self._tmp[0]) val = {} for tree in self._tmp: key = tree[-1][0] if key in val.keys(): val[key] += self._bateman(time, tree) * _nuc.nuclide(key).info['T'] else: val[key] = self._bateman(time, tree) * _nuc.nuclide(key).info['T'] return val
def _decay_list(self, nuc, m = []): if len(nuc.info['MODE']): self._tmp += m for n in nuc.info['MODE']: e = _nuc.nuclide(n[2]) m.append(e._asc_code()) self._decay_list(e, m)
def _decay_list(self, nuc, m=[]): if len(nuc.info['MODE']): self._tmp += m for n in nuc.info['MODE']: e = _nuc.nuclide(n[2]) m.append(e._asc_code()) self._decay_list(e, m)
def _bateman(self, time, tree): value = 0 ratio = product([i[1]/100 for i in tree]) lamb = [_nuc.nuclide(i[0]).info['T'] for i in tree] numer = product(lamb[:-1])*ratio for l in lamb: Cn = numer*_np.exp(-l*time)/denomi(lamb, l) value += Cn try: for iv, v in enumerate(value[1:]): if v <= 0: value[iv+1] = value[iv] except: pass return value
def _bateman(self, time, tree): value = 0 ratio = product([i[1] / 100 for i in tree]) lamb = [_nuc.nuclide(i[0]).info['T'] for i in tree] numer = product(lamb[:-1]) * ratio for l in lamb: Cn = numer * _np.exp(-l * time) / denomi(lamb, l) value += Cn try: for iv, v in enumerate(value[1:]): if v <= 0: value[iv + 1] = value[iv] except: pass return value
# -*- coding: utf-8 -*- import pynuc as pn import numpy as np from matplotlib import pyplot as plt """get element""" elem1 = pn.nuclide('092235') # type 1 elem2 = pn.nuclide('238U') # type 2 """print infomation""" print(elem1) print(elem2) """decay curve plot""" t = np.logspace(1, 18) plt.title('decay curve') plt.ylim(1E-2, 1.2) p1 = plt.plot(t, elem1.decay(t), label=elem1._asc_code()) p2 = plt.plot(t, elem2.decay(t), label=elem2._asc_code()) plt.xscale("log", nonposx='clip') plt.grid(True) plt.legend() plt.show() """activity curve plot""" plt.title('activity curve') plt.plot(t, elem1.activity(t), label=elem1._asc_code()) plt.plot(t, elem2.activity(t), label=elem2._asc_code()) plt.xscale("log", nonposx='clip') plt.grid(True) plt.legend() plt.show()
# -*- coding: utf-8 -*- import pynuc as pn import numpy as np from matplotlib import pyplot as plt """get chain""" elem = pn.nuclide('235U') chain = elem.get_chain() """chain element 1D list""" mixture = chain.decay_mixture() # key list """plot chain decay""" t = np.logspace(-1, 21) N = chain.decay(t) plt.title('Decay curve') plt.ylim(1, 5E30) for key in N.keys(): plt.plot(t, N[key]*1E30, label=key) plt.loglog() plt.grid(True) plt.legend(bbox_to_anchor=(1.05, 1), loc=2, ncol=3, borderaxespad=0.) plt.show() """plot chain activity""" t = np.logspace(-1, 21) N = chain.activity(t) plt.title('activity curve') plt.ylim(1, 1e15) for key in N.keys(): plt.plot(t, N[key]*1E30, label=key)
def element_append(self, nucid, N): code = _pn.nuclide(nucid)._asc_code() self.mixture.append(code)
# -*- coding: utf-8 -*- import pynuc as pn import numpy as np from matplotlib import pyplot as plt """get chain""" elem = pn.nuclide('235U') chain = elem.get_chain() """chain element 1D list""" mixture = chain.decay_mixture() # key list """plot chain decay""" t = np.logspace(-1, 21) N = chain.decay(t) plt.title('Decay curve') plt.ylim(1, 5E30) for key in N.keys(): plt.plot(t, N[key] * 1E30, label=key) plt.loglog() plt.grid(True) plt.legend(bbox_to_anchor=(1.05, 1), loc=2, ncol=3, borderaxespad=0.) plt.show() """plot chain activity""" t = np.logspace(-1, 21) N = chain.activity(t) plt.title('activity curve') plt.ylim(1, 1e15) for key in N.keys(): plt.plot(t, N[key] * 1E30, label=key) plt.loglog() plt.grid(True) plt.legend(bbox_to_anchor=(1.05, 1), loc=2, ncol=3, borderaxespad=0.) plt.show()
def __init__(self, nucid: str, weights: float=1.0): self.C0 = _nuc.nuclide(nucid, weights)
def _chain_tree(self, nucid, arr=[]): for mode in _nuc.nuclide(nucid).info['MODE']: e = _nuc.nuclide(mode[2])._asc_code() nar = arr+[[e, mode[1]]] self._tmp.append(nar) self._chain_tree(e, nar)
# -*- coding: utf-8 -*- import pynuc as pn import numpy as np from matplotlib import pyplot as plt """get element""" elem1 = pn.nuclide('092235') # type 1 elem2 = pn.nuclide('238U') # type 2 """print infomation""" print(elem1) print(elem2) """decay curve plot""" t = np.logspace(1, 18) plt.title('decay curve') plt.ylim(1E-2, 1.2) p1 = plt.plot(t, elem1.decay(t), label=elem1._asc_code()) p2 = plt.plot(t, elem2.decay(t), label=elem2._asc_code()) plt.xscale("log", nonposx='clip') plt.grid(True) plt.legend() plt.show() """activity curve plot""" plt.title('activity curve') plt.plot(t, elem1.activity(t), label=elem1._asc_code()) plt.plot(t, elem2.activity(t), label=elem2._asc_code()) plt.xscale("log", nonposx='clip') plt.grid(True)
def __init__(self, nucid: str, weights: float = 1.0): self.C0 = _nuc.nuclide(nucid, weights)
def _chain_tree(self, nucid, arr=[]): for mode in _nuc.nuclide(nucid).info['MODE']: e = _nuc.nuclide(mode[2])._asc_code() nar = arr + [[e, mode[1]]] self._tmp.append(nar) self._chain_tree(e, nar)