Skip to content
This repository has been archived by the owner on Oct 30, 2022. It is now read-only.

Issue #95: team-01 - User Interface #114

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1f458cb
Initial Commit: Creating Template for streamlit application
aasitvora99 Aug 27, 2022
65c1f61
Refining template: completed nabvar section
aasitvora99 Aug 27, 2022
e02087e
Completed environment page, only left with visualization
aasitvora99 Aug 27, 2022
dafa6ed
Yet to fix addEnvironemnt.py
aasitvora99 Aug 28, 2022
ee37a1b
Still yet to fix add environment
aasitvora99 Aug 28, 2022
9bf7000
I'll document these later I promise
aasitvora99 Sep 13, 2022
83ff743
gonna start fresh here
aasitvora99 Sep 28, 2022
488599b
removed amd
SwayamSonar Sep 28, 2022
35c3f81
initial commit
SwayamSonar Sep 28, 2022
6784def
add motor page initialised
aasitvora99 Sep 28, 2022
0f0d22e
used altair chart for visualization, time to fix the overlapping issue
aasitvora99 Oct 4, 2022
1ea19ab
fixed the dual axis problem, removed the junk clone in the repo
aasitvora99 Oct 6, 2022
1f2c95c
added 3rd graph for env simulation, need to fix the smoothing of 3rd …
aasitvora99 Oct 6, 2022
6059742
added all graphs
aasitvora99 Oct 6, 2022
f5a7f25
Finished environment page
aasitvora99 Oct 6, 2022
7cbfbc9
added input parms, eng input function doesn't work
aasitvora99 Oct 6, 2022
13c4ed5
eng input function not working
aasitvora99 Oct 6, 2022
059c353
fix this report context problem
aasitvora99 Oct 8, 2022
f66a457
added thrust curve wrt time
aasitvora99 Oct 10, 2022
a669af3
added all motor plots
aasitvora99 Oct 10, 2022
5b33d63
visualization arranged
aasitvora99 Oct 10, 2022
a83ec21
motor page dunzo :pinch fingers:
aasitvora99 Oct 10, 2022
d43c880
need to fix zCM issue
aasitvora99 Oct 11, 2022
13ec07d
fixed the zCM issue, added session states to store objects in each page
aasitvora99 Oct 14, 2022
0ff5092
general commit
aasitvora99 Oct 16, 2022
1147584
general commit
aasitvora99 Nov 3, 2022
7e34ab6
flight class runs endlessly
aasitvora99 Nov 7, 2022
c864de5
basic simulation running
aasitvora99 Dec 7, 2022
e3710a9
basic simulation running
aasitvora99 Dec 7, 2022
4aa0c79
added requirements froms streamlit recs to main
aasitvora99 Dec 7, 2022
ebaf0ef
updates ssh problem in requirements.txt
aasitvora99 Dec 7, 2022
5267d0f
updates ssh problem in requirements.txt
aasitvora99 Dec 7, 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ wheels/
.installed.cfg
*.egg
MANIFEST
streamlitFiles/__pycache__
streamlitFiles/appPages/__pycache__

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
13 changes: 0 additions & 13 deletions data/motors/Cesaroni_7450M2505-P.csv

This file was deleted.

16 changes: 0 additions & 16 deletions data/motors/Cesaroni_7450M2505-P.eng

This file was deleted.

20 changes: 0 additions & 20 deletions data/motors/Cesaroni_M1300.eng

This file was deleted.

49 changes: 49 additions & 0 deletions data/motors/STES-L1882.eng
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
L1882 60.0 747.0 P 2.147125 3.579125 STES
0 0.01
0.03 1483.7594
0.06 1515.7693
0.09 1547.5878
0.12 1579.1678
0.1499 1610.4608
0.1799 1641.4176
0.2099 1671.988
0.2399 1702.1214
0.2699 1731.7664
0.2999 1760.8714
0.3299 1789.3845
0.3599 1817.2538
0.3899 1844.4273
0.4199 1870.8536
0.4499 1896.4816
0.4798 1921.2607
0.5098 1945.1414
0.5398 1968.075
0.5698 1990.014
0.5998 2010.9125
0.6298 2030.7259
0.6598 2049.4115
0.6898 2066.9284
0.7198 2083.2379
0.7497 2098.3034
0.7797 2112.091
0.8097 2124.5692
0.8397 2135.709
0.8697 2145.4845
0.8997 2153.1313
0.9297 2159.6191
0.9597 2164.9419
0.9897 2169.0947
1.0197 2172.0735
1.0496 2173.8755
1.0796 2174.499
1.1096 2173.9434
1.1396 2172.2091
1.1696 2169.2976
1.1996 2165.2118
1.2296 2159.9551
1.2596 2153.5327
1.2896 2145.9502
1.3196 2137.2149
1.3495 0.0
;
;
310 changes: 122 additions & 188 deletions docs/notebooks/getting_started.ipynb

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions docs/notebooks/trajectory.kml

