Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 26 additions & 53 deletions rocketpy/Rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ def __init__(

# Parachute data initialization
self.parachutes = []

# Parachute's Calculated Cds data initialization
self.calculated_cds = []

# Rail button data initialization
self.railButtons = None
Expand Down Expand Up @@ -662,63 +665,27 @@ def cnalfa1(cn):
# Return self
return self.aerodynamicSurfaces[-1]

def calculateCds(
self,
finalSpeed = 9,
finalAirDensity = None,
parachuteKind = None,
Cd = None,
area = None
):
"""Calculates the parachute's Cds using its final speed and
air density or its area, that can be given or calculated through
the Cd or kind of the parachute
def calculate_cds(self, final_speed = 9, final_air_density):
"""Returns the parachute's Cds calculated through its final speed and
air density.

Parameters
----------
finalSpeed : float
Final speed of the system rocket/parachute.
finalAirDensity : float
Air density at the lowest height in which the parachute
is being used.
parachuteKind : string
Indicates the format of the parachute.
Cd : float
Value of the parachute's dragg coefficient.
area : float
Surface area of the parachute in squared meters.
final_speed : float, optional
Rocket's speed when landing.
final_air_density : float
Air density right before the rocket lands.

Returns
-------
Cds : float
Estimated Cds of the parachute.
cds : float
Number equal to drag coefficient times reference area for parachute.

"""

if finalAirDensity != None:
Cds = 2 * self.mass * 9.80665 / ((finalSpeed ** 2) * finalAirDensity)

elif Cd != None:
Cds = area * Cd

else:
if parachuteKind == "quarter spherical":
Cd = 0.88

if parachuteKind == "semi-ellipsoidal":
Cd = 0.6

if parachuteKind == "hemispherical":
Cd = 0.7

if parachuteKind == "flat circular":
Cd = 0.75

if parachuteKind == "conical":
Cd = 0.8

if parachuteKind == "toroidal":
Cd = 0.8
Cds = area * Cd
return Cds
cds = 2 * self.mass * 9.80665 / ((final_speed ** 2) * final_air_density)
self.calculated_cds.append(cds)
return cds

def addParachute(
self, name, CdS, trigger, samplingRate=100, lag=0, noise=(0, 0, 0)
Expand Down Expand Up @@ -951,7 +918,10 @@ def info(self):
# Print parachute data
for chute in self.parachutes:
print("\n" + chute.name.title() + " Parachute")
print("CdS Coefficient: " + str(chute.CdS) + " m2")
if chute.CdS in self.calculated_cds:
print("Calculated CdS Coefficient: " + str(chute.CdS) + " m2")
else:
print("CdS Coefficient: " + str(chute.CdS) + " m2")

# Show plots
print("\nAerodynamics Plots")
Expand Down Expand Up @@ -1029,8 +999,11 @@ def allInfo(self):

# Print parachute data
for chute in self.parachutes:
print("\n" + chute.name.title() + " Parachute")
print("CdS Coefficient: " + str(chute.CdS) + " m2")
print("\n" + chute.name.title() + " Parachute")
if chute.CdS in self.calculated_cds:
print("Calculated CdS Coefficient: " + str(chute.CdS) + " m2")
else:
print("CdS Coefficient: " + str(chute.CdS) + " m2")
if chute.trigger.__name__ == "<lambda>":
line = getsourcelines(chute.trigger)[0][0]
print(
Expand Down