Attempt to decrease timestep just adds more steps

9 ビュー (過去 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 Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by