Large diffs are not rendered by default.

93 changes: 81 additions & 12 deletions rocketpy/Environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import numpy as np
import pytz
import requests
import streamlit as st

try:
import netCDF4
Expand Down Expand Up @@ -366,7 +367,7 @@ def __init__(
self.timeZone = None

# Initialize constants
self.earthRadius = 6.3781 * (10**6)
self.earthRadius = 6.3781 * (10 ** 6)
self.airGasConstant = 287.05287 # in J/K/Kg

# Initialize atmosphere
Expand Down Expand Up @@ -1978,7 +1979,7 @@ def processForecastReanalysis(self, file, dictionary):
windV = ((y2 - y) / (y2 - y1)) * f_x_y1 + ((y - y1) / (y2 - y1)) * f_x_y2

# Determine wind speed, heading and direction
windSpeed = np.sqrt(windU**2 + windV**2)
windSpeed = np.sqrt(windU ** 2 + windV ** 2)
windHeading = np.arctan2(windU, windV) * (180 / np.pi) % 360
windDirection = (windHeading - 180) % 360

Expand Down Expand Up @@ -2395,7 +2396,7 @@ def processEnsemble(self, file, dictionary):
windV = ((y2 - y) / (y2 - y1)) * f_x_y1 + ((y - y1) / (y2 - y1)) * f_x_y2

# Determine wind speed, heading and direction
windSpeed = np.sqrt(windU**2 + windV**2)
windSpeed = np.sqrt(windU ** 2 + windV ** 2)
windHeading = np.arctan2(windU, windV) * (180 / np.pi) % 360
windDirection = (windHeading - 180) % 360

Expand Down Expand Up @@ -2973,6 +2974,69 @@ def info(self):
plt.subplots_adjust(wspace=0.5)
plt.show()

def streamlitInfo(self):
"""Prints most important data and graphs available about the
Environment in streamlit interface.

Parameters
----------
None

Return
------
None
"""

# Plot graphs
print("\n\nAtmospheric Model Plots")
# Create height grid
grid = np.linspace(self.elevation, self.maxExpectedHeight)

# Create figure
plt.figure(figsize=(9, 4.5))

# Create wind speed and wind direction subplot
ax1 = plt.subplot(121)
ax1.plot(
[self.windSpeed(i) for i in grid], grid, "#ff7f0e", label="Speed of Sound"
)
ax1.set_xlabel("Wind Speed (m/s)", color="#ff7f0e")
ax1.tick_params("x", colors="#ff7f0e")
ax1up = ax1.twiny()
ax1up.plot(
[self.windDirection(i) for i in grid],
grid,
color="#1f77b4",
label="Density",
)
ax1up.set_xlabel("Wind Direction (°)", color="#1f77b4")
ax1up.tick_params("x", colors="#1f77b4")
ax1up.set_xlim(0, 360)
ax1.set_ylabel("Height Above Sea Level (m)")
ax1.grid(True)

# Create density and speed of sound subplot
ax2 = plt.subplot(122)
ax2.plot(
[self.speedOfSound(i) for i in grid],
grid,
"#ff7f0e",
label="Speed of Sound",
)
ax2.set_xlabel("Speed of Sound (m/s)", color="#ff7f0e")
ax2.tick_params("x", colors="#ff7f0e")
ax2up = ax2.twiny()
ax2up.plot(
[self.density(i) for i in grid], grid, color="#1f77b4", label="Density"
)
ax2up.set_xlabel("Density (kg/m³)", color="#1f77b4")
ax2up.tick_params("x", colors="#1f77b4")
ax2.set_ylabel("Height Above Sea Level (m)")
ax2.grid(True)

plt.subplots_adjust(wspace=0.5)
plt.show()

def allInfo(self):
"""Prints out all data and graphs available about the Environment.

Expand Down Expand Up @@ -3304,6 +3368,11 @@ def allInfoReturned(self):
surfaceTemperature=self.temperature(self.elevation),
surfaceAirDensity=self.density(self.elevation),
surfaceSpeedOfSound=self.speedOfSound(self.elevation),
datum=self.datum,
initialNorth=self.initialNorth,
initialHemisphere=self.initialHemisphere,
initialEast=self.initialEast,
initialEW=self.initialEW,
)
if self.date != None:
info["launch_date"] = self.date.strftime("%Y-%d-%m %H:%M:%S")
Expand Down Expand Up @@ -3412,7 +3481,7 @@ def geodesicToUtm(self, lat, lon, datum):

# Evaluate reference parameters
K0 = 1 - 1 / 2500
e2 = 2 * flattening - flattening**2
e2 = 2 * flattening - flattening ** 2
e2lin = e2 / (1 - e2)

# Evaluate auxiliary parameters
Expand All @@ -3435,9 +3504,9 @@ def geodesicToUtm(self, lat, lon, datum):

# Evaluate new auxiliary parameters
J = (1 - t + c) * ag * ag * ag / 6
K = (5 - 18 * t + t * t + 72 * c - 58 * e2lin) * (ag**5) / 120
K = (5 - 18 * t + t * t + 72 * c - 58 * e2lin) * (ag ** 5) / 120
L = (5 - t + 9 * c + 4 * c * c) * ag * ag * ag * ag / 24
M = (61 - 58 * t + t * t + 600 * c - 330 * e2lin) * (ag**6) / 720
M = (61 - 58 * t + t * t + 600 * c - 330 * e2lin) * (ag ** 6) / 720

# Evaluate the final coordinates
x = 500000 + K0 * n * (ag + J + K)
Expand Down Expand Up @@ -3510,7 +3579,7 @@ def utmToGeodesic(self, x, y, utmZone, hemis, datum):

# Calculate reference values
K0 = 1 - 1 / 2500
e2 = 2 * flattening - flattening**2
e2 = 2 * flattening - flattening ** 2
e2lin = e2 / (1 - e2)
e1 = (1 - (1 - e2) ** 0.5) / (1 + (1 - e2) ** 0.5)

Expand All @@ -3534,20 +3603,20 @@ def utmToGeodesic(self, x, y, utmZone, hemis, datum):
t1 = np.tan(lat1) ** 2
n1 = semiMajorAxis / ((1 - e2 * (np.sin(lat1) ** 2)) ** 0.5)
quoc = (1 - e2 * np.sin(lat1) * np.sin(lat1)) ** 3
r1 = semiMajorAxis * (1 - e2) / (quoc**0.5)
r1 = semiMajorAxis * (1 - e2) / (quoc ** 0.5)
d = (x - 500000) / (n1 * K0)

# Calculate other auxiliary values
I = (5 + 3 * t1 + 10 * c1 - 4 * c1 * c1 - 9 * e2lin) * d * d * d * d / 24
J = (
(61 + 90 * t1 + 298 * c1 + 45 * t1 * t1 - 252 * e2lin - 3 * c1 * c1)
* (d**6)
* (d ** 6)
/ 720
)
K = d - (1 + 2 * t1 + c1) * d * d * d / 6
L = (
(5 - 2 * c1 + 28 * t1 - 3 * c1 * c1 + 8 * e2lin + 24 * t1 * t1)
* (d**5)
* (d ** 5)
/ 120
)

Expand Down Expand Up @@ -3610,8 +3679,8 @@ def calculateEarthRadius(self, lat, datum):
# Calculate the Earth Radius in meters
eRadius = np.sqrt(
(
(np.cos(lat) * (semiMajorAxis**2)) ** 2
+ (np.sin(lat) * (semiMinorAxis**2)) ** 2
(np.cos(lat) * (semiMajorAxis ** 2)) ** 2
+ (np.sin(lat) * (semiMinorAxis ** 2)) ** 2
)
/ ((np.cos(lat) * semiMajorAxis) ** 2 + (np.sin(lat) * semiMinorAxis) ** 2)
)
Expand Down
46 changes: 23 additions & 23 deletions rocketpy/Rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def __init__(

# Define rocket geometrical parameters in SI units
self.radius = radius
self.area = np.pi * self.radius**2
self.area = np.pi * self.radius ** 2

# Center of mass distance to points of interest
self.distanceRocketNozzle = distanceRocketNozzle
Expand Down Expand Up @@ -376,9 +376,9 @@ def addTail(self, topRadius, bottomRadius, length, distanceToCM):

# Calculate cp position relative to cm
if distanceToCM < 0:
cpz = distanceToCM - (length / 3) * (1 + (1 - r) / (1 - r**2))
cpz = distanceToCM - (length / 3) * (1 + (1 - r) / (1 - r ** 2))
else:
cpz = distanceToCM + (length / 3) * (1 + (1 - r) / (1 - r**2))
cpz = distanceToCM + (length / 3) * (1 + (1 - r) / (1 - r ** 2))

# Calculate clalpha
clalpha = -2 * (1 - r ** (-2)) * (topRadius / rref) ** 2
Expand Down Expand Up @@ -534,36 +534,36 @@ def addFins(
(s / 3) * (Cr + 2 * Ct) / Yr
) # span wise position of fin's mean aerodynamic chord
gamac = np.arctan((Cr - Ct) / (2 * s))
Lf = np.sqrt((Cr / 2 - Ct / 2) ** 2 + s**2)
Lf = np.sqrt((Cr / 2 - Ct / 2) ** 2 + s ** 2)
radius = self.radius if radius == 0 else radius
d = 2 * radius
Aref = np.pi * radius**2
AR = 2 * s**2 / Af # Barrowman's convention for fin's aspect ratio
Aref = np.pi * radius ** 2
AR = 2 * s ** 2 / Af # Barrowman's convention for fin's aspect ratio
cantAngleRad = np.radians(cantAngle)
trapezoidalConstant = (
(Cr + 3 * Ct) * s**3
+ 4 * (Cr + 2 * Ct) * radius * s**2
+ 6 * (Cr + Ct) * s * radius**2
(Cr + 3 * Ct) * s ** 3
+ 4 * (Cr + 2 * Ct) * radius * s ** 2
+ 6 * (Cr + Ct) * s * radius ** 2
) / 12

# Fin–body interference correction parameters
τ = (s + radius) / radius
λ = Ct / Cr
liftInterferenceFactor = 1 + 1 / τ
rollForcingInterferenceFactor = (1 / np.pi**2) * (
(np.pi**2 / 4) * ((τ + 1) ** 2 / τ**2)
+ ((np.pi * (τ**2 + 1) ** 2) / (τ**2 * (τ - 1) ** 2))
* np.arcsin((τ**2 - 1) / (τ**2 + 1))
rollForcingInterferenceFactor = (1 / np.pi ** 2) * (
(np.pi ** 2 / 4) * ((τ + 1) ** 2 / τ ** 2)
+ ((np.pi * (τ ** 2 + 1) ** 2) / (τ ** 2 * (τ - 1) ** 2))
* np.arcsin((τ ** 2 - 1) / (τ ** 2 + 1))
- (2 * np.pi * (τ + 1)) / (τ * (τ - 1))
+ ((τ**2 + 1) ** 2)
/ (τ**2 * (τ - 1) ** 2)
* (np.arcsin((τ**2 - 1) / (τ**2 + 1))) ** 2
- (4 * (τ + 1)) / (τ * (τ - 1)) * np.arcsin((τ**2 - 1) / (τ**2 + 1))
+ (8 / (τ - 1) ** 2) * np.log((τ**2 + 1) / (2 * τ))
+ ((τ ** 2 + 1) ** 2)
/ (τ ** 2 * (τ - 1) ** 2)
* (np.arcsin((τ ** 2 - 1) / (τ ** 2 + 1))) ** 2
- (4 * (τ + 1)) / (τ * (τ - 1)) * np.arcsin((τ ** 2 - 1) / (τ ** 2 + 1))
+ (8 / (τ - 1) ** 2) * np.log((τ ** 2 + 1) / (2 * τ))
)
rollDampingInterferenceFactor = 1 + (
((τ - λ) / (τ)) - ((1 - λ) / (τ - 1)) * np.log(τ)
) / (((τ + 1) * (τ - λ)) / (2) - ((1 - λ) * (τ**3 - 1)) / (3 * (τ - 1)))
) / (((τ + 1) * (τ - λ)) / (2) - ((1 - λ) * (τ ** 3 - 1)) / (3 * (τ - 1)))

# Save geometric parameters for later Fin Flutter Analysis and Roll Moment Calculation
self.rootChord = Cr
Expand Down Expand Up @@ -591,11 +591,11 @@ def beta(mach):
"""

if mach < 0.8:
return np.sqrt(1 - mach**2)
return np.sqrt(1 - mach ** 2)
elif mach < 1.1:
return np.sqrt(1 - 0.8**2)
return np.sqrt(1 - 0.8 ** 2)
else:
return np.sqrt(mach**2 - 1)
return np.sqrt(mach ** 2 - 1)

# Defines number of fins correction
def finNumCorrection(n):
Expand Down Expand Up @@ -679,7 +679,7 @@ def finNumCorrection(n):
* clalphaSingleFin
* np.cos(cantAngleRad)
* trapezoidalConstant
/ (Aref * d**2)
/ (Aref * d ** 2)
)
# Function of mach number
rollParameters = [clfDelta, cldOmega, cantAngleRad]
Expand Down
Loading