Water Rocket Code

This MATLAB code simulates the initial velocity of a water rocket based on varying air-water ratios (\alpha) and internal air pressures (P), and visualizes the results in a 3D surface plot.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
close all
clear
aa=0.0001; %The water flow rate
A=0.00038; %Exit area is 0.00038m^2
rho=1000; %The water density is 1000kg/m^3
V=0.00125; %The volume of bottle is 0.00125m^3
u(1)=0; %Initial velocity is 0 m/s
mm=0.01; %The quality of the bottle is 0.01kg
P=100:1:900; %The air pressure inside bottle (kPa)
for j=1:length(P)
p=P(j);
alpha=0.1:0.01:0.9; %The ratio of air and water
for k=1:length(alpha)
M(1)=(1-alpha(k))*V*rho;
i=1;
u=[];
while M(i)>0
if p(i)>0
p(i+1)=(p(i)+101.325)*(((alpha(k)+aa*(i-1))/(alpha(k)+aa*(i))))^1.4-101.325; %Isentropic flow equation
u(1)=0;
v(i)=sqrt(2*p(i)*1000/rho);
m(i)=rho*v(i)*A;
t(i)=aa*V*rho/m(i);
M(i+1)=M(i)-aa*V*rho;
a(i)=(m(i)*v(i))/(M(i+1)+mm);
u(i+1)=u(i)+a(i)*t(i);
else
u(i+1)=u(i);
M(i+1)=0;
end
i=i+1;
end
U(j,k)=max(u);
end
end
figure,
surf(alpha,P,U,'LineStyle','none','FaceColor','interp','FaceLighting','Gouraud');
colormap("cool")
title('Water Rocket Optimal Air-Water Ratio and Pressure', 'fontsize', 18);
xlabel('Air-to-Water Ratio (\alpha)', 'fontsize', 12);
ylabel('Pressure (kPa)', 'fontsize', 12);
zlabel('Initial Velocity (m/s)', 'fontsize', 12);
set(gca, 'fontsize', 12);
打赏
  • © 2020-2025 Yu Xia
  • Powered by Hexo Theme Ayer
    • PV:
    • UV:

Buy me a cup of coffee~

支付宝
微信