Skip to content

BUG: Fix hard-coded radius value for parachute added mass calculation#889

Open
Copilot wants to merge 8 commits intodevelopfrom
copilot/remove-hard-coded-radius-value
Open

BUG: Fix hard-coded radius value for parachute added mass calculation#889
Copilot wants to merge 8 commits intodevelopfrom
copilot/remove-hard-coded-radius-value

Conversation

Copy link

Copilot AI commented Nov 28, 2025

Pull request type

  • Code changes (bugfix, features)
  • Code maintenance (refactoring, formatting, tests)

Checklist

  • Tests for the changes have been added (if needed)
  • Docs have been reviewed and added / updated
  • Lint (black rocketpy/ tests/) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md has been updated (if relevant)

Current behavior

Hard-coded radius=1.5 in Parachute.__init__ and Rocket.add_parachute causes incorrect added mass calculations for smaller parachutes. For drogue chutes (cd_s ≈ 1.0), the added mass was overestimated by ~31x, resulting in excessive drift distances.

New behavior

Radius is now computed from cd_s when not explicitly provided:

R = sqrt(cd_s / (Cd * π))

Using a drag_coefficient of 1.4 by default (typical hemispherical parachute drag coefficient, per NASA SP-8066).

Changes:

  • Default radius parameter changed from 1.5 to None in both Parachute class and Rocket.add_parachute method
  • Added drag_coefficient parameter (default 1.4) to allow users to specify the canopy shape; radius is auto-calculated from cd_s and drag_coefficient when not explicitly provided
  • Updated docstrings with formula documentation and typical drag_coefficient values
  • Updated from_dict to handle new defaults
  • Extracted noise initialization into __init_noise private method to resolve pylint too-many-statements warning in Parachute.__init__
  • make format passes cleanly with no changes

Example results:

Parachute cd_s Old radius New radius
Main 10.0 1.5 m 1.51 m
Drogue 1.0 1.5 m 0.48 m

Users can still explicitly set radius to override auto-calculation.

Breaking change

  • Yes
  • No

Existing code providing explicit radius values is unaffected. Code relying on the implicit default will now get physically appropriate values based on cd_s.

Original prompt

This section details on the original issue you should resolve

<issue_title>Remove Hard coded radius value for lateral acceleration in descent under parachute</issue_title>
<issue_description>Is your feature request related to a problem? Please describe.

Lateral acceleration for descent under parachute (in the function u_dot_parachute) depends on the air trapped beneath a parachute to determine the mass to divide drag force by. This added mass value depends on the radius R which is hard coded to 1.5
This causes issues with drift distance for smaller rockets and drogue parachutes leading to much higher drift distances than expected

Describe the solution you'd like

Either remove the hard coded value or determine radius based on a hard coded value for the coefficient of drag for a parachute, which is a much more reasonable thing to be hard coded.

Additional context

N/A
</issue_description>

<agent_instructions>Remove Hard coded radius value for lateral acceleration in descent under parachute #860
Open
Task
@RyanSamF
Description
RyanSamF
opened on Oct 24
Is your feature request related to a problem? Please describe.

Lateral acceleration for descent under parachute (in the function u_dot_parachute) depends on the air trapped beneath a parachute to determine the mass to divide drag force by. This added mass value depends on the radius R which is hard coded to 1.5
This causes issues with drift distance for smaller rockets and drogue parachutes leading to much higher drift distances than expected

Describe the solution you'd like

Either remove the hard coded value or determine radius based on a hard coded value for the coefficient of drag for a parachute, which is a much more reasonable thing to be hard coded.

Additional context

N/A

Activity

github-project-automation
added this to LibDev Roadmapon Oct 24

github-project-automation
moved this to Backlog in LibDev Roadmapon Oct 24
Gui-FernandesBR
Gui-FernandesBR commented on Oct 25
Gui-FernandesBR
on Oct 25
Member
Could you help us providing references?

RyanSamF
RyanSamF commented on Oct 25
RyanSamF
on Oct 25
Author
RocketPy/rocketpy/simulation/flight.py

Lines 1969 to 1995 in 2655a4f

ka = 1 # Added mass coefficient (depends on parachute's porosity)
R = 1.5 # Parachute radius

to = 1.2

eta = 1

Rdot = (6 * R * (1 - eta) / (1.2**6)) * (

(1 - eta) * t5 + eta * (to3) * (t**2)

)

Rdot = 0

Calculate added mass

ma = ka * rho * (4 / 3) * np.pi * R**3

Calculate freestream speed

freestream_x = vx - wind_velocity_x
freestream_y = vy - wind_velocity_y
freestream_z = vz
free_stream_speed = (freestream_x2 + freestream_y2 + freestream_z**2) ** 0.5

Determine drag force

pseudo_drag = -0.5 * rho * cd_s * free_stream_speed

pseudo_drag = pseudo_drag - ka * rho * 4 * np.pi * (R**2) * Rdot

