-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnuclide_decay_calculator.py
More file actions
70 lines (57 loc) · 3.04 KB
/
nuclide_decay_calculator.py
File metadata and controls
70 lines (57 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
""" Determines the type of particle decay of two elements and the daughter
nuclide of an element and a particle """
periodic_table = ["0", "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne",
"Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr",
"Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb",
"Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn",
"Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu",
"Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os",
"Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac",
"Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No",
"Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc",
"Lv", "Ts", "Og"]
particles = {'4, 2' : 'alpha', '0, -1' : 'beta', '0, 1' : 'positron', '1, 0' :
'neutron', '1, 1' : 'proton', '0, 0' : 'gamma'}
particles_2 = {'alpha' : '4, 2', 'beta' : '0, -1', 'positron' : '0, 1',
'neutron': '1, 0', 'proton' : '1, 1', 'gamma': '0, 0'}
def type_of_decay(left_element, right_element):
"""
Prints the type of decay of two elements
Parameters:
left_element (str): An element and its mass number (e.g. S-26)
right_element (str): An element and its mass number (e.g. P-25)
Prints:
type of decay (str; e.g. proton)
"""
left_element_split = left_element.split("-")
atomic_number_left = periodic_table.index(left_element_split[0])
mass_number_left = left_element_split[1]
right_element_split = right_element.split("-")
atomic_number_right = periodic_table.index(right_element_split[0])
mass_number_right = right_element_split[1]
atomic_difference = atomic_number_left - atomic_number_right
mass_difference = int(mass_number_left) - int(mass_number_right)
decay_number = f"{str(mass_difference)}, {str(atomic_difference)}"
print(particles[decay_number])
def daughter_nuclide(left_element, particle):
"""
Prints the daughter nuclide of an element and a particle
Parameters:
left_element (str): An element and its mass number (e.g. N-10)
particle (str): A nuclear particle (e.g. proton)
Prints:
daughter nuclide element (str; e.g. C-9)
"""
left_element_split = left_element.split("-")
atomic_number_left = periodic_table.index(left_element_split[0])
mass_number_left = left_element_split[1]
particle = particles_2[particle]
particle_split = particle.split(", ")
mass_number_particle = particle_split[0]
atomic_number_particle = particle_split[1]
mass_number_dn = int(mass_number_left) - int(mass_number_particle)
atomic_number_dn = atomic_number_left - int(atomic_number_particle)
print(f"{periodic_table[atomic_number_dn]}-{str(mass_number_dn)}")
# Should print 'proton' and 'C-9' respectively.
type_of_decay('S-26', 'P-25')
daughter_nuclide('N-10', 'proton')