Pythonにおけるqutipの使い方例の詳細


前言
QuTipは開放量子システムの動力学をシミュレートするためのオープンソースライブラリである。QuTipライブラリはNumpy、Scippy、Cythonの数値パッケージに依存します。また、matplotlibはグラフィック出力を提供しています。http://qutip.org/。
pythonのインストールは比較的簡単で、バージョンを選択する必要があります。
一、N原子系の総合スピン確率分布

from qutip import *
import numpy as np
import matplotlib.pyplot as plt

n=2#   
j = n//2
psi0 = spin_coherent(j, np.pi/3, 0)#             

Jp=destroy(2*j+1).dag()#   
J_=destroy(2*j+1)#   
Jz=(Jp*J_-J_*Jp)/2#Jz

H=Jz**2#       

tlist=np.linspace(0,3,100)#    
result=mesolve(H,psi0,tlist)#       

theta=np.linspace(0, np.pi, 50)
phi=np.linspace(0, 2*np.pi, 50)

#           husimi q  
Q1, THETA1, PHI1 = spin_q_function(result.states[0], theta, phi)
Q2, THETA2, PHI2 = spin_q_function(result.states[30], theta, phi)
Q3, THETA3, PHI3 = spin_q_function(result.states[60], theta, phi)
Q4, THETA4, PHI4 = spin_q_function(result.states[90], theta, phi)

#                husimi q  
fig = plt.figure(dpi=150,constrained_layout=1)
ax1 = fig.add_subplot(221,projection='3d')
ax2 = fig.add_subplot(222,projection='3d')
ax3 = fig.add_subplot(223,projection='3d')
ax4 = fig.add_subplot(224,projection='3d')

plot_spin_distribution_3d(Q1, THETA1, PHI1,fig=fig,ax=ax1)
plot_spin_distribution_3d(Q2, THETA2, PHI2,fig=fig,ax=ax2)
plot_spin_distribution_3d(Q3, THETA3, PHI3,fig=fig,ax=ax3)
plot_spin_distribution_3d(Q4, THETA4, PHI4,fig=fig,ax=ax4)

for ax in [ax1,ax2,ax3,ax4]:
 ax.view_init(0.5*np.pi, 0)
 ax.axis('off')#      

fig.show()
実行結果:
在这里插入图片描述
二、原子と光場の相互作用

from qutip import *
import numpy as np
import matplotlib.pyplot as plt

alpha=1#      alpha
n=2#   
j = n/2

psi0 = tensor(coherent(10,alpha),spin_coherent(j, 0, 0))#       

a=destroy(10)#       
a_plus=a.dag()#       
Jp=destroy(n+1).dag()#      
J_=destroy(n+1)#      
Jx=(Jp+J_)/2#   Jx  
Jy=(Jp-J_)/(2j)#   Jy  ,   j     
Jz=(Jp*J_-J_*Jp)/2#   Jz  

H=tensor(a,Jp)+tensor(a_plus,J_)#       
tlist=np.linspace(0,10,1000)#    
result=mesolve(H,psi0,tlist)#       

fig=plt.figure()
ax1 = fig.add_subplot(221)
ax2 = fig.add_subplot(222)
ax3 = fig.add_subplot(223)
ax4 = fig.add_subplot(224)

ax1.plot(tlist,expect(tensor(qeye(10),Jx),result.states))#Jx          
ax2.plot(tlist,expect(tensor(qeye(10),Jy),result.states))#Jy          
ax3.plot(tlist,expect(tensor(qeye(10),Jz),result.states))#Jz          
ax4.plot(tlist,expect(tensor(qeye(10),Jx**2+Jy**2+Jz*2),result.states))#J            

fig.subplots_adjust(top=None,bottom=None,left=None,right=None,wspace=0.4,hspace=0.4)#      
fig.show()
実行結果:
在这里插入图片描述
締め括りをつける
ここでPythonのqutipの使い方についての文章を紹介します。Python qutipの使い方についてもっと詳しく教えてください。以前の文章を検索したり、次の関連記事を見たりしてください。これからもよろしくお願いします。