This Sage worksheet is devoted to the computation of the Riemann tensor of a given metric and to the writing of the Einstein equation. It has been developed with the version 4.7.1 of Sage.
© Eric Gourgoulhon 16 Dec. 2011
This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (version 2) as published by the Free Software Foundation.
Pick a space below or add your own choice
Sphere S2:
{{{id=1| n = 2 ; var('th', latex_name="\\theta"); var('ph', latex_name="\\phi") ; x = [th, ph] ; # spherical coordinates (theta, phi) var('r') ; # sphere radius g = matrix( [[r^2,0], [0, (r*sin(th))^2]] ) ; g # S^2 metric /// }}}Euclidean space R3:
{{{id=59| n = 3 ; var('r'); var('th', latex_name="\\theta"); var('ph', latex_name="\\phi") ; x = [r, th, ph] ; # spherical coordinates (r, theta, phi) g = matrix( [[1,0,0],[0,r^2,0],[0,0,(r*sin(th))^2]] ) ; g # Euclidean metric /// }}}Hypersphere S3:
{{{id=61| n = 3 ; var('ch', latex_name="\\chi"); var('th', latex_name="\\theta"); var('ph', latex_name="\\phi") ; x = [ch, th, ph] ; # coordinates (chi, theta, phi) g = matrix( [[1,0,0],[0,(sin(ch))^2,0],[0,0,(sin(ch)*sin(th))^2]] ) ; g # S^3 metric /// }}}Hyperbolic space H3:
{{{id=64| n = 3 ; var('ro', latex_name="\\rho"); var('th', latex_name="\\theta"); var('ph', latex_name="\\phi") ; x = [ro, th, ph] ; # coordinates (rho, theta, phi) var('b') ; # constant scale factor g = matrix( [[b^2,0,0], [0,(b*sinh(ro))^2,0], [0,0,(b*sinh(ro)*sin(th))^2]] ) ; g # H^3 metric /// }}}Friedmann-Lemaître-Robertson-Walker spacetime:
{{{id=2| n = 4 ; var('t, r') ; var('th', latex_name="\\theta"); var('ph', latex_name="\\phi") ; x = [t, r, th, ph] ; # coordinates (t, r, theta, phi) var('K') ; # curvature parameter of the t = const hypersurfaces a = function('a', t) ; # scale factor a(t) g = matrix( [[-1,0,0,0], [0,a^2/(1-K*r^2), 0, 0], [0, 0, (a*r)^2, 0], [0, 0, 0, (a*r*sin(th))^2 ]] ) ; g # FLRW metric /// }}}Schwarzschild spacetime:
{{{id=106| n = 4 ; var('t, r') ; var('th', latex_name="\\theta"); var('ph', latex_name="\\phi") ; x = [t, r, th, ph] ; # Schwarzschild coordinates (t, r, theta, phi) var('m') ; # mass parameter g = matrix( [[-(1-2*m/r),0,0,0], [0,1/(1-2*m/r), 0, 0], [0, 0, r^2, 0], [0, 0, 0, (r*sin(th))^2 ]] ) ; g /// }}}Kerr spacetime:
{{{id=110| n = 4 ; var('t, r') ; var('th', latex_name="\\theta"); var('ph', latex_name="\\phi") ; x = [t, r, th, ph] ; # Boyer-Lindquist coordinates (t, r, theta, phi) var('m, a') ; # mass and angular momentum parameter rho2 = r^2 + (a*cos(th))^2 ; Delta = r^2 - 2*m*r + a^2 ; g = matrix( [[-(1-2*m*r/rho2),0,0,-2*a*m*r*(sin(th))^2/rho2], [0,rho2/Delta, 0, 0], \ [0, 0, rho2, 0], [-2*a*m*r*(sin(th))^2/rho2, 0, 0, (r^2+a^2+2*m*r*(a*sin(th))^2/rho2)*(sin(th))^2 ]] ) ; g /// }}} {{{id=125| # ginv1 = matrix( [[-((r^2+a^2)*rho2+2*m*a^2*r*(sin(th))^2)/rho2/Delta,0,0, -2*m*a*r/(rho2*Delta)], [0,Delta/rho2,0,0],\ # [0,0,1/rho2,0], [-2*m*a*r/(rho2*Delta),0,0,(Delta-(a*sin(th))^2)/(rho2*Delta*(sin(th))^2)]] ) /// }}}Vacuum:
{{{id=95| Tener = zero_matrix(ZZ, n) /// }}}Perfect fluid for a FLRW cosmological model:
{{{id=79| var('rho, p') ; Tener = matrix( [[rho, 0, 0, 0], [0, p*a^2 / (1-K*r^2), 0, 0], \ [0, 0, p*(a*r)^2, 0], [0, 0, 0, p*(a*r*sin(th))^2]] ) ; Tener /// }}}