Public Member Functions | |
def | __init__ |
def | __getattr__ |
def | __str__ |
def | decayInterval |
def | decay |
Public Attributes | |
name | |
symbol | |
A | |
Z | |
halflife | |
level | |
abundance | |
transitions |
A nuclide
Definition at line 20 of file data.py.
def GenDecay::data::Isotope::__init__ | ( | self, | ||
Z = 0 , |
||||
A = 0 , |
||||
halflife = 0.0 , |
||||
level = 0.0 , |
||||
abundance = 0 | ||||
) |
Definition at line 23 of file data.py.
00024 : 00025 import elements 00026 self.name = '%s(%d)'%(elements.name(Z),A) 00027 self.symbol = '%d%s'%(A,elements.symbol(Z)) 00028 self.A=A 00029 self.Z=Z 00030 self.halflife=halflife 00031 self.level=level 00032 self.abundance=abundance 00033 self.transitions=[] 00034 return 00035 def __getattr__(self,name):
def GenDecay::data::Isotope::__getattr__ | ( | self, | ||
name | ||||
) |
def GenDecay::data::Isotope::__str__ | ( | self | ) |
def GenDecay::data::Isotope::decayInterval | ( | self, | ||
interval | ||||
) |
Decay a number of isotopes drawn from the mean for the given interval. Returns a list of tuples (dt,tranition)
Definition at line 46 of file data.py.
00046 : 00047 '''Decay a number of isotopes drawn from the mean for the 00048 given interval. Returns a list of tuples (dt,tranition)''' 00049 from numpy import random 00050 rate = self.abundance/self.lifetime 00051 mean = rate*interval 00052 ndecays = random.poisson(mean) 00053 #print "Got %d from %f %s"%(ndecays,mean,self) 00054 ret = [] 00055 00056 # reduce abundance by hand to avoid subtracting by small numbers 00057 self.abundance -= ndecays 00058 00059 # generate decay products 00060 while ndecays: 00061 ndecays -= 1 00062 dt,trans = self.decay(False) 00063 dt = random.uniform(0,interval) 00064 ret.append((dt,trans)) 00065 continue 00066 00067 # sorts by time 00068 ret.sort() 00069 00070 return ret 00071 def decay(self,reduceAbundance = True):
def GenDecay::data::Isotope::decay | ( | self, | ||
reduceAbundance = True | ||||
) |
Definition at line 72 of file data.py.
00072 : 00073 'Decay this isotope, return [time,Transition]. Does NOT radiate() the Transition' 00074 # t(n) = t(n-1) * exp(-t/tL) 00075 # u = uniform() 00076 # dt = ((-1*math.log(u)) * lifetime) 00077 from numpy import random 00078 import math 00079 00080 total = sum([t.fraction for t in self.transitions]) 00081 u = random.uniform(0.0,total) 00082 total = 0.0 00083 trans = None 00084 #print 'Checking',len(self.transitions),'transitions with u',u 00085 for t in self.transitions: 00086 total += t.fraction 00087 if u < total: 00088 trans = t 00089 break 00090 continue 00091 if trans is None: return () 00092 00093 u = random.uniform(0,1) 00094 dt = ((-1*math.log(u)) * self.lifetime/self.abundance) 00095 if reduceAbundance: 00096 self.abundance -= 1 00097 #trans.radiate() 00098 return (dt,trans) 00099 00100 pass