Skip to content

Commit 0f8f3a6

Browse files
FelipeAlmeidaUSPGui-FernandesBR
authored andcommitted
Fix: Add opening shock calculation to overshoot loop
1 parent 531cf38 commit 0f8f3a6

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
@@ -774,20 +774,8 @@ def __simulate(self, verbose):
774774
self.sensors,
775775
):
776776

777-
# Calculate opening shock force
778-
opening_altitude = self.y_sol[2]
779-
opening_density = self.env.density(opening_altitude)
780-
opening_velocity = (
781-
(self.y_sol[3]) ** 2
782-
+ (self.y_sol[4]) ** 2
783-
+ (self.y_sol[5]) ** 2
784-
) ** 0.5
785-
786-
parachute.opening_shock_force = (
787-
parachute.calculate_opening_shock(
788-
opening_density, opening_velocity
789-
)
790-
)
777+
# Calculates the parachute's opening shock force
778+
self.calculate_parachute_opening_shock_force(parachute)
791779

792780
# Remove parachute from flight parachutes
793781
self.parachutes.remove(parachute)
@@ -1108,6 +1096,12 @@ def __simulate(self, verbose):
11081096
phase.time_nodes.flush_after(node_index)
11091097
phase.time_nodes.add_node(self.t, [], [], [])
11101098
phase.solver.status = "finished"
1099+
1100+
# Calculates the parachute's opening shock force
1101+
self.calculate_parachute_opening_shock_force(
1102+
parachute
1103+
)
1104+
11111105
# Save parachute event
11121106
self.parachute_events.append(
11131107
[self.t, parachute]
@@ -4371,3 +4365,18 @@ def rail_button2_bending_moment(self):
43714365
def max_rail_button2_bending_moment(self):
43724366
"""Maximum lower rail button bending moment, in N·m."""
43734367
return self.calculate_rail_button_bending_moments[3]
4368+
4369+
def calculate_parachute_opening_shock_force(self, parachute):
4370+
"""Calculates and stores the shock force on parachute opening
4371+
Uses the current self.y_sol and self.env.
4372+
"""
4373+
# Calculate opening shock force
4374+
opening_altitude = self.y_sol[2]
4375+
opening_density = self.env.density(opening_altitude)
4376+
opening_velocity = (
4377+
(self.y_sol[3]) ** 2 + (self.y_sol[4]) ** 2 + (self.y_sol[5]) ** 2
4378+
) ** 0.5
4379+
4380+
parachute.opening_shock_force = parachute.calculate_opening_shock(
4381+
opening_density, opening_velocity
4382+
)

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)