/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes
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.


Constructor & Destructor 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.

00025                                        :
00026         import elements
00027         self.name = '%s(%d)'%(elements.name(Z),A)
00028         self.symbol = '%d%s'%(A,elements.symbol(Z))
00029         self.A=A
00030         self.Z=Z
00031         self.halflife=halflife
00032         self.level=level
00033         self.abundance=abundance
00034         self.transitions=[]
00035         return


Member Function Documentation

def GenDecay::data::Isotope::__getattr__ (   self,
  name 
)

Definition at line 36 of file data.py.

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

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

Definition at line 43 of file data.py.

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

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.

00047                                     :
00048         '''Decay a number of isotopes drawn from the mean for the
00049         given interval.  Returns a list of tuples (dt,tranition)'''
00050         from numpy import random
00051         rate = self.abundance/self.lifetime
00052         mean = rate*interval
00053         ndecays = random.poisson(mean)
00054         #print "Got %d from %f %s"%(ndecays,mean,self)
00055         ret = []
00056 
00057         # reduce abundance by hand to avoid subtracting by small numbers
00058         self.abundance -= ndecays
00059 
00060         # generate decay products
00061         while ndecays:
00062             ndecays -= 1
00063             dt,trans = self.decay(False)
00064             dt = random.uniform(0,interval)
00065             ret.append((dt,trans))
00066             continue
00067 
00068         # sorts by time
00069         ret.sort()
00070 
00071         return ret

def GenDecay::data::Isotope::decay (   self,
  reduceAbundance = True 
)

Definition at line 72 of file data.py.

00073                                           :
00074         'Decay this isotope, return [time,Transition].  Does NOT radiate() the Transition'
00075         # t(n) = t(n-1) * exp(-t/tL)
00076         # u = uniform()
00077         # dt = ((-1*math.log(u)) * lifetime)
00078         from numpy import random
00079         import math
00080 
00081         total = sum([t.fraction for t in self.transitions])
00082         u = random.uniform(0.0,total)
00083         total = 0.0
00084         trans = None
00085         #print 'Checking',len(self.transitions),'transitions with u',u
00086         for t in self.transitions:
00087             total += t.fraction            
00088             if u < total:
00089                 trans  = t
00090                 break
00091             continue
00092         if trans is None: return ()
00093         
00094         u = random.uniform(0,1)
00095         dt = ((-1*math.log(u)) * self.lifetime/self.abundance)
00096         if reduceAbundance:
00097             self.abundance -= 1
00098         #trans.radiate()
00099         return  (dt,trans)


Member Data Documentation

Definition at line 23 of file data.py.

Definition at line 23 of file data.py.

Definition at line 23 of file data.py.

Definition at line 23 of file data.py.

Definition at line 23 of file data.py.

Definition at line 23 of file data.py.

Definition at line 23 of file data.py.

Definition at line 23 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 Fri May 16 2014 10:21:06 for GenDecay by doxygen 1.7.4