From a901b45932bc3bcc238f1760a2009ab67ccd6687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Machado?= <85506246+juliomachad0@users.noreply.github.com> Date: Sat, 20 Jul 2024 19:22:41 -0300 Subject: [PATCH 1/3] ENH: adding rocket radius to RailButtons class (#643) * ENH: Enabling the creation of Rail Buttons separately (adding the rocket_radius attribute to the RailButtons class). Improvement of the Railbuttons class. * ENH: removing unnecessary try except * ENH: improve try/except block * DEV: adds 643 to changelog * ENH: improves add_surfaces for rail buttons --------- Co-authored-by: Gui-FernandesBR --- CHANGELOG.md | 6 +++--- rocketpy/rocket/aero_surface/rail_buttons.py | 14 ++++++++++++-- rocketpy/rocket/rocket.py | 15 +++++++++++---- tests/unit/test_rocket.py | 9 +++++++++ 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 106d31f72..c0345c8d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,8 +35,8 @@ Attention: The newest changes should be on top --> - ### Changed - -- + +- ENH: Adding rocket radius to RailButtons class [#643](https://github.com/RocketPy-Team/RocketPy/pull/643) ### Fixed @@ -50,10 +50,10 @@ You can install this version by running `pip install rocketpy==1.4.1` - Bumps rocketpy version to 1.4.1 [#646](https://github.com/RocketPy-Team/RocketPy/pull/646) - ENH: Insert apogee state into solution list during flight simulation [#638](https://github.com/RocketPy-Team/RocketPy/pull/638) +- MNT: Refactor AeroSurfaces [#634](https://github.com/RocketPy-Team/RocketPy/pull/634) - ENH: Environment class major refactor may 2024 [#605](https://github.com/RocketPy-Team/RocketPy/pull/605) - MNT: Refactors the code to adopt flake8 [#631](https://github.com/RocketPy-Team/RocketPy/pull/631) - MNT: Refactors the code to adopt pylint [#621](https://github.com/RocketPy-Team/RocketPy/pull/621) -- MNT: Refactor AeroSurfaces [#634](https://github.com/RocketPy-Team/RocketPy/pull/634) ## [1.4.0] - 2024-07-06 diff --git a/rocketpy/rocket/aero_surface/rail_buttons.py b/rocketpy/rocket/aero_surface/rail_buttons.py index 6ffafbb97..102f35737 100644 --- a/rocketpy/rocket/aero_surface/rail_buttons.py +++ b/rocketpy/rocket/aero_surface/rail_buttons.py @@ -17,7 +17,13 @@ class RailButtons(AeroSurface): relative to one of the other principal axis. """ - def __init__(self, buttons_distance, angular_position=45, name="Rail Buttons"): + def __init__( + self, + buttons_distance, + angular_position=45, + name="Rail Buttons", + rocket_radius=None, + ): """Initializes RailButtons Class. Parameters @@ -30,6 +36,10 @@ def __init__(self, buttons_distance, angular_position=45, name="Rail Buttons"): relative to one of the other principal axis. name : string, optional Name of the rail buttons. Default is "Rail Buttons". + rocket_radius : int, float, optional + Radius of the rocket at the location of the rail buttons in meters. + If not provided, it will be calculated when the RailButtons object + is added to a Rocket object. Returns ------- @@ -40,7 +50,7 @@ def __init__(self, buttons_distance, angular_position=45, name="Rail Buttons"): self.buttons_distance = buttons_distance self.angular_position = angular_position self.name = name - + self.rocket_radius = rocket_radius self.evaluate_lift_coefficient() self.evaluate_center_of_pressure() diff --git a/rocketpy/rocket/rocket.py b/rocketpy/rocket/rocket.py index d6dff9113..1687d51d2 100644 --- a/rocketpy/rocket/rocket.py +++ b/rocketpy/rocket/rocket.py @@ -947,6 +947,7 @@ def add_surfaces(self, surfaces, positions): the root chord which is highest in the rocket coordinate system. For Tail type, position is relative to the point belonging to the tail which is highest in the rocket coordinate system. + For RailButtons type, position is relative to the lower rail button. See Also -------- @@ -956,11 +957,16 @@ def add_surfaces(self, surfaces, positions): ------- None """ - try: - for surface, position in zip(surfaces, positions): + if not isinstance(surfaces, list): + surfaces = [surfaces] + positions = [positions] + + for surface, position in zip(surfaces, positions): + if isinstance(surface, RailButtons): + surface.rocket_radius = surface.rocket_radius or self.radius + self.rail_buttons.add(surface, position) + else: self.aerodynamic_surfaces.add(surface, position) - except TypeError: - self.aerodynamic_surfaces.add(surfaces, positions) self.evaluate_center_of_pressure() self.evaluate_stability_margin() @@ -1512,6 +1518,7 @@ def set_rail_buttons( rail_buttons = RailButtons( buttons_distance=buttons_distance, angular_position=angular_position ) + rail_buttons.rocket_radius = rail_buttons.rocket_radius or self.radius self.rail_buttons.add(rail_buttons, lower_button_position) return rail_buttons diff --git a/tests/unit/test_rocket.py b/tests/unit/test_rocket.py index a984466ee..e36302c3e 100644 --- a/tests/unit/test_rocket.py +++ b/tests/unit/test_rocket.py @@ -392,6 +392,15 @@ def test_set_rail_button(calisto): ].position == pytest.approx(0.2, 1e-12) +def test_add_rail_button(calisto, calisto_rail_buttons): + calisto.add_surfaces(calisto_rail_buttons, -0.5) + assert calisto.rail_buttons[0].position == -0.5 + upper_position = ( + calisto_rail_buttons.buttons_distance + calisto.rail_buttons[0].position + ) + assert upper_position == pytest.approx(0.2, 1e-12) + + def test_evaluate_total_mass(calisto_motorless): """Tests the evaluate_total_mass method of the Rocket class. Both with respect to return instances and expected behaviour. From 3de383ac3514ac0f3912cd45aeccaecaecd2d440 Mon Sep 17 00:00:00 2001 From: MateusStano <69485049+MateusStano@users.noreply.github.com> Date: Sat, 3 Aug 2024 12:11:23 -0300 Subject: [PATCH 2/3] BUG: Time Node Merge Not Including Controllers (#647) * BUG: merge not including controllers * DEV: changelog --- CHANGELOG.md | 2 +- rocketpy/simulation/flight.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0345c8d9..ff20ee64d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,7 +40,7 @@ Attention: The newest changes should be on top --> ### Fixed -- +- BUG: Time Node Merge Not Including Controllers [#647](https://github.com/RocketPy-Team/RocketPy/pull/647) ## [v1.4.1] - 2024-07-20 diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 6b43b18c1..31d1f79d5 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -3498,6 +3498,7 @@ def merge(self): try: # Try to access the node and merge if it exists tmp_dict[time].parachutes += node.parachutes + tmp_dict[time]._controllers += node._controllers tmp_dict[time].callbacks += node.callbacks except KeyError: # If the node does not exist, add it to the dictionary From 174aee5f051f51ea62bd802fd14c626a7f9ddf96 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Sat, 3 Aug 2024 12:16:54 -0300 Subject: [PATCH 3/3] REL: Bump versioning to RocketPy v1.4.2 --- CHANGELOG.md | 17 ++++++++++++++--- docs/conf.py | 2 +- docs/user/installation.rst | 2 +- pyproject.toml | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff20ee64d..9a833bf37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,10 +32,21 @@ Attention: The newest changes should be on top --> ### Added -- ### Changed - + + +### Fixed + + + +## [v1.4.2] - 2024-08-03 + +You can install this version by running `pip install rocketpy==1.4.2` + +### Changed + +- REL: Bump versioning to RocketPy v1.4.2 [#648](https://github.com/RocketPy-Team/RocketPy/pull/648) - ENH: Adding rocket radius to RailButtons class [#643](https://github.com/RocketPy-Team/RocketPy/pull/643) ### Fixed @@ -48,7 +59,7 @@ You can install this version by running `pip install rocketpy==1.4.1` ### Changed -- Bumps rocketpy version to 1.4.1 [#646](https://github.com/RocketPy-Team/RocketPy/pull/646) +- REL: Bumps rocketpy version to 1.4.1 [#646](https://github.com/RocketPy-Team/RocketPy/pull/646) - ENH: Insert apogee state into solution list during flight simulation [#638](https://github.com/RocketPy-Team/RocketPy/pull/638) - MNT: Refactor AeroSurfaces [#634](https://github.com/RocketPy-Team/RocketPy/pull/634) - ENH: Environment class major refactor may 2024 [#605](https://github.com/RocketPy-Team/RocketPy/pull/605) diff --git a/docs/conf.py b/docs/conf.py index 7de64de99..ce4162c1e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,7 +25,7 @@ author = "RocketPy Team" # The full version, including alpha/beta/rc tags -release = "1.4.1" +release = "1.4.2" # -- General configuration --------------------------------------------------- diff --git a/docs/user/installation.rst b/docs/user/installation.rst index 5bbd6b3af..d82c6bf29 100644 --- a/docs/user/installation.rst +++ b/docs/user/installation.rst @@ -19,7 +19,7 @@ If you want to choose a specific version to guarantee compatibility, you may ins .. code-block:: shell - pip install rocketpy==1.4.1 + pip install rocketpy==1.4.2 Optional Installation Method: ``conda`` diff --git a/pyproject.toml b/pyproject.toml index c150e56eb..93fe7bb93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "rocketpy" -version = "1.4.1" +version = "1.4.2" description="Advanced 6-DOF trajectory simulation for High-Power Rocketry." dynamic = ["dependencies"] readme = "README.md"