It's mostly an issue with not putting brackets at the right places. While Cadabra uses TeX notation, you sometimes have to be a little more explicit than strictly necessary in TeX, in order to avoid ambiguity. So you have to write e.g.
\bar{\psi_{\mu}}
so that it is clear to Cadabra that the \psi_{\mu}
is an 'argument' of \bar
. Ditto for \partial
, which you need to write as
\partial_{\nu}{ \psi_{\rho} }
so that the \psi_{\rho}
explicitly becomes an 'argument' of \partial
. In your example, the \partial_{\nu}\psi_{\rho}
was interpreted as a derivative acting on nothing, multiplied with \psi_{\rho}
, giving nothing.
Here's a tidied-up version which works:
#Rarita-Scwhinger Action
def post_process(ex):
sort_product(ex)
eliminate_kronecker(ex)
canonicalise(ex)
collect_terms(ex)
{\mu,\nu,\rho}::Indices(position=independent);
x::Coordinate;
\Gamma{#}::GammaMatrix(metric=\eta);
\eta_{\mu\nu}::Metric;
\partial{#}::Derivative;
\psi_{\mu}::Spinor;
\bar{#}::DiracBar;
\psi_{\mu}::Depends(x);
S:=\int{\bar{\psi_{\mu}} \Gamma^{\mu\nu\rho} \partial_{\nu}{\psi_{\rho}} }{x};
I have fixed a few typos and also changed the index type to 'independent' to prevent Cadabra from raising/lowering index pairs (usually better for susy computations, as you can then keep all indices on the Gamma's upstairs and more easily convert them using vielbeine).