bump
Implement friction into a model, related to the velocity. (Missile Launch)
조회 수: 2 (최근 30일)
이전 댓글 표시
Does anyone know how I could implement friction into my code located down below?
The friction should be defined as: Ff_vector = - gamma * | v_vector | * v_vector, and should be substracted from the different velocity components of the missile.
The current distance and time outputs I get from running my code are (without friction implemented):
Also important to note is that there is no thrust, just a starting velocity of 2000 m/s.
The rocket also has a mass now of 500 kg.
clear;
close all;
clc;
tic
tic
aT = 0;
ad = 0;
format long
for i = [37:2:53]
r = 6371 * 10^3;
G = 6.674 * 10^-11;
M = 5.972 * 10^24;
g = (G * M)/(r^2);
theta0 = i;
ax = 0;
ay = r;
v0 = 2000;
vx0 = v0*cosd(theta0);
vy0 = v0*sind(theta0);
x = 0;
y = r;
vx = vx0;
vy = vy0;
T = 0;
dt = 0.01;
at = 0;
landed = 0;
z = 1;
while landed == 0
z = z + 1;
T = T + dt;
xo = x;
yo = y;
x = x + vx * dt;
y = y + vy * dt;
d = sqrt(x^2 + y^2);
alpha = atand(x/y);
g = (G*M)/(d^2);
gy = cosd(alpha) * g;
gx = sind(alpha) * g;
vy = vy - (gy * dt);
vx = vx - (gx * dt);
v = vx/sin(alpha);
ax = [ax, x];
ay = [ay, y];
if d < r
landed = 1;
end
end
aT = [aT, T]; % This is the list of times it took for each missile to land
distance = (alpha/360) * 2 * pi * r;
ad = [ad, distance]; % This is the list of distances each missile travelled
figure(1)
th = 2.8*pi/6:pi/500:3.1*pi/6;
xunit = r * cos(th) + 0;
yunit = r * sin(th) + 0;
figure(2)
hold on
plot(ax, ay)
toc
end
th = 2.8*pi/6:pi/500:3.1*pi/6;
xunit = r * cos(th) + 0;
yunit = r * sin(th) + 0;
plot(xunit, yunit)
hold off
legend('37 degrees', '39 degrees', '41 degrees', '43 degrees', '45 degrees', '47 degrees', '49 degrees', '51 degrees', '53 degrees', 'earth')
title('The trajectory of the different missiles')
xlabel('x(m)')
ylabel('y(m)')
toc
The desired output, with friction included should be:
Any help is immensly appreciated!
댓글 수: 3
Walter Roberson
2020년 1월 25일
should be substracted from the different velocity components of the missile.
Would that be before or after
x = x + vx * dt;
y = y + vy * dt;
? Are you calculating the friction coefficients before moving, or are you calculating them after moving ?
답변 (1개)
Jim Riggs
2020년 1월 26일
This question is familiar.
look here.
댓글 수: 2
Jim Riggs
2020년 1월 26일
편집: Jim Riggs
2020년 1월 26일
Assuming that the code gives you the correct answer without the friction term, to add friction do the following;
change this:
vy = vy - gy * dt;
vx = vx - gx * dt;
to this:
Vtot = sqrt(vx^2 + vy^2);
Fy = -gamma * Vtot * vy;
Fx = -gamma * Vtot * vx;
vy = vy + dt*(Fy/mass - gy);
vx = vx + dt*(Fx/mass - gx);
mass is 500 kg.
EDIT: after some thought, it ocurrs to me that the 1/mass factor could be included in gamma. There is no way for me to know. If this is the case, then omit the division by mass "/mass"
참고 항목
카테고리
Help Center 및 File Exchange에서 Biotech and Pharmaceutical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!