Skip to content

Commit 818f8ad

Browse files
committed
Changed interface to use initial volume instead of initial radius
1 parent f1bb304 commit 818f8ad

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

Balloon.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from cmath import isinf, isnan
22
import numpy as np
33
import Air
4-
from Universe import vol_sphere, molar_mass_he, g, R
4+
from Universe import radius_sphere, vol_sphere, molar_mass_he, g, R
55
from Instrument import probe
66
'''
77
Mass: Kilogram
@@ -22,6 +22,9 @@ class Balloon():
2222
# Balloon Mass
2323
m_balloon: float = 2000e-3
2424

25+
# Initial Gas Volume
26+
vol_gas_i: float = 9
27+
2528
# Balllon Initial Radius
2629
r_i: float = 1.4 / 2 # m
2730
# Balllon Burst Radius
@@ -39,32 +42,31 @@ class Balloon():
3942
parachute_r: float = 1.3
4043

4144

42-
def __init__(self, balloon_mass: float, payload_mass: float, initial_diameter: float, burst_diameter: float, drag_coef: float, parachute_diameter: float, parachute_drag_coeff: float) -> None:
45+
def __init__(self, balloon_mass: float, payload_mass: float, initial_volume: float, burst_diameter: float, drag_coef: float, parachute_diameter: float, parachute_drag_coeff: float) -> None:
4346
'''
4447
Creates balloon object
4548
balloon_mass: 1000g, 2000g etc
4649
payload_mass: in kilograms
47-
initial_diameter: balloon start diameter
50+
initial_volume: balloon filled volume (m3)
4851
burst_diameter:
4952
drag_coef: Drag Coefficient
5053
parachute_diameter:
5154
parachute_drag_coeff:
5255
'''
5356
self.m_balloon = balloon_mass * 1e-3
5457
self.m_payload = payload_mass
55-
self.r_i = initial_diameter /2
58+
self.vol_gas = initial_volume
59+
self.r_i = radius_sphere(initial_volume)
5660
self.r_f = burst_diameter /2
5761
self.drag_coeff = drag_coef
5862
self.parachute_Dcoeff = parachute_drag_coeff
5963
self.parachute_r = parachute_diameter /2
60-
61-
vol_gas = vol_sphere(self.r_i)
62-
m_gas = vol_gas * Air.p_he
64+
m_gas = self.vol_gas * Air.p_he
6365

6466
print(f"Payload Mass: {self.m_payload}kg")
6567
print(f"Balloon:\n \tSize: {balloon_mass}g \n\
66-
\tInitial Diameter: {initial_diameter:.2f}m\n\
67-
\tInitial Volume: {vol_gas:.2f}m3\n\
68+
\tInitial Diameter: {initial_volume:.2f}m\n\
69+
\tInitial Volume: {self.vol_gas:.2f}m3\n\
6870
\tBurst Diameter: {burst_diameter:.2f}m\n\
6971
\tExpected He Mass: {m_gas:.4f}kg\n\
7072
\tDrag Coefficient: {drag_coef:.3f}")
@@ -103,7 +105,7 @@ def drag(self, altitude: float, velocity: float) -> float:
103105
self.drag_coeff = self.parachute_Dcoeff
104106
area = np.pi * (self.parachute_r) ** 2
105107
else:
106-
radius = ((3.0/4.0/np.pi) * self.volume(altitude)) ** (1/3)
108+
radius = radius_sphere(self.volume(altitude))
107109
area: float = np.pi * radius * radius
108110

109111
d: float = -(1/2) * self.drag_coeff * Air.density(altitude) * area * (abs(velocity)*velocity)

Universe.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212

1313
def vol_sphere(radius: float) -> float:
1414
return (4/3) * pi * radius**3
15+
16+
def radius_sphere(volume:float) -> float:
17+
return ((3.0/4.0/pi) *volume) ** (1/3)

main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ def main():
2626

2727
print(f"Duration: {time_str}")
2828

29-
balloon = Balloon(balloon_mass=1000, #
30-
payload_mass=1.2, #
31-
initial_diameter=1.909, #
29+
balloon = Balloon(balloon_mass=3000, #
30+
payload_mass=4, #
31+
initial_volume=9, #
3232
burst_diameter=7.86, #
33-
drag_coef=0.35, #
33+
drag_coef=0.35, #
3434
parachute_diameter=1.5, #
3535
parachute_drag_coeff=0.6)
3636

0 commit comments

Comments
 (0)