Skip to content

Commit 809f8eb

Browse files
Fix: Add opening shock calculation to overshoot loop
1 parent 4ca1593 commit 809f8eb

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

rocketpy/rocket/parachute.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ def to_dict(self, **kwargs):
321321
"radius": self.radius,
322322
"height": self.height,
323323
"porosity": self.porosity,
324+
"opening_shock_coefficient": self.opening_shock_coefficient,
324325
}
325326

326327
if kwargs.get("include_outputs", False):
@@ -332,6 +333,7 @@ def to_dict(self, **kwargs):
332333
)
333334
data["noisy_pressure_signal"] = self.noisy_pressure_signal
334335
data["clean_pressure_signal"] = self.clean_pressure_signal
336+
data["opening_shock_force"] = self.opening_shock_force
335337

336338
return data
337339

@@ -354,6 +356,7 @@ def from_dict(cls, data):
354356
radius=data.get("radius", 1.5),
355357
height=data.get("height", None),
356358
porosity=data.get("porosity", 0.0432),
359+
opening_shock_coefficient=data.get("opening_shock_coefficient", 1.6),
357360
)
358361

359362
return parachute

rocketpy/simulation/flight.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -764,20 +764,8 @@ def __simulate(self, verbose):
764764
self.sensors,
765765
):
766766

767-
# Calculate opening shock force
768-
opening_altitude = self.y_sol[2]
769-
opening_density = self.env.density(opening_altitude)
770-
opening_velocity = (
771-
(self.y_sol[3]) ** 2
772-
+ (self.y_sol[4]) ** 2
773-
+ (self.y_sol[5]) ** 2
774-
) ** 0.5
775-
776-
parachute.opening_shock_force = (
777-
parachute.calculate_opening_shock(
778-
opening_density, opening_velocity
779-
)
780-
)
767+
# Calculates the parachute's opening shock force
768+
self.calculate_parachute_opening_shock_force(parachute)
781769

782770
# Remove parachute from flight parachutes
783771
self.parachutes.remove(parachute)
@@ -1098,6 +1086,12 @@ def __simulate(self, verbose):
10981086
phase.time_nodes.flush_after(node_index)
10991087
phase.time_nodes.add_node(self.t, [], [], [])
11001088
phase.solver.status = "finished"
1089+
1090+
# Calculates the parachute's opening shock force
1091+
self.calculate_parachute_opening_shock_force(
1092+
parachute
1093+
)
1094+
11011095
# Save parachute event
11021096
self.parachute_events.append(
11031097
[self.t, parachute]
@@ -4130,3 +4124,18 @@ def rail_button2_bending_moment(self):
41304124
def max_rail_button2_bending_moment(self):
41314125
"""Maximum lower rail button bending moment, in N·m."""
41324126
return self.calculate_rail_button_bending_moments[3]
4127+
4128+
def calculate_parachute_opening_shock_force(self, parachute):
4129+
"""Calculates and stores the shock force on parachute opening
4130+
Uses the current self.y_sol and self.env.
4131+
"""
4132+
# Calculate opening shock force
4133+
opening_altitude = self.y_sol[2]
4134+
opening_density = self.env.density(opening_altitude)
4135+
opening_velocity = (
4136+
(self.y_sol[3]) ** 2 + (self.y_sol[4]) ** 2 + (self.y_sol[5]) ** 2
4137+
) ** 0.5
4138+
4139+
parachute.opening_shock_force = parachute.calculate_opening_shock(
4140+
opening_density, opening_velocity
4141+
)

tests/integration/simulation/test_flight.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,6 @@ def test_rocket_csys_equivalence(
454454
)
455455

456456

457-
# TODO: fix the issues on this test and debug shock analysis
458457
def test_opening_shock_recorded_during_flight(calisto, example_plain_env):
459458
"""
460459
Testing if the opening shock is being saved correctly during simulations.

0 commit comments

Comments
 (0)