Help me understand!
2 views (last 30 days)
Show older comments
I am presented with a task of simulating the movement of three bodies with a constant mass using Newton's laws.
The task is very easy to follow and I have no trouble understanding it, until it comes to solving the differential equation using Runge-Kutta, where M is the mass of a body, is the second derivative of the position, namely, the acceleration and F is the force applied on M due to the two other masses.
Please refer to task number 3 below
Where equation 3 is I am finding it particularly difficult to understand why the right hand of the equation is a column consisten of what appears to be the velocity V for each body and the acceleration .
I would highly appreciate any guidance to the interpertation of the task!
2 Comments
Accepted Answer
AndresVar
on 14 Feb 2022
Edited: AndresVar
on 16 Feb 2022
Equation 3 is a 2nd order system p''=..., the RK3 is given for 1st order p'=...(see it's first difference ) =..)
See for example equation 14 here: part1.pdf (nyu.edu)
you can see how order is reduced by introducing firts time derivatives (V's) as new variables
2 Comments
AndresVar
on 16 Feb 2022
f = Y = RHS(t,X). The RHS you commented above looks good just make sure P1=X(1), V1=X(2)... etc as defined in task#1. You didn't say, but I guess velocity is constant?
% at t0
Y0 = RHS(t0,X0)
% one step later Y(t0+h)=Y1
K1=h*Y0;
K2=h*RHS(t+h/2,Y0+h/2);
K3=...
Y1 = Y0 + 1/6(K1+4*K2+K3)
% two steps later Y(t0+2h)=Y2
K1=h*Y1;
K2=...
K3=...
Y2 = Y1 + 1/6(K1+4*K2+K3)
code repeats, so just turn it into a loop for N steps
h = 0.01;
t(1) = 0;
Y(1)=RHS(t0,X0) %initial
for ii = 1:N
t(ii+1) = t(ii)+h
K1 =...
K2 =...
K3 =...
Y(ii+1) = Y(ii)+1/6(K1+4*K2+K3);
end
plot the forces vs time to see if they behave nicely... if not then you can play with the step size h
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!