필터 지우기
필터 지우기

Help me understand!

조회 수: 4 (최근 30일)
Nour Butrus
Nour Butrus 2022년 2월 14일
댓글: AndresVar 2022년 2월 16일
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
David Hill
David Hill 2022년 2월 14일
Show us what you have done (your code) and ask a specific question.
Nour Butrus
Nour Butrus 2022년 2월 14일
Hey! Below are the tasks I am asked to solve, with the my code.
I am a 2nd year undergraduate student so I apologise that it is not perfect :)
Task 1
clc
clear all
%task #1
%Initial conditions
p=0.05;
P1=[0,0,0]; V1=[p,p,p];
P2=[1,0,0]; V2=[-p,p,p];
P3=[0,0,1]; V3=[-p,-p,-p];
V0=transpose([P1 V1 P2 V2 P3 V3]);
%Masses/Scalars M_i
M1=1; M2=2; M3=0.5;
Task 2
function F= Force(P,M,P1,M1,P2,M2)
F=((-1)*(M*M1).*(P-P1)/((norm(P-P1).^3)))-(1*M*M2.*(P-P2)./((norm(P-P2)).^3));
end
Task 3
function Y=RHS(t,X)
F1=Force(P1,M1,P2,M2,P3,M3);
F2=Force(P2,M2,P1,M1,P3,M3);
F3=Force(P3,M3,P1,M1,P2,M2);
Y=[{V1} {F1./M1} {V2} {F2./M2} {V3} {F3./M3}];
end

댓글을 달려면 로그인하십시오.

채택된 답변

AndresVar
AndresVar 2022년 2월 14일
편집: AndresVar 2022년 2월 16일
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
Nour Butrus
Nour Butrus 2022년 2월 15일
Thanks a lot! So it is the case that I have to represent my initial values of and values of calculated with the intital positions in the vector Y, but am I mistaken to understand that I have to use that vector as to implement Runge-Kutta?
AndresVar
AndresVar 2022년 2월 16일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by