Skip to content
Merged
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 @@ -35,6 +35,7 @@ Attention: The newest changes should be on top -->

### Changed

- ENH: _MotorPrints inheritance - issue #460 [#828](https://github.com/RocketPy-Team/RocketPy/pull/828)

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion rocketpy/mathutils/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from bisect import bisect_left
from collections.abc import Iterable
from copy import deepcopy
from enum import Enum
from functools import cached_property
from inspect import signature
from pathlib import Path
from enum import Enum

import matplotlib.pyplot as plt
import numpy as np
Expand Down
27 changes: 4 additions & 23 deletions rocketpy/prints/hybrid_motor_prints.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import numpy as np

from .motor_prints import _MotorPrints

class _HybridMotorPrints:

class _HybridMotorPrints(_MotorPrints):
"""Class that holds prints methods for HybridMotor class.

Attributes
Expand All @@ -26,6 +28,7 @@ def __init__(
-------
None
"""
super().__init__(hybrid_motor)
self.hybrid_motor = hybrid_motor

def nozzle_details(self):
Expand Down Expand Up @@ -63,28 +66,6 @@ def grain_details(self):
print(f"Grain Volume: {self.hybrid_motor.solid.grain_initial_volume:.3f} m3")
print(f"Grain Mass: {self.hybrid_motor.solid.grain_initial_mass:.3f} kg\n")

def motor_details(self):
"""Prints out all data available about the HybridMotor.

Returns
-------
None
"""
print("Motor Details")
print(f"Total Burning Time: {self.hybrid_motor.burn_duration} s")
print(
f"Total Propellant Mass: {self.hybrid_motor.propellant_initial_mass:.3f} kg"
)
print(f"Structural Mass Ratio: {self.hybrid_motor.structural_mass_ratio:.3f}")
avg = self.hybrid_motor.exhaust_velocity.average(*self.hybrid_motor.burn_time)
print(f"Average Propellant Exhaust Velocity: {avg:.3f} m/s")
print(f"Average Thrust: {self.hybrid_motor.average_thrust:.3f} N")
print(
f"Maximum Thrust: {self.hybrid_motor.max_thrust} N at "
f"{self.hybrid_motor.max_thrust_time} s after ignition."
)
print(f"Total Impulse: {self.hybrid_motor.total_impulse:.3f} Ns\n")

def all(self):
"""Prints out all data available about the HybridMotor.

Expand Down
28 changes: 5 additions & 23 deletions rocketpy/prints/liquid_motor_prints.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class _LiquidMotorPrints:
from .motor_prints import _MotorPrints


class _LiquidMotorPrints(_MotorPrints):
"""Class that holds prints methods for LiquidMotor class.

Attributes
Expand All @@ -23,6 +26,7 @@ def __init__(
-------
None
"""
super().__init__(liquid_motor)
self.liquid_motor = liquid_motor

def nozzle_details(self):
Expand All @@ -35,28 +39,6 @@ def nozzle_details(self):
print("Nozzle Details")
print("Nozzle Radius: " + str(self.liquid_motor.nozzle_radius) + " m\n")

def motor_details(self):
"""Prints out all data available about the motor.

Returns
-------
None
"""
print("Motor Details")
print(f"Total Burning Time: {self.liquid_motor.burn_duration} s")
print(
f"Total Propellant Mass: {self.liquid_motor.propellant_initial_mass:.3f} kg"
)
print(f"Structural Mass Ratio: {self.liquid_motor.structural_mass_ratio:.3f}")
avg = self.liquid_motor.exhaust_velocity.average(*self.liquid_motor.burn_time)
print(f"Average Propellant Exhaust Velocity: {avg:.3f} m/s")
print(f"Average Thrust: {self.liquid_motor.average_thrust:.3f} N")
print(
f"Maximum Thrust: {self.liquid_motor.max_thrust} N at "
f"{self.liquid_motor.max_thrust_time} s after ignition."
)
print(f"Total Impulse: {self.liquid_motor.total_impulse:.3f} Ns\n")

def all(self):
"""Prints out all data available about the LiquidMotor.

Expand Down
28 changes: 5 additions & 23 deletions rocketpy/prints/solid_motor_prints.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class _SolidMotorPrints:
from .motor_prints import _MotorPrints


class _SolidMotorPrints(_MotorPrints):
"""Class that holds prints methods for SolidMotor class.

Attributes
Expand All @@ -23,6 +26,7 @@ def __init__(
-------
None
"""
super().__init__(solid_motor)
self.solid_motor = solid_motor

def nozzle_details(self):
Expand Down Expand Up @@ -53,28 +57,6 @@ def grain_details(self):
print(f"Grain Volume: {self.solid_motor.grain_initial_volume:.3f} m3")
print(f"Grain Mass: {self.solid_motor.grain_initial_mass:.3f} kg\n")

def motor_details(self):
"""Prints out all data available about the SolidMotor.

Returns
-------
None
"""
print("Motor Details")
print("Total Burning Time: " + str(self.solid_motor.burn_duration) + " s")
print(
f"Total Propellant Mass: {self.solid_motor.propellant_initial_mass:.3f} kg"
)
print(f"Structural Mass Ratio: {self.solid_motor.structural_mass_ratio:.3f}")
average = self.solid_motor.exhaust_velocity.average(*self.solid_motor.burn_time)
print(f"Average Propellant Exhaust Velocity: {average:.3f} m/s")
print(f"Average Thrust: {self.solid_motor.average_thrust:.3f} N")
print(
f"Maximum Thrust: {self.solid_motor.max_thrust} N "
f"at {self.solid_motor.max_thrust_time} s after ignition."
)
print(f"Total Impulse: {self.solid_motor.total_impulse:.3f} Ns\n")

def all(self):
"""Prints out all data available about the SolidMotor.

Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_environment_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import matplotlib as plt
import pytest

from rocketpy import Environment

plt.rcParams.update({"figure.max_open_warning": 0})
Expand Down