Dx = pseudo_drag * freestream_x
Dy = pseudo_drag * freestream_y
Dz = pseudo_drag * freestream_z
ax = Dx / (mp + ma)
ay = Dy / (mp + ma)
az = (Dz - 9.8 * mp) / (mp + ma)

Gui-FernandesBR
added the
Task
issue type 8 hours ago

Gui-FernandesBR
added
Parachute
Related to parachutes methods and usage
8 hours ago
Gui-FernandesBR
Gui-FernandesBR commented 8 hours ago
Gui-FernandesBR
8 hours ago
Member
@RyanSamF when I say "reference", I was actually meaning "bibliometric references". I'm going to search about it.

I have to investigate it better, but I think @ArthurJWH has already solved this one with his recent modifications to the parachute class

Gui-FernandesBR
Gui-FernandesBR commented now
Gui-FernandesBR
now
Member
The main reference for parachute modeling is: https://apps.dtic.mil/sti/tr/pdf/ADA247666.pdf

Also, don't forget to run make format, make lint e make pytest antes de marcar o PR como concluido.

</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@Gui-FernandesBR Could you help us providing references? @Gui-FernandesBR @RyanSamF when I say "reference", I was actually meaning "bibliometric references". I'm going to search about it.

I have to investigate it better, but I think @ArthurJWH has already solved this one with his recent modifications to the parachute class</comment_new>
<comment_new>@Gui-FernandesBR
The main reference for parachute modeling is: https://apps.dtic.mil/sti/tr/pdf/ADA247666.pdf</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Remove hard coded radius value for lateral acceleration Fix hard-coded radius value for parachute added mass calculation Nov 28, 2025
@Gui-FernandesBR
Copy link
Member

@copilot remind to add the PR to the CHANGELOG file

Copilot AI added a commit that referenced this pull request Nov 28, 2025
Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>
Copy link
Author

Copilot AI commented Nov 28, 2025

@copilot remind to add the PR to the CHANGELOG file

Added the CHANGELOG entry in commit 314ca47.

@Gui-FernandesBR Gui-FernandesBR marked this pull request as ready for review November 28, 2025 02:57
@Gui-FernandesBR Gui-FernandesBR requested a review from a team as a code owner November 28, 2025 02:57
@codecov
Copy link

codecov bot commented Nov 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.08%. Comparing base (9cf3dd4) to head (fb64171).
⚠️ Report is 34 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #889      +/-   ##
===========================================
+ Coverage    80.27%   81.08%   +0.80%     
===========================================
  Files          104      107       +3     
  Lines        12769    13897    +1128     
===========================================
+ Hits         10250    11268    +1018     
- Misses        2519     2629     +110     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@ArthurJWH ArthurJWH left a comment

Choose a reason for hiding this comment

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

The PR seems reasonable and correct, although it will introduce breaking changes to current simulations that relies on the previously hard coded radius. If this PR proceeds, I would suggest first changing the add_parachute default radius value for consistency in rocket class.

@Gui-FernandesBR
Copy link
Member

The PR seems reasonable and correct, although it will introduce breaking changes to current simulations that relies on the previously hard coded radius. If this PR proceeds, I would suggest first changing the add_parachute default radius value for consistency in rocket class.

@copilot please solve the backwards compatibility issue here.

Copy link
Author

Copilot AI commented Dec 2, 2025

The PR seems reasonable and correct, although it will introduce breaking changes to current simulations that relies on the previously hard coded radius. If this PR proceeds, I would suggest first ch...

Updated rocket.add_parachute to use radius=None as the default, matching the Parachute class. Now both APIs consistently auto-calculate radius from cd_s when not explicitly provided. See commit 24eb9a8.

Gui-FernandesBR added a commit that referenced this pull request Dec 2, 2025
Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>
@Gui-FernandesBR Gui-FernandesBR force-pushed the copilot/remove-hard-coded-radius-value branch from 24eb9a8 to 77903d8 Compare December 2, 2025 13:25
@Gui-FernandesBR Gui-FernandesBR marked this pull request as draft December 11, 2025 18:39
Gui-FernandesBR added a commit that referenced this pull request Feb 28, 2026
Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>
@Gui-FernandesBR Gui-FernandesBR force-pushed the copilot/remove-hard-coded-radius-value branch from 601ba5d to e41f227 Compare February 28, 2026 00:37
@Gui-FernandesBR Gui-FernandesBR marked this pull request as ready for review February 28, 2026 01:11
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>
Copilot AI and others added 4 commits February 27, 2026 22:11
Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>
Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>
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>
…uce drag_coefficient parameter for radius estimation
@Gui-FernandesBR Gui-FernandesBR force-pushed the copilot/remove-hard-coded-radius-value branch from 3489a70 to 9c43855 Compare February 28, 2026 01:11
@Gui-FernandesBR
Copy link
Member

@copilot please fix the pylint error by extracting a few definitions from the init method, just like this:

