Misner Space

Spacetime discussed in Section 2.7, p 81, Carroll
(ds^2)=(t/(Sqrt[1+(t^2)]))(dt^2)-(2/(Sqrt[1+(t^2)]))  dt dx -(t/(Sqrt[1+(t^2)])) (dx^2)
0<x<1, -∞<t<+∞

Initialization

Needs["xAct`xCoba`"]

(*$PrePrint=ScreenDollarIndices;
$DefInfoQ=False;
$UndefInfoQ=False;*)

DefManifold[M,2,{λ,μ,ν,ρ,σ,α,β,γ,δ}];
dimM = DimOfManifold[M];dimM1 = dimM-1;

Here is the definition of the coordinate system, and the metric:
Simply define the list coords = {....} and the matrix gmatrix

coords = {t[],x[]};
(*DefConstantSymbol[mass,PrintAs->"M"];*)
DefScalarFunction[ascale,PrintAs->"a"]; (*Use as e.g. ascale[t[],r[]] for a function of (t,r)*)
gmatrix = {
{((t[])/(Sqrt[1+((t[])^2)])),   ((-1)/(Sqrt[1+((t[])^2)]))},
{  ((-1)/(Sqrt[1+((t[])^2)])),  ((-t[])/(Sqrt[1+((t[])^2)]))}
};
DefChart[ch,M,{0,1},coords,ChartColor->Blue];
g=CTensor[gmatrix,{-ch,-ch}];
SetCMetric[g,ch,SignatureOfMetric-> {1,1,0}];
CD = CovDOfMetric[g];
$Assumptions = 0<x[]<1 && t∈Reals;

Print[
"(Subscript[g, μν])= ",ComponentArray[g[{-μ,-ch},{-ν,-ch}]]//MatrixForm,"    ,       ",
"(g^(μν))= ",ComponentArray[g[{  μ,   ch},{   ν,  ch}]]//MatrixForm,"\n",
"g  =", Determinant[g,ch][]," = ",Det[ComponentArray[g[{-μ,-ch},{-ν,-ch}]]]//Simplify
]

Affine Connection

Print nonzero components:
(Subscript[(Γ^λ), μν])=(1/2)(g^(λσ))((∂_μ) (Subscript[g, σν])+(∂_ν) (Subscript[g, σμ])-(∂_σ) (Subscript[g, μν]))
The components of the Christoffel symbols are collected  by the ComponentArray[expr] function.

list =ComponentArray[Christoffel[CD,PDch][{α,ch},{-β,-ch},{-γ,-ch}]];
list = Table[
If[
UnsameQ[list[[i,j,k]],0],{Subscript[Superscript["Γ",i-1],j-1,k-1],list[[i,j,k]]}
],
{i,1,Length[list]},{j,1,Length[list]},{k,1,j}
];
Partition[DeleteCases[Flatten[list],Null],2]//TableForm

Curvature

Print nonzero components of Riemann: (Subscript[(R^μ), νρσ])
(Subscript[(R^λ), ρμν]) = (∂_μ) (Subscript[(Γ^λ), νρ])-(∂_ν) (Subscript[(Γ^λ), μρ]) + (Subscript[(Γ^λ), μσ]) (Subscript[(Γ^σ), νρ]) - (Subscript[(Γ^λ), νσ]) (Subscript[(Γ^σ), μρ])  (Carroll+Hartle’s convention)
xCoba has Wald’s convention, which for a Levi-Civita Connection gives the same reult after some index raising/lowering.

The components of the Riemann tensor are collected by the ComponentArray[expr] function.

list=ComponentArray[Riemann[CD][{α,ch},{-β,-ch},{-γ,-ch},{-δ,-ch}]];
list = Table[
If[
UnsameQ[list[[i,j,k,l]],0],{Subscript[Superscript["R",i-1],j-1,k-1,l-1]
,list[[i,j,k,l]]}
],
{i,1,Length[list]},{j,1,Length[list]},{k,1,Length[list]},{l,1,k-1}
];
Partition[DeleteCases[Flatten[list],Null],2]//TableForm

