From 365d67365523cf9b5a97a3e515d304c4ac11652b Mon Sep 17 00:00:00 2001 From: MateusStano Date: Wed, 28 Jun 2023 22:31:14 -0300 Subject: [PATCH 1/5] ENH: create all prints files --- rocketpy/plots/fluid_plots.py | 0 rocketpy/plots/hybrid_motor_plots.py | 0 rocketpy/plots/liquid_motor_plots.py | 0 rocketpy/plots/motor_plots.py | 0 rocketpy/plots/solid_motor_plots.py | 0 rocketpy/plots/tank_geometry_plots.py | 0 rocketpy/plots/tank_plots.py | 0 rocketpy/prints/fluid_prints.py | 46 +++++++++ rocketpy/prints/hybrid_motor_prints.py | 127 +++++++++++++++++++++++ rocketpy/prints/liquid_motor_prints.py | 102 +++++++++++++++++++ rocketpy/prints/motor_prints.py | 84 ++++++++++++++++ rocketpy/prints/solid_motor_prints.py | 128 ++++++++++++++++++++++++ rocketpy/prints/tank_geometry_prints.py | 46 +++++++++ rocketpy/prints/tank_prints.py | 46 +++++++++ 14 files changed, 579 insertions(+) create mode 100644 rocketpy/plots/fluid_plots.py create mode 100644 rocketpy/plots/hybrid_motor_plots.py create mode 100644 rocketpy/plots/liquid_motor_plots.py create mode 100644 rocketpy/plots/motor_plots.py create mode 100644 rocketpy/plots/solid_motor_plots.py create mode 100644 rocketpy/plots/tank_geometry_plots.py create mode 100644 rocketpy/plots/tank_plots.py create mode 100644 rocketpy/prints/fluid_prints.py create mode 100644 rocketpy/prints/hybrid_motor_prints.py create mode 100644 rocketpy/prints/liquid_motor_prints.py create mode 100644 rocketpy/prints/motor_prints.py create mode 100644 rocketpy/prints/solid_motor_prints.py create mode 100644 rocketpy/prints/tank_geometry_prints.py create mode 100644 rocketpy/prints/tank_prints.py diff --git a/rocketpy/plots/fluid_plots.py b/rocketpy/plots/fluid_plots.py new file mode 100644 index 000000000..e69de29bb diff --git a/rocketpy/plots/hybrid_motor_plots.py b/rocketpy/plots/hybrid_motor_plots.py new file mode 100644 index 000000000..e69de29bb diff --git a/rocketpy/plots/liquid_motor_plots.py b/rocketpy/plots/liquid_motor_plots.py new file mode 100644 index 000000000..e69de29bb diff --git a/rocketpy/plots/motor_plots.py b/rocketpy/plots/motor_plots.py new file mode 100644 index 000000000..e69de29bb diff --git a/rocketpy/plots/solid_motor_plots.py b/rocketpy/plots/solid_motor_plots.py new file mode 100644 index 000000000..e69de29bb diff --git a/rocketpy/plots/tank_geometry_plots.py b/rocketpy/plots/tank_geometry_plots.py new file mode 100644 index 000000000..e69de29bb diff --git a/rocketpy/plots/tank_plots.py b/rocketpy/plots/tank_plots.py new file mode 100644 index 000000000..e69de29bb 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..948bd54ce --- /dev/null +++ b/rocketpy/prints/hybrid_motor_prints.py @@ -0,0 +1,127 @@ +__author__ = "Mateus Stano Junqueira" +__copyright__ = "Copyright 20XX, RocketPy Team" +__license__ = "MIT" + + +class _HybridMotor: + """Class that holds prints methods for HybridMotor class. + + Attributes + ---------- + _HybridMotor.hybrid_motor : hybrid_motor + HybridMotor object that will be used for the prints. + + """ + + def __init__( + self, + hybrid_motor, + ): + """Initializes _HybridMotor 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("Nozzle Radius: " + str(self.nozzleRadius) + " m") + print("Nozzle Throat Radius: " + str(self.solid.throatRadius) + " m") + + def grain_details(self): + """Prints out all data available about the Grain. + + Parameters + ---------- + None + + Return + ------ + None + """ + # 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") + + def motor_details(self): + """Prints out all data available about the HybridMotor. + + Parameters + ---------- + None + + Return + ------ + None + """ + # 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") + + def all(self): + """Prints out all data available about the HybridMotor. + + Parameters + ---------- + None + + Return + ------ + None + """ + + self.nozzle_details() + print() + + self.grain_details() + print() + + self.motor_details() + print() + + return None diff --git a/rocketpy/prints/liquid_motor_prints.py b/rocketpy/prints/liquid_motor_prints.py new file mode 100644 index 000000000..eb66f69dc --- /dev/null +++ b/rocketpy/prints/liquid_motor_prints.py @@ -0,0 +1,102 @@ +__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 Details") + print("Nozzle Radius: " + str(self.nozzleRadius) + " m") + + def motor_details(self): + """Prints out all data available about the motor. + + Parameters + ---------- + None + + Return + ------ + None + """ + # 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") + + def all(self): + """Prints out all data available about the LiquidMotor. + + Parameters + ---------- + None + + Return + ------ + None + """ + + self.nozzle_details() + print() + + self.motor_details() + print() + + return None diff --git a/rocketpy/prints/motor_prints.py b/rocketpy/prints/motor_prints.py new file mode 100644 index 000000000..7a5d63d16 --- /dev/null +++ b/rocketpy/prints/motor_prints.py @@ -0,0 +1,84 @@ +__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("\nMotor Details\n") + 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") + + 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/solid_motor_prints.py b/rocketpy/prints/solid_motor_prints.py new file mode 100644 index 000000000..55dbf1aa2 --- /dev/null +++ b/rocketpy/prints/solid_motor_prints.py @@ -0,0 +1,128 @@ +__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("\nNozzle Details\n") + print("Nozzle Radius: " + str(self.nozzleRadius) + " m") + print("Nozzle Throat Radius: " + str(self.throatRadius) + " m") + + def grain_details(self): + """Prints out all data available about the SolidMotor grain. + + Parameters + ---------- + None + + Return + ------ + None + """ + + # Print grain details + print("\nGrain Details\n") + 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") + + def motor_details(self): + """Prints out all data available about the SolidMotor. + + Parameters + ---------- + None + + Return + ------ + None + """ + + # Print motor details + print("\nMotor Details\n") + 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") + + def all(self): + """Prints out all data available about the SolidMotor. + + Parameters + ---------- + None + + Return + ------ + None + """ + self.nozzle_details() + print() + + self.grain_details() + print() + + self.motor_details() + print() + + return None diff --git a/rocketpy/prints/tank_geometry_prints.py b/rocketpy/prints/tank_geometry_prints.py new file mode 100644 index 000000000..ff98be588 --- /dev/null +++ b/rocketpy/prints/tank_geometry_prints.py @@ -0,0 +1,46 @@ +__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 all(self): + """Prints out all data available about the TankGeometry. + + Parameters + ---------- + None + + Return + ------ + None + """ + + return None diff --git a/rocketpy/prints/tank_prints.py b/rocketpy/prints/tank_prints.py new file mode 100644 index 000000000..823ac1131 --- /dev/null +++ b/rocketpy/prints/tank_prints.py @@ -0,0 +1,46 @@ +__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 From 2fff51eb58089282896759f53a5c0d93a78310c2 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Thu, 29 Jun 2023 11:31:31 -0300 Subject: [PATCH 2/5] ENH: plots files --- rocketpy/plots/fluid_plots.py | 45 +++ rocketpy/plots/hybrid_motor_plots.py | 400 ++++++++++++++++++++++++++ rocketpy/plots/liquid_motor_plots.py | 288 +++++++++++++++++++ rocketpy/plots/motor_plots.py | 245 ++++++++++++++++ rocketpy/plots/rocket_plots.py | 4 +- rocketpy/plots/solid_motor_plots.py | 398 +++++++++++++++++++++++++ rocketpy/plots/tank_geometry_plots.py | 45 +++ rocketpy/plots/tank_plots.py | 45 +++ 8 files changed, 1468 insertions(+), 2 deletions(-) diff --git a/rocketpy/plots/fluid_plots.py b/rocketpy/plots/fluid_plots.py index e69de29bb..cb8334461 100644 --- a/rocketpy/plots/fluid_plots.py +++ 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 index e69de29bb..018e24e7f 100644 --- a/rocketpy/plots/hybrid_motor_plots.py +++ b/rocketpy/plots/hybrid_motor_plots.py @@ -0,0 +1,400 @@ +__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.burn_time) + self.totalMass(*self.burn_time) + self.massFlowRate(*self.burn_time) + self.exhaustVelocity(*self.burn_time) + self.grainInnerRadius(*self.burn_time) + self.grainHeight(*self.burn_time) + self.burnRate(self.burn_time[0], self.grainBurnOut) + self.burnArea(*self.burn_time) + self.Kn() + self.centerOfMass(*self.burn_time) + self.I_11(*self.burn_time) + self.I_22(*self.burn_time) + self.I_33(*self.burn_time) + self.I_12(*self.burn_time) + self.I_13(*self.burn_time) + self.I_23(*self.burn_time) + + return None diff --git a/rocketpy/plots/liquid_motor_plots.py b/rocketpy/plots/liquid_motor_plots.py index e69de29bb..862baa368 100644 --- a/rocketpy/plots/liquid_motor_plots.py +++ 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.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) + + return None diff --git a/rocketpy/plots/motor_plots.py b/rocketpy/plots/motor_plots.py index e69de29bb..9ef6dc615 100644 --- a/rocketpy/plots/motor_plots.py +++ 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 index e69de29bb..43b1450bb 100644 --- a/rocketpy/plots/solid_motor_plots.py +++ 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.burn_time) + self.totalMass(*self.burn_time) + self.massFlowRate(*self.burn_time) + self.exhaustVelocity(*self.burn_time) + self.grainInnerRadius(*self.burn_time) + self.grainHeight(*self.burn_time) + self.burnRate(self.burn_time[0], self.grainBurnOut) + self.burnArea(*self.burn_time) + self.Kn() + self.centerOfMass(*self.burn_time) + self.I_11(*self.burn_time) + self.I_22(*self.burn_time) + self.I_33(*self.burn_time) + self.I_12(*self.burn_time) + self.I_13(*self.burn_time) + self.I_23(*self.burn_time) + + return None diff --git a/rocketpy/plots/tank_geometry_plots.py b/rocketpy/plots/tank_geometry_plots.py index e69de29bb..da729864b 100644 --- a/rocketpy/plots/tank_geometry_plots.py +++ b/rocketpy/plots/tank_geometry_plots.py @@ -0,0 +1,45 @@ +__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 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 + """ + + return None diff --git a/rocketpy/plots/tank_plots.py b/rocketpy/plots/tank_plots.py index e69de29bb..7643bf5c9 100644 --- a/rocketpy/plots/tank_plots.py +++ 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 From 92f2608c7a0946133c0d2c6862e7ddea447db2fb Mon Sep 17 00:00:00 2001 From: MateusStano Date: Thu, 29 Jun 2023 12:32:00 -0300 Subject: [PATCH 3/5] ENH: add plots and prints in the main classes --- rocketpy/motors/Fluid.py | 7 +++ rocketpy/motors/HybridMotor.py | 69 +++++-------------------- rocketpy/motors/LiquidMotor.py | 53 +++++-------------- rocketpy/motors/Motor.py | 69 ++++++------------------- rocketpy/motors/SolidMotor.py | 71 +++++--------------------- rocketpy/motors/Tank.py | 6 +++ rocketpy/motors/TankGeometry.py | 6 +++ rocketpy/plots/__init__.py | 6 +++ rocketpy/plots/hybrid_motor_plots.py | 32 ++++++------ rocketpy/plots/liquid_motor_plots.py | 22 ++++---- rocketpy/plots/solid_motor_plots.py | 30 +++++------ rocketpy/prints/__init__.py | 6 +++ rocketpy/prints/hybrid_motor_prints.py | 64 +++++++++++++++-------- rocketpy/prints/liquid_motor_prints.py | 22 +++++--- rocketpy/prints/motor_prints.py | 14 ++--- rocketpy/prints/solid_motor_prints.py | 50 ++++++++++++------ 16 files changed, 227 insertions(+), 300 deletions(-) diff --git a/rocketpy/motors/Fluid.py b/rocketpy/motors/Fluid.py index 84e7fadf1..1097a2207 100644 --- a/rocketpy/motors/Fluid.py +++ b/rocketpy/motors/Fluid.py @@ -5,6 +5,9 @@ __license__ = "MIT" from dataclasses import dataclass +from rocketpy.plots.fluid_plots import _FluidPlots + +from rocketpy.prints.fluid_prints import _FluidPrints @dataclass @@ -45,6 +48,10 @@ 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) + def __repr__(self): """Representation method. diff --git a/rocketpy/motors/HybridMotor.py b/rocketpy/motors/HybridMotor.py index b169b5f1a..a91d503ed 100644 --- a/rocketpy/motors/HybridMotor.py +++ b/rocketpy/motors/HybridMotor.py @@ -10,6 +10,8 @@ from rocketpy.tools import cached_property from rocketpy.Function import funcify_method +from rocketpy.plots.hybrid_motor_plots import _HybridMotorPlots +from rocketpy.prints.hybrid_motor_prints import _HybridMotorPrints from .Motor import Motor from .LiquidMotor import LiquidMotor from .SolidMotor import SolidMotor @@ -316,6 +318,9 @@ def __init__( interpolationMethod, coordinateSystemOrientation, ) + # Initialize plots and prints object + self.prints = _HybridMotorPrints(self) + self.plots = _HybridMotorPlots(self) @funcify_method("Time (s)", "Exhaust velocity (m/s)") def exhaustVelocity(self): @@ -531,6 +536,11 @@ def addTank(self, tank, position): self.liquid.addTank(tank, position) self.solid.massFlowRate = self.totalMassFlowRate - self.liquid.massFlowRate + def info(self): + """Prints out basic data about the Motor.""" + self.prints.all() + self.plots.thrust() + def allInfo(self): """Prints out all data and graphs available about the Motor. @@ -542,61 +552,6 @@ 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 diff --git a/rocketpy/motors/LiquidMotor.py b/rocketpy/motors/LiquidMotor.py index eebf26c56..685eeed25 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 +from rocketpy.plots.liquid_motor_plots import _LiquidMotorPlots +from rocketpy.prints.liquid_motor_prints import _LiquidMotorPrints from .Motor import Motor @@ -242,6 +244,10 @@ def __init__( self.positioned_tanks = [] + # Initialize plots and prints object + self.prints = _LiquidMotorPrints(self) + self.plots = _LiquidMotorPlots(self) + @funcify_method("Time (s)", "Exhaust Velocity (m/s)") def exhaustVelocity(self): """Computes the exhaust velocity of the motor from its mass flow @@ -429,6 +435,11 @@ def addTank(self, tank, position): """ self.positioned_tanks.append({"tank": tank, "position": position}) + def info(self): + """Prints out basic data about the Motor.""" + self.prints.all() + self.plots.thrust() + def allInfo(self): """Prints out all data and graphs available about the Motor. @@ -436,43 +447,5 @@ 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() diff --git a/rocketpy/motors/Motor.py b/rocketpy/motors/Motor.py index a2f81300f..4bee17dfc 100644 --- a/rocketpy/motors/Motor.py +++ b/rocketpy/motors/Motor.py @@ -7,6 +7,8 @@ import re 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 @@ -310,6 +312,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 @@ -1015,38 +1021,20 @@ 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") + self.prints.all() # Show plots print("\nPlots") - self.thrust() + self.plots.thrust() return None @abstractmethod def allInfo(self): """Prints out all data and graphs available about the Motor.""" - pass + self.prints.all() + + self.plots.all() class GenericMotor(Motor): @@ -1089,6 +1077,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 @@ -1200,39 +1191,11 @@ 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") + self.print.all() # 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.plots.all() class EmptyMotor: diff --git a/rocketpy/motors/SolidMotor.py b/rocketpy/motors/SolidMotor.py index 444285ee8..241029491 100644 --- a/rocketpy/motors/SolidMotor.py +++ b/rocketpy/motors/SolidMotor.py @@ -6,6 +6,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 @@ -330,6 +333,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)") @@ -673,64 +680,14 @@ 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() + 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 be4f19333..734cb17d5 100644 --- a/rocketpy/motors/Tank.py +++ b/rocketpy/motors/Tank.py @@ -7,6 +7,8 @@ from abc import ABC, abstractmethod 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 @@ -47,6 +49,10 @@ def __init__(self, name, geometry, flux_time, gas, liquid, discretize=100): self.gas = gas self.liquid = liquid self.discretize = discretize + + # Initialize plots and prints object + self.prints = _TankPrints(self) + self.plots = _TankPlots(self) return None @property diff --git a/rocketpy/motors/TankGeometry.py b/rocketpy/motors/TankGeometry.py index 3e1c51a0b..567ee57f4 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.prints.tank_geometry_prints import _TankGeometryPrints +from rocketpy.plots.tank_geometry_plots import _TankGeometryPlots try: from functools import cache @@ -98,6 +100,10 @@ def __init__(self, geometry_dict=dict()): """ self.geometry = geometry_dict + # Initialize plots and prints object + self.prints = _TankGeometryPrints(self) + self.plots = _TankGeometryPlots(self) + @property def geometry(self): """ diff --git a/rocketpy/plots/__init__.py b/rocketpy/plots/__init__.py index 547bfa429..f42673e67 100644 --- a/rocketpy/plots/__init__.py +++ b/rocketpy/plots/__init__.py @@ -3,3 +3,9 @@ from .environment_plots import _EnvironmentPlots from .flight_plots import _FlightPlots from .rocket_plots import _RocketPlots +from .motor_plots import _MotorPlots +from .solid_motor_plots import _SolidMotorPlots +from .liquid_motor_plots import _LiquidMotorPlots +from .hybrid_motor_plots import _HybridMotorPlots +from .tank_geometry_plots import _TankGeometryPlots +from .tank_plots import _TankPlots diff --git a/rocketpy/plots/hybrid_motor_plots.py b/rocketpy/plots/hybrid_motor_plots.py index 018e24e7f..6bac824bb 100644 --- a/rocketpy/plots/hybrid_motor_plots.py +++ b/rocketpy/plots/hybrid_motor_plots.py @@ -380,21 +380,23 @@ def all(self): None """ - self.thrust(*self.burn_time) - self.totalMass(*self.burn_time) - self.massFlowRate(*self.burn_time) - self.exhaustVelocity(*self.burn_time) - self.grainInnerRadius(*self.burn_time) - self.grainHeight(*self.burn_time) - self.burnRate(self.burn_time[0], self.grainBurnOut) - self.burnArea(*self.burn_time) + 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.burn_time) - self.I_11(*self.burn_time) - self.I_22(*self.burn_time) - self.I_33(*self.burn_time) - self.I_12(*self.burn_time) - self.I_13(*self.burn_time) - self.I_23(*self.burn_time) + 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 index 862baa368..59b07bdff 100644 --- a/rocketpy/plots/liquid_motor_plots.py +++ b/rocketpy/plots/liquid_motor_plots.py @@ -273,16 +273,16 @@ def all(self): None """ - 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.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/solid_motor_plots.py b/rocketpy/plots/solid_motor_plots.py index 43b1450bb..7fc948266 100644 --- a/rocketpy/plots/solid_motor_plots.py +++ b/rocketpy/plots/solid_motor_plots.py @@ -378,21 +378,21 @@ def all(self): None """ - self.thrust(*self.burn_time) - self.totalMass(*self.burn_time) - self.massFlowRate(*self.burn_time) - self.exhaustVelocity(*self.burn_time) - self.grainInnerRadius(*self.burn_time) - self.grainHeight(*self.burn_time) - self.burnRate(self.burn_time[0], self.grainBurnOut) - self.burnArea(*self.burn_time) + 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.burn_time) - self.I_11(*self.burn_time) - self.I_22(*self.burn_time) - self.I_33(*self.burn_time) - self.I_12(*self.burn_time) - self.I_13(*self.burn_time) - self.I_23(*self.burn_time) + 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/prints/__init__.py b/rocketpy/prints/__init__.py index 45e380f73..0b74249ad 100644 --- a/rocketpy/prints/__init__.py +++ b/rocketpy/prints/__init__.py @@ -4,3 +4,9 @@ from .flight_prints import _FlightPrints from .parachute_prints import _ParachutePrints from .rocket_prints import _RocketPrints +from .motor_prints import _MotorPrints +from .solid_motor_prints import _SolidMotorPrints +from .liquid_motor_prints import _LiquidMotorPrints +from .hybrid_motor_prints import _HybridMotorPrints +from .tank_geometry_prints import _TankGeometryPrints +from .tank_prints import _TankPrints diff --git a/rocketpy/prints/hybrid_motor_prints.py b/rocketpy/prints/hybrid_motor_prints.py index 948bd54ce..fbb021ded 100644 --- a/rocketpy/prints/hybrid_motor_prints.py +++ b/rocketpy/prints/hybrid_motor_prints.py @@ -3,12 +3,12 @@ __license__ = "MIT" -class _HybridMotor: +class _HybridMotorPrints: """Class that holds prints methods for HybridMotor class. Attributes ---------- - _HybridMotor.hybrid_motor : hybrid_motor + _HybridMotorPrints.hybrid_motor : hybrid_motor HybridMotor object that will be used for the prints. """ @@ -17,7 +17,7 @@ def __init__( self, hybrid_motor, ): - """Initializes _HybridMotor class + """Initializes _HybridMotorPrints class Parameters ---------- @@ -44,8 +44,10 @@ def nozzle_details(self): """ # Print nozzle details print("Nozzle Details") - print("Nozzle Radius: " + str(self.nozzleRadius) + " m") - print("Nozzle Throat Radius: " + str(self.solid.throatRadius) + " m") + print("Nozzle Radius: " + str(self.hybrid_motor.nozzleRadius) + " m") + print( + "Nozzle Throat Radius: " + str(self.hybrid_motor.solid.throatRadius) + " m" + ) def grain_details(self): """Prints out all data available about the Grain. @@ -60,14 +62,30 @@ def grain_details(self): """ # 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("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" + ) def motor_details(self): """Prints out all data available about the HybridMotor. @@ -82,26 +100,32 @@ def motor_details(self): """ # Print motor details print("\nMotor Details") - print("Total Burning Time: " + str(self.burnDuration) + " s") + print("Total Burning Time: " + str(self.hybrid_motor.burnDuration) + " s") print( "Total Propellant Mass: " - + "{:.3f}".format(self.propellantInitialMass) + + "{:.3f}".format(self.hybrid_motor.propellantInitialMass) + " kg" ) print( "Average Propellant Exhaust Velocity: " - + "{:.3f}".format(self.exhaustVelocity.average(*self.burn_time)) + + "{:.3f}".format( + self.hybrid_motor.exhaustVelocity.average(*self.hybrid_motor.burn_time) + ) + " m/s" ) - print("Average Thrust: " + "{:.3f}".format(self.averageThrust) + " N") + print( + "Average Thrust: " + "{:.3f}".format(self.hybrid_motor.averageThrust) + " N" + ) print( "Maximum Thrust: " - + str(self.maxThrust) + + str(self.hybrid_motor.maxThrust) + " N at " - + str(self.maxThrustTime) + + str(self.hybrid_motor.maxThrustTime) + " s after ignition." ) - print("Total Impulse: " + "{:.3f}".format(self.totalImpulse) + " Ns") + print( + "Total Impulse: " + "{:.3f}".format(self.hybrid_motor.totalImpulse) + " Ns" + ) def all(self): """Prints out all data available about the HybridMotor. diff --git a/rocketpy/prints/liquid_motor_prints.py b/rocketpy/prints/liquid_motor_prints.py index eb66f69dc..ae4d39a3a 100644 --- a/rocketpy/prints/liquid_motor_prints.py +++ b/rocketpy/prints/liquid_motor_prints.py @@ -45,7 +45,7 @@ def nozzle_details(self): # Print nozzle details print("Nozzle Details") - print("Nozzle Radius: " + str(self.nozzleRadius) + " m") + print("Nozzle Radius: " + str(self.liquid_motor.nozzleRadius) + " m") def motor_details(self): """Prints out all data available about the motor. @@ -60,26 +60,32 @@ def motor_details(self): """ # Print motor details print("\nMotor Details") - print("Total Burning Time: " + str(self.burnDuration) + " s") + print("Total Burning Time: " + str(self.liquid_motor.burnDuration) + " s") print( "Total Propellant Mass: " - + "{:.3f}".format(self.propellantInitialMass) + + "{:.3f}".format(self.liquid_motor.propellantInitialMass) + " kg" ) print( "Average Propellant Exhaust Velocity: " - + "{:.3f}".format(self.exhaustVelocity.average(*self.burn_time)) + + "{:.3f}".format( + self.liquid_motor.exhaustVelocity.average(*self.liquid_motor.burn_time) + ) + " m/s" ) - print("Average Thrust: " + "{:.3f}".format(self.averageThrust) + " N") + print( + "Average Thrust: " + "{:.3f}".format(self.liquid_motor.averageThrust) + " N" + ) print( "Maximum Thrust: " - + str(self.maxThrust) + + str(self.liquid_motor.maxThrust) + " N at " - + str(self.maxThrustTime) + + str(self.liquid_motor.maxThrustTime) + " s after ignition." ) - print("Total Impulse: " + "{:.3f}".format(self.totalImpulse) + " Ns") + print( + "Total Impulse: " + "{:.3f}".format(self.liquid_motor.totalImpulse) + " Ns" + ) def all(self): """Prints out all data available about the LiquidMotor. diff --git a/rocketpy/prints/motor_prints.py b/rocketpy/prints/motor_prints.py index 7a5d63d16..24449655f 100644 --- a/rocketpy/prints/motor_prints.py +++ b/rocketpy/prints/motor_prints.py @@ -44,26 +44,26 @@ def motor_details(self): """ # Print motor details print("\nMotor Details\n") - print("Total Burning Time: " + str(self.burnOutTime) + " s") + print("Total Burning Time: " + str(self.motor.burnOutTime) + " s") print( "Total Propellant Mass: " - + "{:.3f}".format(self.propellantInitialMass) + + "{:.3f}".format(self.motor.propellantInitialMass) + " kg" ) print( "Propellant Exhaust Velocity: " - + "{:.3f}".format(self.exhaustVelocity) + + "{:.3f}".format(self.motor.exhaustVelocity) + " m/s" ) - print("Average Thrust: " + "{:.3f}".format(self.averageThrust) + " N") + print("Average Thrust: " + "{:.3f}".format(self.motor.averageThrust) + " N") print( "Maximum Thrust: " - + str(self.maxThrust) + + str(self.motor.maxThrust) + " N at " - + str(self.maxThrustTime) + + str(self.motor.maxThrustTime) + " s after ignition." ) - print("Total Impulse: " + "{:.3f}".format(self.totalImpulse) + " Ns") + print("Total Impulse: " + "{:.3f}".format(self.motor.totalImpulse) + " Ns") return None diff --git a/rocketpy/prints/solid_motor_prints.py b/rocketpy/prints/solid_motor_prints.py index 55dbf1aa2..2b6d03dd9 100644 --- a/rocketpy/prints/solid_motor_prints.py +++ b/rocketpy/prints/solid_motor_prints.py @@ -44,8 +44,8 @@ def nozzle_details(self): """ # Print nozzle details print("\nNozzle Details\n") - print("Nozzle Radius: " + str(self.nozzleRadius) + " m") - print("Nozzle Throat Radius: " + str(self.throatRadius) + " m") + print("Nozzle Radius: " + str(self.solid_motor.nozzleRadius) + " m") + print("Nozzle Throat Radius: " + str(self.solid_motor.throatRadius) + " m") def grain_details(self): """Prints out all data available about the SolidMotor grain. @@ -61,14 +61,24 @@ def grain_details(self): # Print grain details print("\nGrain Details\n") - 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("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" + ) def motor_details(self): """Prints out all data available about the SolidMotor. @@ -84,26 +94,32 @@ def motor_details(self): # Print motor details print("\nMotor Details\n") - print("Total Burning Time: " + str(self.burnDuration) + " s") + print("Total Burning Time: " + str(self.solid_motor.burnDuration) + " s") print( "Total Propellant Mass: " - + "{:.3f}".format(self.propellantInitialMass) + + "{:.3f}".format(self.solid_motor.propellantInitialMass) + " kg" ) print( "Average Propellant Exhaust Velocity: " - + "{:.3f}".format(self.exhaustVelocity.average(*self.burn_time)) + + "{:.3f}".format( + self.solid_motor.exhaustVelocity.average(*self.solid_motor.burn_time) + ) + " m/s" ) - print("Average Thrust: " + "{:.3f}".format(self.averageThrust) + " N") + print( + "Average Thrust: " + "{:.3f}".format(self.solid_motor.averageThrust) + " N" + ) print( "Maximum Thrust: " - + str(self.maxThrust) + + str(self.solid_motor.maxThrust) + " N at " - + str(self.maxThrustTime) + + str(self.solid_motor.maxThrustTime) + " s after ignition." ) - print("Total Impulse: " + "{:.3f}".format(self.totalImpulse) + " Ns") + print( + "Total Impulse: " + "{:.3f}".format(self.solid_motor.totalImpulse) + " Ns" + ) def all(self): """Prints out all data available about the SolidMotor. From 587004b0c51e8c0da3d15dab87323a551c8d034f Mon Sep 17 00:00:00 2001 From: Guilherme Date: Fri, 30 Jun 2023 22:53:22 +0200 Subject: [PATCH 4/5] MAINT: improve motors plots and prints - Sort imports - avoid printing blank lines - more prints and plots for tank geometry --- rocketpy/motors/Fluid.py | 3 ++- rocketpy/motors/HybridMotor.py | 5 ++++- rocketpy/motors/LiquidMotor.py | 4 ++++ rocketpy/motors/Motor.py | 14 +++++------- rocketpy/motors/SolidMotor.py | 3 ++- rocketpy/motors/TankGeometry.py | 3 ++- rocketpy/plots/__init__.py | 6 ++--- rocketpy/plots/tank_geometry_plots.py | 16 +++++++++++++- rocketpy/prints/__init__.py | 12 +++++----- rocketpy/prints/hybrid_motor_prints.py | 29 ++++++++++++++----------- rocketpy/prints/liquid_motor_prints.py | 18 ++++++--------- rocketpy/prints/motor_prints.py | 8 ++----- rocketpy/prints/solid_motor_prints.py | 20 +++++++---------- rocketpy/prints/tank_geometry_prints.py | 21 +++++++++++++++++- rocketpy/prints/tank_prints.py | 1 - 15 files changed, 96 insertions(+), 67 deletions(-) diff --git a/rocketpy/motors/Fluid.py b/rocketpy/motors/Fluid.py index 1097a2207..0c11c57bd 100644 --- a/rocketpy/motors/Fluid.py +++ b/rocketpy/motors/Fluid.py @@ -5,8 +5,8 @@ __license__ = "MIT" from dataclasses import dataclass -from rocketpy.plots.fluid_plots import _FluidPlots +from rocketpy.plots.fluid_plots import _FluidPlots from rocketpy.prints.fluid_prints import _FluidPrints @@ -51,6 +51,7 @@ def __post_init__(self): # 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 081f7a029..012f36d0b 100644 --- a/rocketpy/motors/HybridMotor.py +++ b/rocketpy/motors/HybridMotor.py @@ -12,7 +12,7 @@ from rocketpy.Function import funcify_method from rocketpy.plots.hybrid_motor_plots import _HybridMotorPlots from rocketpy.prints.hybrid_motor_prints import _HybridMotorPrints -from .Motor import Motor + from .LiquidMotor import LiquidMotor from .Motor import Motor from .SolidMotor import SolidMotor @@ -322,6 +322,7 @@ def __init__( # 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): @@ -503,6 +504,7 @@ 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. @@ -514,3 +516,4 @@ def allInfo(self): self.prints.all() self.plots.all() return None + return None diff --git a/rocketpy/motors/LiquidMotor.py b/rocketpy/motors/LiquidMotor.py index 27c01ab5b..dac256947 100644 --- a/rocketpy/motors/LiquidMotor.py +++ b/rocketpy/motors/LiquidMotor.py @@ -12,6 +12,7 @@ from rocketpy.Function import Function, funcify_method from rocketpy.plots.liquid_motor_plots import _LiquidMotorPlots from rocketpy.prints.liquid_motor_prints import _LiquidMotorPrints + from .Motor import Motor @@ -247,6 +248,7 @@ def __init__( # 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): @@ -440,6 +442,7 @@ 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. @@ -450,3 +453,4 @@ def allInfo(self): """ self.prints.all() self.plots.all() + return None diff --git a/rocketpy/motors/Motor.py b/rocketpy/motors/Motor.py index 0e561a719..3e4bf30aa 100644 --- a/rocketpy/motors/Motor.py +++ b/rocketpy/motors/Motor.py @@ -7,9 +7,9 @@ import re 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: @@ -1036,10 +1036,8 @@ def info(self): """ # Print motor details self.prints.all() - - # Show plots - print("\nPlots") self.plots.thrust() + return None return None @@ -1047,8 +1045,8 @@ def info(self): def allInfo(self): """Prints out all data and graphs available about the Motor.""" self.prints.all() - self.plots.all() + return None class GenericMotor(Motor): @@ -1223,11 +1221,9 @@ def propellant_I_23(self): def allInfo(self): """Prints out all data and graphs available about the Motor.""" # Print motor details - self.print.all() - - # Show plots - print("\nPlots") + self.prints.all() self.plots.all() + return None class EmptyMotor: diff --git a/rocketpy/motors/SolidMotor.py b/rocketpy/motors/SolidMotor.py index 822849268..8ffd02ec8 100644 --- a/rocketpy/motors/SolidMotor.py +++ b/rocketpy/motors/SolidMotor.py @@ -6,8 +6,8 @@ import numpy as np from scipy import integrate -from rocketpy.plots.solid_motor_plots import _SolidMotorPlots +from rocketpy.plots.solid_motor_plots import _SolidMotorPlots from rocketpy.prints.solid_motor_prints import _SolidMotorPrints try: @@ -685,6 +685,7 @@ 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.""" diff --git a/rocketpy/motors/TankGeometry.py b/rocketpy/motors/TankGeometry.py index 804471e90..b24d14165 100644 --- a/rocketpy/motors/TankGeometry.py +++ b/rocketpy/motors/TankGeometry.py @@ -5,8 +5,8 @@ import numpy as np from rocketpy.Function import Function, PiecewiseFunction, funcify_method -from rocketpy.prints.tank_geometry_prints import _TankGeometryPrints from rocketpy.plots.tank_geometry_plots import _TankGeometryPlots +from rocketpy.prints.tank_geometry_prints import _TankGeometryPrints try: from functools import cache @@ -103,6 +103,7 @@ def __init__(self, geometry_dict=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 df03fb946..6d1b4d624 100644 --- a/rocketpy/plots/__init__.py +++ b/rocketpy/plots/__init__.py @@ -9,10 +9,10 @@ from .environment_analysis_plots import _EnvironmentAnalysisPlots from .environment_plots import _EnvironmentPlots from .flight_plots import _FlightPlots -from .rocket_plots import _RocketPlots +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 .liquid_motor_plots import _LiquidMotorPlots -from .hybrid_motor_plots import _HybridMotorPlots from .tank_geometry_plots import _TankGeometryPlots from .tank_plots import _TankPlots diff --git a/rocketpy/plots/tank_geometry_plots.py b/rocketpy/plots/tank_geometry_plots.py index da729864b..98b95559c 100644 --- a/rocketpy/plots/tank_geometry_plots.py +++ b/rocketpy/plots/tank_geometry_plots.py @@ -30,6 +30,18 @@ def __init__(self, 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. @@ -41,5 +53,7 @@ def all(self): ------ None """ - + self.radius() + self.area() + self.volume() return None diff --git a/rocketpy/prints/__init__.py b/rocketpy/prints/__init__.py index 274891f82..9a46f62de 100644 --- a/rocketpy/prints/__init__.py +++ b/rocketpy/prints/__init__.py @@ -1,19 +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 .motor_prints import _MotorPrints from .solid_motor_prints import _SolidMotorPrints -from .liquid_motor_prints import _LiquidMotorPrints -from .hybrid_motor_prints import _HybridMotorPrints from .tank_geometry_prints import _TankGeometryPrints from .tank_prints import _TankPrints diff --git a/rocketpy/prints/hybrid_motor_prints.py b/rocketpy/prints/hybrid_motor_prints.py index fbb021ded..5d6319d61 100644 --- a/rocketpy/prints/hybrid_motor_prints.py +++ b/rocketpy/prints/hybrid_motor_prints.py @@ -2,6 +2,8 @@ __copyright__ = "Copyright 20XX, RocketPy Team" __license__ = "MIT" +import numpy as np + class _HybridMotorPrints: """Class that holds prints methods for HybridMotor class. @@ -44,10 +46,12 @@ def nozzle_details(self): """ # Print nozzle details print("Nozzle Details") - print("Nozzle Radius: " + str(self.hybrid_motor.nozzleRadius) + " m") - print( - "Nozzle Throat Radius: " + str(self.hybrid_motor.solid.throatRadius) + " m" - ) + 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. @@ -61,7 +65,7 @@ def grain_details(self): None """ # Print grain details - print("\nGrain 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") @@ -84,8 +88,9 @@ def grain_details(self): print( "Grain Mass: " + "{:.3f}".format(self.hybrid_motor.solid.grainInitialMass) - + " kg" + + " kg\n" ) + return None def motor_details(self): """Prints out all data available about the HybridMotor. @@ -99,7 +104,7 @@ def motor_details(self): None """ # Print motor details - print("\nMotor Details") + print("Motor Details") print("Total Burning Time: " + str(self.hybrid_motor.burnDuration) + " s") print( "Total Propellant Mass: " @@ -124,8 +129,11 @@ def motor_details(self): + " s after ignition." ) print( - "Total Impulse: " + "{:.3f}".format(self.hybrid_motor.totalImpulse) + " Ns" + "Total Impulse: " + + "{:.3f}".format(self.hybrid_motor.totalImpulse) + + " Ns\n" ) + return None def all(self): """Prints out all data available about the HybridMotor. @@ -140,12 +148,7 @@ def all(self): """ self.nozzle_details() - print() - self.grain_details() - print() - self.motor_details() - print() return None diff --git a/rocketpy/prints/liquid_motor_prints.py b/rocketpy/prints/liquid_motor_prints.py index ae4d39a3a..bb4671bdc 100644 --- a/rocketpy/prints/liquid_motor_prints.py +++ b/rocketpy/prints/liquid_motor_prints.py @@ -42,10 +42,9 @@ def nozzle_details(self): ------ None """ - - # Print nozzle details print("Nozzle Details") - print("Nozzle Radius: " + str(self.liquid_motor.nozzleRadius) + " m") + print("Nozzle Radius: " + str(self.liquid_motor.nozzleRadius) + " m\n") + return None def motor_details(self): """Prints out all data available about the motor. @@ -58,8 +57,7 @@ def motor_details(self): ------ None """ - # Print motor details - print("\nMotor Details") + print("Motor Details") print("Total Burning Time: " + str(self.liquid_motor.burnDuration) + " s") print( "Total Propellant Mass: " @@ -84,8 +82,11 @@ def motor_details(self): + " s after ignition." ) print( - "Total Impulse: " + "{:.3f}".format(self.liquid_motor.totalImpulse) + " Ns" + "Total Impulse: " + + "{:.3f}".format(self.liquid_motor.totalImpulse) + + " Ns\n" ) + return None def all(self): """Prints out all data available about the LiquidMotor. @@ -98,11 +99,6 @@ def all(self): ------ None """ - self.nozzle_details() - print() - self.motor_details() - print() - return None diff --git a/rocketpy/prints/motor_prints.py b/rocketpy/prints/motor_prints.py index 24449655f..a67ced2f3 100644 --- a/rocketpy/prints/motor_prints.py +++ b/rocketpy/prints/motor_prints.py @@ -42,8 +42,7 @@ def motor_details(self): ------ None """ - # Print motor details - print("\nMotor Details\n") + print("Motor Details") print("Total Burning Time: " + str(self.motor.burnOutTime) + " s") print( "Total Propellant Mass: " @@ -63,8 +62,7 @@ def motor_details(self): + str(self.motor.maxThrustTime) + " s after ignition." ) - print("Total Impulse: " + "{:.3f}".format(self.motor.totalImpulse) + " Ns") - + print("Total Impulse: " + "{:.3f}".format(self.motor.totalImpulse) + " Ns\n") return None def all(self): @@ -78,7 +76,5 @@ def all(self): ------ None """ - self.motor_details() - return None diff --git a/rocketpy/prints/solid_motor_prints.py b/rocketpy/prints/solid_motor_prints.py index 2b6d03dd9..33751d22e 100644 --- a/rocketpy/prints/solid_motor_prints.py +++ b/rocketpy/prints/solid_motor_prints.py @@ -43,9 +43,9 @@ def nozzle_details(self): None """ # Print nozzle details - print("\nNozzle Details\n") + print("Nozzle Details") print("Nozzle Radius: " + str(self.solid_motor.nozzleRadius) + " m") - print("Nozzle Throat Radius: " + str(self.solid_motor.throatRadius) + " 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. @@ -60,7 +60,7 @@ def grain_details(self): """ # Print grain details - print("\nGrain Details\n") + 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") @@ -77,7 +77,9 @@ def grain_details(self): + " m3" ) print( - "Grain Mass: " + "{:.3f}".format(self.solid_motor.grainInitialMass) + " kg" + "Grain Mass: " + + "{:.3f}".format(self.solid_motor.grainInitialMass) + + " kg\n" ) def motor_details(self): @@ -93,7 +95,7 @@ def motor_details(self): """ # Print motor details - print("\nMotor Details\n") + print("Motor Details") print("Total Burning Time: " + str(self.solid_motor.burnDuration) + " s") print( "Total Propellant Mass: " @@ -118,7 +120,7 @@ def motor_details(self): + " s after ignition." ) print( - "Total Impulse: " + "{:.3f}".format(self.solid_motor.totalImpulse) + " Ns" + "Total Impulse: " + "{:.3f}".format(self.solid_motor.totalImpulse) + " Ns\n" ) def all(self): @@ -133,12 +135,6 @@ def all(self): None """ self.nozzle_details() - print() - self.grain_details() - print() - self.motor_details() - print() - return None diff --git a/rocketpy/prints/tank_geometry_prints.py b/rocketpy/prints/tank_geometry_prints.py index ff98be588..47b61f293 100644 --- a/rocketpy/prints/tank_geometry_prints.py +++ b/rocketpy/prints/tank_geometry_prints.py @@ -31,6 +31,25 @@ def __init__( 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. @@ -42,5 +61,5 @@ def all(self): ------ None """ - + self.geometry() return None diff --git a/rocketpy/prints/tank_prints.py b/rocketpy/prints/tank_prints.py index 823ac1131..d964b28fa 100644 --- a/rocketpy/prints/tank_prints.py +++ b/rocketpy/prints/tank_prints.py @@ -42,5 +42,4 @@ def all(self): ------ None """ - return None From be524dcdca508608f390b3be79bde8d6234277db Mon Sep 17 00:00:00 2001 From: Guilherme Date: Fri, 30 Jun 2023 22:56:54 +0200 Subject: [PATCH 5/5] MAINT: explicating rocket inertia when printing it --- rocketpy/prints/rocket_prints.py | 36 ++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) 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