It is implemented a tensor class with monoterm canonicalization
and algebraic operations on tensors.
There are two applications:
check of identities involving the cyclic symmetry of the Riemann tensor
>>> from sympy.tensor.tensor import TensorIndexType, tensor_indices, TensorSymmetry, TensorType, riemann_cyclic, riemann_bsgs
>>> Lorentz = TensorIndexType('Lorentz', dummy_fmt='L')
>>> i, j, k, l = tensor_indices('i,j,k,l', Lorentz)
>>> symr = TensorSymmetry(riemann_bsgs)
>>> R4 = TensorType([Lorentz]*4, symr)
>>> R = R4('R')
>>> t = R(i,j,k,l)*(R(-i,-j,-k,-l) - 2*R(-i,-k,-j,-l))
>>> riemann_cyclic(t)
0
gamma matrices in dimensional regularization
>>> from sympy import Symbol, S
>>> from sympy.tensor.tensor import (TensorIndexType, tensor_indices,\
TensorSymmetry, get_symmetric_group_sgs, TensorType, Tensor)
>>> from sympy.tensor.dgamma_matr import GammaMatrices
>>> D = Symbol('D')
>>> Lorentz = TensorIndexType('Lorentz', dim=D, dummy_fmt='L')
>>> sym1 = TensorSymmetry(get_symmetric_group_sgs(1))
>>> S1 = TensorType([Lorentz], sym1)
>>> GM = GammaMatrices(Lorentz)
>>> gamma_trace = GM.gamma_trace
>>> G = GM.G
>>> m0, m1, m2, m3 = tensor_indices('m0,m1,m2,m3', Lorentz)
>>> gamma_trace(G(m0)*G(m1)*G(-m0)*G(m3))
(-4*D + 8)*metric(m1, m3)
>>> p, q = S1('p,q')
>>> t = G(m0)*G(m1)*G(m2)*G(m3)*p(-m1)*q(-m3)
>>> gamma_trace(t)
-4*metric(m0, m2)*p(L_0)*q(-L_0) + 4*p(m0)*q(m2) + 4*p(m2)*q(m0)
git pull https://github.com/pernici/sympy can3
Or view, comment on, or merge it at:
https://github.com/sympy/sympy/pull/1699
—
Reply to this email directly or view it on GitHub.
I would like to review this but won't have time until this weekend. Also, @Krastanov might be interested.
This interests me a lot. I will try to look at it during the weekend.
@pernici, could you consider breaking this in three or more pull requests? It will help a lot with reviewing.
For instance pernici@36cbcd1 seems to be good enough to be a PR on its own. The stuff before it as another PR and the stuff afterwards as a third PR.
Or you can suggest other way to break up this in more manageable pieces.
SymPy Bot Summary: Failed after merging pernici/can3 (d48be8a) into master (d503614).
@pernici: Please fix the test failures.
PyPy 2.0.0-beta-1; 2.7.3-final-42: fail
Python 2.7.2-final-0: fail
Python 3.2.1-final-0: fail
Sphinx 1.1.3: fail
Docs build command: make clean && make html-errors && make latex && cd _build/latex && xelatex sympy-*.tex
In sympy/tensor/tensor.py:
> +from functools import wraps > + > +from sympy.core import S, Symbol, sympify, Tuple, Integer, Basic > +from sympy.core.decorators import call_highest_priority > +from sympy.core.sympify import SympifyError > +from sympy.matrices import ShapeError > +from sympy.simplify import simplify > +from sympy import cacheit > + > +class TensorIndexType(object): > + def __init__(self, name, metric_sym=0, dim=None, eps_dim = None, > + dummy_fmt=None): > + """ > + name name of the tensor type > + > + `metric\_sym`:
Use twoo backticks for variable names.
could you consider breaking this in three or more pull requests? It will help a lot with reviewing.
I have opened a PR #1700 which does not include gamma matrices.
Waiting for review of PR #1700 I update this PR to it, and I keep it open as a WIP PR, to which I plan to add related
things, and as a place for discussion.
Now I will implement the Kronecker delta; currently g(i, -j)
behaves as a Kronecker delta, but there are
various reasons to implement it separately; for instance if metric_sym=None
there is no metric, but there should
be the Kronecker delta. I will not add it to PR #1700 because it is already long enough to review.
SymPy Bot Summary: Failed after merging pernici/can3 (0389c6d) into master (8083428).
@pernici: Please fix the test failures.
Python 2.5.0-final-0: fail
Python 2.6.6-final-0: fail
Python 2.7.2-final-0: fail
Python 2.6.8-final-0: pass
Python 2.7.3-final-0: fail
PyPy 2.0.0-beta-1; 2.7.3-final-42: pass
Python 3.2.2-final-0: pass
Python 3.3.0-final-0: pass
Python 3.2.3-final-0: pass
Python 3.3.0-final-0: pass
Python 3.3.0-final-0: pass
**Sphinx 1.1.3:** fail
I started the module group_factors
to compute group theoretical factors, which are useful in quantum field theory.
This topic is a good playground for adding matching and substitution rules for tensors.