Professional Documents
Culture Documents
clear all
close all
clc;
%Constants
g = 9.81; %acceleration of gravity
Cd = 0.5; %drag coefficient for sphere
R = 2077.1; % gas const helium kg/m^3
massb = 500; %mass of balloon material in kg
masspass = 65 * 10; %mass of passengers in kg
masscraft = 10000; %mass of capsule in kg
%Initial values
vol = 15000; %initial balloon volume in meters cubed
alt(1) = 0;
deltat = 1;
rhov(i) = rho;
Pv(i) = P;
Tv(i) = T;
rhohelium(i) = P / (R*T); %Density of helium @ altitude
Volatalt(i) = masshelium/rhohelium(i); %volume of balloon @ altitude
Diamatalt(i) = 2 * (((3/4) * (Volatalt(i) / pi))^(1/3)); %Diameter of balloon @
altitude
Fb(i) = rho * Volatalt(i) * g; %Buoyant force
if i==1
Ftot(i) = Fb(i) - Weight;
else
Ftot(i) = Fb(i) - Weight - Drag(i-1); %Total force without accounting for
drag
end
Acc(i) = 0.01; % Ftot(i) / masstot;; %Acceleration from F=ma
if i==1
Velocity(i) = (Acc(i) * deltat);
else
Velocity(i) = (Velocity(i-1) + Acc(i) * deltat); %Velocity from acceleration
end
Drag(i) = 0.5 * Cd * rho * Velocity(i)^2 * ((pi/4) * Diamatalt(i)^2); %Drag
calculation
alt(i+1) = alt(i) + Velocity(i) * deltat/0.308;
% Plotting
figure(1);
subplot(3, 3, 1);
plot(Tv,alt(1:end-1));
title('Air/Helium Temperature vs Altitude');
xlabel('Temperature (K)');
ylabel('Altitude (ft)');
subplot(3, 3, 2);
plot(Pv,alt(1:end-1))
title('Air/Helium Pressure vs Altitude')
xlabel('Pressure (N/m^2)')
ylabel('Altitude (ft)')
subplot(3, 3, 3);
plot(rhov,alt(1:end-1));
hold on
plot(rhohelium,alt(1:end-1));
hold off
legend('Air', 'Helium');
title('Density of Air and Helium vs Altitude')
xlabel('Density (kg/m^3)')
ylabel('Altitude (ft)')
subplot(3, 3, 4);
plot(Volatalt,alt(1:end-1));
title('Volume of Balloon');
xlabel('Volume (m^3)');
ylabel('Altitude (ft)');
subplot(3, 3, 5);
plot(Diamatalt, alt(1:end-1));
title('Diameter of Balloon');
xlabel('Diameter (m)');
ylabel('Altitude (ft)');
subplot(3, 3, 6);
plot(Velocity,alt(1:end-1));
title('Velocity of Craft');
xlabel('Velocity (m/s)');
ylabel('Altitude (ft)');
subplot(3, 3, 7);
plot(Acc,alt(1:end-1));
title('Acceleration of Craft');
xlabel('Acceleration (m/s^2)');
ylabel('Altitude (ft)');
xlim([-.05,0.05]);
subplot(3, 3, 8);
plot(Drag,alt(1:end-1));
title('Drag');
xlabel('Force (N)');
ylabel('Altitude (ft)');
subplot(3, 3, 9);
plot(Fb,alt(1:end-1));
title('Net Buoyancy Force');
xlabel('Force (N)');
ylabel('Altitude (ft)');
altsteps = Velocity*deltat;
time = [0:1:9999];
figure(2)
plot(time, altsteps)
title('Time');
xlabel('Time (s)');
ylabel('Altitude (10^3 ft)');
xlim([0,10000]);
ylim([0,110]);
hold on
Descending Code:
clear all
close all
clear;
clc;
%Constants
g = 9.81; %acceleration of gravity
Cd = 0.5; %drag coefficient for sphere
R = 2077.1; % gas const helium kg/m^3
massb = 500; %mass of balloon material in kg
masspass = 65 * 10; %mass of passengers in kg
masscraft = 10000; %mass of capsule in kg
%Initial values
pres100 = 1090.2; %from atmos at 100k feet
T100= 227.13; %from atmos at 100k feet
rhohe100 = pres100./(R.*T100);
vol = masshelium./rhohe100; % balloon volume in meters cubed
alt(10000) = 100000;
deltat = 1;
%Descent
masshelium2 = masshelium-5; %removing () kg of helium
masstot2 = masshelium2+massb+masspass+masscraft; % new mass total
Weight = masstot2*g;
for i=10000 : -1 : 2
altmeters(i) = 0.3048 * alt(i);
[rho,a,T,P,nu,z,sigma] = atmos(altmeters(i)); %Temp, speed of sound, Pressure,
density @ altitude
rhov(i) = rho;
Pv(i) = P;
Tv(i) = T;
rhohelium(i) = P / (R*T); %Density of helium @ altitude
Volatalt(i) = masshelium2/rhohelium(i); %volume of balloon @ altitude
Diamatalt(i) = 2 * (((3/4) * (Volatalt(i) / pi))^(1/3)); %Diameter of balloon @
altitude
Fb(i) = rho * Volatalt(i) * g; %Buoyant force
if i==10000
Ftot(i) = Fb(i) - Weight;
else
Ftot(i) = Fb(i) - Weight + Drag(i+1); %Total force without accounting for
drag
end
if i==10000
Velocity(i) = 0;
Velocity(i-1) = (Acc(i) * deltat);
else
Velocity(i-1) = (Velocity(i+1) + Acc(i) * deltat); %Velocity from
acceleration
end
Drag(i) = 0.5 * Cd * rho * Velocity(i)^2 * (4*pi * (Diamatalt(i)./2).^2); %Drag
calculation
if alt(i-1) == 0
alt(i-1) = 0;
break
end
end
% Plotting
figure(1);
subplot(3, 3, 1);
plot(Tv,alt);
title('Air/Helium Temperature vs Altitude');
xlabel('Temperature (K)');
ylabel('Altitude (ft)');
ylim([0,100000]);
subplot(3, 3, 2);
plot(Pv,alt)
title('Air/Helium Pressure vs Altitude')
xlabel('Pressure (N/m^2)')
ylabel('Altitude (ft)')
ylim([0,100000]);
subplot(3, 3, 3);
plot(rhov,alt);
hold on
plot(rhohelium,alt);
hold off
legend('Air', 'Helium');
title('Density of Air and Helium vs Altitude')
xlabel('Density (kg/m^3)')
ylabel('Altitude (ft)')
ylim([0,100000]);
subplot(3, 3, 4);
plot(Volatalt,alt);
title('Volume of Balloon');
xlabel('Volume (m^3)');
ylabel('Altitude (ft)');
ylim([0,100000]);
subplot(3, 3, 5);
plot(Diamatalt, alt);
title('Diameter of Balloon');
xlabel('Diameter (m)');
ylabel('Altitude (ft)');
ylim([0,100000]);
subplot(3, 3, 6);
plot(Velocity,alt);
title('Velocity of Craft');
xlabel('Velocity (m/s)');
ylabel('Altitude (ft)');
ylim([0,100000]);
subplot(3, 3, 7);
plot(Acc,alt);
title('Acceleration of Craft');
xlabel('Acceleration (m/s^2)');
ylabel('Altitude (ft)');
xlim([-.05,0.05]);
ylim([0,100000]);
subplot(3, 3, 8);
plot(Drag,alt);
title('Drag');
xlabel('Force (N)');
ylabel('Altitude (ft)');
ylim([0,100000]);
subplot(3, 3, 9);
plot(Fb,alt);
title('Net Buoyancy Force');
xlabel('Force (N)');
ylabel('Altitude (ft)');
ylim([0,100000]);
altsteps = -2*Velocity*deltat;
time = [0:1:9999];
figure(2)
plot(time, altsteps)
title('Time');
xlabel('Time (s)');
ylabel('Altitude (10^3 ft)');
xlim([0,10000]);
ylim([0,110]);
hold on
Additional Code:
time = [0:1:7200];
altitude = 100;
u = repelem(altitude,7201);
plot(time, u)
title('Time');
xlabel('Time (s)');
ylabel('Altitude (10^3 ft)');
xlim([0,7200]);
ylim([0,110]);
hold on