The Riemann tensor with all lower indices: (Subscript[R, μνρσ])

list=ComponentArray[Riemann[CD][{-α,-ch},{-β,-ch},{-γ,-ch},{-δ,-ch}]];
list = Table[
If[
UnsameQ[list[[i,j,k,l]],0],{Subscript["R",i-1,j-1,k-1,l-1]
,list[[i,j,k,l]]}
],
{i,1,Length[list]},{j,1,i-1},{k,1,Length[list]},{l,1,k-1}
];
Partition[DeleteCases[Flatten[list],Null],2]//TableForm

The Riemann tensor with all upper indices: (R^(μνρσ))

list=ComponentArray[Riemann[CD][{α,ch},{β,ch},{γ,ch},{δ,ch}]];
list = Table[
If[
UnsameQ[list[[i,j,k,l]],0],{Superscript[Superscript[Superscript[Superscript["R",i-1],j-1],k-1],l-1]
,list[[i,j,k,l]]}
],
{i,1,Length[list]},{j,1,i-1},{k,1,Length[list]},{l,1,k-1}
];
Partition[DeleteCases[Flatten[list],Null],2]//TableForm

The Ricci tensor: (Subscript[R, μν])

list=ComponentArray[Ricci[CD][{-α,-ch},{-β,-ch}]];
list = Table[
If[
UnsameQ[list[[i,j]],0],{Subscript["R",i-1,j-1]
,list[[i,j]]}
],
{i,1,Length[list]},{j,1,i}
];
Partition[DeleteCases[Flatten[list],Null],2]//TableForm

Ricci scalar:

Print["R = ",RicciScalar[CD][]]

(R^2) scalar

Print["(R^2) = ",Kretschmann[CD][]]

Geodesic Equations

DefTensor[u[μ],M];

The geodesic equations are:
((du^μ)/(dτ))+(Subscript[(Γ^μ), ⋁ρ])(u^ν)(u^ρ)=0
geqs is a list with the second term geqs[μ+1]= (Subscript[(Γ^μ), ⋁ρ])(u^ν)(u^ρ) for each μ=0,..,d-1.
(careful, in the expressions below, when e.g.  (u^(3^2))=((((u^3)))^2), the squared terms don’t appear nicely)

geqs=ComponentArray[Christoffel[CD,PDch][{μ,ch},{-ν,-ch},{-ρ,-ch}] u[{ν,ch}]u[{ρ,ch}]]//ContractBasis//Simplify;
For[i=1,i<= Length[geqs],i++,Print["(d/(dτ))",u[{i-1,ch}],"+(",geqs[[i]],")=0"]]

DefScalarFunction[  dx0  ,PrintAs->"(OverDot[t])"];DefScalarFunction[  dx1  ,PrintAs->"(OverDot[x])"];
DefScalarFunction[ddx0  ,PrintAs->"(Overscript[t, ¨])"];DefScalarFunction[ddx1  ,PrintAs->"(Overscript[x, ¨])"];
u   = CTensor[{  dx0[] ,  dx1[]},{ch}];
du = CTensor[{ddx0[],ddx1[]},{ch}];
{u,du}

geqs=ComponentArray[Christoffel[CD,PDch][{μ,ch},{-ν,-ch},{-ρ,-ch}] u[{ν,ch}]u[{ρ,ch}]]//ContractBasis//Simplify;
For[i=1,i<= Length[geqs],i++,Print[du[{i-1,ch}],"+(",geqs[[i]],")=0"]]

u[μ] u[-μ]//Simplify

