Ask Your Question
2

Contracting with Christoffel symbols

asked 2019-04-19 23:19:54 +0100

ljp gravatar image
MM = Manifold(4, 'MM', latex_name=r'\mathcal{M}', start_index=0)  
chartt.<t,x,y,z> = MM.chart()

gg = MM.lorentzian_metric('gg')
gg[0,0] = -1
gg[1,1] = 1
gg[2,2] = 1
gg[3,3] = 1

some_tensor = MM.tensor_field(1,1)
christoffel = gg.christoffel_symbols()
some_contraction = some_tensor['^i_j'] * christoffel['^j_kl']

The above code doesn't work and crashes with the following error:
ValueError: wrong number of indices: 3 expected, while 4 are provided

I know that the Christoffels are only a CompWithSym and not a real tensor, but shouldn't one still be able to generate some contracted quantities?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-04-22 12:22:01 +0100

dan_fulea gravatar image

updated 2019-04-22 13:55:19 +0100

I see this instance for the first time, so the answer is a dry one, only pointing to the error. It comes, because the "magic" is not implemented. In fact, sage: christoffel['^j_kl'] produces the error. Going into it, i.e. rather in its implementation via

christoffel.__getitem__('^j_kl')

the caller is the method christoffel.__getitem__ . Inspecting it in the sage interpreter via

sage: christoffel.__getitem__??

we see that this method is not ready for use in the above context. The method tries to parse the data for the "known purposes", so first, it is parsing the arguments, here only '^j_kl'. I was not starting the debugger, but it is a good chance that we run into this code:

        else:
            format_type = args[-1]
            indices = args[:-1]
    if isinstance(indices, slice):
        return self._get_list(indices, no_format, format_type)
    else:
        sign, ind = self._ordered_indices(indices)
        if (sign == 0) or (ind not in self._comp): # the value is zero:

so it goes into indices = args[:-1], which makes the indices variable be ^j_k, which is of course nonsense from the mathematical point of view. (And format_type gets the last letter.) Now the error message comes from something like

sage: christoffel = gg.christoffel_symbols()
sage: try:
....:     christoffel._ordered_indices('^j_k')
....: except ValueError:
....:     import traceback
....:     traceback.print_exc()
....:     
Traceback (most recent call last):
  File "<ipython-input-247-b13ce8540566>", line 2, in <module>
    christoffel._ordered_indices('^j_k')
  File "/usr/lib/python2.7/site-packages/sage/tensor/modules/comp.py", line 3101, in _ordered_indices
    ind = list(self._check_indices(indices))
  File "/usr/lib/python2.7/site-packages/sage/tensor/modules/comp.py", line 660, in _check_indices
    " while {} are provided").format(self._nid, len(ind)))
ValueError: wrong number of indices: 3 expected, while 4 are provided
sage:

Note: The method that crashes would work for instance for:

sage: christoffel._ordered_indices((2,1,0))
(1, (2, 0, 1))

As a rule, personally, i do not expect that "similar classes" have "similar magic", because the developers may differ, so much of the implementation may be designed in an other way, often so that features of the "other class" are not implemented / implementable (without hard work).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-04-19 23:19:54 +0100

Seen: 7,578 times

Last updated: Apr 22 '19