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

Hi.

Two questions please.

Please consider the following code:

from cdb.core.component import *

{i,j,k,l,m,n}::Indices(topological,)
\epsilon::EpsilonTensor.
Ki := (K_{i})_{m n} = \epsilon_{i m n}.
get_component(Ki, $0, 0, 0$);

The answer it provides is entirely correct (\epsilon_{0 0 0}) but

  1. I would like it to go the next step and display the actual value 1.
  2. Is there any way to obtain all the components of the complete matrix Ki for a given i?

Of course, if I have the answer to Q1, I can do a for-loop and get the answer to Q2. Ideally, I would like some function that provides a list or dict which I can then further format.

Many thanks as always!

GPN

in General questions by (2.0k points)

1 Answer

+2 votes
 
Best answer

Tensors do not have component values by default in Cadabra. You typically write down some tensor expression in abstract form (like that Ki line of yours) and then evaluate the components of that expression by making use of implicit or explicit rules about the components of the tensors that make up this expression.

In your case, try something like

from cdb.core.component import *

{i,j,k,l,m,n}::Indices(topological, values={1,2,3}).
\epsilon{#}::EpsilonTensor.
Ki := (K_{i})_{m n} = \epsilon_{i m n}.

evaluate(Ki, rhsonly=True);

get_component(Ki, $1, 2, 3$);

Note that I have also added the range of the indices.

There isn't anything simple at the moment to get a two-index object in the form of a matrix, unfortunately.

by (83.1k points)
selected by
...