Skip to content
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

ENH: Eliminating multiple plots for inertia components #566

Merged
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ Attention: The newest changes should be on top -->

### Added

- ENH: CP and Thrust Eccentricity Effects Generate Roll Moment [#617](https://github.com/RocketPy-Team/RocketPy/pull/617)
- ENH: Add Prandtl-Gauss transformation to NoseCone and Tail [#609](https://github.com/RocketPy-Team/RocketPy/pull/609)
- ENH: Implement power series nose cones[#603](https://github.com/RocketPy-Team/RocketPy/pull/603)

### Changed

- ENH: Eliminating multiple plots for inertia components [#566](https://github.com/RocketPy-Team/RocketPy/pull/566)
- MNT: Fix warnings in test suite and adds support for numpy 2.0 [#623](https://github.com/RocketPy-Team/RocketPy/pull/623)
- MNT: bump minimum Python version to 3.9. [#624](https://github.com/RocketPy-Team/RocketPy/pull/624)

### Fixed
Expand All @@ -53,9 +59,6 @@ You can install this version by running `pip install rocketpy==1.3.0`

### Added

- ENH: CP and Thrust Eccentricity Effects Generate Roll Moment [#617](https://github.com/RocketPy-Team/RocketPy/pull/617)
- ENH: Add Prandtl-Gauss transformation to NoseCone and Tail [#609](https://github.com/RocketPy-Team/RocketPy/pull/609)
- ENH: Implement power series nose cones[#603](https://github.com/RocketPy-Team/RocketPy/pull/603)
- DOC: Adds prometheus data, Spaceport America 2022 [#601](https://github.com/RocketPy-Team/RocketPy/pull/601)
- ENH: Pre-calculate attributes in Rocket class [#595](https://github.com/RocketPy-Team/RocketPy/pull/595)
- ENH: Complex step differentiation [#594](https://github.com/RocketPy-Team/RocketPy/pull/594)
Expand All @@ -66,7 +69,6 @@ You can install this version by running `pip install rocketpy==1.3.0`

### Changed

- MNT: Fix warnings in test suite and adds support for numpy 2.0 [#623](https://github.com/RocketPy-Team/RocketPy/pull/623)
- REL: Bump versioning to RocketPy v1.3.0 [#614](https://github.com/RocketPy-Team/RocketPy/pull/614)
- ENH: Adds StochasticModel.visualize_attributes() method [#612](https://github.com/RocketPy-Team/RocketPy/pull/612)
- DOC: Monte carlo documentation updates [#607](https://github.com/RocketPy-Team/RocketPy/pull/607)
Expand Down
7 changes: 1 addition & 6 deletions rocketpy/plots/hybrid_motor_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,4 @@ def all(self):
self.burn_rate(self.motor.burn_time[0], self.motor.solid.grain_burn_out)
self.burn_area(*self.motor.burn_time)
self.Kn()
self.I_11(*self.motor.burn_time)
self.I_22(*self.motor.burn_time)
self.I_33(*self.motor.burn_time)
self.I_12(*self.motor.burn_time)
self.I_13(*self.motor.burn_time)
self.I_23(*self.motor.burn_time)
self.inertia_tensor(*self.motor.burn_time)
7 changes: 1 addition & 6 deletions rocketpy/plots/liquid_motor_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,4 @@ def all(self):
self.total_mass(*self.motor.burn_time)
self.propellant_mass(*self.motor.burn_time)
self.center_of_mass(*self.motor.burn_time)
self.I_11(*self.motor.burn_time)
self.I_22(*self.motor.burn_time)
self.I_33(*self.motor.burn_time)
self.I_12(*self.motor.burn_time)
self.I_13(*self.motor.burn_time)
self.I_23(*self.motor.burn_time)
self.inertia_tensor(*self.motor.burn_time)
129 changes: 32 additions & 97 deletions rocketpy/plots/motor_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,113 +135,53 @@ def exhaust_velocity(self, lower_limit=None, upper_limit=None):
"""
self.motor.exhaust_velocity.plot(lower=lower_limit, upper=upper_limit)

def I_11(self, lower_limit=None, upper_limit=None):
"""Plots I_11 of the motor as a function of time.
def inertia_tensor(self, lower_limit=None, upper_limit=None, show_products=False):
"""Plots all inertia tensors (I_11, I_22, I_33, I_12, I_13, I_23)
of the motor as a function of time in a single chart.

Parameters
----------
lower_limit : float
Lower limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.
upper_limit : float
Upper limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.

Return
------
None
"""
self.motor.I_11.plot(lower=lower_limit, upper=upper_limit)

def I_22(self, lower_limit=None, upper_limit=None):
"""Plots I_22 of the motor as a function of time.

Parameters
----------
lower_limit : float
Lower limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.
upper_limit : float
Upper limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.

Return
------
None
"""
self.motor.I_22.plot(lower=lower_limit, upper=upper_limit)

def I_33(self, lower_limit=None, upper_limit=None):
"""Plots I_33 of the motor as a function of time.

Parameters
----------
lower_limit : float
Lower limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.
upper_limit : float
Upper limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.

Return
------
None
"""
self.motor.I_33.plot(lower=lower_limit, upper=upper_limit)

def I_12(self, lower_limit=None, upper_limit=None):
"""Plots I_12 of the motor as a function of time.

Parameters
----------
lower_limit : float
Lower limit of the plot. Default is none, which means that the plot
Lower limit of the plot. Default is None, which means that the plot
limits will be automatically calculated.
upper_limit : float
Upper limit of the plot. Default is none, which means that the plot
Upper limit of the plot. Default is None, which means that the plot
limits will be automatically calculated.
show_products : bool
If True, the products of inertia (I_12, I_13, I_23) will be shown
in the plot. Default is False. These are kept as hidden by default
because they are usually very small compared to the main inertia
components.

Return
------
None
"""
self.motor.I_12.plot(lower=lower_limit, upper=upper_limit)

def I_13(self, lower_limit=None, upper_limit=None):
"""Plots I_13 of the motor as a function of time.
lower = lower_limit or self.motor.burn_start_time
upper = upper_limit or self.motor.burn_out_time

Parameters
----------
lower_limit : float
Lower limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.
upper_limit : float
Upper limit of the plot. Default is none, which means that the plot
limits will be automatically calculated.
time = np.linspace(lower, upper, 100)

Return
------
None
"""
self.motor.I_13.plot(lower=lower_limit, upper=upper_limit)
_, ax = plt.subplots()
ax.plot(time, self.motor.I_11(time), label='I_11', linestyle='-')
ax.plot(time, self.motor.I_22(time), label='I_22', linestyle='--', linewidth=3)
ax.plot(time, self.motor.I_33(time), label='I_33', linestyle='-.')
if show_products:
ax.plot(time, self.motor.I_12(time), label='I_12', linestyle=':')
ax.plot(
time, self.motor.I_13(time), label='I_13', linestyle='-.', linewidth=2
)
ax.plot(
time, self.motor.I_23(time), label='I_23', linestyle='--', linewidth=3
)

def I_23(self, lower_limit=None, upper_limit=None):
"""Plots I_23 of the motor as a function of time.
ax.set_title('Inertia tensor over time')
ax.set_xlabel('Time (s)')
ax.set_ylabel('Inertia (kg*m^2)')
ax.legend()
ax.grid(True)

Parameters
----------
lower_limit : float
Lower limit of the plot. Default is None, which means that the plot
limits will be automatically calculated.
upper_limit : float
Upper limit of the plot. Default is None, which means that the plot
limits will be automatically calculated.

Return
------
None
"""
self.motor.I_23.plot(lower=lower_limit, upper=upper_limit)
plt.show()

def _generate_nozzle(self, translate=(0, 0), csys=1):
"""Generates a patch that represents the nozzle of the motor. It is
Expand Down Expand Up @@ -544,9 +484,4 @@ def all(self):
self.total_mass(*self.motor.burn_time)
self.propellant_mass(*self.motor.burn_time)
self.center_of_mass(*self.motor.burn_time)
self.I_11(*self.motor.burn_time)
self.I_22(*self.motor.burn_time)
self.I_33(*self.motor.burn_time)
self.I_12(*self.motor.burn_time)
self.I_13(*self.motor.burn_time)
self.I_23(*self.motor.burn_time)
self.inertia_tensor(*self.motor.burn_time)
7 changes: 1 addition & 6 deletions rocketpy/plots/solid_motor_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,4 @@ def all(self):
self.burn_rate(self.motor.burn_time[0], self.motor.grain_burn_out)
self.burn_area(*self.motor.burn_time)
self.Kn()
self.I_11(*self.motor.burn_time)
self.I_22(*self.motor.burn_time)
self.I_33(*self.motor.burn_time)
self.I_12(*self.motor.burn_time)
self.I_13(*self.motor.burn_time)
self.I_23(*self.motor.burn_time)
self.inertia_tensor(*self.motor.burn_time)
Loading