Skip to content

Commit

Permalink
Merge pull request #596 from RocketPy-Team/mnt/refactor-u-dot-parachute
Browse files Browse the repository at this point in the history
MNT: refactor u_dot parachute method
  • Loading branch information
Gui-FernandesBR authored May 19, 2024
2 parents 63ef48d + 64bdab2 commit 1e17549
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- MNT: refactor u_dot parachute method [#596](https://github.com/RocketPy-Team/RocketPy/pull/596)
- BLD: Change setup.py to pyproject.toml [#589](https://github.com/RocketPy-Team/RocketPy/pull/589)
- DEP: delete deprecated rocketpy.tools.cached_property [#587](https://github.com/RocketPy-Team/RocketPy/pull/587)
- ENH: Flight simulation speed up [#581] (https://github.com/RocketPy-Team/RocketPy/pull/581)
Expand Down
51 changes: 30 additions & 21 deletions rocketpy/simulation/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -1789,34 +1789,42 @@ def u_dot_parachute(self, t, u, post_processing=False):
e0dot, e1dot, e2dot, e3dot, alpha1, alpha2, alpha3].
"""
# Parachute data
cd_s = self.parachute_cd_s
ka = 1
R = 1.5
rho = self.env.density.get_value_opt(u[2])
to = 1.2
ma = ka * rho * (4 / 3) * np.pi * R**3
mp = self.rocket.dry_mass
eta = 1
Rdot = (6 * R * (1 - eta) / (1.2**6)) * (
(1 - eta) * t**5 + eta * (to**3) * (t**2)
)
Rdot = 0
# Get relevant state data
x, y, z, vx, vy, vz, e0, e1, e2, e3, omega1, omega2, omega3 = u
# Get wind data
z, vx, vy, vz = u[2:6]

# Get atmospheric data
rho = self.env.density.get_value_opt(z)
wind_velocity_x = self.env.wind_velocity_x.get_value_opt(z)
wind_velocity_y = self.env.wind_velocity_y.get_value_opt(z)
free_stream_speed = (
(wind_velocity_x - vx) ** 2 + (wind_velocity_y - vy) ** 2 + (vz) ** 2
) ** 0.5

# Get Parachute data
cd_s = self.parachute_cd_s

# Get the mass of the rocket
mp = self.rocket.dry_mass

# Define constants
ka = 1 # Added mass coefficient (depends on parachute's porosity)
R = 1.5 # Parachute radius
# to = 1.2
# eta = 1
# Rdot = (6 * R * (1 - eta) / (1.2**6)) * (
# (1 - eta) * t**5 + eta * (to**3) * (t**2)
# )
# Rdot = 0

# Calculate added mass
ma = ka * rho * (4 / 3) * np.pi * R**3

# Calculate freestream speed
freestream_x = vx - wind_velocity_x
freestream_y = vy - wind_velocity_y
freestream_z = vz
free_stream_speed = (freestream_x**2 + freestream_y**2 + freestream_z**2) ** 0.5

# Determine drag force
pseudoD = (
-0.5 * rho * cd_s * free_stream_speed - ka * rho * 4 * np.pi * (R**2) * Rdot
)
pseudoD = -0.5 * rho * cd_s * free_stream_speed
# pseudoD = pseudoD - ka * rho * 4 * np.pi * (R**2) * Rdot
Dx = pseudoD * freestream_x
Dy = pseudoD * freestream_y
Dz = pseudoD * freestream_z
Expand Down Expand Up @@ -2785,6 +2793,7 @@ def __transform_pressure_signals_lists_to_functions(self):
"""
# Transform parachute sensor feed into functions
for parachute in self.rocket.parachutes:
# TODO: these Functions do not need input validation
parachute.clean_pressure_signal_function = Function(
parachute.clean_pressure_signal,
"Time (s)",
Expand Down

0 comments on commit 1e17549

Please sign in to comment.