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

In This Package:

GenDecay::u238::U238Tests Class Reference

List of all members.

Public Member Functions

def __init__
def isotope
def chain
def setAbundance
def meanRate
def singleDecays
def radiateTransitions
def decayChainInterval
def trackAbundances
def plotAbundances
def setSecularEquilibrium
def generateDecays

Public Attributes

 random

Static Private Attributes

int _chain = 4

Detailed Description

Definition at line 10 of file u238.py.


Member Function Documentation

def GenDecay::u238::U238Tests::__init__ (   self  ) 

Definition at line 14 of file u238.py.

00014                       :
00015         import random
00016         self.random = random.Random()
00017         return
00018 
    def isotope(self): return self.chain().head

def GenDecay::u238::U238Tests::isotope (   self  ) 

Definition at line 19 of file u238.py.

00019 : return self.chain().head

def GenDecay::u238::U238Tests::chain (   self  ) 

Definition at line 20 of file u238.py.

00020                    : return U238Tests._chain
00021 

def GenDecay::u238::U238Tests::setAbundance (   self,
  grams 
)

Definition at line 22 of file u238.py.

00022                                 :
00023         self.isotope().abundance = grams * 6.02e23/238.0
00024 
    def meanRate(self):

def GenDecay::u238::U238Tests::meanRate (   self  ) 

Definition at line 25 of file u238.py.

00025                       :
00026         return self.isotope().lifetime/self.isotope().abundance
00027 
    def singleDecays(self):

def GenDecay::u238::U238Tests::singleDecays (   self  ) 

Definition at line 28 of file u238.py.

00028                           :
00029         target = 10000
00030         count = 0
00031         while count < target:
00032             count += 1
00033             rad = self.isotope().decay()
00034             #print 'Resulting radiation:'
00035             while rad:
00036                 time,trans = rad
00037                 #print '\t@%.4E: %s'%rad
00038                 rad = trans.final.decay()
00039                 continue
00040             continue
00041         for iso in self.chain().groundStates:
00042             print '%s abundance=%.3f'%(iso,iso.abundance)
00043         return
00044 
    def radiateTransitions(self,dt_trans):

def GenDecay::u238::U238Tests::radiateTransitions (   self,
  dt_trans 
)

Definition at line 45 of file u238.py.

00045                                          :
00046         '''Given list of (dt,transition), radiate the transitions.  If
00047         a transition results in a excited daughter, immediately radate
00048         the gamma.  A copy of dt_trans, with any gamma transitions
00049         appended, is returned.'''
00050 
00051         ret = []
00052 
00053         # radiate all transitions to increase daugher abundance
00054         for dt,tran in dt_trans:
00055             #print '%f %s'%(dt,tran)
00056             tran.radiate()
00057 
00058             ret.append((dt,tran))
00059 
00060             try: # if final state is excited, radiate gamma immediately
00061                 t = tran.final.transitions[0]
00062                 if type(t.radiation) == decay.GammaDecay:
00063                     ret.append((dt,t))
00064             except IndexError:
00065                 pass
00066             continue
        return ret

def GenDecay::u238::U238Tests::decayChainInterval (   self,
  interval 
)

Definition at line 67 of file u238.py.

00070                                          :
00071         import decay
00072         dt_trans = []
00073         for s in self.chain().groundStates:
00074             if s.abundance == 0.0: continue
00075             dks = s.decayInterval(interval)
00076             #print 'Got %d %s decays in %f seconds'%(len(dks),s,interval/units.second)
00077             if not dks: continue
00078             dt_trans += dks
            continue

def GenDecay::u238::U238Tests::trackAbundances (   self,
  cycles,
  interval 
)

Definition at line 79 of file u238.py.

00082                                              :
00083         abs = {}
00084         for s in self.chain().groundStates:
00085             abs[s] = []
00086         ntrans = []
00087         while cycles:
00088             cycles -= 1
00089             dks = self.decayChainInterval(interval)
00090             ntrans.append(len(dks))
00091             for s in self.chain().groundStates:
00092                 abs[s].append(s.abundance)
00093                 continue
            continue

def GenDecay::u238::U238Tests::plotAbundances (   self,
  abs 
)

Definition at line 94 of file u238.py.

00097                                 :
00098         import matplotlib.pyplot as plt
00099         plt.figure(1)
00100 
00101         nplots = sum([s.abundance > 0.0 and s.symbol != '238U' for s in abs.keys()])
00102 
00103         nstates = len(abs)
00104         n = 0
00105         for s,ab in abs.iteritems():
00106             if s.abundance == 0.0 or s.symbol == '238U': 
00107                 print 'Skipping %s'%s
00108                 continue
00109             n += 1
00110             end = len(ab)
00111             print 'Plotting %s with final abundance %f from 0 to %d'%(s,s.abundance,end)
00112             plt.subplot(nplots,1,n)
00113             plt.plot(range(0,end),ab,'r')
00114             plt.title(s.symbol)
00115             continue
        plt.show()

def GenDecay::u238::U238Tests::setSecularEquilibrium (   self  ) 

Sets 8 isotopes starting subchains in secular equilibrium
with the 238U.  Returns a list with 238U and the 8 daughters

Definition at line 116 of file u238.py.

00119                                    :
00120         '''Sets 8 isotopes starting subchains in secular equilibrium
00121         with the 238U.  Returns a list with 238U and the 8 daughters'''
00122         daughters = ['234Th','234U','230Th','226Ra','222Rn','210Pb','210Bi','210Po']
00123         u238 = self.isotope()
00124         ret = [u238]
00125         for s in self.chain().groundStates:
00126             if not s.symbol in daughters: continue
00127             s.abundance = u238.abundance*s.halflife/u238.halflife
00128             ret.append(s)
        print '\n'.join(map(str,ret))

def GenDecay::u238::U238Tests::generateDecays (   self,
  states,
  ndecays 
)

Generate ndecays starting from the given list of parent
states.  Parent states are considered independent in the sense
that a decay subchain is fortced to occur until either a
stable state is reached or a state in the list of states is
reached.  A list of the resulting radiations will be returned.

Definition at line 129 of file u238.py.

00132                                            :
00133         '''Generate ndecays starting from the given list of parent
00134         states.  Parent states are considered independent in the sense
00135         that a decay subchain is fortced to occur until either a
00136         stable state is reached or a state in the list of states is
00137         reached.  A list of the resulting radiations will be returned.
00138         '''
00139         totalrate = 0
00140         for s in states:
00141             totalrate += s.abundance/s.halflife
00142             continue
00143 
00144         decays = []
00145 
00146         while ndecays:
00147             ndecays -= 1
00148 
00149             # choose which state gets to do the honors
00150             r = self.random.uniform(0,totalrate)
00151             goal = 0
00152             for s in states:
00153                 goal += s.abundance/s.halflife
00154                 if r < goal: 
00155                     goal = s
00156                     break
00157                 continue
00158         
00159             print 'Starting %s (%f/%f)'%(goal,r,totalrate)
00160 
00161             # decay until stable or daughter is in list of states
00162             while True:
00163                 rad = goal.decay()
00164                 decays.append(rad)
00165                 trans = rad[1]
00166                 trans.radiate()
00167                 final = trans.final
00168                 if final in states or final.symbol == '206Pb':
00169                     break
00170                 goal = final
00171                 continue
            continue


Member Data Documentation

int GenDecay::u238::U238Tests::_chain = 4 [static, private]

Definition at line 12 of file u238.py.

GenDecay::u238::U238Tests::random

Definition at line 16 of file u238.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