/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 | Static Private Attributes
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

tuple _chain = chain.G4DataChain(92,238)

Detailed Description

Definition at line 10 of file u238.py.


Constructor & Destructor Documentation

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

Definition at line 14 of file u238.py.

00015                       :
00016         import random
00017         self.random = random.Random()
00018         return


Member Function Documentation

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.

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

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

Definition at line 25 of file u238.py.

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

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

Definition at line 28 of file u238.py.

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

def GenDecay::u238::U238Tests::radiateTransitions (   self,
  dt_trans 
)
Given list of (dt,transition), radiate the transitions.  If
a transition results in a excited daughter, immediately radate
the gamma.  A copy of dt_trans, with any gamma transitions
appended, is returned.

Definition at line 45 of file u238.py.

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

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

Definition at line 70 of file u238.py.

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

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

Definition at line 82 of file u238.py.

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

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

Definition at line 97 of file u238.py.

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

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 119 of file u238.py.

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

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

Member Data Documentation

tuple GenDecay::u238::U238Tests::_chain = chain.G4DataChain(92,238) [static, private]

Definition at line 12 of file u238.py.

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