Skip to content

Enh/zero inertia tensor check #833

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Attention: The newest changes should be on top -->

- ENH: _MotorPrints inheritance - issue #460 [#828](https://github.com/RocketPy-Team/RocketPy/pull/828)
- MNT: fix deprecations and warnings [#829](https://github.com/RocketPy-Team/RocketPy/pull/829)
- Enh/zero inertia tensor check [#833](https://github.com/RocketPy-Team/RocketPy/pull/833)

### Fixed

Expand Down
23 changes: 23 additions & 0 deletions rocketpy/rocket/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,29 @@ def __init__( # pylint: disable=too-many-statements
self.I_12_without_motor = inertia[3]
self.I_13_without_motor = inertia[4]
self.I_23_without_motor = inertia[5]
inertia_matrix = Matrix(
[
[
self.I_11_without_motor,
self.I_12_without_motor,
self.I_13_without_motor,
],
[
self.I_12_without_motor,
self.I_22_without_motor,
self.I_23_without_motor,
],
[
self.I_13_without_motor,
self.I_23_without_motor,
self.I_33_without_motor,
],
]
) # Initial Inertia Tensor determinant singularity check
if abs(inertia_matrix) == 0:
Copy link
Preview

Copilot AI Jun 22, 2025

Choose a reason for hiding this comment

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

Using abs(inertia_matrix) to check for a singular matrix might not correctly compute the determinant; it is recommended to use the proper determinant method (e.g., inertia_matrix.det()) for an accurate singularity check.

Suggested change
if abs(inertia_matrix) == 0:
if inertia_matrix.det() == 0:

Copilot uses AI. Check for mistakes.

raise ValueError(
"The rocket inertia tensor is singular (determinant is zero). "
)
Comment on lines +295 to +317
Copy link
Member

Choose a reason for hiding this comment

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

I think having the dry inertia as zero should not stop the simulation, since someone might only have the inertias on the motor for some reason.

In any case, we need the determinant of the Rocket + Motor Inertia Matrix to be different from zero. Could you move this check so that it is done when a motor is added?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So you mean to say someone might want to simulate just a motor and check the trajectory?

Yes agreed I'll move it to when the motor is added.


# Define rocket geometrical parameters in SI units
self.center_of_mass_without_motor = center_of_mass_without_motor
Expand Down
Loading