Skip to content
RocketPy-Team
RocketPy
Repository navigation
Code
Issues
61
(61)
Pull requests
16
(16)
Agents
Actions
Projects
Wiki
Security
Insights
Settings
BUG: Fix hard-coded radius value for parachute added mass calculation
#936
Closed
Gui-FernandesBR
wants to merge 6 commits into
copilot/remove-hard-coded-radius-value
from
claude/kind-hodgkin
+205
-39
Lines changed: 205 additions & 39 deletions
Conversation0 (0)
Commits6 (6)
Checks8 (8)
Files changed5 (5)
Pull Request Toolbar
0 / 1 viewed
Filter files…
File tree
rocketpy/rocket
parachute.py
MNT: Extract noise initialization to fix pylint too-many-statements in Parachute.init
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
Gui-FernandesBRclaude
Gui-FernandesBR
and
claude
committed
3 minutes ago
·
·
Verified
commit
158b81a
‎rocketpy/rocket/parachute.py‎
+15
-13
Lines changed: 15 additions & 13 deletions
Original file line number Diff line number Diff line change
self.sampling_rate = sampling_rate
self.lag = lag
self.noise = noise
self.noise_signal = [[-1e-6, np.random.normal(noise[0], noise[1])]]
self.noisy_pressure_signal = []
self.clean_pressure_signal = []
self.noise_bias = noise[0]
self.noise_deviation = noise[1]
self.noise_corr = (noise[2], (1 - noise[2] ** 2) ** 0.5)
self.clean_pressure_signal_function = Function(0)
self.noisy_pressure_signal_function = Function(0)
self.noise_signal_function = Function(0)
self._initialize_noise_attributes(noise)
self.drag_coefficient = drag_coefficient
# Estimate radius from cd_s if not provided.
# cd_s = Cd * S = Cd * π * R² => R = sqrt(cd_s / (Cd * π))
- 0.25975 * self.porosity2
+ 1.2626 * self.porosity
3
)
self.prints = _ParachutePrints(self)

    self.__evaluate_trigger_function(trigger)
def _initialize_noise_attributes(self, noise):
    """Initializes noise-related attributes for the parachute pressure signal."""
    self.noise_signal = [[-1e-6, np.random.normal(noise[0], noise[1])]]
    self.noisy_pressure_signal = []
    self.clean_pressure_signal = []
    self.noise_bias = noise[0]
    self.noise_deviation = noise[1]
    self.noise_corr = (noise[2], (1 - noise[2] ** 2) ** 0.5)
    self.clean_pressure_signal_function = Function(0)
    self.noisy_pressure_signal_function = Function(0)
    self.noise_signal_function = Function(0)
    alpha, beta = self.noise_corr
    self.noise_function = lambda: (
        alpha * self.noise_signal[-1][1]
        + beta * np.random.normal(noise[0], noise[1])
    )

    self.prints = _ParachutePrints(self)
    self.__evaluate_trigger_function(trigger)
def __evaluate_trigger_function(self, trigger):
    """This is used to set the triggerfunc attribute that will be used to
    interact with the Flight class.

…n Parachute.__init__

Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>
Copy link
Author

Copilot AI commented Mar 9, 2026

@copilot please fix the pylint error by extracting a few definitions from the init method, just like this:

[Skip to content](#936...

Extracted noise initialization into a __init_noise private method (commit fb64171). The pylint score went from 9.25/10 to 9.39/10 with the "too-many-statements" warning resolved. Also confirmed make format passes cleanly (255 files unchanged).

Copilot AI changed the title Fix hard-coded radius value for parachute added mass calculation BUG: Fix hard-coded radius value for parachute added mass calculation Mar 9, 2026
if radius is None:
self.radius = np.sqrt(cd_s / (drag_coefficient * np.pi))
else:
self.radius = radius
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe can be rewritten as self.radius = radius or np.sqrt(cd_s / (drag_coefficient * np.pi))
I am not sure if that reduces the number of statements

canopy area), in [0, 1]. Affects only the added-mass scaling
during descent; it does not change `cd_s` (drag). The default
value of 0.0432 yields an `added_mass_coefficient` of
approximately 1.0.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we keep the "neutral behavior" description to keep it consistent with the description in Parachute class?

- BUG: Fix hard-coded radius value for parachute added mass calculation [#889](https://github.com/RocketPy-Team/RocketPy/pull/889)
- DOC: Fix documentation build [#908](https://github.com/RocketPy-Team/RocketPy/pull/908)
- BUG: energy_data plot not working for 3 dof sims [[#906](https://github.com/RocketPy-Team/RocketPy/issues/906)]
- BUG: Fix parallel Monte Carlo simulation showing incorrect iteration count [#806](https://github.com/RocketPy-Team/RocketPy/pull/806)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this showing as an addition in this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Backlog

Development

Successfully merging this pull request may close these issues.

Remove Hard coded radius value for lateral acceleration in descent under parachute

3 participants