十年匠心定制 · 商业建站与技术教学双线并行 咨询热线:400-886-1026 service@lmnt.cn
ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

用Qutip绘制布洛赫球

用Qutip绘制布洛赫球 文章目录布洛赫球的物理意义Qutip绘图布洛赫球的物理意义布洛赫球Bloch sphere是量子计算中用来直观表示单量子比特qubit状态的几何模型。再量子计算中qubit的任意纯态可表示为两个基态的线性叠加∣ ψ ⟩ α ∣ 0 ⟩ β ∣ 1 ⟩ |\psi\rangle\alpha|0\rangle\beta|1\rangle∣ψ⟩α∣0⟩β∣1⟩其中α , β \alpha,\betaα,β均为复数且满足归一化条件$$\alpha2\beta21\to\begin{aligned}\alpha\cos\frac{\theta}{2}e^{i\gamma_\alpha}\\beta\sin\frac{\theta}{2}e^{i\gamma_\beta}\\end{aligned}$$由于量子态∣ ψ ⟩ |\psi\rangle∣ψ⟩和e i γ ∣ ψ ⟩ e^{i\gamma}|\psi\rangleeiγ∣ψ⟩代表同一物理态所以用相位差来表示α , β \alpha,\betaα,β从而量子态可表示为∣ ψ ⟩ cos ⁡ θ 2 ∣ 0 ⟩ e i ϕ sin ⁡ θ 2 ∣ 1 ⟩ |\psi\rangle\cos\frac{\theta}{2}|0\ranglee^{i\phi}\sin\frac\theta 2|1\rangle∣ψ⟩cos2θ​∣0⟩eiϕsin2θ​∣1⟩式中θ \thetaθ为极角ϕ \phiϕ为方位角二者刚好能构成一个三维的单位球如下图所示。在Bloch球中球面上的每一个点都代表量子比特的一个纯态其中北极代表∣ 0 ⟩ |0\rangle∣0⟩南极代表∣ 1 ⟩ |1\rangle∣1⟩赤道上θ π 2 \theta\frac{\pi}{2}θ2π​代表∣ 0 ⟩ |0\rangle∣0⟩和∣ 1 ⟩ |1\rangle∣1⟩的等概率叠加具体来说ϕ 0 \phi0ϕ0代表∣ ⟩ ∣ 0 ⟩ ∣ 1 ⟩ 2 |\rangle\frac{|0\rangle|1\rangle}{\sqrt2}∣⟩2​∣0⟩∣1⟩​ϕ π \phi\piϕπ代表∣ − ⟩ ∣ 0 ⟩ − ∣ 1 ⟩ 2 |-\rangle\frac{|0\rangle-|1\rangle}{\sqrt2}∣−⟩2​∣0⟩−∣1⟩​ϕ π 2 \phi\frac{\pi}{}2ϕπ​2代表∣ i ⟩ ∣ 0 ⟩ i ∣ 1 ⟩ 2 |i\rangle\frac{|0\ranglei|1\rangle}{\sqrt2}∣i⟩2​∣0⟩i∣1⟩​ϕ 3 π 2 \phi\frac{3\pi}{2}ϕ23π​代表∣ − i ⟩ ∣ 0 ⟩ − i ∣ 1 ⟩ 2 |-i\rangle\frac{|0\rangle-i|1\rangle}{\sqrt2}∣−i⟩2​∣0⟩−i∣1⟩​Qutip绘图Qutip中提供了便捷的Bloch球绘图函数想要得到上面的Bloch球代码如下importqutip bqutip.Bloch()b.render()importmatplotlib.pyplotasplt plt.show()【Bloch】即Bloch球的类【render】用于渲染绘图。布洛赫球上可以用向量或点表示不同的量子态示例如下代码为bqutip.Bloch()x(qutip.basis(2,0)(10j)*qutip.basis(2,1)).unit()y(qutip.basis(2,0)(01j)*qutip.basis(2,1)).unit()z(qutip.basis(2,0)(00j)*qutip.basis(2,1)).unit()b.add_states([x,y,z])thnp.linspace(0,2*np.pi,20)xp,yp,zpnp.cos(th),np.sin(th),np.zeros(20)b.add_points([xp,yp,zp])b.render()
返回列表