Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

(This is a re-post of a question, now under "feature request")

I suggest adding two new properties for tensors that are not scalars

  1. "Normal" can be applied to a 1D tensor (vector or covector), with two fields
    1. 'norm' that can be either +1 or -1
    2. 'deriv' that will reference a Derivative symbol (like if you defined \nabla{#}:Derivative earlier)
  2. "Orthogonal" can be applied to any tensor (that is not a scalar)

The properties will be unaffected by raising or lower indices, e.g. if A_{m,n} is orthogonal, then A_{m}^{n} is also orthogonal and if B_{k} is normal then so is B^{k}.

Then there need to be a new method contract_normal(expr), that will scan an expression and look for contractions between tensors

  • if two tensors are 1D normal vector & 1D covector then their contraction is the value of 'norm'
  • if one tensor is orthogonal and the other is a normal vector/covector then their contraction is 0
  • if one tensor is a normal vector and the other is the 'deriv' operator on a normal vector e.g. A^{m} \nabla_{k}{A_{m}} or A_{m} \nabla_{k}{A^{m}}, then the contraction is 0.
in Feature requests by (400 points)

1 Answer

+1 vote

I am not in principle against adding some functionality to make these kind of manipulations easier. However, most of what you want to do can be achieved with some simple substitution rules. I think that the main thing you are looking for is some way to "put vectors or tensors in a labelled set", so that you can apply a rule whenever such an object appears. That makes things more useful in a wider context; your solution is very much tuned to a particular class of problems, and does not generalise well to situations where you may have multiple vector bundles or multiple surfaces to which something can be "orthogonal" or "normal".

Let's think this through a bit. Feel free to continue the discussion here so we get a better idea of what your requirements are.

by (83.1k points)

Hi Kasper, You're right that my use-cases are not general for multiple vector bundle. I currently focus on 3+1 foliation of spacetime, where the normal space is 1D.

Here's an example of calculations for 3+1 foliation, and perhaps you can tell me what I'm missing.

A foliation is defined by a normal vector field n^{\mu} The extrinsic curvature tensor B_{\mu \nu} is a symmetric tensor. Also, its contraction with a n^{\mu} (in either of its indices) would vanish. I wrote the following code in Cadabra:

{x#}::Coordinate; {\mu,\nu,\rho,\sigma,\kappa,\eta,\xi,\zeta,\alpha,\beta}::Indices(position=fixed,values=[x0,x1,x2,x3]); {n^{\mu}}::Depends(x0,x1,x2,x3);

cond_normal1 := n^{\mu} n{\mu} -> (-1);

cond_normal2 := n^{\mu} \nabla{\kappa}{n_{\mu}} -> 0;

cond_normal3 := n{\mu} \nabla_{\kappa}{n^{\mu}} -> 0;

B_{\mu \nu}::Symmetric;

cond_B_normal1 := B{\mu \nu} n^{\mu} -> 0;

cond_B_normal2 := B{\mu \nu} n^{\nu} -> 0;

The reason I need both cond_B_normal_1 & cond_B_normal_2 is that the Symmetric property isn't enough to make the following expression vanish ( I add another general vector v)

expr := B_{\mu \nu} v^{\mu} n^{\nu};

substitute(expr,cond_B_normal_1);

I have to run substitute(expr,cond_B_normal_2); to make the contraction vanish.

Later I found that I have to also write the more substitution rules to account for other possible contractions: cond_B_normal_3 := B^{\mu \nu} n_{\mu} -> 0;

cond_B_normal_4 := B^{\mu \nu} n_{\nu} -> 0;

cond_B_normal_5 := B_{\mu}^{\nu} n^{\mu} -> 0;

cond_B_normal_6 := B_{\mu}^{\nu} n_{\nu} -> 0;

...