Clear[tcp0,xcp0,xc0,tc0];
nullcon = Solve[((u[μ] u[-μ]//Simplify) /.{dx0[]-> tcp0,dx1[]-> xcp0, x[]-> xc0, t[]-> tc0}) ==0,tcp0]

rhs = -(geqs /. {dx0[]-> tcp[τ],dx1[]-> xcp[τ], x[]-> xc[τ], t[]-> tc[τ]}/.{xcp[τ] -> xc'[τ],tcp[τ] -> tc'[τ]})

tcp0 = tcp0 /.nullcon

Notice that the horizontal lines are not part of the curve, they represent the jump to the other side of the strip.
I don’t know how to get rid of that (I tried Exclusions->”Discontinuities”, doesn’t work)

Clear[tcp0,xcp0,xc0,tc0];
xcp0 = -0.9; τmax= 2.65;
xc0   = 0.5;tc0 = -1.0;
direction = 1; (* 1 or 2, the two roots in nullcon. The negative sign is backwards in time t *)
tcp0= tcp0 /.nullcon[[direction,1]];
Print["(Subscript[x, 0])= ",xc0,"  (Subscript[t, 0])= ",tc0,"  (Subscript[(OverDot[x]), 0])= ", xcp0,"  (Subscript[(OverDot[t]), 0])= ",tcp0];
dsol = NDSolve[{
tc''[τ] == rhs[[1]],
xc''[τ] == rhs[[2]],
tc'  [0] == tcp0,
xc'  [0] == xcp0,
tc     [0] == tc0,
xc     [0] == xc0
},{tc,xc},{τ,0,τmax}
];
{ParametricPlot[Evaluate[{Mod[xc[τ],1.0],tc[τ]}/.dsol],{τ,0,τmax},Exclusions->"Discontinuities"],
ParametricPlot3D[Evaluate[{Cos[2 π xc[τ]],Sin[2 π xc[τ]],tc[τ]}/.dsol],{τ,0,τmax}],
ListPlot[Table[Evaluate[{Mod[xc[τ],1.0],tc[τ]}/.dsol[[1]]],{τ,0,τmax,0.03}]]}

Clear[tcp0,xcp0,xc0,tc0];
xcp0 = 0.9; τmax= 2.7;
xc0   = 0.5;tc0 = -1.0;
direction = 1; (* 1 or 2, the two roots in nullcon. The negative sign is backwards in time t *)
tcp0= tcp0 /.nullcon[[direction,1]];
Print["(Subscript[x, 0])= ",xc0,"  (Subscript[t, 0])= ",tc0,"  (Subscript[(OverDot[x]), 0])= ", xcp0,"  (Subscript[(OverDot[t]), 0])= ",tcp0];
dsol = NDSolve[{
tc''[τ] == rhs[[1]],
xc''[τ] == rhs[[2]],
tc'  [0] == tcp0,
xc'  [0] == xcp0,
tc     [0] == tc0,
xc     [0] == xc0
},{tc,xc},{τ,0,τmax}
];
{
ParametricPlot[Evaluate[{Mod[xc[τ],1.0],tc[τ]}/.dsol],{τ,0,τmax},Exclusions->"Discontinuities"],
ParametricPlot3D[Evaluate[{Cos[2 π xc[τ]],Sin[2 π xc[τ]],tc[τ]}/.dsol],{τ,0,τmax}],
ListPlot[Table[Evaluate[{Mod[xc[τ],1.0],tc[τ]}/.dsol[[1]]],{τ,0,τmax,0.03}],PlotStyle->PointSize[0.01]]
}

Acknowledgements

This notebook has been programmed by Konstantinos Anagnostopoulos, Physics Department, National Technical University of Athens, Greece, while he was an instructor of the 4th year undergraduate course "General Relativity and Cosmology". It was created for fun, but it may turn out to be useful to everyone studying the General Theory of Relativity for the first time.
Email: konstant@mail.ntua.gr
Web:    http://physics.ntua.gr/konstant 
It is offered under a GPL/CC BY 4.0 license (in that order, depending on whether they apply on the programming part or the text part of the notebook).