Skip to content
This repository was archived by the owner on Oct 30, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
70fefd5
added parachute testing code
a6zero Aug 27, 2022
8bc0567
Incomplete basis for parachute shock functions
a6zero Aug 27, 2022
c312953
Create Jasns_analysis_version_1.0.py
a6zero Aug 28, 2022
1e46abd
Made a test profile to test analysis class
a6zero Aug 28, 2022
958f6dc
Moved and renamed analysis
jkan1001 Aug 28, 2022
5627c05
Move and rename analysis (finish commit)
jkan1001 Aug 28, 2022
baefcc3
removed flight parameter from apogee func
jkan1001 Aug 28, 2022
8949734
added valid Drag function args
jkan1001 Aug 28, 2022
fc98611
fixed indentation of chute_radius_finder
jkan1001 Aug 28, 2022
e90ab2f
Added out of rail velocity func
jkan1001 Aug 28, 2022
b833948
Added Function return to apogee_by_mass func
jkan1001 Aug 28, 2022
176e5e2
fixes for radius finder
jkan1001 Aug 28, 2022
85020e9
Updated analysis class
a6zero Aug 28, 2022
274fbbb
Create Jasns_... file for merge
jkan1001 Aug 28, 2022
fa3340c
Merge branch '#18_#72_#73_07' of https://github.com/Jasn6z/RocketPy-H…
a6zero Aug 28, 2022
6ec9edb
Transferred new chute funcs to Analysis from jasn
jkan1001 Aug 28, 2022
90ed7ad
Renamed my_stuff to hackathon_tests
jkan1001 Aug 28, 2022
effab2b
Changed motor and rocket in integration test
jkan1001 Aug 28, 2022
73395be
corrected attribute references in Analysis. const
jkan1001 Aug 28, 2022
555b528
Created Analysis instance for testing
jkan1001 Aug 28, 2022
a8c92dc
fixed drag function issue
jkan1001 Aug 28, 2022
d17b450
Made some fixes and added some testing
jkan1001 Aug 28, 2022
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,3 @@ fetchCuritibaRioSaoPauloEnsemble.py

# Tests
naboI/

455 changes: 455 additions & 0 deletions hackathon_tests/InstantaneousShockForce.ipynb

Large diffs are not rendered by default.

575 changes: 575 additions & 0 deletions hackathon_tests/Integration_tests.ipynb

Large diffs are not rendered by default.

1,600 changes: 1,600 additions & 0 deletions hackathon_tests/Parachute_stuff.ipynb

Large diffs are not rendered by default.

157 changes: 157 additions & 0 deletions rocketpy/Analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
from .Flight import Flight
from .Function import Function
from .Rocket import Rocket

class Analysis:
def __init__(self, flight: Flight):
self.flight = flight
self.rocket = self.flight.rocket
self.motor = self.rocket.motor
self.env = self.flight.env

def apogee_by_mass(self):
"""
Returns a RocketPy Function that, for a given Flight configuration,
estimates the apogee as a function of the dry mass of the rocket.

Returns:
RocketPy Function that provides predicted apogee as a function of dry mass
"""
og_mass = self.rocket.mass # immutable value creates different object unaffected by subsequent code
# Create version of flight that has variable mass
def apogee(mass):
self.rocket.mass = mass

test_flight = Flight(
rocket=self.rocket,
environment=self.env,
inclination=self.flight.inclination,
heading=self.flight.heading,
terminateOnApogee=True,
)

return test_flight.apogee

# restore original mass of rocket
self.rocket.mass = og_mass
return Function(apogee, inputs="Mass (kg)", outputs="Estimated Apogee (m)")


def rail_exit_velocity_by_mass(self, wind_v=-5):
self.env.setAtmosphericModel(type="CustomAtmosphere", wind_v=wind_v)
def speed(mass):
# self.rocket.mass = mass

# ^^^ In theory this could and should replace the variable_rocket definition
# but due to a bug could not be used; calisto drag curves are used below
# for demonstration purposes.

