Two-sphere
This notebook computes the curvature of a 2-sphere by computing connection coefficients and the Riemann tensor components.{\theta, \varphi}::Coordinate;
{\alpha, \beta, \gamma, \delta, \rho, \sigma, \mu, \nu, \lambda}::Indices(values={\varphi, \theta}, position=fixed);
\partial{#}::PartialDerivative;
g_{\alpha\beta}::Metric.
g^{\alpha\beta}::InverseMetric.
Attached property Coordinate to [θ,φ].
Attached property Indices(position=fixed) to [α,β,γ,δ,ρ,σ,μ,ν,λ].
Attached property PartialDerivative to ∂#.
sphe:={ g_{\theta\theta} = r**2,
g_{\varphi\varphi} = r**2 \sin(\theta)**2 }.
complete(sphe, $g^{\alpha\beta}$);
[gθθ=r2,gφφ=r2(sinθ)2,gφφ=(r2(sinθ)2)−1,gθθ=r−2]
{g_{\theta \theta} = (r)**2, g_{\varphi \varphi} = (r)**2 (\sin(\theta))**2, g^{\varphi \varphi} = ((r)**2 (\sin(\theta))**2)**-1, g^{\theta \theta} = (r)**-2}
The Christoffel symbols are given in terms of the metric by the following expression.
ch:= \Gamma^{\alpha}_{\mu\nu} = 1/2 g^{\alpha\beta} ( \partial_{\nu}{g_{\beta\mu}}
+\partial_{\mu}{g_{\beta\nu}}
-\partial_{\beta}{g_{\mu\nu}} );
Γαμν=12gαβ(∂νgβμ+∂μgβν−∂βgμν)
\Gamma^{\alpha}_{\mu \nu} = 1/2 g^{\alpha \beta} (\partial_{\nu}(g_{\beta \mu}) + \partial_{\mu}(g_{\beta \nu})-\partial_{\beta}(g_{\mu \nu}))
We evaluate the components using
evaluate
and then massage them a bit further using sympy.evaluate(ch, sphe, rhsonly=True)
map_sympy(ch, "expand_trig");
Γαμν=◻μνα{◻φθφ=(tanθ)−1◻θφφ=(tanθ)−1◻φφθ=−sinθcosθ
\Gamma^{\alpha}_{\mu \nu} = \components_{\mu \nu}^{\alpha}({{\varphi, \theta, \varphi} = (\tan(\theta))**-1, {\theta, \varphi, \varphi} = (\tan(\theta))**-1, {\varphi, \varphi, \theta} = -\sin(\theta) \cos(\theta)})
The Riemann tensor is given in terms of the Christoffel symbols by the expression below.
rm:= R^{\rho}_{\sigma\mu\nu} = +\partial_{\mu}{\Gamma^{\rho}_{\sigma\nu}}
-\partial_{\nu}{\Gamma^{\rho}_{\sigma\mu}}
+\Gamma^{\rho}_{\beta\mu} \Gamma^{\beta}_{\sigma\nu}
-\Gamma^{\rho}_{\beta\nu} \Gamma^{\beta}_{\sigma\mu};
substitute(rm, ch)
evaluate(rm, sphe, rhsonly=True);
Rρσμν=∂μΓρσν−∂νΓρσμ+ΓρβμΓβσν−ΓρβνΓβσμ
R^{\rho}_{\sigma \mu \nu} = \partial_{\mu}(\Gamma^{\rho}_{\sigma \nu})-\partial_{\nu}(\Gamma^{\rho}_{\sigma \mu}) + \Gamma^{\rho}_{\beta \mu} \Gamma^{\beta}_{\sigma \nu}-\Gamma^{\rho}_{\beta \nu} \Gamma^{\beta}_{\sigma \mu}
Rρσμν=◻σνρμ{◻φφθθ=(sinθ)2◻θφφθ=−1◻φθθφ=−(sinθ)2◻θθφφ=1
R^{\rho}_{\sigma \mu \nu} = \components_{\sigma \nu}^{\rho}_{\mu}({{\varphi, \varphi, \theta, \theta} = (\sin(\theta))**2, {\theta, \varphi, \varphi, \theta} = -1, {\varphi, \theta, \theta, \varphi} = -(\sin(\theta))**2, {\theta, \theta, \varphi, \varphi} = 1})
These are not in the simplest form possible yet, but this is a
sympy
simplification issue; for the time being
we will continue and compute the Ricci tensor and scalar.ricci:= R_{\sigma\nu} = R^{\rho}_{\sigma\rho\nu};
substitute(ricci, rm)
evaluate(ricci, sphe, rhsonly=True);
Rσν=Rρσρν
R_{\sigma \nu} = R^{\rho}_{\sigma \rho \nu}
Rσν=◻σν{◻φφ=(sinθ)2◻θθ=1
R_{\sigma \nu} = \components_{\sigma \nu}({{\varphi, \varphi} = (\sin(\theta))**2, {\theta, \theta} = 1})
R:= R = R_{\sigma\nu} g^{\sigma\nu};
substitute(R, ricci)
evaluate(R, sphe, rhsonly=True);
R=Rσνgσν
R = R_{\sigma \nu} g^{\sigma \nu}
R=2r−2
R = 2(r)**-2
The main time computing this is spent in the rather inefficient
sympy
bridge. You can see timing information
by querying the server
object for the totals
list.server.totals();
{}[
cadabra::collect_terms: 21 calls, 0 steps, 0 ms
, cadabra::complete: 1 calls, 0 steps, 268 ms
, cadabra::evaluate: 4 calls, 0 steps, 2212 ms
, cadabra::map_sympy: 1 calls, 0 steps, 20 ms
, cadabra::simplify: 49 calls, 0 steps, 2209 ms
, cadabra::substitute: 3 calls, 0 steps, 5 ms
, scalar_backend: 49 calls, 0 steps, 2209 ms
, sympy: 49 calls, 0 steps, 2209 ms
]