I am trying to write a program using the Mathematica function IsotopeData, but am finding the code troublesome. Due to my (relative) familiarity with Python, I am puzzled as to how Mathematica works, as they are very different. $\require{mhchem}$
What I am trying to do, is to find the elements in a decay chain which end with either $\ce{^{191}_{77}Ir}$ or $\ce{^{193}_{77}Ir}$.
In Python syntax, what I'm trying to do would look a bit like this:
#A would be the Atomic Mass and Z the Atomic Number
#DaughterNuclide(Z,A) would return the Daughter Nuclides of the isotope
def IsoCheck(z,a):
try:
x = DaughterNuclide(z,a)
if x in Isotopes:
return [z,a]
else:
return [0,0]
except:
return [0,0]
L=[]
Isotopes = [[76,191],[78,191]]
for a in xrange(1,295):
for z in xrange(1,119):
if IsoCheck(z,a) != [0,0]:
L.append(IsoCheck(z,a))
repeat = 1
#Then, repeat until all chains are over
while repeat == 1:
repeat = 0
for x in L:
if IsoCheck(x) != [0,0] #Lets just pretend it isn't a list
L.append(x)
repeat = 1
Now, my question is this: what would the equivalent code to perform this task in Mathematica look like?
Answer
It is a nice application for the Graph[] features in Mma.
We can calculate quickly all possible decays for all known isotopes, and then let VertexComponent[] look for the chains ending in {"Iridium191", "Iridium193"}.
g = Graph@Union@Flatten[Thread[DirectedEdge @@ ##] & /@
Select[{#, IsotopeData[#, "DaughterNuclides"]} & /@ IsotopeData[], #[[2]] != {} &]];
Union@Flatten[VertexComponent[g, #] & /@ {"Iridium191", "Iridium193"}]
$\begin{array}{l} Actinium207&Actinium209&Astatine195\\ Astatine197&Astatine199&Astatine201 \\ Bismuth191&Bismuth193&Bismuth195 \\ Bismuth197&Francium199&Francium201 \\ Francium203&Francium205&Gold191 \\ Gold193&Iridium191&Iridium193 \\ Lead191&Lead193&Mercury191 \\ Mercury193&Osmium191&Osmium193 \\ Platinum191&Platinum193&Polonium191 \\ Polonium193&Polonium195&Polonium197 \\ Protactinium213&Radium203&Radium205 \\ Radon195&Radon197&Radon199 \\ Radon201&Rhenium191&Rhenium193 \\ Thallium191&Thallium193&Thorium209 \\ \end{array}$
Edit
The possible decay chains are:
g1 = Union[Flatten[VertexComponent[g, #] & /@ #], #] &@{"Iridium191", "Iridium193"}
g2 = Subgraph[g, g1, VertexShapeFunction -> "Name", GraphLayout -> "LayeredDrawing"]

Edit 2
Another application.
(*All possible decays of all Isotopes *)
decays = Select[{#, IsotopeData[#, "DaughterNuclides"]} & /@ IsotopeData[], #[[2]] != {} &];
(*Identify the Isotope with more ways to decay *)
mostModes = SortBy[decays, -Length@#[[2]] &][[1, 1]];
(*Get its decay characteristics*)
mMdecays = IsotopeData[mostModes, #] & /@ {"DaughterNuclides", "DecayModeSymbols", "BranchingRatios"};
(*Aux Function*)
pos[mostModes] = Above; Table[pos[i] = Below, {i, mMdecays[[1]]}];
(*Draw a scheme of its decays modes and percentages*)
g = Framed@Graph[Labeled[#, Placed[{Text@Style[#, 14, FontFamily -> "Helvetica"]},
{pos[#]}]] & /@ Join[{mostModes}, mMdecays[[1]]],
Labeled[DirectedEdge[mostModes, #[[1]]], Placed[{ToString@StandardForm@#[[2]] <> "\n" <>
ToString[100 #[[3]]] <> "%"}, {"Middle"}]] & /@ (Transpose@ mMdecays),
ImagePadding -> 30]

Comments
Post a Comment