# Most likely, some internal process is causing the rail exit velocity to
# be the same even for different masses.
variable_rocket = Rocket(
motor=self.motor,
radius=self.rocket.radius,
mass=mass,
inertiaI=self.rocket.inertiaI,
inertiaZ=self.rocket.inertiaZ,
distanceRocketNozzle=self.rocket.distanceRocketNozzle,
distanceRocketPropellant=self.rocket.distanceRocketPropellant,
powerOffDrag="../data/calisto/powerOffDragCurve.csv",
powerOnDrag="../data/calisto/powerOnDragCurve.csv",
)

test_flight = Flight(
rocket=self.rocket,
environment=self.env,
inclination=self.flight.inclination,
heading=self.flight.heading,
terminateOnApogee=True,
)

return test_flight.outOfRailVelocity

return Function(speed, inputs="Mass (kg)", outputs="Out of Rail Speed (m/s)")


def chute_radius_finder(self):
from numpy import pi
desiredterminal = float(input('Enter desired landing velocity in m/s '))
mass = self.rocket.mass
d = self.env.density(1)

parachute_type = input("Enter parachute type (eg: 'toroidal' or 'custom') ")

if parachute_type == 'flat':
dragcoeff = 0.8
elif parachute_type == 'toroidal':
dragcoeff = 2.2
elif parachute_type == 'spherical':
dragcoeff = 1.5
elif parachute_type == 'custom':
dragcoeff = float(input('Enter custom drag coefficient '))
else:
print('Not a valid chute type, enter custom drag coefficient?')
dragcoeff = float(input())


desiredCdS = (2*mass*9.81)/(d*(desiredterminal)**2)

area = desiredCdS / dragcoeff

radius = (2 * area) / pi # using formula from fruitychutes

print("Estimated required radius: {:.6f} meters".format(radius))

return radius

def snatchforce_calculator(self, main_CdS):
"""
Calculates the shock force of parachute deployment based on the CdS
and velocity while the parachute is deployed. Works only for main parachute,
does not account for drogue.

Args:
main_CdS (number): Drag coefficient times reference area of main chute.

Returns:
float: Shock force of main chute
"""
density = self.env.density
return (1/2)* density * (self.flight.impactVelocity**2) * main_CdS


def CdS_finder(self, chutetype,ventedchute,oradius,iradius,customCd):
from numpy import pi

chutetypedict = {
'flat' : [0.75,0.80],
'conical' : [0.75,0.90],
'biconical' : [0.75,0.92],
'triconical' : [0.80,0.96],
'polyconical' : [0.80,0.96],
'extended skirt' : [0.78,0.87],
'skirt' : [0.78,0.87],
'hemisphere' : [0.62,0.77],
'guide surface' : [0.28,0.42],
'annular' : [0.85,0.95],
}

if (chutetype not in chutetypedict.keys()) and ventedchute.lower() == 'n':
CdShigh = (oradius**2 * pi) * customCd
CdSlow = (oradius**2 * pi) * customCd
elif chutetype not in chutetypedict.keys() and ventedchute.lower() == 'y':
CdShigh = ((oradius**2 * pi)-(iradius**2 * pi)) * customCd
CdSlow = ((oradius**2 * pi)-(iradius**2 * pi)) * customCd
elif ventedchute.lower() == 'n':
CdShigh = (oradius**2 * pi) * chutetypedict[chutetype.lower()][1]
CdSlow = (oradius**2 * pi) * chutetypedict[chutetype.lower()][0]
elif ventedchute.lower() == 'y':
CdShigh = ((oradius**2 * pi)-(iradius**2 * pi)) * chutetypedict[chutetype.lower()][1]
CdSlow = ((oradius**2 * pi)-(iradius**2 * pi)) * chutetypedict[chutetype.lower()][0]

meanCdS = (CdShigh+CdSlow)/2

print('With your chute configuradtion, the CdS will be about {:.6f} maximum'.format(CdShigh))
print('and {:.6f} minimum'.format(CdSlow))
print('Mean CdS = {:.6}'.format(meanCdS))
return(CdShigh,CdSlow,meanCdS)
1 change: 1 addition & 0 deletions rocketpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
__email__ = "ghceotto@gmail.com"
__status__ = "Production"

from .Analysis import Analysis
from .Environment import Environment
from .EnvironmentAnalysis import EnvironmentAnalysis
from .Flight import Flight
Expand Down