Clear["Global`*"]

$Path;

<<xAct`xCoba`;
<<xAct`xPert`

$CVVerbose=False;
$Pre=ScreenDollarIndices;
$CovDFormat="Prefix";
SetOptions[ContractMetric,AllowUpperDerivatives->True,UseMetricOnVBundle->All];

DefManifold[M,4,IndexRange[a,l]];

DefMetric[-1,gdd[-a,-b],Cd,SymbolOfCovD->{";","∇"},PrintAs->"g"];

DefChart[B,M,{0,1,2,3},{t[],x[],y[],z[]}];

metric=List[{-(1-ϵ*ϕ[x[],y[],z[]]),0,0,0},{0,1+ϵ*ψ[x[],y[],z[]],0,0},{0,0,1+ϵ*ψ[x[],y[],z[]],0},{0,0,0,1+ϵ*ψ[x[],y[],z[]]}]

metric2=Series[metric,{ϵ,0,1}]

Inverse[metric]//Simplify
%*metric//Simplify

Inverse2=Series[Inverse[metric],{ϵ,0,1}]
%*metric2//Simplify

Series[Inverse2-Inverse[metric],{ϵ,0,1}]

Series[metric*Inverse2,{ϵ,0,1}]

gdd[a,-a]

MetricInBasis[gdd,-B,metric2]//Normal

MetricCompute[gdd,B,All,CVSimplify->Simplify];

metricdd=TensorValues[gdd]//Normal

Last@TensorValues[gdd]//Normal
Last@TensorValues[ChristoffelCdPDB]//Normal
Last@TensorValues[RiemannCd]//Simplify//Normal
Last@TensorValues[RicciCd]//Simplify//Normal
Last@TensorValues[RicciScalarCd]//Simplify//Normal

DefTensor[A[-a],M]

A[b]

DefTensor[P[-a],M]
IndexSet[A[-a_],P[-a]Exp[I*S[x,y,z]]]
IndexSet[A[a_],P[a]Exp[I*S[x,y,z]]]

DefTensor[F[-a,-b],M,Antisymmetric[{-a,-b}]]

IndexSet[F[-a_,-b_],Cd[-a][A[-b]]-Cd[-b][A[-a]]]
IndexSet[F[a_,b_],Cd[a][A[b]]-Cd[b][A[a]]]
IndexSet[F[-a_,b_],Cd[-a][A[b]]-Cd[b][A[-a]]]
IndexSet[F[a_,-b_],Cd[a][A[-b]]-Cd[-b][A[a]]]

gdd[a,b]F[-a,-b]

Cd[a][A[b]]

F[-a,-b]

F[a,b]

F[a,-b]

(*canonindices[npairs_,frees_]:=Join[frees,Flatten[{#,-#}&/@GetIndicesOfVBundle[TangentM,npairs,Join[frees,-frees]]]];
productR[n_,frees_:{}]:=Apply[Times,Apply[R,Partition[canonindices[2n-Length[frees]/2,frees][[First@RandomPerm[4n]]],4],1]];
EvenQ[Length[frees]];*)

DefTensor[G[h],M]

(*k1*RicciCd[a,b]*Cd[-a][F[-b,h]]+k2*RicciCd[a,b]Cd[-a][F[d,e]epsilongdd[-d,-e,-b,h]]+k3*RicciScalarCd[]*Cd[-a][F[-c,-d]epsilongdd[c,d,a,h]]+*)

DefConstantSymbol[k4,PrintAs->"(Subscript[k, 4])"]
DefConstantSymbol[k5,PrintAs->"(Subscript[k, 5])"]
DefConstantSymbol[k6,PrintAs->"(Subscript[k, 6])"]
DefConstantSymbol[k7,PrintAs->"(Subscript[k, 7])"]

IndexSet[G[h_],k4*RiemannCd[h,a,b,c]Cd[-a][F[-b,-c]]+k5*RiemannCd[h,a,b,c]Cd[-a][F[d,e]epsilongdd[-d,-e,-b,-c]]+k6*RiemannCd[h,b,a,c]Cd[-a][F[-b,-c]]+k7*RiemannCd[h,b,a,c]Cd[-a][F[d,e]epsilongdd[-d,-e,-b,-c]]/.Cd[-a_][Cd[b_]S[x,y,z]]->0/.PD[-a_][P[b_]]->0]

DefTensor[G4[h],M]
DefTensor[G5[h],M]
DefTensor[G6[h],M]
DefTensor[G7[h],M]

IndexSet[G4[h_],k4*RiemannCd[h,a,b,c] Cd[-a][F[-b,-c]]]
IndexSet[G5[h_],k5*RiemannCd[h,a,b,c] Cd[-a][F[d,e] epsilongdd[-d,-e,-b,-c]]]
IndexSet[G6[h_],k6*RiemannCd[h,b,a,c] Cd[-a][F[-b,-c]]]
IndexSet[G7[h_],k7*RiemannCd[h,b,a,c] Cd[-a][F[d,e] epsilongdd[-d,-e,-b,-c]]]

G[h]/.Cd[-a_][Cd[a_]S[x,y,z]]->0/.PD[-a_][P[a_]]->0
ChangeCovD[%,PD,Cd]
%//RiemannToChristoffel/.Cd[-a_][Cd[a_]S[x,y,z]]->0/.PD[-a_][P[a_]]->0
%//CovDToChristoffel/.Cd[-a_][Cd[a_]S[x,y,z]]->0/.PD[-a_][P[a_]]->0
%//ChristoffelToMetric/.Cd[-a_][Cd[a_]S[x,y,z]]->0/.PD[-a_][P[a_]]->0

(*%//ContractMetric//TraceBasisDummy//ToBasis*)

(*due=k2*RicciCd[a,b]Cd[-a][F[d,e]epsilongdd[-d,-e,-b,h]]
tre=k3*RicciScalarCd[]*Cd[-a]Christoffel[F[-c,-d]epsilongdd[c,d,a,h]]
quat=k4*RiemannCd[h,a,b,c]Cd[-a][F[-b,-c]]
cinq=k5*RiemannCd[h,a,b,c]Cd[-a][F[d,e]epsilongdd[-d,-e,-b,-c]]
sei=k6*RiemannCd[h,b,a,c]Cd[-a][F[-b,-c]]
set=k7*RiemannCd[h,b,a,c]Cd[-a][F[d,e]epsilongdd[-d,-e,-b,-c]] *)

(*BianchiID={CD[-a_]@Phi[]*CD[-b_]@RicciCD[b_,a_]:>1/2 CD[-a]@Phi[] metric[b,a] CD[-b]@RicciScalarCD[],CD[a_][Phi[]]*CD[-b_][RicciCD[-a_,b_]]:>1/2 CD[a]@Phi[]*CD[-a]@RicciScalarCD[]}*)
(*SEOM3=SEOMgal2/.BianchiID*)