diff --git a/CHANGELOG.md b/CHANGELOG.md index f78b34edb..bc100f3a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/rocketpy/rocket/rocket.py b/rocketpy/rocket/rocket.py index 31ef9dd3f..67ae4568e 100644 --- a/rocketpy/rocket/rocket.py +++ b/rocketpy/rocket/rocket.py @@ -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: + raise ValueError( + "The rocket inertia tensor is singular (determinant is zero). " + ) # Define rocket geometrical parameters in SI units self.center_of_mass_without_motor = center_of_mass_without_motor