Python教程

python 画能级图

本文主要是介绍python 画能级图,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

核结构经常要画能级图,所以记一下这个代码吧。

# plt 绘制 energy 中的能级,按照 0+,2+,4+,6+,8+,... 的顺序,画在 xleft 处,
# 如果 flaglabel == True, 则把 0+, 2+, ..., 画在 xlabel 处。
def EnergyLevels( plt, xleft, xlabel, energy, flaglabel ): 
        for i in range(len(energy)):
                t = energy[i]
                plt.quiver(xleft, t, 1, 0, width = 0.003, scale=0.5, headwidth=0, scale_units='x')
                if flaglabel : plt.text(xlabel, t, '%d$^+$' % (2 * i), fontsize=12)
plt.figure(figsize=(10,4.8))
plt.cla(); ax = plt.axes()
plt.xticks([]); plt.axis(xmin = -1, xmax = 24, ymin = -3, ymax = 15)
ax.spines['top'].set_visible(False); ax.spines['bottom'].set_visible(False)
plt.ylabel("$E_x$ (MeV)", fontsize = 15)
# Zn60 data
J =    [        0,        2,        4,        6,        8,       10,       12 ]
PVPC = [ -252.446, -251.649, -250.055, -248.382, -246.383, -243.103, -239.464 ] # lineartol = 1E-3
PVPC_Ex = np.array(PVPC) - (-252.446)
PHF =  [ -252.260, -251.489, -249.935, -248.372, -246.490, -243.147, -239.665 ]
PHF_Ex = np.array(PHF) - (-252.260)
SM =   [ -254.71978, -253.66814, -252.57132, -251.15156 ]
SM_Ex = np.array(SM) - (-254.71978)
EXP_Ex = [      0,    1.004,     2.193,   3.808,    5.292,    8.476,   12.132  ]
# plot Zn60
xleft = 1; xlabel = -0.3; EnergyLevels(plt, xleft, xlabel, EXP_Ex, True )
plt.text(xleft, -1, "Expt.", fontsize=12 )    # EXP
xleft = 3; xlabel = 3.7; EnergyLevels(plt, xleft, xlabel, SM_Ex, False)
plt.text(xleft, -1, "SM", fontsize=12 )     # SM
xleft = 5; xlabel = 5.7; EnergyLevels(plt, xleft, xlabel, PVPC_Ex, False )
plt.text(xleft, -1, "PVPC", fontsize=12 )     # PVPC
xleft = 7; xlabel = 7.7; EnergyLevels(plt, xleft, xlabel, PHF_Ex, False)
plt.text(xleft, -1, "PHF", fontsize=12 )     # PHF
plt.text(4, -2.5, "$^{60}Zn$", fontsize = 15)
plt.show()

类似地,再画上 Zn62, Zn64 的能级,得到如下图片:
image

这篇关于python 画能级图的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!