TDCRPy 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Code/Activity_TDCR.py +305 -0
- Code/EfficiencyProfils.py +96 -0
- Code/TDCRPy.py +425 -0
- Code/TDCR_model_lib.py +1781 -0
- Code/TDCRoptimize.py +99 -0
- Code/__init__.py +1 -0
- Code/decay.py +29 -0
- Code/test1.py +87 -0
- TDCRPy-0.0.1.dist-info/LICENCE +0 -0
- TDCRPy-0.0.1.dist-info/METADATA +21 -0
- TDCRPy-0.0.1.dist-info/RECORD +13 -0
- TDCRPy-0.0.1.dist-info/WHEEL +5 -0
- TDCRPy-0.0.1.dist-info/top_level.txt +1 -0
Code/TDCRoptimize.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created on Wed Jul 5 10:04:53 2023
|
|
4
|
+
|
|
5
|
+
@author: romain.coulon
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
import TDCRPy as td
|
|
10
|
+
import scipy.optimize as opt
|
|
11
|
+
import sys, time
|
|
12
|
+
sys.path.insert(1, 'G:\Python_modules\BIPM_RI_PyModules')
|
|
13
|
+
import TDCRcalculation as tc
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def eff(TDCR_measure, TAB, TBC, TAC, Rad, kB):
|
|
18
|
+
|
|
19
|
+
N=50000
|
|
20
|
+
L=1
|
|
21
|
+
# r=opt.minimize_scalar(td.TDCRPy, args=(TDCR_measure, TAB, TBC, TAC, Rad, "1", N, kB, 0.98, 1000, "res", "sym"), method='golden')#,options={'xatol': 1e-7, 'disp': True, 'maxiter':100})
|
|
22
|
+
# r=opt.minimize_scalar(td.TDCRPy, args=(TDCR_measure, TAB, TBC, TAC, Rad, "1", N, kB, 0.98, 1000, "res", "sym"), method='brent')
|
|
23
|
+
r=opt.minimize_scalar(td.TDCRPy, args=(TDCR_measure, TAB, TBC, TAC, Rad, "1", N, kB, 0.98, 1000, "res", "sym"), method='bounded', bounds=[0.5, 2])
|
|
24
|
+
|
|
25
|
+
# r=opt.minimize(td.TDCRPy, L, args=(TDCR_measure, TAB, TBC, TAC, Rad, "1", N, kB, 0.98, 1000, "res", "sym"), method='nelder-mead',options={'xatol': 1e-7, 'disp': True, 'maxiter':100})
|
|
26
|
+
L=r.x
|
|
27
|
+
print(r)
|
|
28
|
+
#L=(L*0.995, L*1.021, L*0.988) # Free paramete in keV-1
|
|
29
|
+
# L = (L, L, L)
|
|
30
|
+
# r=opt.minimize(td.TDCRPy, L, args=(TDCR_measure, TAB, TBC, TAC, Rad, "1", N, kB, 0.98, 1000, "res", "asym"), method='nelder-mead',options={'xatol': 1e-7, 'disp': True, 'maxiter':100})
|
|
31
|
+
# L=r.x
|
|
32
|
+
# print(r)
|
|
33
|
+
out=td.TDCRPy(L,TDCR_measure, TAB, TBC, TAC, Rad, "1", N, kB, 0.98, 1000, "eff", "sym")
|
|
34
|
+
return np.mean(L), L, out[2], out[2], out[3]
|
|
35
|
+
|
|
36
|
+
def TicTocGenerator():
|
|
37
|
+
"""
|
|
38
|
+
Generator that returns time differences
|
|
39
|
+
"""
|
|
40
|
+
ti = 0 # initial time
|
|
41
|
+
tf = time.time() # final time
|
|
42
|
+
while True:
|
|
43
|
+
ti = tf
|
|
44
|
+
tf = time.time()
|
|
45
|
+
yield tf-ti # returns the time difference
|
|
46
|
+
|
|
47
|
+
TicToc = TicTocGenerator() # create an instance of the TicTocGen generator
|
|
48
|
+
|
|
49
|
+
# This will be the main function through which we define both tic() and toc()
|
|
50
|
+
def toc(tempBool=True):
|
|
51
|
+
"""
|
|
52
|
+
Prints the time difference yielded by generator instance TicToc
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
tempTimeInterval = next(TicToc)
|
|
56
|
+
if tempBool:
|
|
57
|
+
print( "Elapsed time: %f seconds.\n" %tempTimeInterval )
|
|
58
|
+
|
|
59
|
+
def tic():
|
|
60
|
+
"""
|
|
61
|
+
Records a time in TicToc, marks the beginning of a time interval
|
|
62
|
+
"""
|
|
63
|
+
toc(False)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
"""
|
|
67
|
+
TEST
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
Rad="Co-60" # list of radionuclides (Na-24)
|
|
71
|
+
kB =1.0e-5 # Birks constant in cm/keV
|
|
72
|
+
TDCR_measure = 0.977667386529166 # Measured TDCR value
|
|
73
|
+
TAB = 0.992232838598821
|
|
74
|
+
TBC = 0.992343419459002
|
|
75
|
+
TAC = 0.99275350064608
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
tic()
|
|
80
|
+
F1, FFF, eff1, eff2 = tc.I2calc(TDCR_measure, TAB, TBC, TAC, Rad, kB)
|
|
81
|
+
toc()
|
|
82
|
+
|
|
83
|
+
print("/nanalytical model")
|
|
84
|
+
print("free parameter = ", F1)
|
|
85
|
+
print("free parameters = ", FFF)
|
|
86
|
+
print("Double count rate efficiency (sym) = ", eff1)
|
|
87
|
+
print("Double count rate efficiency (asym) = ", eff2)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
tic()
|
|
91
|
+
F1, FFF, eff1, eff2, u = eff(TDCR_measure, TAB, TBC, TAC, Rad, kB)
|
|
92
|
+
toc()
|
|
93
|
+
|
|
94
|
+
print("/nstochastic model")
|
|
95
|
+
print("free parameter = ", F1)
|
|
96
|
+
print("free parameters = ", FFF)
|
|
97
|
+
print("Double count rate efficiency (sym) = ", eff1)
|
|
98
|
+
print("Double count rate efficiency (asym) = ", eff2)
|
|
99
|
+
print("u(eff) = ", u)
|
Code/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from TDCRPy import TDCRPy
|
Code/decay.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This program aims to calculate the relative composition of radionuclides
|
|
3
|
+
decaying in chain using the Bateman model implemented in the radioactivedecay module form (MIT)
|
|
4
|
+
|
|
5
|
+
Romain Coulon, Jialin Hu
|
|
6
|
+
Bureau International des Poids et Mesures
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# pip install radioactivedecay
|
|
10
|
+
import radioactivedecay as rd
|
|
11
|
+
import matplotlib.pyplot as plt
|
|
12
|
+
|
|
13
|
+
rad = "Ra-223" # Radionuclide
|
|
14
|
+
A0 = 1 # Inital activity
|
|
15
|
+
unit = 'Bq' # unit for the activity
|
|
16
|
+
decaytime = 2 # decay time
|
|
17
|
+
unitt = 'd' # unit for the time
|
|
18
|
+
|
|
19
|
+
rad_t0 = rd.Inventory({rad: A0}, unit)
|
|
20
|
+
rad_t1 = rad_t0.decay(decaytime, unitt)
|
|
21
|
+
rad_t1.activities(unit)
|
|
22
|
+
print(rad_t1)
|
|
23
|
+
|
|
24
|
+
decayGraph = rad_t0.plot(decaytime, unitt, yunits=unit)
|
|
25
|
+
plt.savefig('decayGraph.png')
|
|
26
|
+
|
|
27
|
+
nuc = rd.Nuclide(rad)
|
|
28
|
+
decayChain = nuc.plot()
|
|
29
|
+
plt.savefig('decayChain.png')
|
Code/test1.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created on Mon May 15 15:41:41 2023
|
|
4
|
+
|
|
5
|
+
@author: romain.coulon
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
import zipfile
|
|
11
|
+
import numpy as np
|
|
12
|
+
|
|
13
|
+
file = 'decayData/All-nuclides_Ensdf.zip'
|
|
14
|
+
z = zipfile.ZipFile(file)
|
|
15
|
+
|
|
16
|
+
with z.open('Ag-108m.txt') as f:
|
|
17
|
+
data = f.readlines()
|
|
18
|
+
nL = np.size(data)
|
|
19
|
+
|
|
20
|
+
## fomatage en list de vecteur pour chaque line du fichier ENSDF
|
|
21
|
+
for i in range(nL): # boucle dans data
|
|
22
|
+
data[i] = str(data[i]) # conversion en string
|
|
23
|
+
data[i] = data[i].replace("b'",'') # on enlève les caratères de formatage
|
|
24
|
+
data[i] = data[i].replace("\\r\\n'",'') # on enlève les caratères de formatage
|
|
25
|
+
for i in range(nL):
|
|
26
|
+
data[i] = data[i].split()
|
|
27
|
+
|
|
28
|
+
for i in range(nL):
|
|
29
|
+
if i>0 and ("L" in data[i]) and ("AUGER" in data[i]) and ("|]" in data[i-1]):
|
|
30
|
+
data.insert(i,[data[i][0], 'T'])
|
|
31
|
+
|
|
32
|
+
## Définir des repères
|
|
33
|
+
index_auger = [] # indice de
|
|
34
|
+
daugther = [] # liste des filles
|
|
35
|
+
index_end = [] # indice dernier valeur pour une fille
|
|
36
|
+
posi = [] # indice des blocs transitions
|
|
37
|
+
for i, p in enumerate(data): # boucle dans le fichier
|
|
38
|
+
if 'DECAY' in p:
|
|
39
|
+
daugther.append(p[0]) # liste des filles
|
|
40
|
+
if 'Auger' in p:
|
|
41
|
+
index_auger.append(i) # repère de ligne pour ensuite définir l'ensemble des blocs
|
|
42
|
+
if len(p)==2:
|
|
43
|
+
posi.append(i) # repère de ligne pour ensuite définir les blocs (2)
|
|
44
|
+
# if 'L' in p
|
|
45
|
+
# posi:
|
|
46
|
+
if 'P' in p:
|
|
47
|
+
index_end.append(i) # repère de fin pour ensuite définir l'ensemble des blocs
|
|
48
|
+
posi.append(i)
|
|
49
|
+
|
|
50
|
+
## Filtrage des données utiles et formatage
|
|
51
|
+
energy = []
|
|
52
|
+
prob = []
|
|
53
|
+
Type = []
|
|
54
|
+
Fille = []
|
|
55
|
+
for i in range(len(posi)-1): # bloucle dans les blocs
|
|
56
|
+
start = posi[i]+1 # indice debut du bloc
|
|
57
|
+
end = posi[i+1] # indice fin du bloc
|
|
58
|
+
d = data[start:end] # Le bloc
|
|
59
|
+
e_b = [] # Energie des transitions du bloc
|
|
60
|
+
prob_b = [] # Proba des transitions du bloc
|
|
61
|
+
Type_b = [] # Types des transitions du bloc
|
|
62
|
+
Fille_b = [] # Fille des transitions du bloc
|
|
63
|
+
#e2 = []
|
|
64
|
+
if start == end:
|
|
65
|
+
continue
|
|
66
|
+
if start-1 in index_end:
|
|
67
|
+
#e = []
|
|
68
|
+
continue
|
|
69
|
+
for n, p1 in enumerate(d):
|
|
70
|
+
#e2 = []
|
|
71
|
+
if '-' in p1[2]: # traitement des intervals de nombres réels
|
|
72
|
+
x = p1[2].split('-')
|
|
73
|
+
p1[2] = round((float(x[1])+float(x[0]))/2,3) # Moyenne
|
|
74
|
+
if '|]' in p1: # traitment des accolades
|
|
75
|
+
if len(p1)>6: # repère de la ligne portant la proba pour le groupe
|
|
76
|
+
prob_b.append(float(p1[4]))
|
|
77
|
+
e_b.append(float(p1[2]))
|
|
78
|
+
else:
|
|
79
|
+
e_b.append(float(p1[2]))
|
|
80
|
+
prob_b.append(float(p1[3]))
|
|
81
|
+
|
|
82
|
+
if len(prob_b)==1 and len(e_b)>1:
|
|
83
|
+
e_b = [np.mean(e_b)]
|
|
84
|
+
|
|
85
|
+
print(e_b)
|
|
86
|
+
print(prob_b)
|
|
87
|
+
print(" ")
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: TDCRPy
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: TDCR model
|
|
5
|
+
Home-page: UNKNOWN
|
|
6
|
+
Author: RomainCoulon (Romain Coulon)
|
|
7
|
+
Author-email: <romain.coulon@bipm.org>
|
|
8
|
+
License: UNKNOWN
|
|
9
|
+
Keywords: python,TDCR
|
|
10
|
+
Platform: UNKNOWN
|
|
11
|
+
Classifier: Development Status :: 1 - Planning
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Operating System :: Unix
|
|
15
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
+
License-File: LICENCE
|
|
18
|
+
Requires-Dist: numpy
|
|
19
|
+
|
|
20
|
+
UNKNOWN
|
|
21
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Code/Activity_TDCR.py,sha256=wcllEOJbeEOexAYzcFGQx2luIBhxSU3LtpEalRmNziw,11530
|
|
2
|
+
Code/EfficiencyProfils.py,sha256=-ZUPva1dU7lMRcKbQAewX9QyiTDwCiNQDoaQiw7dOI4,4829
|
|
3
|
+
Code/TDCRPy.py,sha256=ffOfmaqWdk5PWoVDep8zs_VoQLUhUCQePC0oAbPOYVs,23202
|
|
4
|
+
Code/TDCR_model_lib.py,sha256=vl0pMsGG3FKAmfpnHfjUX8mokay1dvlH99GHYd9BnsI,79115
|
|
5
|
+
Code/TDCRoptimize.py,sha256=2CssmP_SZSe6C_Bkgei3hon21RPytH4DetMbXi-e6wk,3171
|
|
6
|
+
Code/__init__.py,sha256=SUEsH4EdNiXOzPbsBgLHk3OmEti8M7guimMrV0HpP4o,25
|
|
7
|
+
Code/decay.py,sha256=Lnq-kj-6Xs2Rw9w3Y3LlK_ffFip1QzemHdesiug0Wko,817
|
|
8
|
+
Code/test1.py,sha256=rGA9d1cgArhAfxRAAdtiz-vPGQ0Ns3HEdN8sCwydHYM,3250
|
|
9
|
+
TDCRPy-0.0.1.dist-info/LICENCE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
TDCRPy-0.0.1.dist-info/METADATA,sha256=WPlPzU3GXr_yyOrvbFyihNPp0ToVOO8wnDfgtwhfswI,574
|
|
11
|
+
TDCRPy-0.0.1.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
12
|
+
TDCRPy-0.0.1.dist-info/top_level.txt,sha256=5dSMF0KOskVmT0QGz9KnqcD9Ccc2Dkq0Sa8FOZk-7Ck,5
|
|
13
|
+
TDCRPy-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Code
|