some basic tensors with sympy

259 views
Skip to first unread message

Chaffra Affouda

unread,
Jan 2, 2015, 4:59:13 PM1/2/15
to sy...@googlegroups.com
How do I implement the Levi-Civita and Kroenecker tensors in sympy? I am doing

from sympy.tensor.tensor import TensorIndexType, tensor_indices
from sympy.tensor.tensor import tensorhead, TensorManager
from sympy.tensor.tensor import get_symmetric_group_sgs
from sympy import LeviCivita

Lorentz = TensorIndexType('Lorentz',
                          dim=3,
                          eps_dim=3,
                          metric=False,
                          dummy_fmt='L')



Lorentz.data = [1,1,1]


Lorentz.epsilon.data = [[[LeviCivita(i,j,k) for k in range(3)] 
                         for j in range(3)] 
                        for i in range(3)]

i,j,k,l,m, n = tensor_indices('i,j,k,l,m,n', Lorentz)

eps = Lorentz.epsilon
delta = Lorentz.delta

Is this correct?

Francesco Bonazzi

unread,
Jan 3, 2015, 9:39:45 AM1/3/15
to sy...@googlegroups.com
eps is a Levi-Civita symbol.

Be careful, LeviCivita is not part of sympy.tensor.tensor, and is not designed to interoperate with that module.

Also consider that you are defining a Lorentz tensor index type as a 3 dimensional Euclidean index type.

I just noticed that the Kronecker delta is not filled with components data. Opened an issue:
https://github.com/sympy/sympy/issues/8743
Reply all
Reply to author
Forward
0 new messages