Hi GPN.
You posed a very interesting question. I got a bit further in the direction you wanted. Let me explain.
Following your example, I stated with these definitions (properties
):
from cdb.relativity.abstract import christoffel_from_metric
g_{\mu\nu}::Metric.
g_{\mu\nu}::Depends(\partial{#}).
g^{\mu\nu}::InverseMetric.
g^{\mu\nu}::Depends(\partial{#}).
\Gamma^{\mu}_{\nu\rho}::Depends(\partial{#}).
ch = christoffel_from_metric()
Now, the expression to manipulate is the following:
ch_2 := \Gamma^{\rho}_{\nu\sigma}\Gamma^{\sigma}_{\rho\mu};
substitute(ch_2,ch)
distribute(ch_2);
Let's say that you want to manipulate the fourth term. My approach is to define a new expression using the target term
old = ch_2[3]
old := 4 @(old);
BEWARE:
- In the last code block the first definition of the variable
old
is a python command (note the assignation through the equal sign (without colon), so it don't require to end in semi-colon.
- The re-definition of
old
is a cadabra expression (uses the :=
) whose purpose is to eliminate the numerical factor, which raises an error in the next step.
Next, I define a new
expression which might be a copy of old
, i.e. new := @(old)
to be manipulated through cadabra algorithms, or just a hand-made expression. The goal is to define a substitution rule.
In the code block below I use the second scenario:
new := A_{\mu \nu};
rl := @(old) -> @(new);
Finally, I apply the substitution rule to the original expression ch_2
:
substitute(ch_2, rl);
Hope this could be useful for your case!
Dox.