On Saturday, January 11, 2014 4:04:03 AM UTC-5, mario wrote:
>
> Currently one must do the following
>
> ```
> >>> Ric
> Riem(L_0, -d1, -L_0, -d3)
> >>> R = (Ric(d0, d1)*g(-d0, -d1)).contract_metric(g)
> >>> R
> Riem(L_0, -L_1, -L_0, L_1)
> ```
>
> One cannot write
>
> ```
> >>> Ric(d1, -d1)
> Riem(L_0, d1, -L_0, -d1)
> ```
>
> I think this is a bug; the Einstein summation convention is assumed, so if 
> the substitution
> indices are (d1, -d1) it should give the contracted tensor.
>

Thanks for the tips.  The expression for the Einstein tensor now prints out 
fine (modulo a need for a printer which renders the tensor expression with 
indices nicely).

However, when I try to define the Einstein tensor G(a,b) = R(a,b) - 
(1/2)*g(a,b)*R I get the following error:

In [*3*]: run RiemRicREinstein.py

  File "/Users/comerduncan/sympytensor/RiemRicREinstein.py", line 52

    G(a,b) = Ric(a,b) -gR

SyntaxError: can't assign to function call

So, what's the problem?  I should be able to dynamically define various new 
tensors from ones already defined, right? I've attached the version I am 
using now.

Thanks for your help.

Comer
 

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.
from sympy import Matrix, eye
from sympy.combinatorics import Permutation
from sympy.core import S, Rational, Symbol, Basic
from sympy.core.containers import Tuple
from sympy.core.symbol import symbols
from sympy.external import import_module
#from sympy.functions.elementary.miscellaneous import sqrt
from sympy.printing.pretty.pretty import pretty
from sympy.tensor.tensor import TensorIndexType, tensor_indices, TensorSymmetry, \
get_symmetric_group_sgs, TensorType, TensorIndex, tensor_mul, TensAdd, \
riemann_cyclic_replace, riemann_cyclic, TensMul, \
tensorsymmetry, tensorhead, TensorManager, TensExpr, TIDS

Lorentz = TensorIndexType('Lorentz',dim=4,eps_dim=4, dummy_fmt='L')

d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11 =tensor_indices('d0:12', Lorentz)


a,b,c,d = tensor_indices('a,b,c,d',Lorentz)

g = Lorentz.metric

Riem = tensorhead('Riem', [Lorentz]*4, [[2, 2]])

sym2 = tensorsymmetry([1]*2)

S2 = TensorType([Lorentz]*2,sym2)

Ric = S2('Ric')

# Ric(a,b) = (Riem(d0,a,d1,b)*g(-d0,-d1)).contract_metric(g)

# R = (Ric(d0, d1)*g(-d0, -d1)).contract_metric(g)
# Ric = Riem(d0, -d1, -d0, -d3)

print  Ric(a,b)

R = (Ric(d0,d1)*g(-d0,-d1)).contract_metric(g)



G = S2('G')


gR = tensor_mul(Rational(1,2)*g(a,b)*R)

gR = TensMul(*gR.args)
print gR

#attempt to define Einstein tensor fails

G(a,b) = Ric(a,b) -gR
# print "Einstein tensor G:",G(-a,-b)
# 



Reply via email to