Hi all,
Im trying to learn how to use Sympy in quantum mechanics. At beginning I have taken a simple task - to prove equality
[L_i,L_k] = i*hbar*\epsilon_{ikl}*L_l
where L - is quantum angular momentum.
My code following:
from sympy.physics.quantum.constants import hbar
from sympy import symbols, I, Derivative,Function
from sympy.physics.quantum.operator import DifferentialOperator,
Operator
from sympy.physics.quantum import Commutator, Wavefunction
from sympy.physics.quantum.qapply import qapply
from sympy.tensor.tensor import TensorIndexType, tensor_indices
from sympy.tensor.tensor import tensorhead
from sympy.tensor.tensor import TensorSymmetry, TensorType
from sympy.combinatorics.tensor_can import get_symmetric_group_sgs
euclid = TensorIndexType('Euclidean', dim=3, dummy_fmt='e')
euclid.data = [1, 1, 1]
i, j, k = tensor_indices('i j k', euclid)
L,r,p = tensorhead('L,r,p', [euclid], [[1]])
sym = TensorSymmetry(get_symmetric_group_sgs(3, 1))
Sdim = TensorType([euclid]*3, sym)
epsilon = Sdim('epsilon')
epsilon.data = (((0,0,0),(0,0,1),(0,-1,0)),
((0,0,-1),(0,0,0),(1,0,0)), ((0,1,0),(-1,0,0),(0,0,0)))
x, y, z = symbols('x y z', commutative=False)
r.data = [x,y,z]
px, py, pz = symbols('p_x p_y p_z', commutative=False)
f = Function('f')
px = -I*hbar*DifferentialOperator(Derivative(f(x,y,z),
x),f(x,y,z))
py = -I*hbar*DifferentialOperator(Derivative(f(x,y,z),
y),f(x,y,z))
pz = -I*hbar*DifferentialOperator(Derivative(f(x,y,z),
z),f(x,y,z))
p.data = [px,py,pz]
L = epsilon(i,j,k)*r(-j)*p(-k)
L.data
psi= Function("psi")
pw=Wavefunction(psi(x,y,z),x,y,z)
qapply((L(i)*L(j)-L(j)*L(i))*pw)
gives as a result 0. Probably the Tensors package doesn't consider the non-commutative nature of quantum operators. How to force a Tensors package to consider quantum operator nature his component?
Please, can someone give me advice?
Thanks.