Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH: Improve Stability Margin with Angle of Attack Dependency#899

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge2 commits intodevelop
base:develop
Choose a base branch
Loading
fromcopilot/improve-stability-margin-computation

Conversation

Copy link

CopilotAI commentedDec 2, 2025
edited
Loading

Pull request type

  • Code changes (bugfix, features)

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

Stability margin uses CN_α (lift coefficient derivative) to compute center of pressure:

CP = Σ(CN_α × X_cp) / Σ(CN_α)

This produces a CP independent of angle of attack, unlike OpenRocket's more dynamic behavior.

New behavior

Stability margin now uses CN(α) (actual lift coefficient) for CP calculation:

CP = Σ(CN(α) × X_cp) / Σ(CN(α))

New methods inRocket class:

  • get_cp_position_from_alpha(alpha, mach) - computes CP as function of AoA and Mach
  • get_stability_margin_from_alpha(alpha, mach, time) - computes stability margin using AoA-dependent CP

Updated inFlight class:

  • stability_margin now uses simulation's angle of attack data
# New methods availablecp=rocket.get_cp_position_from_alpha(alpha=0.1,mach=0.5)sm=rocket.get_stability_margin_from_alpha(alpha=0.1,mach=0.5,time=2.0)# Flight.stability_margin now accounts for AoA automaticallyflight.stability_margin# Uses actual AoA from simulation

Note: With current linear lift models (cl = clalpha * α), the α cancels mathematically. This change establishes the correct framework for future non-linear aerodynamic models (custom airfoils, wind tunnel data).

Breaking change

  • No

Additional information

References:

Original prompt

This section details on the original issue you should resolve

<issue_title>ENH: Improve Stability Margin</issue_title>
<issue_description>Currently we use the rocket's total center of pressure to compute the stability margin of the Flight class.

Since this center of pressure is defined based on the normal force coefficient derivative with respect to the angle of attack (cnalpha) we end up with a curve that does not change with the angle of attack, as reported by user Eli [ARIS]
(dvoeli05_67950) in our discord.

On RocketPy:
Image

On OpenRocket:
Image

As you can see, in OpenRocket the stability margin is much more "dynamic" than ours.

Describe the solution you'd like

In the Flight class, instead of using the angle of attack independent center of pressure for the stability margin calculations :

$$CP = \frac{ \sum (C_{N})_{\alpha} \cdot (X_{cp})_{\text{surface}}} {\sum (C_{N})_{\alpha}}$$

We should use a calculation that is dependent on alpha:

$$CP = \frac{ \sum C_{N}(\alpha) \cdot (X_{cp})_{\text{surface}}} {\sum C_{N}(\alpha) }$$

References:

<agent_instructions>Please solve the issue described here.

Make a plan, find where in the code you're going to implement new changes. Then implement it following project guidelines.</agent_instructions>

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


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

CopilotAI changed the title[WIP] Enhance stability margin calculation in Flight classENH: Improve Stability Margin with Angle of Attack DependencyDec 2, 2025
@Gui-FernandesBRGui-FernandesBR linked an issueDec 2, 2025 that may beclosed by this pull request
@Gui-FernandesBRGui-FernandesBRforce-pushed thecopilot/improve-stability-margin-computation branch from1898cb3 to0dff1a7CompareDecember 2, 2025 17:08
@codecov
Copy link

codecovbot commentedDec 2, 2025
edited
Loading

Codecov Report

❌ Patch coverage is96.66667% with1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.11%. Comparing base (9cf3dd4) to head (581ad7a).
⚠️ Report is 24 commits behind head on develop.

Files with missing linesPatch %Lines
rocketpy/rocket/rocket.py95.00%1 Missing⚠️
Additional details and impacted files
@@             Coverage Diff             @@##           develop     #899      +/-   ##===========================================+ Coverage    80.27%   81.11%   +0.84%===========================================  Files          104      107       +3       Lines        12769    13841    +1072     ===========================================+ Hits         10250    11227     +977- Misses        2519     2614      +95

☔ 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.

Comment on lines +3124 to +3694
aoa_values=self.angle_of_attack.y_array
mach_values=self.mach_number.y_array
time_values=self.time

results= []
fori,tinenumerate(time_values):
# Convert angle of attack from degrees to radians
alpha_rad=np.deg2rad(aoa_values[i])
mach=mach_values[i]
sm=self.rocket.get_stability_margin_from_alpha(alpha_rad,mach,t)
results.append((t,sm))

returnresults

Choose a reason for hiding this comment

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

could be more pythonic

@Gui-FernandesBRGui-FernandesBRforce-pushed thecopilot/improve-stability-margin-computation branch from0dff1a7 tod1e1a42CompareDecember 3, 2025 22:38
CopilotAIand others added2 commitsDecember 8, 2025 21:25
Add new methods to compute center of pressure and stability marginas a function of angle of attack (α) instead of just using the liftcoefficient derivative. This provides a more accurate stabilitymargin that varies with angle of attack, similar to OpenRocket.- Add Rocket.get_cp_position_from_alpha(alpha, mach) method- Add Rocket.get_stability_margin_from_alpha(alpha, mach, time) method- Update Flight.stability_margin to use angle of attack from simulation- Add tests for new functionalityCo-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>
- Add comment explaining degrees to radians conversion in Flight.stability_margin- Replace magic number 1e-10 with named constant epsilon in get_cp_position_from_alphaCo-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com>
@Gui-FernandesBRGui-FernandesBRforce-pushed thecopilot/improve-stability-margin-computation branch fromd1e1a42 to581ad7aCompareDecember 9, 2025 00:25
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@Gui-FernandesBRGui-FernandesBRGui-FernandesBR left review comments

At least 1 approving review is required to merge this pull request.

Labels

None yet

Projects

No open projects
Status: Backlog

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

ENH: Improve Stability Margin

2 participants

@Gui-FernandesBR

[8]ページ先頭

©2009-2025 Movatter.jp