Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be "fixed"

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Attention: The newest changes should be on top -->

- BUG: Fix the handling of reference pressure for older rpy files. [#808](https://github.com/RocketPy-Team/RocketPy/pull/808)
- BUG: Non-overshootable simulations error on time parsing. [#807](https://github.com/RocketPy-Team/RocketPy/pull/807)
- BUG: Wrong Phi Initialization For nose_to_tail Rockets [#809](https://github.com/RocketPy-Team/RocketPy/pull/809)

## v1.9.0 - 2025-03-24

Expand Down
6 changes: 4 additions & 2 deletions rocketpy/simulation/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,9 @@ def __init_flight_state(self):
try:
self.phi_init += (
self.rocket.rail_buttons[0].component.angular_position_rad
* self.rocket._csys
if self.rocket._csys == 1
else 2 * np.pi
- self.rocket.rail_buttons[0].component.angular_position_rad
)
except IndexError:
pass
Expand Down Expand Up @@ -1277,7 +1279,7 @@ def __set_ode_solver(self, solver):
f"Invalid ``ode_solver`` input: {solver}. "
f"Available options are: {', '.join(ODE_SOLVER_MAP.keys())}"
) from e

self.__is_lsoda = issubclass(self._solver, LSODA)

@cached_property
Expand Down
14 changes: 14 additions & 0 deletions tests/fixtures/flight/flight_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ def flight_calisto_robust(calisto_robust, example_spaceport_env):
)


@pytest.fixture
def flight_calisto_nose_to_tail_robust(
calisto_nose_to_tail_robust, example_spaceport_env
):
return Flight(
environment=example_spaceport_env,
rocket=calisto_nose_to_tail_robust,
rail_length=5.2,
inclination=85,
heading=0,
terminate_on_apogee=False,
)


@pytest.fixture
def flight_calisto_robust_solid_eom(calisto_robust, example_spaceport_env):
"""Similar to flight_calisto_robust, but with the equations of motion set to
Expand Down
27 changes: 27 additions & 0 deletions tests/fixtures/rockets/rocket_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,33 @@ def calisto_robust(
return calisto


@pytest.fixture
def calisto_nose_to_tail_robust(
calisto_nose_to_tail,
calisto_nose_cone,
calisto_tail,
calisto_trapezoidal_fins,
calisto_main_chute,
calisto_drogue_chute,
):
"""Calisto with nose to tail coordinate system orientation. This is the same
as calisto_robust, but with the coordinate system orientation set to
"nose_to_tail"."""
csys = -1
# we follow this format: calisto.add_surfaces(surface, position)
calisto_nose_to_tail.add_surfaces(calisto_nose_cone, 1.160 * csys)
calisto_nose_to_tail.add_surfaces(calisto_tail, -1.313 * csys)
calisto_nose_to_tail.add_surfaces(calisto_trapezoidal_fins, -1.168 * csys)
calisto_nose_to_tail.set_rail_buttons(
upper_button_position=0.082 * csys,
lower_button_position=-0.618 * csys,
angular_position=360 - 0,
)
calisto_nose_to_tail.parachutes.append(calisto_main_chute)
calisto_nose_to_tail.parachutes.append(calisto_drogue_chute)
return calisto_nose_to_tail


@pytest.fixture
def calisto_air_brakes_clamp_on(calisto_robust, controller_function):
"""Create an object class of the Rocket class to be used in the tests. This
Expand Down
34 changes: 34 additions & 0 deletions tests/integration/test_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,37 @@ def test_freestream_speed_at_apogee(example_plain_env, calisto):
test_flight.free_stream_speed(test_flight.apogee_time), 0.0, atol=soft_atol
)
assert np.isclose(test_flight.apogee_freestream_speed, 0.0, atol=soft_atol)


def test_rocket_csys_equivalence(
flight_calisto_robust, flight_calisto_nose_to_tail_robust
):
"""Test the equivalence of the rocket coordinate systems between two
different flight simulations.

Parameters
----------
flight_calisto_robust : rocketpy.Flight
Flight object to be tested. See the conftest.py file for more info.
flight_calisto_nose_to_tail_robust : rocketpy.Flight
Flight object to be tested. See the conftest.py file for more info.
"""
assert np.isclose(
flight_calisto_robust.apogee, flight_calisto_nose_to_tail_robust.apogee
)
assert np.isclose(
flight_calisto_robust.apogee_time,
flight_calisto_nose_to_tail_robust.apogee_time,
)
assert np.isclose(
flight_calisto_robust.x_impact,
flight_calisto_nose_to_tail_robust.x_impact,
)
assert np.isclose(
flight_calisto_robust.y_impact,
flight_calisto_nose_to_tail_robust.y_impact,
)
assert np.allclose(
flight_calisto_robust.initial_solution,
flight_calisto_nose_to_tail_robust.initial_solution,
)