I have a simulated system as shown in the following image:

bodies in simulation

$L_0$ is attached to two other bodies $L_1$ and $L_2$. Furthermore, body $L_3$ is also in the simulation (it is attached to $L_2$ but that is not important). Each body has a position, so $L_0$'s position is $\vec{P}^0 = (x_0, y_0)$, $L_1$'s position is $\vec{P}^1 = (x_1, y_1)$, and so on.

$L_0$'s movement is governed by two forces, a linear attraction force to bodies it is attached to:

$\vec{A}_0 = \frac{\Delta P}{\Delta t} = k(\vec{P}^1 - \vec{P}^0) + k(\vec{P}^2 - \vec{P}^0)$

which adheres to Hook's Law of springs: $\vec{F} = -kr$ where $r$ is the distance between the two bodies. and a non-linear repulsion force which acts on $L_0$ from all other bodies:

$\vec{R} = \frac{\Delta P}{\Delta t} = \vec{U}^{01} \frac{Gm^0m^1}{|\vec{P}^0 - \vec{P}^1|^2} + \vec{U}^{02} \frac{Gm^0m^2}{|\vec{P}^0 - \vec{P}^2|^2} + \vec{U}^{03} \frac{Gm^0m^3}{|\vec{P}^0 - \vec{P}^3|^2}$

Where $\vec{U}^{01}$ is the direction vector from $L_1$ to $L_0$, so

$\vec{U}^{01} = \frac{\vec{P}^1 - \vec{P}^0}{|\vec{P}^1 - \vec{P}^0|}$ and the same is true for $\vec{U}^{02}$ and $\vec{U}^{03}$

This force adheres to Newton's law of gravity between two bodies with masses $m^1$ and $m^2$, $\vec{F} = \frac{Gm^1m^2}{r^2}$ where $r$ is the distance between the two bodies (so the repulsion increases quadratically as the bodies get closer)

In essence then, $L_0$'s movement is governed by the equation:

$\frac{\Delta P}{\Delta t} = k(\vec{P}^1 - \vec{P}^0) + k(\vec{P}^2 - \vec{P}^0) + \vec{U}^{01} \frac{Gm^0m^1}{|\vec{P}^0 - \vec{P}^1|^2} + \vec{U}^{02} \frac{Gm^0m^2}{|\vec{P}^0 - \vec{P}^2|^2} + \vec{U}^{03} \frac{Gm^0m^3}{|\vec{P}^0 - \vec{P}^3|^2}$

In my simulation, I want to use the implicit (Backward Euler) method of the discretized equation, so I discretize to:

$\vec{P}_{n+1}^0 = \vec{P}_n^0 + \Delta tk(\vec{P}_n^1 - \vec{P}_n^0) + \Delta tk(\vec{P}_n^2 - \vec{P}_n^0) + \Delta t\vec{U}_n^{01} \frac{Gm^0m^1}{|\vec{P}_n^0 - \vec{P}_n^1|^2} + \Delta t\vec{U}_n^{02} \frac{Gm^0m^2}{|\vec{P}_n^0 - \vec{P}_n^2|^2} + \Delta t\vec{U}_n^{03} \frac{Gm^0m^3}{|\vec{P}_n^0 - \vec{P}_n^3|^2}$

and then substitute $P_{n+1}^0$ instead of $P_n^0$ at the appropriate places to get:

$\vec{P}_{n+1}^0 = \vec{P}_n^0 + \Delta tk(\vec{P}_n^1 - \vec{P}_{n+1}^0) + \Delta tk(\vec{P}_n^2 - \vec{P}_{n+1}^0) + \Delta t\frac{\vec{P}_{n+1}^0 - \vec{P}_n^1}{|\vec{P}_{n+1}^0 - \vec{P}_n^1|} \frac{Gm^0m^1}{|\vec{P}_{n+1}^0 - \vec{P}_n^1|^2} + \Delta t\frac{\vec{P}_{n+1}^0 - \vec{P}_n^2}{|\vec{P}_{n+1}^0 - \vec{P}_n^2|} \frac{Gm^0m^2}{|\vec{P}_{n+1}^0 - \vec{P}_n^2|^2} + \Delta t\frac{\vec{P}_{n+1}^0 - \vec{P}_n^3}{|\vec{P}_{n+1}^0 - \vec{P}_n^3|} \frac{Gm^0m^3}{|\vec{P}_{n+1}^0 - \vec{P}_n^3|^2}$

This is where I'm stuck. How do I solve for $P_{n+1}^0$? Can I isolate it? do I need to use Newton's method, and if so how do I do that for a 2-coordinate vector?

The example talks about $L_0$, but I actually have to do it for each of the bodies described. So I hope the answer I get could be generalized for $L_1$, $L_2$, and $L_3$

  • $\begingroup$ Yes, Newton's method will probably work well here. $\endgroup$ – David Ketcheson Apr 19 '16 at 3:49
  • $\begingroup$ You can find an example of Newton's method for systems here: scicomp.stackexchange.com/questions/11212/… (and many other places on the internet, in books, etc.) $\endgroup$ – David Ketcheson Apr 19 '16 at 8:25
  • $\begingroup$ So just to make sure I got it right. I will basically express both the $x$ and $y$ components of the vector $\vec{P}_{n+1}^0$ (which will be some hideous combination of the $x$ and $y$ components of all vectors in question), and then find the derivative of each component, and use Newton's method on each component individually at each iteration (i.e. find the $k+1$ estimate for x, then for y, then find the $k+2$ estimate for x, then for y, and so on)? $\endgroup$ – WhiteTiger Apr 19 '16 at 19:56

Browse other questions tagged or ask your own question.