From 318793ca2e8e6eeb740ff61bdc35a7c6e8fc1eff Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 28 Nov 2025 00:43:12 +0000 Subject: [PATCH 1/4] Fix hard-coded radius value for parachute added mass calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calculate radius from cd_s using a typical hemispherical parachute drag coefficient (1.4) when radius is not explicitly provided. This fixes drift distance calculations for smaller parachutes like drogues. Formula: R = sqrt(cd_s / (Cd * π)) Closes #860 Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com> --- rocketpy/rocket/parachute.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/rocketpy/rocket/parachute.py b/rocketpy/rocket/parachute.py index f0bf86f67..574890cee 100644 --- a/rocketpy/rocket/parachute.py +++ b/rocketpy/rocket/parachute.py @@ -94,8 +94,8 @@ class Parachute: Function of clean_pressure_signal. Parachute.radius : float Length of the non-unique semi-axis (radius) of the inflated hemispheroid - parachute in meters. - Parachute.height : float, None + parachute in meters. Estimated from ``cd_s`` if not explicitly provided. + Parachute.height : float Length of the unique semi-axis (height) of the inflated hemispheroid parachute in meters. Parachute.porosity : float @@ -108,6 +108,10 @@ class Parachute: calculated from the porosity of the parachute. """ + # Typical drag coefficient for hemispherical parachute + # Used to estimate radius from cd_s when radius is not provided + HEMISPHERICAL_CD = 1.4 + def __init__( self, name, @@ -116,7 +120,7 @@ def __init__( sampling_rate, lag=0, noise=(0, 0, 0), - radius=1.5, + radius=None, height=None, porosity=0.0432, ): @@ -173,7 +177,9 @@ def __init__( Units are in Pa. radius : float, optional Length of the non-unique semi-axis (radius) of the inflated hemispheroid - parachute. Default value is 1.5. + parachute. If not provided, it is estimated from ``cd_s`` assuming a + typical hemispherical parachute drag coefficient of 1.4, using the + formula: ``radius = sqrt(cd_s / (HEMISPHERICAL_CD * pi))``. Units are in meters. height : float, optional Length of the unique semi-axis (height) of the inflated hemispheroid @@ -200,8 +206,13 @@ def __init__( self.clean_pressure_signal_function = Function(0) self.noisy_pressure_signal_function = Function(0) self.noise_signal_function = Function(0) - self.radius = radius - self.height = height or radius + # Estimate radius from cd_s if not provided + if radius is None: + # cd_s = Cd * S = Cd * π * R² => R = sqrt(cd_s / (Cd * π)) + self.radius = np.sqrt(cd_s / (self.HEMISPHERICAL_CD * np.pi)) + else: + self.radius = radius + self.height = height or self.radius self.porosity = porosity self.added_mass_coefficient = 1.068 * ( 1 @@ -340,8 +351,8 @@ def from_dict(cls, data): sampling_rate=data["sampling_rate"], lag=data["lag"], noise=data["noise"], - radius=data.get("radius", 1.5), - height=data.get("height", None), + radius=data.get("radius"), + height=data.get("height"), porosity=data.get("porosity", 0.0432), ) From 4a13b2b587da80bdb0a4d3ef79039569b7d5f4f4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 28 Nov 2025 00:46:08 +0000 Subject: [PATCH 2/4] Address code review: improve docstrings and add explicit None defaults Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com> --- rocketpy/rocket/parachute.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rocketpy/rocket/parachute.py b/rocketpy/rocket/parachute.py index 574890cee..90645c4fd 100644 --- a/rocketpy/rocket/parachute.py +++ b/rocketpy/rocket/parachute.py @@ -94,7 +94,8 @@ class Parachute: Function of clean_pressure_signal. Parachute.radius : float Length of the non-unique semi-axis (radius) of the inflated hemispheroid - parachute in meters. Estimated from ``cd_s`` if not explicitly provided. + parachute in meters. Estimated from ``cd_s`` using the formula + ``R = sqrt(cd_s / (1.4 * π))`` if not explicitly provided. Parachute.height : float Length of the unique semi-axis (height) of the inflated hemispheroid parachute in meters. @@ -351,8 +352,8 @@ def from_dict(cls, data): sampling_rate=data["sampling_rate"], lag=data["lag"], noise=data["noise"], - radius=data.get("radius"), - height=data.get("height"), + radius=data.get("radius", None), + height=data.get("height", None), porosity=data.get("porosity", 0.0432), ) From 95b51310f70a003cf8b7bbd450f11af8fd61f879 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 28 Nov 2025 01:01:40 +0000 Subject: [PATCH 3/4] Add CHANGELOG entry for PR #889 Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com> --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1e06c193..6b35e3d7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Attention: The newest changes should be on top --> ### Fixed +- BUG: Fix hard-coded radius value for parachute added mass calculation [#889](https://github.com/RocketPy-Team/RocketPy/pull/889) - BUG: Fix parallel Monte Carlo simulation showing incorrect iteration count [#806](https://github.com/RocketPy-Team/RocketPy/pull/806) - BUG: Fix CSV column header spacing in FlightDataExporter [#864](https://github.com/RocketPy-Team/RocketPy/issues/864) From 77903d8c7683a2388a20dbb21743c65acdb77b56 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 2 Dec 2025 01:58:37 +0000 Subject: [PATCH 4/4] Update rocket.add_parachute to use radius=None for consistency Changed the default radius from 1.5 to None in the add_parachute method to match the Parachute class behavior. This ensures consistent automatic radius calculation from cd_s across both APIs. Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com> --- rocketpy/rocket/rocket.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rocketpy/rocket/rocket.py b/rocketpy/rocket/rocket.py index c3b1f364d..8faadc8ac 100644 --- a/rocketpy/rocket/rocket.py +++ b/rocketpy/rocket/rocket.py @@ -1475,7 +1475,7 @@ def add_parachute( sampling_rate=100, lag=0, noise=(0, 0, 0), - radius=1.5, + radius=None, height=None, porosity=0.0432, ): @@ -1538,7 +1538,9 @@ def add_parachute( are in pascal. radius : float, optional Length of the non-unique semi-axis (radius) of the inflated hemispheroid - parachute. Default value is 1.5. + parachute. If not provided, it is estimated from ``cd_s`` assuming a + typical hemispherical parachute drag coefficient of 1.4, using the + formula: ``radius = sqrt(cd_s / (1.4 * pi))``. Units are in meters. height : float, optional Length of the unique semi-axis (height) of the inflated hemispheroid