(* This line depends on your directories. You can just drop GREATER2.m in the Mathematica applications directory and then it is not needed at all.


PrependTo[$Path, ToFileName[{$HomeDirectory, "physics", "Mathematica-apps"}]];

*)
Needs["GREATER2`"];

(* Metric of Reissner-Nordstrom *)
ds2 = -f[r]dt^2 + ((dr^2)/(f[r])) + r^2 (dθ^2 + Sin[θ]^2 dϕ^2);
X = {t,r,θ,ϕ};
Gdd = Metric[ds2, X];


(* Inverse metric *)
Guu = IMetric[Gdd];
plugf = {f->Function[{r}, 1  - 2m/r + q^2/r^2]};

Edd = EinsteinTensor[Gdd,X];

(* (Subscript[A, μ]) *)
Ad =  -{q/r, 0, 0, 0};
Fdd = FieldStrength[Ad, X];
Tdd =(1/(4π))  MaxwellStressTensor[Fdd, Gdd];
Edd/.plugf//SMF
Tdd/.plugf//SMF
Edd - 8π  Tdd/.plugf//SMF

(* Here's the 1st row of the Field strength, ie the electric field *)
Fdd[[;;,1]]

(* Change coordinates and expand near the horizon *)
X2 = {η, ϵ, θ,ϕ};
transformation = {r==(m+(Sqrt[m^2-q^2]))(1 + ϵ^2), η== λ t};
(* The -1's here indicate that we are doing a coordinate change on a rank-(0,2) tensor, ie 2 lower indices *)
ChangeCoords[Gdd/.plugf, X, X2, transformation, {-1,-1}]+O[ϵ]^3//SMF

(* Let's check the Maxwell equations *)
DdFdd = CoD[Fdd, Gdd, X, {-1,-1}];
DdFdd//Dimensions
Guu = IMetric[Gdd];
DuFdd = Guu.DdFdd;
Table[Sum[DuFdd[[μ, μ, ν]], {μ,4}], {ν,4}]//Simplify

(* Some other curvature functions *)
SCurvature[Gdd,X]
%/.plugf//S
Rdd = Ricci[Gdd,X];
Rdd/.plugf//SMF

Γ = Christoffel[Gdd,X];
ShowComponents[Γ, X, {1,-1,-1}, "Γ"]

(* The "FieldStrength" function is built-in, but we could also compute it directly as an antisymmetrized partial derivative *)

AnotherFdd = 2 antisymmetrize[SimpleDeriv[Ad, X]]
Fdd