Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: flight.prints.max_values() fails when launching an EmptyMotor #438

Merged
merged 3 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions rocketpy/simulation/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,9 @@ def max_acceleration_power_on_time(self):
burn_out_time_index = find_closest(
self.acceleration.source[:, 0], self.rocket.motor.burn_out_time
)
if burn_out_time_index == 0:
return 0 # the burn out time is before the first time step

max_acceleration_time_index = np.argmax(
self.acceleration[:burn_out_time_index, 1]
)
Expand Down
27 changes: 27 additions & 0 deletions tests/test_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,32 @@ def test_initial_solution(mock_show, example_env, calisto_robust):
assert test_flight.all_info() == None


@patch("matplotlib.pyplot.show")
def test_empty_motor_flight(mock_show, example_env, calisto_motorless):
flight = Flight(
rocket=calisto_motorless,
environment=example_env,
rail_length=5,
initial_solution=[ # a random flight starting at apogee
22.945995194368354,
277.80976806186936,
353.29457980509113,
3856.1112773441596,
12.737953434495966,
15.524649322067267,
-0.00011874766384947776,
-0.06086838708814366,
0.019695167217632138,
-0.35099420532705555,
-0.9338841410225396,
0.25418555574446716,
0.03632002739509155,
2.0747266017020563,
],
)
assert flight.all_info() == None


@pytest.mark.parametrize("wind_u, wind_v", [(0, 10), (0, -10), (10, 0), (-10, 0)])
@pytest.mark.parametrize(
"static_margin, max_time",
Expand Down Expand Up @@ -537,6 +563,7 @@ def test_rail_length(calisto_robust, example_env, rail_length, out_of_rail_time)
assert abs(test_flight.z(test_flight.out_of_rail_time) - out_of_rail_time) < 1e-6


@pytest.mark.slow
Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved
@patch("matplotlib.pyplot.show")
def test_time_overshoot(mock_show, calisto_robust, example_env_robust):
"""Test the time_overshoot parameter of the Flight class. This basically
Expand Down