sympy 中的量子谐振子:哈密顿量的矩阵元素不符合预期

问题描述 投票:0回答:1

我正在尝试计算谐振子的哈密顿量的矩阵元素。我使用

sympy.physics.quatnum.qho_1d
中的解决方案。我的期望是
<pis(i)|H|psi(j)>=0
if $i!=j$ 其中
psi(i)
是哈罗敏振荡器的第 i 个解。 然而,在我的代码中,如果 i+2=j 则情况并非如此。对于所有其他组合,它都有效。

import sympy as sp
from sympy.physics.qho_1d import psi_n
import sympy.physics.units
import numpy as np

x =sp.Symbol('x',real=True)
m=1
omega=1
hbar=sp.physics.units.hbar

def H(psi):
    return -hbar**2/(2*m) *sp.diff(psi,x,x) +1/2*m**2*omega**2*x**2*psi

psi = sp.Function('psi')


# computes matrix elements <psi1|H|psi2>
def matrix_elem(H,psi1,psi2):
   return sp.simplify(sp.integrate(sp.simplify(psi1.conjugate()*H(psi2)),(x,-sp.oo,sp.oo)))


max_n=5
H_matrix = sp.Matrix(
  [[matrix_elem(H,psi_n(i,x,1,1),psi_n(j,x,1,1)) for j in range(max_n)] for i in range(max_n)])

print(sp.simplify(H_matrix))
for i in range(max_n):
  for j in range(max_n):
    if i!=j and H_matrix[i,j] !=0: print(f"{i} {j}: {H_matrix[i,j]=}") 

我不清楚的另一件事是 hbar**2/hbar 没有简化为 hbar。

非常感谢您的任何建议。

sympy physics
1个回答
0
投票

不确定这是否有帮助,但似乎您应该使用不同的 hbar 常数。即

from sympy.physics.quantum.constants import hbar

然后我得到以下H矩阵:

H Matrix

这满足了您的要求,即

i<>j
为零。我的量子力学有点生疏,所以我不确定对角线值是否是你所期望的。

© www.soinside.com 2019 - 2024. All rights reserved.