Public Member Functions | |
def | __init__ |
def | modeledSpectra |
def | sampledSpectra |
Look at Beta decay Spectra
Definition at line 5 of file beta.py.
def GenDecay::beta::Spectra::__init__ | ( | self, | ||
z, | ||||
a | ||||
) |
Create Spectra for given ground state isotope of given Z and A.
Definition at line 8 of file beta.py.
00010 : 00011 ''' 00012 Create Spectra for given ground state isotope of given Z and A. 00013 ''' 00014 import random 00015 self.random = random.Random() 00016 00017 from g4data import G4RadData 00018 rd = G4RadData() 00019 rd = G4RadData() 00020 self.nuc = rd.nuclideData(z,a) 00021 state = self.nuc.excitedState() 00022 00023 betas = [] 00024 for dk in state.decays: 00025 if dk.type[0:4] == 'Beta': 00026 betas.append(dk) 00027 continue 00028 continue 00029 00030 if not betas: 00031 print 'Warning: no beta decays for: %s'%nuc 00032 return 00033 00034 self.betas = betas return
def GenDecay::beta::Spectra::modeledSpectra | ( | self, | ||
nbins = 100 | ||||
) |
Definition at line 35 of file beta.py.
00037 : 00038 total_fraction = sum([dk.fraction for dk in self.betas]) 00039 maximum = max([dk.radiation.endpoint for dk in self.betas]) 00040 00041 ret = [] 00042 from numpy import array 00043 total = array([0.0 for x in range(nbins)]) 00044 bins = [(x+0.5)*maximum/nbins for x in range(nbins)] 00045 for dk in self.betas: 00046 ratio = dk.fraction/total_fraction 00047 Sm = [] 00048 Sm = map(dk.radiation.dnde,bins) 00049 scaled = [ratio*x for x in Sm] 00050 total += scaled 00051 ret.append(scaled) 00052 continue return (ret,bins,total)
def GenDecay::beta::Spectra::sampledSpectra | ( | self, | ||
ndecays = 1000 , |
||||
nbins = 100 | ||||
) |
Return a list of tuples (decay.BetaDecay,numpy.histogram). Each histogram has the given number of bins and gives the sampled energy spectrum. The total number of entries of all histograms is as given. The branching fractions of the decay are used to divide up the total number of decays when sampling each branch. Histograms are normalized so their sum is 1 and keeping the branching ratios intact
Definition at line 53 of file beta.py.
00055 : 00056 '''Return a list of tuples (decay.BetaDecay,numpy.histogram). 00057 Each histogram has the given number of bins and gives the 00058 sampled energy spectrum. The total number of entries of all 00059 histograms is as given. The branching fractions of the decay 00060 are used to divide up the total number of decays when sampling 00061 each branch. Histograms are normalized so their sum is 1 and 00062 keeping the branching ratios intact''' 00063 from numpy import histogram, array 00064 00065 total_fraction = float(sum([dk.fraction for dk in self.betas])) 00066 maximum = max([dk.radiation.endpoint for dk in self.betas]) 00067 ret = [] 00068 00069 binwidth = maximum/nbins 00070 00071 for dk in self.betas: 00072 ratio = dk.fraction/total_fraction 00073 energies = [] 00074 dk_number = ndecays*ratio 00075 for count in range(0,int(dk_number)): 00076 energies.append(dk.radiation.sampleEnergy()) 00077 h = histogram(energies,nbins,(0,maximum)) 00078 norm = ratio/(binwidth*sum(h[0])) 00079 scaled = array([ bin*norm for bin in h[0] ]) 00080 ret.append((dk,(scaled,h[1]))) 00081 continue 00082 return ret 00083