ENH: Zero Inertia tensor Check

未關閉
#826 0 則留言 1 個 reaction 已指派 1 人 在 GitHub 檢視

維護者通常 3 天內回覆

@aZira371 已經在處理了。

開始於 2025年6月13日。

  • #833 來自 @aZira371 —— 已關閉,未合併

評估

這個 Issue 還沒有評估資料。

描述

Enhancement

Is your feature request related to a problem? Please describe.

Previously, users could accidentally set the rocket's dry inertia tensor to a zero vector or otherwise singular configuration. This led to runtime errors during simulation, typically manifesting as RuntimeWarning: divide by zero encountered in scalar divide and subsequent integration failures in the ODE solver.

Describe the solution you'd like

The dry inertia tensor should be validated as soon as the Rocket object is initialized. Specifically:

  • Construct the 3×3 inertia matrix from user-provided I_ij values in Rocket.init.

  • Immediately compute its determinant.

  • Raise a clear ValueError if the determinant is zero (i.e., the tensor is singular), with a helpful message prompting users to provide physically realistic values.

  • This approach shifts error detection earlier in the development cycle, prevents invalid configurations from reaching the solver, and gives users a precise explanation of what's wrong.

  • No changes are made to motor or dynamic inertia evaluation. Only the dry inertia (which is static and available at init) is validated.

Additional context

  • This change improves usability and safety, especially for multi-stage and upper-stage configurations where users often define placeholder or dummy inertia values.

  • It avoids obscure integration failures and makes RocketPy more robust to user error.

  • The solution avoids invasive structural changes by operating entirely within the Rocket class and leveraging existing Matrix functionality.

Future extensions could optionally introduce runtime checks for singular dynamic inertias (e.g., in u_dot_generalized), but this patch focuses only on validating static dry inertia at creation time. For dynamic inertia evaluation a debug_inertia_check can be implemented as optional boolean flag added to the Flight class to catch near-singular total inertia tensors during simulation. When enabled, it performs a lightweight determinant check on the dynamically evaluated total inertia matrix at each time step. If the determinant falls below a safe threshold, a clear error is raised indicating potential instability due to ill-conditioned inertial properties. This helps users catch modeling or configuration issues in motor or mass properties that may otherwise cause silent solver failures. The feature is off by default to avoid performance overhead in production runs.

主要語言
Python
星號
1.1k
分支
280
平均合併
3 天 2 小時
30 天內合併 PR
24

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

RocketPy-Team/RocketPy 的其他 Issue

查看 RocketPy-Team/RocketPy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。