3
$\begingroup$

I have got a system of differential equations. The system has $4$ variables. I am trying to plot trajectory of a particle outside a Kerr Black Hole. I have used Mathematica to calculate all the $4$ differential equation and now I am using NDSolve to calculate the trajectory numerically. The code is

kerr = NDSolve[{
   eqnr[s] == 0, eqnt[s] == 0, eqnϕ[s] == 0, eqnθ[s] == 0,
   r[0] == 5, θ[0] == Pi/Pi^2, t[0] == 0, ϕ[0] == 0,
   r'[0] == 0.01, θ'[0] == 0.003, 
   t'[0] == 0.01, ϕ'[0] == 0.003
   },
  {r, θ, ϕ, t}, {s, 0, 2}]

Initial conditions are randomly set. What this code gives as output are 4 arrays of coordinate $r$, $\theta$, $\phi$ and $t$. Now I want to covert this output from cartesian to spherical coordinate system. I know there is a command for doing such a thing but that will not be helpful here as to use that I need to extract the array computed by NDSolve and then insert into the function and then plot the parametric plot.

So my questions are: (i) Is there a direct way to do that? (ii) else how can I extract the computed array of coordinates? (The array that are outputted is shown as in the attached image)

enter image description here

$\endgroup$
5
  • 2
    $\begingroup$ The code does not execute. $\endgroup$ Commented Jun 24, 2018 at 6:50
  • $\begingroup$ Somebody edited the code. Else it would have. Anyways it's not a problem. What I want is a way to extract the arrays produced by by the NDSolve command. Take any differential equation and solve it using NDSolve whatever the output is how to extract it? $\endgroup$ Commented Jun 24, 2018 at 7:05
  • 2
    $\begingroup$ That was me. And it doesn't make a difference. radial, time, phi, and theta are undefined and seemingly not related to the system of ODE. Actually, there are no ODEs at all. $\endgroup$ Commented Jun 24, 2018 at 7:07
  • $\begingroup$ Yes I agree. That is why I didn't revert it back. :P It was just to give an idea what I am talking about. Anyway? How to extract the array? $\endgroup$ Commented Jun 24, 2018 at 7:14
  • $\begingroup$ Use NDSolveValue rather than NDSolve $\endgroup$
    – m_goldberg
    Commented Jul 4, 2018 at 4:10

2 Answers 2

2
$\begingroup$

The InterpolatingFunctions are Hermite splines of order 3. That is, their internal data consists of triplets of position, derivative, and second derivative. As an example, here the triples for r Partition[(r /. kerr[[1]])[[4, 3]], 3]. You would have to manipulate not only the positions but also first and second derivatives. It is easier to transform the trajectories to Cartesian coordinates this way. (Note that I use NDSolveValue only for convenience.)

kerr = s \[Function] Evaluate[
    NDSolveValue[{
      r''[s] == 0, t''[s] == 0, ϕ''[s] == 0, θ''[s] == 0,
      r[0] == 5, θ[0] == Pi/Pi^2, t[0] == 0, ϕ[0] == 0,
      r'[0] == 0.01, θ'[0] == 0.003, 
      t'[0] == 0.01, ϕ'[0] == 0.003
      },
     {r[s], θ[s], ϕ[s], t[s]}, {s, 0, 2}]
    ];

SphericalToCart = Block[{r, θ, ϕ, t},
   {r, θ, ϕ, t} \[Function] 
    Evaluate[
     Append[CoordinateTransform[ 
       "Spherical" -> "Cartesian", {r, θ, ϕ}], t]]
   ];

curve = s \[Function] SphericalToCart @@ kerr[s];
$\endgroup$
4
  • $\begingroup$ In the code above that I have provided, those are not just accelerations but instead (say) $eqn\phi==0$ is a complete equation which I have not shown above. Equations were monstrously large to be shown here. $\endgroup$ Commented Jun 24, 2018 at 7:54
  • 2
    $\begingroup$ @ShashwatSharan If you provide only an idea what you are talking about in the question, you'll get only an idea how to solve the problem as an answer. "In the code above that I have provided" - a crucial part of solving differential equations are the differential equations. So in fact you didn't provide any code at all. You can either 1) use the idea given by Henrik to work out the solution by yourself, 2) provide everything that's necessary to fully reproduce your issue, or 3) fabricate a nontrivial minimal working example. $\endgroup$
    – corey979
    Commented Jun 24, 2018 at 11:55
  • $\begingroup$ sorry to sound rude. I was just saying because he edited the code not that it was a problem but it doesn't matter. It's not that I didn't acknowledge his answer it's just that I am new to mathematica and programming hence I didn't understand it much. $\endgroup$ Commented Jun 25, 2018 at 0:36
  • $\begingroup$ @ShashwatSharan I didn't think you were rude. I just wanted to point out, as a general advice, that the more complete information you give on your actual problem, the better answer you'll get. And, if you consider Henrik's answer helpful in solving your problem, consider accepting it. $\endgroup$
    – corey979
    Commented Jun 25, 2018 at 21:54
