| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

GenDecay::data::Isotope Class Reference

List of all members.

Public Member Functions

def __init__
def __getattr__
def __str__
def decayInterval
def decay

Public Attributes

 name
 symbol
 A
 Z
 halflife
 level
 abundance
 transitions

Detailed Description

A nuclide

Definition at line 20 of file data.py.


Member Function Documentation

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 
)

Definition at line 36 of file data.py.

00036                               :
00037         if name == 'N': return self.A - self.Z
00038         if name == 'lifetime':
00039             import math
00040             return self.halflife/math.log(2.0)
00041         raise AttributeError,'no such attribute ' + name
00042 
    def __str__(self):

def GenDecay::data::Isotope::__str__ (   self  ) 

Definition at line 43 of file data.py.

00043                      :
00044         return '%s (%.3f)'%(self.symbol,self.level/units.MeV)
00045 
    def decayInterval(self,interval):

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
    


Member Data Documentation

GenDecay::data::Isotope::name

Definition at line 25 of file data.py.

GenDecay::data::Isotope::symbol

Definition at line 26 of file data.py.

GenDecay::data::Isotope::A

Definition at line 27 of file data.py.

GenDecay::data::Isotope::Z

Definition at line 28 of file data.py.

GenDecay::data::Isotope::halflife

Definition at line 29 of file data.py.

GenDecay::data::Isotope::level

Definition at line 30 of file data.py.

GenDecay::data::Isotope::abundance

Definition at line 31 of file data.py.

GenDecay::data::Isotope::transitions

Definition at line 32 of file data.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 21:01:10 2011 for GenDecay by doxygen 1.4.7