Hi Troops,
Here is a code that computes the Ricci tensor explicitly in terms of the metric gab and its inverse. That works fine. The second part of the code evaluates the Rab as a Sympy string (which I'll later use to generate C-code, that bit is not is this code).
The problem is that when Cadabra hits the last line it hangs. I let it run for over 7 hours with out a result (the memory usage also crept up slowly form 41Mbytes to about 115Mbytes).
I admit that I'm asking a lot here -- the expression for Rab has many thousands of terms. Am I asking too much from Cadabra? Or is there a better way to do this job?
Cheers,
Leo
{a,b,c,d,e,f,i,j,k,l,m,n,o,p,q,r,s,t,u#}::Indices(position=independent,values={x,y,z}).
{x,y,z}::Coordinate.
\partial{#}::PartialDerivative;
g_{a b}::Symmetric;
g^{a b}::Symmetric;
g_{a}^{b}::KroneckerDelta.
g^{a}_{b}::KroneckerDelta.
g_{a b}::Depends(\partial{#});
g^{a b}::Depends(\partial{#});
KDelta := g_{a b} g^{b c} -> g_{a}^{c}.
Gamma := \Gamma^{a}_{b c} ->
(1/2) g^{a e} ( \partial_{b}{g_{e c}}
+ \partial_{c}{g_{b e}}
- \partial_{e}{g_{b c}}).
Riem := R^{a}_{b c d} ->
\partial_{c}{\Gamma^{a}_{b d}} + \Gamma^{a}_{e c} \Gamma^{e}_{b d}
- \partial_{d}{\Gamma^{a}_{b c}} - \Gamma^{a}_{e d} \Gamma^{e}_{b c}.
Ric := R_{a b} -> g^{c d} g_{a e} R^{e}_{c b d}.
Rab := R_{a b}.
substitute (Rab, Ric)
substitute (Rab, Riem)
substitute (Rab, Gamma)
distribute (Rab)
product_rule (Rab)
distribute (Rab)
substitute (Rab, KDelta)
eliminate_kronecker (Rab)
# the Ricci tensor in terms of the metric
canonicalise (Rab);
# now start preparing to "evaluate" Rab
substitute (Rab, $\partial_{a b}{g_{c d}} -> dg_{c d a b}$)
substitute (Rab, $\partial_{a}{g_{b c}} -> dg_{b c a}$)
substitute (Rab, $\partial_{a}{g^{b c}} -> dg^{b c}_{a}$)
gup=[]
gdn=[]
Rdn=[]
for a in ["x","y","z"]:
for b in ["x","y","z"]:
gup.append("g^{"+a+" "+b+"} = gup"+a+b)
gdn.append("g_{"+a+" "+b+"} = gdn"+a+b)
Rdn.append("R_{"+a+" "+b+"} = R"+a+b)
gup_rl = Ex(','.join(gup))
gdn_rl = Ex(','.join(gdn))
Rdn_rl = Ex(','.join(Rdn))
gupd1=[]
gdnd1=[]
for a in ["x","y","z"]:
for b in ["x","y","z"]:
for c in ["x","y","z"]:
gupd1.append("dg^{"+a+" "+b+"}_{"+c+"} = gup"+a+b+c)
gdnd1.append("dg_{"+a+" "+b+" "+c+"} = gdn"+a+b+c)
gupd1_rl = Ex(','.join(gupd1))
gdnd1_rl = Ex(','.join(gdnd1))
gdnd2=[]
for a in ["x","y","z"]:
for b in ["x","y","z"]:
for c in ["x","y","z"]:
for d in ["x","y","z"]:
gdnd2.append("dg_{"+a+" "+b+" "+c+" "+d+"} = gdn"+a+b+c+d)
gdnd2_rl = Ex(','.join(gdnd2))
# the final expression for Rab but ...
# Cadabra (or sympy) hangs (:
evaluate (Rab,gup_rl+gdn_rl+gupd1_rl+gdnd1_rl+gdnd2_rl,rhsonly=True);