Skip to content

Commit

Permalink
MNT: apply parallel_axis_theorem function to hybrid and liquid motors
Browse files Browse the repository at this point in the history
  • Loading branch information
Gui-FernandesBR committed Mar 8, 2024
1 parent 82bc824 commit 4815512
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
31 changes: 15 additions & 16 deletions rocketpy/motors/hybrid_motor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from rocketpy.tools import parallel_axis_theorem

from ..mathutils.function import Function, funcify_method, reset_funcified_methods
from ..plots.hybrid_motor_plots import _HybridMotorPlots
from ..prints.hybrid_motor_prints import _HybridMotorPrints
Expand Down Expand Up @@ -455,23 +457,20 @@ def propellant_I_11(self):
----------
.. [1] https://en.wikipedia.org/wiki/Moment_of_inertia#Inertia_tensor
"""
solid_correction = (
self.solid.propellant_mass
* (self.solid.center_of_propellant_mass - self.center_of_propellant_mass)
** 2
)
liquid_correction = (
self.liquid.propellant_mass
* (self.liquid.center_of_propellant_mass - self.center_of_propellant_mass)
** 2
)

I_11 = (
self.solid.propellant_I_11
+ solid_correction
+ self.liquid.propellant_I_11
+ liquid_correction
)
solid_mass = self.solid.propellant_mass
liquid_mass = self.liquid.propellant_mass

cm = self.center_of_propellant_mass
solid_cm_to_cm = self.solid.center_of_propellant_mass - cm
liquid_cm_to_cm = self.liquid.center_of_propellant_mass - cm

solid_prop_inertia = self.solid.propellant_I_11
liquid_prop_inertia = self.liquid.propellant_I_11

I_11 = parallel_axis_theorem(
solid_prop_inertia, solid_mass, solid_cm_to_cm
) + parallel_axis_theorem(liquid_prop_inertia, liquid_mass, liquid_cm_to_cm)

return I_11

Expand Down
8 changes: 3 additions & 5 deletions rocketpy/motors/liquid_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
funcify_method,
reset_funcified_methods,
)
from rocketpy.tools import parallel_axis_theorem

from ..plots.liquid_motor_plots import _LiquidMotorPlots
from ..prints.liquid_motor_prints import _LiquidMotorPrints
Expand Down Expand Up @@ -388,11 +389,8 @@ def propellant_I_11(self):
for positioned_tank in self.positioned_tanks:
tank = positioned_tank.get("tank")
tank_position = positioned_tank.get("position")
I_11 += (
tank.inertia
+ tank.fluid_mass
* (tank_position + tank.center_of_mass - center_of_mass) ** 2
)
distance = tank_position + tank.center_of_mass - center_of_mass
I_11 += parallel_axis_theorem(tank.inertia, tank.fluid_mass, distance)

return I_11

Expand Down

0 comments on commit 4815512

Please sign in to comment.