3
$\begingroup$

As I understand the author from another of his topics, he investigates the motion of particles in the Kerr metric. His question concerns the mapping of the trajectory of motion using NDSolve[] and ParametricPlot3D[]. I will give a sample code using his own code

 \[Rho] = r^2 + a^2 Cos[\[Theta]]^2;
\[CapitalDelta] = r^2 - 2 m r + a^2;

metric = {{-\[Rho]^2/\[CapitalDelta], 0, 0, 0}, {0, -\[Rho]^2, 0, 
    0}, {0, 0, -(r^2 + 
         a^2) Sin[\[Theta]]^2 - (2 m r a^2 Sin[\[Theta]]^4)/\[Rho]^2, \
(2 m a r)/\[Rho]^2 Sin[\[Theta]]^2}, {0, 
    0, (2 m a r)/\[Rho]^2 Sin[\[Theta]]^2, (1 - (2 m r)/\[Rho]^2)}};

inversemetric = Simplify[Inverse[metric]];
coord = {r, \[Theta], \[Phi], t};
christ[i_, j_, k_] := 
 christ[i, j, k] = 
  Simplify[Sum[
    1/2 inversemetric[[i, d]] (D[metric[[d, k]], coord[[j]]] + 
       D[metric[[d, j]], coord[[k]]] - 
       D[metric[[j, k]], coord[[d]]]), {d, 1, 4}]]
eq = Table[
   coord[[i]]'' + 
    Sum[christ[i, j, k] coord[[j]]' coord[[k]]', {j, 1, 4}, {k, 1, 
      4}], {i, 1, 4, 1}];
eqs = eq /. {r'' -> 
     r''[s], \[Theta]'' -> \[Theta]''[s], \[Phi]'' -> \[Phi]''[s], 
    t'' -> t''[s], 
    r' -> r'[s], \[Theta]' -> \[Theta]'[s], \[Phi]' -> \[Phi]'[s], 
    t' -> t'[s], 
    r -> r[s], \[Theta] -> \[Theta][s], \[Phi] -> \[Phi][s], 
    t -> t[s]};
EQ = Table[eqs[[i]] == 0 /. {m -> 1, a -> .3}, {i, 1, 4}];
kerr = NDSolve[{EQ, r[0] == 5, \[Theta][0] == Pi/2, 
    t[0] == 0, \[Phi][0] == 0, r'[0] == -0., \[Theta]'[0] == 0.00006, 
    t'[0] == 1, \[Phi]'[0] == 0.003}, {r, \[Theta], \[Phi], t}, {s, 0,
     2000}];
ParametricPlot3D[
 Evaluate[{Sqrt[a^2 + r[s]^2]*Sin[\[Theta][s]]*Cos[\[Phi][s]], 
     Sqrt[a^2 + r[s]^2]*Sin[\[Theta][s]]*Sin[\[Phi][s]], 
     r[s]*Cos[\[Theta][s]]} /. kerr /. a -> .3], {s, 0, 2000}, 
 ColorFunction -> Hue, AxesLabel -> {"x", "y", "z"}]

fig1

$\endgroup$
3
  • $\begingroup$ In the Kerr metric, it seems that the calculation in the inverse metric of kerr have a problem? $\endgroup$ Commented Mar 18, 2022 at 9:17
  • $\begingroup$ @Stone What problem do you have with Kerr metric? $\endgroup$ Commented Mar 18, 2022 at 10:52
  • $\begingroup$ Thanks for your interest. I saw in the general relativity book, about the definition of the contravariant form of the metric. The contravariant form of the metric is equal to the metric's algebraic cofactor divided by the metric's determinant. I've tried both the algebraic cofactor case and the direct inverse form, and the results are not the same. If it is a spherically symmetric Schwarzschild metric, the results of both are the same. But the Kerr metric is axisymmetric, so I have this doubt. Thank you for your attention. $\endgroup$ Commented Mar 20, 2022 at 2:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.