How do I speed up the symbolic calculation of Riemann tensor?

asked 2024-08-16 09:23:16 +0100

aneet gravatar image

updated 2024-08-26 12:29:34 +0100

I've been trying to use sagemath for a derivation in general relativity. For a particular step I need to calculate the riemann tensor of a perturbation metric (This metric has no particular form) and the cell did not execute for even after 16 hours of run time. Here's the snippet of my code. can someone help me in defining a metric in some other way, probably indicial notation or something else so that the process can speed up?

here's a minimal code:

h=M.metric('h') for i in range(4): for j in range(4): h[i, j] = function(f'h{i}{j}')(t, x, y, z) h[i, j] = h[j, i]

h[:] riemann=h.riemann() riemann.display()

edit retag flag offensive close merge delete

Comments

1

please provide a minimal code example

FrédéricC gravatar imageFrédéricC ( 2024-08-17 08:23:54 +0100 )edit

Try to give the metric in a closed form as much as you can: For example, use a function f(t,x) instead of $t^3+xt+x^2$.

tolga gravatar imagetolga ( 2024-08-17 08:31:59 +0100 )edit
1

You could try to use a simplification chain lighter than the default one, since this is where most of the CPU time is spent. See https://doc.sagemath.org/html/en/refe...

eric_g gravatar imageeric_g ( 2024-08-21 11:04:52 +0100 )edit

here's a minimal code:

h=M.metric('h')
for i in range(4):
    for j in range(4):
        h[i, j] = function(f'h{i}{j}')(t, x, y, z)
        h[i, j] = h[j, i]

h[:]
riemann=h.riemann()
riemann.display()
aneet gravatar imageaneet ( 2024-08-26 12:28:24 +0100 )edit

If all of the elements of your metric are nonzero and strictly depend on each coordinate, then the Riemann tensor calculation should take a serious amount of time. A lighter simplification suggestion of @eric_g seems like the only way to have a result (useful or not). However, I would first think about the restrictions I could put on the metric (e.g. no time dependence, no g_{tr} terms, etc.).

tolga gravatar imagetolga ( 2024-08-26 19:48:54 +0100 )edit