I have a code like this. I use constant th12 and constant dm12 in the first definition and accordingly I get an oscillation varying between 12. I also want to use "th23" "dm23" "th13" "dm13" values in this definition.
But if I use th12 in the process that takes place inside the def, the value of dm12 should come, or if I use th23, the value of dm23 should be used. So if th and dm have the same set of numbers, the transaction should occur.
If th12 and dm23 are used as an example, the operation will give incorrect results. I don't know how to prepare a definition under this information.
Do you have any suggestions to fetch the th and dm values like this?
# (converted from degrees to radians)
th12 = np.radians(33.82)
th23 = np.radians(48.3)
th13 = np.radians(8.61)
th = [th12,th23,th13]
# del_m square
dm12 = 7.39*10**(-5)# eV^2
dm13 = 2.45*10**(-3) # eV^2
dm23 = dm12-dm13
dm = [dm12,dm23,dm13]
def prob(E,th12,dm12,L):
return pow(np.sin(2*th12) * np.sin(1.27*dm12 * L /(E)),2)
def plotprob(E_list,th12,dm12,L_min,L_max,L_step):
L = np.arange(L_min,L_max,L_step)
for E in E_list:
plt.plot(prob(E,th12,dm12,L), label=r"$E =$" str(E) " GeV")
plt.xlim([L_min,L_max])
plt.ylim([0,1.0])
plt.xlabel(r"$L{\rm [km]}$")
plt.ylabel("$Probability$")
plt.legend()
plt.show()
plotprob([0.1,0.01],th12,dm12,1,10000,1)
CodePudding user response:
You can try the zip function with for loop to get the pairs of those lists
for i,j in zip(th,dm):
plotprob(elist, i, j , *otherstuff)
CodePudding user response:
I came up with such a result. I used dictionary for th and dm values. I can use both at the same time. I wanted to use a separate definition for plotting, but I couldn't manage to plot outside.
th12 = np.radians(33.82)
th23 = np.radians(48.3)
th13 = np.radians(8.61)
# del_m square
dm12 = 7.39*10**(-5)# eV^2
dm13 = 2.45*10**(-3) # eV^2
def prob(th12,th23,th13,dm12,dm13,E,L_min,L_max,L_step):
L = np.arange(L_min,L_max,L_step)
dm23 = dm12 - dm13
dms = {"21": dm12, "32": dm23, "31": dm13}
ths = {"21": th12, "32": th23, "31": th13}
lnus = {"21": r'$P(\nu_\mu \to \nu_e)$', "32": r'$P(\nu_\tau \to \nu_\mu)$', "31": r'$P(\nu_\tau \to \nu_e)$'}
for i in range(3):
for j in range(i):
dm = dms[str(i 1) str(j 1)]
th = ths[str(i 1) str(j 1)]
lnu = lnus[str(i 1) str(j 1)]
prob = pow(np.sin(2*th) * np.sin(1.27*dm * L /(E)),2)
plt.plot(L,prob,label= "Osc. " lnu)
plt.xlim([L_min,L_max])
plt.ylim([0,1.0])
plt.legend()
plt.xlabel(r"$L{\rm [km]}$")
plt.ylabel("$Probability$")
return prob
prob(th12,th23,th13,dm12,dm13,1,1,35000,1)
plt.show()