Skip to content

Instantly share code, notes, and snippets.

@onionmk2
Created December 1, 2017 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onionmk2/0cee7fcba59c759a60e93186e2c20e38 to your computer and use it in GitHub Desktop.
Save onionmk2/0cee7fcba59c759a60e93186e2c20e38 to your computer and use it in GitHub Desktop.
from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead, TensorManager
Lorentz = TensorIndexType('Lorentz')
i0, i1, i2, i3, i4 = tensor_indices('i0:5', Lorentz)
A = tensorhead('A', [Lorentz], [[1]])
G = tensorhead('G', [Lorentz], [[1]], 'Gcomm')
GH = tensorhead('GH', [Lorentz], [[1]], 'GHcomm')
TensorManager.set_comm('Gcomm', 'GHcomm', 0)
(GH(i1) * G(i0)).canon_bp()
@onionmk2
Copy link
Author

onionmk2 commented Dec 1, 2017

image

get_comm(i, j)

Return the commutation parameter for commutation group numbers i, j
see _TensorManager.set_comm

set_comm(i, j, c)

i, j can be symbols, strings or numbers, apart from 0, 1 and 2 which are reserved respectively for commuting, anticommuting tensors and tensors not commuting with any other group apart with the commuting tensors.

http://docs.sympy.org/latest/modules/tensor/tensor.html#sympy.tensor.tensor._TensorManager.set_comm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment