Memory efficient calculation of the Kretschmann scalar

36 views
Skip to first unread message

Mattia Villani

unread,
Dec 29, 2019, 10:33:16 AM12/29/19
to sage-support
Currently I use the following code to calculate the Kretschmann scalar kr of my metric g:

R=g.Riemann();
uR=R.up(g)
dR=R.down(g)

kr=uR['^{abcd}']*dR['_{abcd}']

It works, but it consumes a lot of memory: is there a more memory efficient way to calculate the Kretschamann scalar?

Eric Gourgoulhon

unread,
Dec 31, 2019, 5:42:06 AM12/31/19
to sage-support
Well, if memory is really an issue, you can avoid the creation of the intermediate tensor fields uR and dR by writing

gc = g.components()
igc
= g.inverse().components()
Rc = R.components()
kr
= 0
for a in M.irange():
   
for b in M.irange():
       
for c in M.irange():
           
for d in M.irange():
               
for i in M.irange():
                   
for j in M.irange():
                       
for k in M.irange():
                           
for l in M.irange():
                                kr
+= gc[[a, i]]*igc[[b, j]]*igc[[c, k]]*igc[[d, l]] \
                                     
*Rc[[i, b, c, d]]*Rc[[a, j, k, l]]
kr
.expr()

It is certainly more efficient in term of memory, but less efficient in term of CPU time, since the symmetries of the Riemann tensor are not taken into account in the above writing.

Best wishes,

Eric.
Reply all
Reply to author
Forward
0 new messages