# star motion NDSolve

I have Schwarzschild Lagrangian:

    L = (1/2)*((1 + (-((2*G*M)/(r[\[Tau]]*c^2))))*c^2*
Derivative[1][t][\[Tau]]^2 -
1/(1 - (-((2*G*M)/(r[\[Tau]]*c^2))))*Derivative[1][r][\[Tau]]^2 -
r[\[Tau]]^2*(Derivative[1][\[Theta]][\[Tau]]^2 +
Sin[\[Theta][\[Tau]]]^2 Derivative[1][\[Phi]][\[Tau]]^2))


and these are Euler-Lagrange equations:

    EQ\[Theta]2 =D[L, \[Theta][\[Tau]]] - D[D[L, \[Theta]'[\[Tau]]], \[Tau]] == 0
EQ\[Phi]2 =D[L, \[Phi][\[Tau]]] - D[D[L, \[Phi]'[\[Tau]]], \[Tau]] == 0
EQr2 = D[L, r[\[Tau]]] - D[D[L, r'[\[Tau]]], \[Tau]] == 0
Derivative[1][t][\[Tau]] = (En r[\[Tau]])/(-2 G M + c^2 r[\[Tau]])


These are the physics constants:

    En = 0.99; M = 4.3 10^6; c = 63197.7909261(*AU/year*); G =
4 \[Pi]^2(* AU^3Msun^-1year^-2*);
Derivative[1][t][\[Tau]]


I tried to solve the equations:

    ss = NDSolve[{EQ\[Phi]2, EQr2, EQ\[Theta]2,
r[0] == 1758.4646597315134,
r'[0] == 0.13814885940063001, \[Phi][0] ==
0, \[Phi]'[0] == -0.1*r'[0], \[Theta][0] == \[Pi]/2, \[Theta]'[
0] == 0.1 \[Phi]'[0]}, {\[Phi], r, \[Theta]}, {\[Tau], 1992.224,
2010}, Method -> {StiffnessSwitching,
Method -> {ExplicitRungeKutta, Automatic}}, AccuracyGoal -> 15,
PrecisionGoal -> 16, MaxSteps -> Infinity]


The initial conditions r[0] and r'[0] were given by positions of S2 star at 1992.224. But if I solve the equations i get a straight line and not an ellipse.

     \[Phi]\[Phi][tt_] := \[Phi][tt] /. ss[[1]] /. tt -> \[Tau]
rr[tt_] := r[tt] /. ss[[1]] /. tt -> \[Tau]
\[Theta]\[Theta][tt_] := \[Theta][tt] /. ss[[1]] /. tt -> \[Tau]
x[tt_] :=rr[tt] Sin[ \[Theta]\[Theta][tt]] Cos[ \[Phi]\[Phi][tt]] /.ss[[1]] /. tt -> \[Tau]
y[tt_] :=rr[tt] Sin[ \[Theta]\[Theta][tt]] Sin[ \[Phi]\[Phi][tt]] /.ss[[1]] /. tt -> \[Tau]
z[tt_] := rr[tt] Cos[ \[Theta]\[Theta][tt]] /. ss[[1]] /. tt -> \[Tau]
ParametricPlot[{x[\[Tau]], y[\[Tau]]}, {\[Tau], 1992.224, 2010}]


Do you have any suggestions?

There are a few typos and missinterpretation how to define functions.

Correct t to r in L

L = (1/2)*((1 + (-((2*G*M)/(r[\[Tau]]*c^2))))*c^2*
Derivative[1][r][\[Tau]]^2 -
1/(1 - (-((2*G*M)/(r[\[Tau]]*c^2))))*Derivative[1][r][\[Tau]]^2 -
r[\[Tau]]^2*(Derivative[1][\[Theta]][\[Tau]]^2 +
Sin[\[Theta][\[Tau]]]^2 Derivative[1][\[Phi]][\[Tau]]^2)
)


In Euler equations correct also t to r and use Equal (==) in the last line.

EQ\[Theta]2 =
D[L, \[Theta][\[Tau]]] - D[D[L, \[Theta]'[\[Tau]]], \[Tau]] == 0
EQ\[Phi]2 =
D[L, \[Phi][\[Tau]]] - D[D[L, \[Phi]'[\[Tau]]], \[Tau]] == 0
EQr2 = D[L, r[\[Tau]]] - D[D[L, r'[\[Tau]]], \[Tau]] == 0
Derivative[1][r][\[Tau]] == (En r[\[Tau]])/(-2 G M + c^2 r[\[Tau]])

En = 0.99; M = 4.3 10^6; c =   63197.7909261(*AU/year*); G =
4 \[Pi]^2(*AU^3Msun^-1year^-2*);


You don't need all the options in NDSolve, the initial definitions are defined at tau=1992.22 not 0. NDSolve does not know \[Phi]'[0] == -0.1*r'[0] , insert the known number for r'[0] and the same for phi'[0].

ss = NDSolve[{EQ\[Phi]2, EQr2, EQ\[Theta]2,
r[1992.224] == 1758.4646597315134,
r'[1992.224] == 0.13814885940063001, \[Phi][1992.224] ==
0, \[Phi]'[1992.224] == -0.1*0.13814885940063001, \[Theta][
1992.224] == \[Pi]/2, \[Theta]'[1992.224] ==
0.1 - 0.1*0.13814885940063001}, {\[Phi], r, \[Theta]}, {\[Tau],
1992.224, 2010}]


ss was ordered to give pure functions for r, phi, theta. So following function definition is better.

\[Phi]\[Phi][tt_] = \[Phi][tt] /. ss[[1]]
rr[tt_] = r[tt] /. ss[[1]]
\[Theta]\[Theta][tt_] = \[Theta][tt] /. ss[[1]]
x[tt_] = rr[tt] Sin[\[Theta]\[Theta][tt]] Cos[\[Phi]\[Phi][tt]]
y[tt_] = rr[tt] Sin[\[Theta]\[Theta][tt]] Sin[\[Phi]\[Phi][tt]]
z[tt_] = rr[tt] Cos[\[Theta]\[Theta][tt]]

ParametricPlot[{x[\[Tau]], y[\[Tau]]}, {\[Tau], 1992.224, 2010}
]


• Sorry why should I correct t to e in L? Apr 15, 2020 at 7:49
• What function should t have? Is it an additional variable? Then you should solve for in NDSolve. Apr 15, 2020 at 8:26
• I didn't say, correct t to e, but t to r !!! Please read correctly. Apr 15, 2020 at 8:27
• yes sorry I mean r, I just wrote the Schwarzschild Lagrangian and this is the known form Apr 15, 2020 at 8:45
• As i wrote in my answer, i think that Derivative[1][t][\[Tau]]^2  in your L is a typo. What else than r should t mean here? Apr 15, 2020 at 9:15