필터 지우기
필터 지우기

Attempt to decrease timestep just adds more steps

조회 수: 1 (최근 30일)
Tom Oud
Tom Oud 2018년 12월 13일
답변: Walter Roberson 2018년 12월 13일
Writing a script which is supposed to simulate the trajectory of a water rocket. Having some trouble conrtolling the timestep though. When I make dt smaller, all that seems to happen is more steps being added instead of the actual increment decreasing. What am I doing wrong?
This is my code so far:
close all
clear all
P0 = 6e5; %Pa
Pout = 1e5; %Pa
V0 = 2e-3; %m^3
V(1) = 1.5e-3; %m^3
gamma = 1.4;
rho_w = 998; %kg/m^3
Rn = 0.002; %m
dt = 0.01;
t = 1:dt:10;
Ve(1) = 0; %m/s
Pin(1) = 6e5; %Pa
SP0 = 0; %m/s
SP = 0; %m/s
M0 = 0.1; %kg
M(1) = M0 + (V0-V)*rho_w;
for i = 1:numel(t)
k = t(i);
Pin(i+1) = Pin(i) - P0*(V(i)/V0).^-gamma;
Ve(i+1) = sqrt(2*(Pin(i) - Pout)/rho_w);
M(i+1) = M(i) - Ve(i)*pi*Rn.^2*rho_w;
V(i+1) = V0*(Pin(i)/P0).^gamma;
if V(i) > V0 - 1e-18
V(i+1) = V(i);
end
if M(i) < M0 + 1
M(i+1) = M0;
end
if Pin(i) < Pout
Pin(i+1) = Pout;
Ve(i+1) = Ve(i);
end
%SP = Ve*log(M0/M) + SP0;
end

채택된 답변

Walter Roberson
Walter Roberson 2018년 12월 13일
You should be multiplying the change by dt.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by