Effacer les filtres
Effacer les filtres

Attempt to decrease timestep just adds more steps

1 vue (au cours des 30 derniers jours)
Tom Oud
Tom Oud le 13 Déc 2018
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

Réponse acceptée

Walter Roberson
Walter Roberson le 13 Déc 2018
You should be multiplying the change by dt.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by