diff --git a/rocketpy/motors/Fluid.py b/rocketpy/motors/Fluid.py index 84e7fadf1..0c11c57bd 100644 --- a/rocketpy/motors/Fluid.py +++ b/rocketpy/motors/Fluid.py @@ -6,6 +6,9 @@ from dataclasses import dataclass +from rocketpy.plots.fluid_plots import _FluidPlots +from rocketpy.prints.fluid_prints import _FluidPrints + @dataclass class Fluid: @@ -45,6 +48,11 @@ def __post_init__(self): if self.quality < 0 or self.quality > 1: raise ValueError("The quality must be a number between 0 and 1.") + # Initialize plots and prints object + self.prints = _FluidPrints(self) + self.plots = _FluidPlots(self) + return None + def __repr__(self): """Representation method. diff --git a/rocketpy/motors/HybridMotor.py b/rocketpy/motors/HybridMotor.py index aa69105dc..901df7ca0 100644 --- a/rocketpy/motors/HybridMotor.py +++ b/rocketpy/motors/HybridMotor.py @@ -9,8 +9,9 @@ except ImportError: from rocketpy.tools import cached_property - from rocketpy.Function import funcify_method, reset_funcified_methods +from rocketpy.plots.hybrid_motor_plots import _HybridMotorPlots +from rocketpy.prints.hybrid_motor_prints import _HybridMotorPrints from .LiquidMotor import LiquidMotor from .Motor import Motor @@ -318,6 +319,10 @@ def __init__( interpolationMethod, coordinateSystemOrientation, ) + # Initialize plots and prints object + self.prints = _HybridMotorPrints(self) + self.plots = _HybridMotorPlots(self) + return None @funcify_method("Time (s)", "Exhaust velocity (m/s)") def exhaustVelocity(self): @@ -496,6 +501,12 @@ def addTank(self, tank, position): self.solid.massFlowRate = self.totalMassFlowRate - self.liquid.massFlowRate reset_funcified_methods(self) + def info(self): + """Prints out basic data about the Motor.""" + self.prints.all() + self.plots.thrust() + return None + def allInfo(self): """Prints out all data and graphs available about the Motor. @@ -503,61 +514,7 @@ def allInfo(self): ------ None """ - # Print nozzle details - print("Nozzle Details") - print("Nozzle Radius: " + str(self.nozzleRadius) + " m") - print("Nozzle Throat Radius: " + str(self.solid.throatRadius) + " m") - - # Print grain details - print("\nGrain Details") - print("Number of Grains: " + str(self.solid.grainNumber)) - print("Grain Spacing: " + str(self.solid.grainSeparation) + " m") - print("Grain Density: " + str(self.solid.grainDensity) + " kg/m3") - print("Grain Outer Radius: " + str(self.solid.grainOuterRadius) + " m") - print("Grain Inner Radius: " + str(self.solid.grainInitialInnerRadius) + " m") - print("Grain Height: " + str(self.solid.grainInitialHeight) + " m") - print("Grain Volume: " + "{:.3f}".format(self.solid.grainInitialVolume) + " m3") - print("Grain Mass: " + "{:.3f}".format(self.solid.grainInitialMass) + " kg") - - # Print motor details - print("\nMotor Details") - print("Total Burning Time: " + str(self.burnDuration) + " s") - print( - "Total Propellant Mass: " - + "{:.3f}".format(self.propellantInitialMass) - + " kg" - ) - print( - "Average Propellant Exhaust Velocity: " - + "{:.3f}".format(self.exhaustVelocity.average(*self.burn_time)) - + " m/s" - ) - print("Average Thrust: " + "{:.3f}".format(self.averageThrust) + " N") - print( - "Maximum Thrust: " - + str(self.maxThrust) - + " N at " - + str(self.maxThrustTime) - + " s after ignition." - ) - print("Total Impulse: " + "{:.3f}".format(self.totalImpulse) + " Ns") - - # Show plots - print("\nPlots") - self.thrust.plot(*self.burn_time) - self.totalMass.plot(*self.burn_time) - self.massFlowRate.plot(*self.burn_time) - self.solid.grainInnerRadius.plot(*self.burn_time) - self.solid.grainHeight.plot(*self.burn_time) - self.solid.burnRate.plot(self.burn_time[0], self.solid.grainBurnOut) - self.solid.burnArea.plot(*self.burn_time) - self.solid.Kn.plot(*self.burn_time) - self.centerOfMass.plot(*self.burn_time) - self.I_11.plot(*self.burn_time) - self.I_22.plot(*self.burn_time) - self.I_33.plot(*self.burn_time) - self.I_12.plot(*self.burn_time) - self.I_13.plot(*self.burn_time) - self.I_23.plot(*self.burn_time) - + self.prints.all() + self.plots.all() + return None return None diff --git a/rocketpy/motors/LiquidMotor.py b/rocketpy/motors/LiquidMotor.py index f81a91d7d..aaa0cdded 100644 --- a/rocketpy/motors/LiquidMotor.py +++ b/rocketpy/motors/LiquidMotor.py @@ -10,6 +10,8 @@ from rocketpy.tools import cached_property from rocketpy.Function import Function, funcify_method, reset_funcified_methods +from rocketpy.plots.liquid_motor_plots import _LiquidMotorPlots +from rocketpy.prints.liquid_motor_prints import _LiquidMotorPrints from .Motor import Motor @@ -243,6 +245,11 @@ def __init__( self.positioned_tanks = [] + # Initialize plots and prints object + self.prints = _LiquidMotorPrints(self) + self.plots = _LiquidMotorPlots(self) + return None + @funcify_method("Time (s)", "Exhaust Velocity (m/s)") def exhaustVelocity(self): """Computes the exhaust velocity of the motor from its mass flow @@ -432,6 +439,12 @@ def addTank(self, tank, position): self.positioned_tanks.append({"tank": tank, "position": position}) reset_funcified_methods(self) + def info(self): + """Prints out basic data about the Motor.""" + self.prints.all() + self.plots.thrust() + return None + def allInfo(self): """Prints out all data and graphs available about the Motor. @@ -439,43 +452,6 @@ def allInfo(self): ------ None """ - # Print nozzle details - print("Nozzle Details") - print("Nozzle Radius: " + str(self.nozzleRadius) + " m") - - # Print motor details - print("\nMotor Details") - print("Total Burning Time: " + str(self.burnDuration) + " s") - print( - "Total Propellant Mass: " - + "{:.3f}".format(self.propellantInitialMass) - + " kg" - ) - print( - "Average Propellant Exhaust Velocity: " - + "{:.3f}".format(self.exhaustVelocity.average(*self.burn_time)) - + " m/s" - ) - print("Average Thrust: " + "{:.3f}".format(self.averageThrust) + " N") - print( - "Maximum Thrust: " - + str(self.maxThrust) - + " N at " - + str(self.maxThrustTime) - + " s after ignition." - ) - print("Total Impulse: " + "{:.3f}".format(self.totalImpulse) + " Ns") - - # Show plots - print("\nPlots") - self.thrust.plot(*self.burn_time) - self.totalMass.plot(*self.burn_time) - self.massFlowRate.plot(*self.burn_time) - self.exhaustVelocity.plot(*self.burn_time) - self.centerOfMass.plot(*self.burn_time) - self.I_11.plot(*self.burn_time) - self.I_22.plot(*self.burn_time) - self.I_33.plot(*self.burn_time) - self.I_12.plot(*self.burn_time) - self.I_13.plot(*self.burn_time) - self.I_23.plot(*self.burn_time) + self.prints.all() + self.plots.all() + return None diff --git a/rocketpy/motors/Motor.py b/rocketpy/motors/Motor.py index 53a12b1af..3e4bf30aa 100644 --- a/rocketpy/motors/Motor.py +++ b/rocketpy/motors/Motor.py @@ -8,6 +8,8 @@ import warnings from abc import ABC, abstractmethod +from rocketpy.plots.motor_plots import _MotorPlots +from rocketpy.prints.motor_prints import _MotorPrints from rocketpy.tools import tuple_handler try: @@ -309,6 +311,10 @@ def __init__( maxThrustIndex = np.argmax(self.thrust.yArray) self.maxThrustTime = self.thrust.source[maxThrustIndex, 0] self.averageThrust = self.totalImpulse / self.burnDuration + + # Initialize plots and prints object + self.prints = _MotorPrints(self) + self.plots = _MotorPlots(self) return None @property @@ -1029,38 +1035,18 @@ def info(self): Motor. """ # Print motor details - print("\nMotor Details") - print("Total Burning Time: " + str(self.burnDuration) + " s") - print( - "Total Propellant Mass: " - + "{:.3f}".format(self.propellantInitialMass) - + " kg" - ) - print( - "Propellant Exhaust Velocity: " - + "{:.3f}".format(self.exhaustVelocity.average(*self.burn_time)) - + " m/s" - ) - print("Average Thrust: " + "{:.3f}".format(self.averageThrust) + " N") - print( - "Maximum Thrust: " - + str(self.maxThrust) - + " N at " - + str(self.maxThrustTime) - + " s after ignition." - ) - print("Total Impulse: " + "{:.3f}".format(self.totalImpulse) + " Ns") - - # Show plots - print("\nPlots") - self.thrust() + self.prints.all() + self.plots.thrust() + return None return None @abstractmethod def allInfo(self): """Prints out all data and graphs available about the Motor.""" - pass + self.prints.all() + self.plots.all() + return None class GenericMotor(Motor): @@ -1109,6 +1095,9 @@ def __init__( self.center_of_dry_mass = ( center_of_dry_mass if center_of_dry_mass else chamberPosition ) + # Initialize plots and prints object + self.prints = _MotorPrints(self) + self.plots = _MotorPlots(self) return None @cached_property @@ -1232,39 +1221,9 @@ def propellant_I_23(self): def allInfo(self): """Prints out all data and graphs available about the Motor.""" # Print motor details - print("\nMotor Details") - print("Total Burning Time: " + str(self.burnOutTime) + " s") - print( - "Total Propellant Mass: " - + "{:.3f}".format(self.propellantInitialMass) - + " kg" - ) - print( - "Propellant Exhaust Velocity: " - + "{:.3f}".format(self.exhaustVelocity) - + " m/s" - ) - print("Average Thrust: " + "{:.3f}".format(self.averageThrust) + " N") - print( - "Maximum Thrust: " - + str(self.maxThrust) - + " N at " - + str(self.maxThrustTime) - + " s after ignition." - ) - print("Total Impulse: " + "{:.3f}".format(self.totalImpulse) + " Ns") - - # Show plots - print("\nPlots") - self.thrust() - self.totalMass() - self.centerOfMass() - self.I_11() - self.I_22() - self.I_33() - self.I_12() - self.I_13() - self.I_23() + self.prints.all() + self.plots.all() + return None class EmptyMotor: diff --git a/rocketpy/motors/SolidMotor.py b/rocketpy/motors/SolidMotor.py index 0aa040efc..fe60b5370 100644 --- a/rocketpy/motors/SolidMotor.py +++ b/rocketpy/motors/SolidMotor.py @@ -7,6 +7,9 @@ import numpy as np from scipy import integrate +from rocketpy.plots.solid_motor_plots import _SolidMotorPlots +from rocketpy.prints.solid_motor_prints import _SolidMotorPrints + try: from functools import cached_property except ImportError: @@ -331,6 +334,10 @@ def __init__( self.grainInitialMass = self.grainDensity * self.grainInitialVolume self.evaluateGeometry() + + # Initialize plots and prints object + self.prints = _SolidMotorPrints(self) + self.plots = _SolidMotorPlots(self) return None @funcify_method("Time (s)", "Mass (kg)") @@ -676,64 +683,15 @@ def propellant_I_13(self): def propellant_I_23(self): return 0 + def info(self): + """Prints out basic data about the Motor.""" + self.prints.all() + self.plots.thrust() + return None + def allInfo(self): """Prints out all data and graphs available about the Motor.""" - # Print nozzle details - print("Nozzle Details") - print("Nozzle Radius: " + str(self.nozzleRadius) + " m") - print("Nozzle Throat Radius: " + str(self.throatRadius) + " m") - - # Print grain details - print("\nGrain Details") - print("Number of Grains: " + str(self.grainNumber)) - print("Grain Spacing: " + str(self.grainSeparation) + " m") - print("Grain Density: " + str(self.grainDensity) + " kg/m3") - print("Grain Outer Radius: " + str(self.grainOuterRadius) + " m") - print("Grain Inner Radius: " + str(self.grainInitialInnerRadius) + " m") - print("Grain Height: " + str(self.grainInitialHeight) + " m") - print("Grain Volume: " + "{:.3f}".format(self.grainInitialVolume) + " m3") - print("Grain Mass: " + "{:.3f}".format(self.grainInitialMass) + " kg") - - # Print motor details - print("\nMotor Details") - print("Total Burning Time: " + str(self.burnDuration) + " s") - print( - "Total Propellant Mass: " - + "{:.3f}".format(self.propellantInitialMass) - + " kg" - ) - print( - "Average Propellant Exhaust Velocity: " - + "{:.3f}".format(self.exhaustVelocity.average(*self.burn_time)) - + " m/s" - ) - print("Average Thrust: " + "{:.3f}".format(self.averageThrust) + " N") - print( - "Maximum Thrust: " - + str(self.maxThrust) - + " N at " - + str(self.maxThrustTime) - + " s after ignition." - ) - print("Total Impulse: " + "{:.3f}".format(self.totalImpulse) + " Ns") - - # Show plots - print("\nPlots") - self.thrust() - self.totalMass() - self.massFlowRate() - self.exhaustVelocity() - self.grainInnerRadius() - self.grainHeight() - self.burnRate.plot(self.burn_time[0], self.grainBurnOut) - self.burnArea() - self.Kn() - self.centerOfMass.plot(*self.burn_time) - self.I_11.plot(*self.burn_time) - self.I_22.plot(*self.burn_time) - self.I_33.plot(*self.burn_time) - self.I_12.plot(*self.burn_time) - self.I_13.plot(*self.burn_time) - self.I_23.plot(*self.burn_time) + self.prints.all() + self.plots.all() return None diff --git a/rocketpy/motors/Tank.py b/rocketpy/motors/Tank.py index 5ec3f2860..b046db40f 100644 --- a/rocketpy/motors/Tank.py +++ b/rocketpy/motors/Tank.py @@ -9,6 +9,8 @@ import numpy as np from rocketpy.Function import Function, funcify_method +from rocketpy.plots.tank_plots import _TankPlots +from rocketpy.prints.tank_prints import _TankPrints from rocketpy.tools import tuple_handler @@ -112,6 +114,11 @@ def __init__(self, name, geometry, flux_time, liquid, gas, discretize=100): self.liquid = liquid self.discretize = discretize + # Initialize plots and prints object + self.prints = _TankPrints(self) + self.plots = _TankPlots(self) + return None + @property def flux_time(self): """Returns the start and final times of the tank flux. diff --git a/rocketpy/motors/TankGeometry.py b/rocketpy/motors/TankGeometry.py index e244b64c3..b24d14165 100644 --- a/rocketpy/motors/TankGeometry.py +++ b/rocketpy/motors/TankGeometry.py @@ -5,6 +5,8 @@ import numpy as np from rocketpy.Function import Function, PiecewiseFunction, funcify_method +from rocketpy.plots.tank_geometry_plots import _TankGeometryPlots +from rocketpy.prints.tank_geometry_prints import _TankGeometryPrints try: from functools import cache @@ -98,6 +100,11 @@ def __init__(self, geometry_dict=dict()): """ self.geometry = geometry_dict + # Initialize plots and prints object + self.prints = _TankGeometryPrints(self) + self.plots = _TankGeometryPlots(self) + return None + @property def geometry(self): """ diff --git a/rocketpy/plots/__init__.py b/rocketpy/plots/__init__.py index 0af338778..6d1b4d624 100644 --- a/rocketpy/plots/__init__.py +++ b/rocketpy/plots/__init__.py @@ -9,4 +9,10 @@ from .environment_analysis_plots import _EnvironmentAnalysisPlots from .environment_plots import _EnvironmentPlots from .flight_plots import _FlightPlots +from .hybrid_motor_plots import _HybridMotorPlots +from .liquid_motor_plots import _LiquidMotorPlots +from .motor_plots import _MotorPlots from .rocket_plots import _RocketPlots +from .solid_motor_plots import _SolidMotorPlots +from .tank_geometry_plots import _TankGeometryPlots +from .tank_plots import _TankPlots diff --git a/rocketpy/plots/fluid_plots.py b/rocketpy/plots/fluid_plots.py new file mode 100644 index 000000000..cb8334461 --- /dev/null +++ b/rocketpy/plots/fluid_plots.py @@ -0,0 +1,45 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + + +class _FluidPlots: + """Class that holds plot methods for Fluid class. + + Attributes + ---------- + _FluidPlots.fluid : Fluid + Fluid object that will be used for the plots. + + """ + + def __init__(self, fluid): + """Initializes _MotorClass class. + + Parameters + ---------- + fluid : Fluid + Instance of the Fluid class + + Returns + ------- + None + """ + + self.fluid = fluid + + return None + + def all(self): + """Prints out all graphs available about the Fluid. It simply calls + all the other plotter methods in this class. + + Parameters + ---------- + None + Return + ------ + None + """ + + return None diff --git a/rocketpy/plots/hybrid_motor_plots.py b/rocketpy/plots/hybrid_motor_plots.py new file mode 100644 index 000000000..6bac824bb --- /dev/null +++ b/rocketpy/plots/hybrid_motor_plots.py @@ -0,0 +1,402 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + + +class _HybridMotorPlots: + """Class that holds plot methods for HybridMotor class. + + Attributes + ---------- + _HybridMotorPlots.hybrid_motor : HybridMotor + HybridMotor object that will be used for the plots. + + """ + + def __init__(self, hybrid_motor): + """Initializes _MotorClass class. + + Parameters + ---------- + hybrid_motor : HybridMotor + Instance of the HybridMotor class + + Returns + ------- + None + """ + + self.hybrid_motor = hybrid_motor + + return None + + def thrust(self, lower_limit=None, upper_limit=None): + """Plots thrust of the hybrid_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.hybrid_motor.thrust.plot(lower=lower_limit, upper=upper_limit) + + return None + + def totalMass(self, lower_limit=None, upper_limit=None): + """Plots totalMass of the hybrid_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.hybrid_motor.totalMass.plot(lower=lower_limit, upper=upper_limit) + + return None + + def massFlowRate(self, lower_limit=None, upper_limit=None): + """Plots massFlowRate of the hybrid_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.hybrid_motor.massFlowRate.plot(lower=lower_limit, upper=upper_limit) + + return None + + def exhaustVelocity(self, lower_limit=None, upper_limit=None): + """Plots exhaustVelocity of the hybrid_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.hybrid_motor.exhaustVelocity.plot(lower=lower_limit, upper=upper_limit) + + return None + + def grainInnerRadius(self, lower_limit=None, upper_limit=None): + """Plots grainInnerRadius of the hybrid_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.hybrid_motor.solid.grainInnerRadius.plot( + lower=lower_limit, upper=upper_limit + ) + + return None + + def grainHeight(self, lower_limit=None, upper_limit=None): + """Plots grainHeight of the hybrid_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.hybrid_motor.solid.grainHeight.plot(lower=lower_limit, upper=upper_limit) + + return None + + def burnRate(self, lower_limit=None, upper_limit=None): + """Plots burnRate of the hybrid_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.hybrid_motor.solid.burnRate.plot(lower=lower_limit, upper=upper_limit) + + return None + + def burnArea(self, lower_limit=None, upper_limit=None): + """Plots burnArea of the hybrid_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.hybrid_motor.solid.burnArea.plot(lower=lower_limit, upper=upper_limit) + + return None + + def Kn(self, lower_limit=None, upper_limit=None): + """Plots Kn of the hybrid_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.hybrid_motor.solid.Kn.plot(lower=lower_limit, upper=upper_limit) + + return None + + def centerOfMass(self, lower_limit=None, upper_limit=None): + """Plots centerOfMass of the hybrid_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.hybrid_motor.centerOfMass.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_11(self, lower_limit=None, upper_limit=None): + """Plots I_11 of the hybrid_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.hybrid_motor.I_11.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_22(self, lower_limit=None, upper_limit=None): + """Plots I_22 of the hybrid_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.hybrid_motor.I_22.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_33(self, lower_limit=None, upper_limit=None): + """Plots I_33 of the hybrid_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.hybrid_motor.I_33.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_12(self, lower_limit=None, upper_limit=None): + """Plots I_12 of the hybrid_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.hybrid_motor.I_12.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_13(self, lower_limit=None, upper_limit=None): + """Plots I_13 of the hybrid_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.hybrid_motor.I_13.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_23(self, lower_limit=None, upper_limit=None): + """Plots I_23 of the hybrid_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.hybrid_motor.I_23.plot(lower=lower_limit, upper=upper_limit) + + return None + + def all(self): + """Prints out all graphs available about the HybridMotor. It simply calls + all the other plotter methods in this class. + + Parameters + ---------- + None + Return + ------ + None + """ + + self.thrust(*self.hybrid_motor.burn_time) + self.totalMass(*self.hybrid_motor.burn_time) + self.massFlowRate(*self.hybrid_motor.burn_time) + self.exhaustVelocity(*self.hybrid_motor.burn_time) + self.grainInnerRadius(*self.hybrid_motor.burn_time) + self.grainHeight(*self.hybrid_motor.burn_time) + self.burnRate( + self.hybrid_motor.burn_time[0], self.hybrid_motor.solid.grainBurnOut + ) + self.burnArea(*self.hybrid_motor.burn_time) + self.Kn() + self.centerOfMass(*self.hybrid_motor.burn_time) + self.I_11(*self.hybrid_motor.burn_time) + self.I_22(*self.hybrid_motor.burn_time) + self.I_33(*self.hybrid_motor.burn_time) + self.I_12(*self.hybrid_motor.burn_time) + self.I_13(*self.hybrid_motor.burn_time) + self.I_23(*self.hybrid_motor.burn_time) + + return None diff --git a/rocketpy/plots/liquid_motor_plots.py b/rocketpy/plots/liquid_motor_plots.py new file mode 100644 index 000000000..59b07bdff --- /dev/null +++ b/rocketpy/plots/liquid_motor_plots.py @@ -0,0 +1,288 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + + +class _LiquidMotorPlots: + """Class that holds plot methods for LiquidMotor class. + + Attributes + ---------- + _LiquidMotorPlots.liquid_motor : LiquidMotor + LiquidMotor object that will be used for the plots. + + """ + + def __init__(self, liquid_motor): + """Initializes _MotorClass class. + + Parameters + ---------- + liquid_motor : LiquidMotor + Instance of the LiquidMotor class + + Returns + ------- + None + """ + + self.liquid_motor = liquid_motor + + return None + + def thrust(self, lower_limit=None, upper_limit=None): + """Plots thrust of the liquid_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.liquid_motor.thrust.plot(lower=lower_limit, upper=upper_limit) + + return None + + def totalMass(self, lower_limit=None, upper_limit=None): + """Plots totalMass of the liquid_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.liquid_motor.totalMass.plot(lower=lower_limit, upper=upper_limit) + + return None + + def massFlowRate(self, lower_limit=None, upper_limit=None): + """Plots massFlowRate of the liquid_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.liquid_motor.massFlowRate.plot(lower=lower_limit, upper=upper_limit) + + return None + + def exhaustVelocity(self, lower_limit=None, upper_limit=None): + """Plots exhaustVelocity of the liquid_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.liquid_motor.exhaustVelocity.plot(lower=lower_limit, upper=upper_limit) + + return None + + def centerOfMass(self, lower_limit=None, upper_limit=None): + """Plots centerOfMass of the liquid_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.liquid_motor.centerOfMass.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_11(self, lower_limit=None, upper_limit=None): + """Plots I_11 of the liquid_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.liquid_motor.I_11.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_22(self, lower_limit=None, upper_limit=None): + """Plots I_22 of the liquid_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.liquid_motor.I_22.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_33(self, lower_limit=None, upper_limit=None): + """Plots I_33 of the liquid_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.liquid_motor.I_33.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_12(self, lower_limit=None, upper_limit=None): + """Plots I_12 of the liquid_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.liquid_motor.I_12.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_13(self, lower_limit=None, upper_limit=None): + """Plots I_13 of the liquid_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.liquid_motor.I_13.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_23(self, lower_limit=None, upper_limit=None): + """Plots I_23 of the liquid_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.liquid_motor.I_23.plot(lower=lower_limit, upper=upper_limit) + + return None + + def all(self): + """Prints out all graphs available about the LiquidMotor. It simply calls + all the other plotter methods in this class. + + Parameters + ---------- + None + Return + ------ + None + """ + + self.thrust(*self.liquid_motor.burn_time) + self.totalMass(*self.liquid_motor.burn_time) + self.massFlowRate(*self.liquid_motor.burn_time) + self.exhaustVelocity(*self.liquid_motor.burn_time) + self.centerOfMass(*self.liquid_motor.burn_time) + self.I_11(*self.liquid_motor.burn_time) + self.I_22(*self.liquid_motor.burn_time) + self.I_33(*self.liquid_motor.burn_time) + self.I_12(*self.liquid_motor.burn_time) + self.I_13(*self.liquid_motor.burn_time) + self.I_23(*self.liquid_motor.burn_time) + + return None diff --git a/rocketpy/plots/motor_plots.py b/rocketpy/plots/motor_plots.py new file mode 100644 index 000000000..9ef6dc615 --- /dev/null +++ b/rocketpy/plots/motor_plots.py @@ -0,0 +1,245 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + + +class _MotorPlots: + """Class that holds plot methods for Motor class. + + Attributes + ---------- + _MotorPlots.motor : Motor + Motor object that will be used for the plots. + + """ + + def __init__(self, motor): + """Initializes _MotorClass class. + + Parameters + ---------- + motor : Motor + Instance of the Motor class + + Returns + ------- + None + """ + + self.motor = motor + + return None + + def thrust(self, lower_limit=None, upper_limit=None): + """Plots thrust 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.thrust.plot(lower=lower_limit, upper=upper_limit) + + return None + + def totalMass(self, lower_limit=None, upper_limit=None): + """Plots totalMass 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.totalMass.plot(lower=lower_limit, upper=upper_limit) + + return None + + def centerOfMass(self, lower_limit=None, upper_limit=None): + """Plots centerOfMass 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.centerOfMass.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_11(self, lower_limit=None, upper_limit=None): + """Plots I_11 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_11.plot(lower=lower_limit, upper=upper_limit) + + return None + + 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) + + return None + + 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) + + return None + + 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 + 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_12.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_13(self, lower_limit=None, upper_limit=None): + """Plots I_13 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_13.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_23(self, lower_limit=None, upper_limit=None): + """Plots I_23 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_23.plot(lower=lower_limit, upper=upper_limit) + + return None + + def all(self): + """Prints out all graphs available about the Motor. It simply calls + all the other plotter methods in this class. + + Parameters + ---------- + None + Return + ------ + None + """ + + # Show plots + self.thrust() + self.totalMass() + self.centerOfMass() + self.I_11() + self.I_22() + self.I_33() + self.I_12() + self.I_13() + self.I_23() + + return None diff --git a/rocketpy/plots/rocket_plots.py b/rocketpy/plots/rocket_plots.py index 1826be771..301277867 100644 --- a/rocketpy/plots/rocket_plots.py +++ b/rocketpy/plots/rocket_plots.py @@ -8,7 +8,7 @@ class _RocketPlots: - """Class that holds plot methods for Environment class. + """Class that holds plot methods for Rocket class. Attributes ---------- @@ -18,7 +18,7 @@ class _RocketPlots: """ def __init__(self, rocket) -> None: - """Initializes _EnvironmentPlots class. + """Initializes _RocketPlots class. Parameters ---------- diff --git a/rocketpy/plots/solid_motor_plots.py b/rocketpy/plots/solid_motor_plots.py new file mode 100644 index 000000000..7fc948266 --- /dev/null +++ b/rocketpy/plots/solid_motor_plots.py @@ -0,0 +1,398 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + + +class _SolidMotorPlots: + """Class that holds plot methods for SolidMotor class. + + Attributes + ---------- + _SolidMotorPlots.solid_motor : SolidMotor + SolidMotor object that will be used for the plots. + + """ + + def __init__(self, solid_motor): + """Initializes _MotorClass class. + + Parameters + ---------- + solid_motor : SolidMotor + Instance of the SolidMotor class + + Returns + ------- + None + """ + + self.solid_motor = solid_motor + + return None + + def thrust(self, lower_limit=None, upper_limit=None): + """Plots thrust of the solid_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.solid_motor.thrust.plot(lower=lower_limit, upper=upper_limit) + + return None + + def totalMass(self, lower_limit=None, upper_limit=None): + """Plots totalMass of the solid_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.solid_motor.totalMass.plot(lower=lower_limit, upper=upper_limit) + + return None + + def massFlowRate(self, lower_limit=None, upper_limit=None): + """Plots massFlowRate of the solid_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.solid_motor.massFlowRate.plot(lower=lower_limit, upper=upper_limit) + + return None + + def exhaustVelocity(self, lower_limit=None, upper_limit=None): + """Plots exhaustVelocity of the solid_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.solid_motor.exhaustVelocity.plot(lower=lower_limit, upper=upper_limit) + + return None + + def grainInnerRadius(self, lower_limit=None, upper_limit=None): + """Plots grainInnerRadius of the solid_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.solid_motor.grainInnerRadius.plot(lower=lower_limit, upper=upper_limit) + + return None + + def grainHeight(self, lower_limit=None, upper_limit=None): + """Plots grainHeight of the solid_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.solid_motor.grainHeight.plot(lower=lower_limit, upper=upper_limit) + + return None + + def burnRate(self, lower_limit=None, upper_limit=None): + """Plots burnRate of the solid_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.solid_motor.burnRate.plot(lower=lower_limit, upper=upper_limit) + + return None + + def burnArea(self, lower_limit=None, upper_limit=None): + """Plots burnArea of the solid_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.solid_motor.burnArea.plot(lower=lower_limit, upper=upper_limit) + + return None + + def Kn(self, lower_limit=None, upper_limit=None): + """Plots Kn of the solid_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.solid_motor.Kn.plot(lower=lower_limit, upper=upper_limit) + + return None + + def centerOfMass(self, lower_limit=None, upper_limit=None): + """Plots centerOfMass of the solid_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.solid_motor.centerOfMass.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_11(self, lower_limit=None, upper_limit=None): + """Plots I_11 of the solid_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.solid_motor.I_11.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_22(self, lower_limit=None, upper_limit=None): + """Plots I_22 of the solid_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.solid_motor.I_22.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_33(self, lower_limit=None, upper_limit=None): + """Plots I_33 of the solid_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.solid_motor.I_33.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_12(self, lower_limit=None, upper_limit=None): + """Plots I_12 of the solid_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.solid_motor.I_12.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_13(self, lower_limit=None, upper_limit=None): + """Plots I_13 of the solid_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.solid_motor.I_13.plot(lower=lower_limit, upper=upper_limit) + + return None + + def I_23(self, lower_limit=None, upper_limit=None): + """Plots I_23 of the solid_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.solid_motor.I_23.plot(lower=lower_limit, upper=upper_limit) + + return None + + def all(self): + """Prints out all graphs available about the SolidMotor. It simply calls + all the other plotter methods in this class. + + Parameters + ---------- + None + Return + ------ + None + """ + + self.thrust(*self.solid_motor.burn_time) + self.totalMass(*self.solid_motor.burn_time) + self.massFlowRate(*self.solid_motor.burn_time) + self.exhaustVelocity(*self.solid_motor.burn_time) + self.grainInnerRadius(*self.solid_motor.burn_time) + self.grainHeight(*self.solid_motor.burn_time) + self.burnRate(self.solid_motor.burn_time[0], self.solid_motor.grainBurnOut) + self.burnArea(*self.solid_motor.burn_time) + self.Kn() + self.centerOfMass(*self.solid_motor.burn_time) + self.I_11(*self.solid_motor.burn_time) + self.I_22(*self.solid_motor.burn_time) + self.I_33(*self.solid_motor.burn_time) + self.I_12(*self.solid_motor.burn_time) + self.I_13(*self.solid_motor.burn_time) + self.I_23(*self.solid_motor.burn_time) + + return None diff --git a/rocketpy/plots/tank_geometry_plots.py b/rocketpy/plots/tank_geometry_plots.py new file mode 100644 index 000000000..98b95559c --- /dev/null +++ b/rocketpy/plots/tank_geometry_plots.py @@ -0,0 +1,59 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + + +class _TankGeometryPlots: + """Class that holds plot methods for TankGeometry class. + + Attributes + ---------- + _TankGeometryPlots.tank_geometry : TankGeometry + TankGeometry object that will be used for the plots. + + """ + + def __init__(self, tank_geometry): + """Initializes _MotorClass class. + + Parameters + ---------- + tank_geometry : TankGeometry + Instance of the TankGeometry class + + Returns + ------- + None + """ + + self.tank_geometry = tank_geometry + + return None + + def radius(self, upper=None, lower=None): + self.tank_geometry.radius.plot(lower, upper) + return None + + def area(self, upper=None, lower=None): + self.tank_geometry.area.plot(lower, upper) + return None + + def volume(self, upper=None, lower=None): + self.tank_geometry.volume.plot(lower, upper) + return None + + def all(self): + """Prints out all graphs available about the TankGeometry. It simply calls + all the other plotter methods in this class. + + Parameters + ---------- + None + Return + ------ + None + """ + self.radius() + self.area() + self.volume() + return None diff --git a/rocketpy/plots/tank_plots.py b/rocketpy/plots/tank_plots.py new file mode 100644 index 000000000..7643bf5c9 --- /dev/null +++ b/rocketpy/plots/tank_plots.py @@ -0,0 +1,45 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + + +class _TankPlots: + """Class that holds plot methods for Tank class. + + Attributes + ---------- + _TankPlots.tank : Tank + Tank object that will be used for the plots. + + """ + + def __init__(self, tank): + """Initializes _MotorClass class. + + Parameters + ---------- + tank : Tank + Instance of the Tank class + + Returns + ------- + None + """ + + self.tank = tank + + return None + + def all(self): + """Prints out all graphs available about the Tank. It simply calls + all the other plotter methods in this class. + + Parameters + ---------- + None + Return + ------ + None + """ + + return None diff --git a/rocketpy/prints/__init__.py b/rocketpy/prints/__init__.py index 2d7ba7860..9a46f62de 100644 --- a/rocketpy/prints/__init__.py +++ b/rocketpy/prints/__init__.py @@ -1,13 +1,19 @@ from .aero_surface_prints import ( - _NoseConePrints, - _TrapezoidalFinsPrints, _EllipticalFinsPrints, - _TailPrints, + _NoseConePrints, _RailButtonsPrints, + _TailPrints, + _TrapezoidalFinsPrints, ) from .compare_prints import _ComparePrints from .environment_analysis_prints import _EnvironmentAnalysisPrints from .environment_prints import _EnvironmentPrints from .flight_prints import _FlightPrints +from .hybrid_motor_prints import _HybridMotorPrints +from .liquid_motor_prints import _LiquidMotorPrints +from .motor_prints import _MotorPrints from .parachute_prints import _ParachutePrints from .rocket_prints import _RocketPrints +from .solid_motor_prints import _SolidMotorPrints +from .tank_geometry_prints import _TankGeometryPrints +from .tank_prints import _TankPrints diff --git a/rocketpy/prints/fluid_prints.py b/rocketpy/prints/fluid_prints.py new file mode 100644 index 000000000..6fe14bc8c --- /dev/null +++ b/rocketpy/prints/fluid_prints.py @@ -0,0 +1,46 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + + +class _FluidPrints: + """Class that holds prints methods for Fluid class. + + Attributes + ---------- + _FluidPrints.fluid : fluid + Fluid object that will be used for the prints. + + """ + + def __init__( + self, + fluid, + ): + """Initializes _FluidPrints class + + Parameters + ---------- + fluid: Fluid + Instance of the Fluid class. + + Returns + ------- + None + """ + self.fluid = fluid + return None + + def all(self): + """Prints out all data available about the Fluid. + + Parameters + ---------- + None + + Return + ------ + None + """ + + return None diff --git a/rocketpy/prints/hybrid_motor_prints.py b/rocketpy/prints/hybrid_motor_prints.py new file mode 100644 index 000000000..5d6319d61 --- /dev/null +++ b/rocketpy/prints/hybrid_motor_prints.py @@ -0,0 +1,154 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + +import numpy as np + + +class _HybridMotorPrints: + """Class that holds prints methods for HybridMotor class. + + Attributes + ---------- + _HybridMotorPrints.hybrid_motor : hybrid_motor + HybridMotor object that will be used for the prints. + + """ + + def __init__( + self, + hybrid_motor, + ): + """Initializes _HybridMotorPrints class + + Parameters + ---------- + hybrid_motor: HybridMotor + Instance of the HybridMotor class. + + Returns + ------- + None + """ + self.hybrid_motor = hybrid_motor + return None + + def nozzle_details(self): + """Prints out all data available about the Nozzle. + + Parameters + ---------- + None + + Return + ------ + None + """ + # Print nozzle details + print("Nozzle Details") + print(f"Outlet Radius: {self.hybrid_motor.nozzleRadius} m") + print(f"Throat Radius: {self.hybrid_motor.solid.throatRadius} m") + print(f"Outlet Area: {np.pi*self.hybrid_motor.nozzleRadius**2:.6f} m²") + print(f"Throat Area: {np.pi*self.hybrid_motor.solid.throatRadius**2:.6f} m²") + print(f"Position: {self.hybrid_motor.nozzlePosition} m\n") + return None + + def grain_details(self): + """Prints out all data available about the Grain. + + Parameters + ---------- + None + + Return + ------ + None + """ + # Print grain details + print("Grain Details") + print("Number of Grains: " + str(self.hybrid_motor.solid.grainNumber)) + print("Grain Spacing: " + str(self.hybrid_motor.solid.grainSeparation) + " m") + print("Grain Density: " + str(self.hybrid_motor.solid.grainDensity) + " kg/m3") + print( + "Grain Outer Radius: " + + str(self.hybrid_motor.solid.grainOuterRadius) + + " m" + ) + print( + "Grain Inner Radius: " + + str(self.hybrid_motor.solid.grainInitialInnerRadius) + + " m" + ) + print("Grain Height: " + str(self.hybrid_motor.solid.grainInitialHeight) + " m") + print( + "Grain Volume: " + + "{:.3f}".format(self.hybrid_motor.solid.grainInitialVolume) + + " m3" + ) + print( + "Grain Mass: " + + "{:.3f}".format(self.hybrid_motor.solid.grainInitialMass) + + " kg\n" + ) + return None + + def motor_details(self): + """Prints out all data available about the HybridMotor. + + Parameters + ---------- + None + + Return + ------ + None + """ + # Print motor details + print("Motor Details") + print("Total Burning Time: " + str(self.hybrid_motor.burnDuration) + " s") + print( + "Total Propellant Mass: " + + "{:.3f}".format(self.hybrid_motor.propellantInitialMass) + + " kg" + ) + print( + "Average Propellant Exhaust Velocity: " + + "{:.3f}".format( + self.hybrid_motor.exhaustVelocity.average(*self.hybrid_motor.burn_time) + ) + + " m/s" + ) + print( + "Average Thrust: " + "{:.3f}".format(self.hybrid_motor.averageThrust) + " N" + ) + print( + "Maximum Thrust: " + + str(self.hybrid_motor.maxThrust) + + " N at " + + str(self.hybrid_motor.maxThrustTime) + + " s after ignition." + ) + print( + "Total Impulse: " + + "{:.3f}".format(self.hybrid_motor.totalImpulse) + + " Ns\n" + ) + return None + + def all(self): + """Prints out all data available about the HybridMotor. + + Parameters + ---------- + None + + Return + ------ + None + """ + + self.nozzle_details() + self.grain_details() + self.motor_details() + + return None diff --git a/rocketpy/prints/liquid_motor_prints.py b/rocketpy/prints/liquid_motor_prints.py new file mode 100644 index 000000000..bb4671bdc --- /dev/null +++ b/rocketpy/prints/liquid_motor_prints.py @@ -0,0 +1,104 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + + +class _LiquidMotorPrints: + """Class that holds prints methods for LiquidMotor class. + + Attributes + ---------- + _LiquidMotorPrints.liquid_motor : liquid_motor + LiquidMotor object that will be used for the prints. + + """ + + def __init__( + self, + liquid_motor, + ): + """Initializes _LiquidMotorPrints class + + Parameters + ---------- + liquid_motor: LiquidMotor + Instance of the LiquidMotor class. + + Returns + ------- + None + """ + self.liquid_motor = liquid_motor + return None + + def nozzle_details(self): + """Prints out all data available about the Nozzle. + + Parameters + ---------- + None + + Return + ------ + None + """ + print("Nozzle Details") + print("Nozzle Radius: " + str(self.liquid_motor.nozzleRadius) + " m\n") + return None + + def motor_details(self): + """Prints out all data available about the motor. + + Parameters + ---------- + None + + Return + ------ + None + """ + print("Motor Details") + print("Total Burning Time: " + str(self.liquid_motor.burnDuration) + " s") + print( + "Total Propellant Mass: " + + "{:.3f}".format(self.liquid_motor.propellantInitialMass) + + " kg" + ) + print( + "Average Propellant Exhaust Velocity: " + + "{:.3f}".format( + self.liquid_motor.exhaustVelocity.average(*self.liquid_motor.burn_time) + ) + + " m/s" + ) + print( + "Average Thrust: " + "{:.3f}".format(self.liquid_motor.averageThrust) + " N" + ) + print( + "Maximum Thrust: " + + str(self.liquid_motor.maxThrust) + + " N at " + + str(self.liquid_motor.maxThrustTime) + + " s after ignition." + ) + print( + "Total Impulse: " + + "{:.3f}".format(self.liquid_motor.totalImpulse) + + " Ns\n" + ) + return None + + def all(self): + """Prints out all data available about the LiquidMotor. + + Parameters + ---------- + None + + Return + ------ + None + """ + self.nozzle_details() + self.motor_details() + return None diff --git a/rocketpy/prints/motor_prints.py b/rocketpy/prints/motor_prints.py new file mode 100644 index 000000000..a67ced2f3 --- /dev/null +++ b/rocketpy/prints/motor_prints.py @@ -0,0 +1,80 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + + +class _MotorPrints: + """Class that holds prints methods for Motor class. + + Attributes + ---------- + _MotorPrints.motor : Motor + Motor object that will be used for the prints. + + """ + + def __init__( + self, + motor, + ): + """Initializes _MotorPrints class + + Parameters + ---------- + motor: Motor + Instance of the Motor class. + + Returns + ------- + None + """ + self.motor = motor + return None + + def motor_details(self): + """Print Motor details. + + Parameters + ---------- + None + + Return + ------ + None + """ + print("Motor Details") + print("Total Burning Time: " + str(self.motor.burnOutTime) + " s") + print( + "Total Propellant Mass: " + + "{:.3f}".format(self.motor.propellantInitialMass) + + " kg" + ) + print( + "Propellant Exhaust Velocity: " + + "{:.3f}".format(self.motor.exhaustVelocity) + + " m/s" + ) + print("Average Thrust: " + "{:.3f}".format(self.motor.averageThrust) + " N") + print( + "Maximum Thrust: " + + str(self.motor.maxThrust) + + " N at " + + str(self.motor.maxThrustTime) + + " s after ignition." + ) + print("Total Impulse: " + "{:.3f}".format(self.motor.totalImpulse) + " Ns\n") + return None + + def all(self): + """Prints out all data available about the Motor. + + Parameters + ---------- + None + + Return + ------ + None + """ + self.motor_details() + return None diff --git a/rocketpy/prints/rocket_prints.py b/rocketpy/prints/rocket_prints.py index babbd9d65..8f00a86b6 100644 --- a/rocketpy/prints/rocket_prints.py +++ b/rocketpy/prints/rocket_prints.py @@ -45,12 +45,36 @@ def inertia_details(self): print( "Rocket Mass: {:.3f} kg (With Propellant)".format(self.rocket.totalMass(0)) ) - print("Rocket Inertia 11: {:.3f} kg*m2".format(self.rocket.dry_I_11)) - print("Rocket Inertia 22: {:.3f} kg*m2".format(self.rocket.dry_I_22)) - print("Rocket Inertia 33: {:.3f} kg*m2".format(self.rocket.dry_I_33)) - print("Rocket Inertia 12: {:.3f} kg*m2".format(self.rocket.dry_I_12)) - print("Rocket Inertia 13: {:.3f} kg*m2".format(self.rocket.dry_I_13)) - print("Rocket Inertia 23: {:.3f} kg*m2".format(self.rocket.dry_I_23)) + print( + "Rocket Inertia (with motor, but without propellant) 11: {:.3f} kg*m2".format( + self.rocket.dry_I_11 + ) + ) + print( + "Rocket Inertia (with motor, but without propellant) 22: {:.3f} kg*m2".format( + self.rocket.dry_I_22 + ) + ) + print( + "Rocket Inertia (with motor, but without propellant) 33: {:.3f} kg*m2".format( + self.rocket.dry_I_33 + ) + ) + print( + "Rocket Inertia (with motor, but without propellant) 12: {:.3f} kg*m2".format( + self.rocket.dry_I_12 + ) + ) + print( + "Rocket Inertia (with motor, but without propellant) 13: {:.3f} kg*m2".format( + self.rocket.dry_I_13 + ) + ) + print( + "Rocket Inertia (with motor, but without propellant) 23: {:.3f} kg*m2".format( + self.rocket.dry_I_23 + ) + ) return None diff --git a/rocketpy/prints/solid_motor_prints.py b/rocketpy/prints/solid_motor_prints.py new file mode 100644 index 000000000..33751d22e --- /dev/null +++ b/rocketpy/prints/solid_motor_prints.py @@ -0,0 +1,140 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + + +class _SolidMotorPrints: + """Class that holds prints methods for SolidMotor class. + + Attributes + ---------- + _SolidMotorPrints.solid_motor : solid_motor + SolidMotor object that will be used for the prints. + + """ + + def __init__( + self, + solid_motor, + ): + """Initializes _SolidMotorPrints class + + Parameters + ---------- + solid_motor: SolidMotor + Instance of the SolidMotor class. + + Returns + ------- + None + """ + self.solid_motor = solid_motor + return None + + def nozzle_details(self): + """Prints out all data available about the SolidMotor nozzle. + + Parameters + ---------- + None + + Return + ------ + None + """ + # Print nozzle details + print("Nozzle Details") + print("Nozzle Radius: " + str(self.solid_motor.nozzleRadius) + " m") + print("Nozzle Throat Radius: " + str(self.solid_motor.throatRadius) + " m\n") + + def grain_details(self): + """Prints out all data available about the SolidMotor grain. + + Parameters + ---------- + None + + Return + ------ + None + """ + + # Print grain details + print("Grain Details") + print("Number of Grains: " + str(self.solid_motor.grainNumber)) + print("Grain Spacing: " + str(self.solid_motor.grainSeparation) + " m") + print("Grain Density: " + str(self.solid_motor.grainDensity) + " kg/m3") + print("Grain Outer Radius: " + str(self.solid_motor.grainOuterRadius) + " m") + print( + "Grain Inner Radius: " + + str(self.solid_motor.grainInitialInnerRadius) + + " m" + ) + print("Grain Height: " + str(self.solid_motor.grainInitialHeight) + " m") + print( + "Grain Volume: " + + "{:.3f}".format(self.solid_motor.grainInitialVolume) + + " m3" + ) + print( + "Grain Mass: " + + "{:.3f}".format(self.solid_motor.grainInitialMass) + + " kg\n" + ) + + def motor_details(self): + """Prints out all data available about the SolidMotor. + + Parameters + ---------- + None + + Return + ------ + None + """ + + # Print motor details + print("Motor Details") + print("Total Burning Time: " + str(self.solid_motor.burnDuration) + " s") + print( + "Total Propellant Mass: " + + "{:.3f}".format(self.solid_motor.propellantInitialMass) + + " kg" + ) + print( + "Average Propellant Exhaust Velocity: " + + "{:.3f}".format( + self.solid_motor.exhaustVelocity.average(*self.solid_motor.burn_time) + ) + + " m/s" + ) + print( + "Average Thrust: " + "{:.3f}".format(self.solid_motor.averageThrust) + " N" + ) + print( + "Maximum Thrust: " + + str(self.solid_motor.maxThrust) + + " N at " + + str(self.solid_motor.maxThrustTime) + + " s after ignition." + ) + print( + "Total Impulse: " + "{:.3f}".format(self.solid_motor.totalImpulse) + " Ns\n" + ) + + def all(self): + """Prints out all data available about the SolidMotor. + + Parameters + ---------- + None + + Return + ------ + None + """ + self.nozzle_details() + self.grain_details() + self.motor_details() + return None diff --git a/rocketpy/prints/tank_geometry_prints.py b/rocketpy/prints/tank_geometry_prints.py new file mode 100644 index 000000000..47b61f293 --- /dev/null +++ b/rocketpy/prints/tank_geometry_prints.py @@ -0,0 +1,65 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + + +class _TankGeometryPrints: + """Class that holds prints methods for TankGeometry class. + + Attributes + ---------- + _TankGeometryPrints.tank_geometry : TankGeometry + TankGeometry object that will be used for the prints. + + """ + + def __init__( + self, + tank_geometry, + ): + """Initializes _TankGeometryPrints class + + Parameters + ---------- + tank_geometry: TankGeometry + Instance of the TankGeometry class. + + Returns + ------- + None + """ + self.tank_geometry = tank_geometry + return None + + def geometry(self): + """Prints out the geometry of the tank. + + Parameters + ---------- + None + + Return + ------ + None + """ + print(f"Tank Geometry:") + print(f"Average radius {self.tank_geometry.average_radius:.3f} m") + print(f"Bottom: {self.tank_geometry.bottom} m") + print(f"Top: {self.tank_geometry.top} m") + print(f"Total height: {self.tank_geometry.total_height} m") + print(f"Total volume: {self.tank_geometry.total_volume:.6f} m^3\n") + return None + + def all(self): + """Prints out all data available about the TankGeometry. + + Parameters + ---------- + None + + Return + ------ + None + """ + self.geometry() + return None diff --git a/rocketpy/prints/tank_prints.py b/rocketpy/prints/tank_prints.py new file mode 100644 index 000000000..d964b28fa --- /dev/null +++ b/rocketpy/prints/tank_prints.py @@ -0,0 +1,45 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + + +class _TankPrints: + """Class that holds prints methods for Tank class. + + Attributes + ---------- + _TankPrints.tank : tank + Tank object that will be used for the prints. + + """ + + def __init__( + self, + tank, + ): + """Initializes _TankPrints class + + Parameters + ---------- + tank: Tank + Instance of the Tank class. + + Returns + ------- + None + """ + self.tank = tank + return None + + def all(self): + """Prints out all data available about the Tank. + + Parameters + ---------- + None + + Return + ------ + None + """ + return None