From 064384ad9e310c4465df4fad9fe0cd5b69f6dcd7 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Thu, 9 Nov 2023 21:02:17 -0300 Subject: [PATCH] ENH: Add propellant_mass plot to motors plots --- rocketpy/plots/liquid_motor_plots.py | 6 ++--- rocketpy/plots/motor_plots.py | 36 ++++++++++++++++------------ rocketpy/plots/solid_motor_plots.py | 6 ++--- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/rocketpy/plots/liquid_motor_plots.py b/rocketpy/plots/liquid_motor_plots.py index c70f23ef0..a13a91bfb 100644 --- a/rocketpy/plots/liquid_motor_plots.py +++ b/rocketpy/plots/liquid_motor_plots.py @@ -33,12 +33,12 @@ def all(self): ------- None """ - self.thrust(*self.motor.burn_time) - self.total_mass(*self.motor.burn_time) - self.center_of_mass(*self.motor.burn_time) self.mass_flow_rate(*self.motor.burn_time) self.exhaust_velocity(*self.motor.burn_time) + self.total_mass(*self.motor.burn_time) + self.propellant_mass(*self.motor.burn_time) + self.center_of_mass(*self.motor.burn_time) self.I_11(*self.motor.burn_time) self.I_22(*self.motor.burn_time) self.I_33(*self.motor.burn_time) diff --git a/rocketpy/plots/motor_plots.py b/rocketpy/plots/motor_plots.py index 18a6615aa..70e12967e 100644 --- a/rocketpy/plots/motor_plots.py +++ b/rocketpy/plots/motor_plots.py @@ -20,7 +20,6 @@ def __init__(self, motor): ------- None """ - self.motor = motor def thrust(self, lower_limit=None, upper_limit=None): @@ -39,7 +38,6 @@ def thrust(self, lower_limit=None, upper_limit=None): ------ None """ - self.motor.thrust.plot(lower=lower_limit, upper=upper_limit) def total_mass(self, lower_limit=None, upper_limit=None): @@ -58,9 +56,26 @@ def total_mass(self, lower_limit=None, upper_limit=None): ------ None """ - self.motor.total_mass.plot(lower=lower_limit, upper=upper_limit) + def propellant_mass(self, lower_limit=None, upper_limit=None): + """Plots propellant_mass 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.propellant_mass.plot(lower=lower_limit, upper=upper_limit) + def center_of_mass(self, lower_limit=None, upper_limit=None): """Plots center_of_mass of the motor as a function of time. @@ -77,7 +92,6 @@ def center_of_mass(self, lower_limit=None, upper_limit=None): ------ None """ - self.motor.center_of_mass.plot(lower=lower_limit, upper=upper_limit) def mass_flow_rate(self, lower_limit=None, upper_limit=None): @@ -96,7 +110,6 @@ def mass_flow_rate(self, lower_limit=None, upper_limit=None): ------ None """ - self.motor.mass_flow_rate.plot(lower=lower_limit, upper=upper_limit) def exhaust_velocity(self, lower_limit=None, upper_limit=None): @@ -115,7 +128,6 @@ def exhaust_velocity(self, lower_limit=None, upper_limit=None): ------ None """ - self.motor.exhaust_velocity.plot(lower=lower_limit, upper=upper_limit) def I_11(self, lower_limit=None, upper_limit=None): @@ -134,7 +146,6 @@ def I_11(self, lower_limit=None, upper_limit=None): ------ None """ - self.motor.I_11.plot(lower=lower_limit, upper=upper_limit) def I_22(self, lower_limit=None, upper_limit=None): @@ -153,7 +164,6 @@ def I_22(self, lower_limit=None, upper_limit=None): ------ None """ - self.motor.I_22.plot(lower=lower_limit, upper=upper_limit) def I_33(self, lower_limit=None, upper_limit=None): @@ -172,7 +182,6 @@ def I_33(self, lower_limit=None, upper_limit=None): ------ None """ - self.motor.I_33.plot(lower=lower_limit, upper=upper_limit) def I_12(self, lower_limit=None, upper_limit=None): @@ -191,7 +200,6 @@ def I_12(self, lower_limit=None, upper_limit=None): ------ None """ - self.motor.I_12.plot(lower=lower_limit, upper=upper_limit) def I_13(self, lower_limit=None, upper_limit=None): @@ -210,7 +218,6 @@ def I_13(self, lower_limit=None, upper_limit=None): ------ None """ - self.motor.I_13.plot(lower=lower_limit, upper=upper_limit) def I_23(self, lower_limit=None, upper_limit=None): @@ -229,7 +236,6 @@ def I_23(self, lower_limit=None, upper_limit=None): ------ None """ - self.motor.I_23.plot(lower=lower_limit, upper=upper_limit) def draw(self): @@ -243,12 +249,12 @@ def all(self): ------- None """ - - # Show plots self.thrust(*self.motor.burn_time) + # self.mass_flow_rate(*self.motor.burn_time) + self.exhaust_velocity(*self.motor.burn_time) self.total_mass(*self.motor.burn_time) + self.propellant_mass(*self.motor.burn_time) self.center_of_mass(*self.motor.burn_time) - self.exhaust_velocity(*self.motor.burn_time) self.I_11(*self.motor.burn_time) self.I_22(*self.motor.burn_time) self.I_33(*self.motor.burn_time) diff --git a/rocketpy/plots/solid_motor_plots.py b/rocketpy/plots/solid_motor_plots.py index 02940ad66..a4a464442 100644 --- a/rocketpy/plots/solid_motor_plots.py +++ b/rocketpy/plots/solid_motor_plots.py @@ -129,12 +129,12 @@ def all(self): ------- None """ - self.thrust(*self.motor.burn_time) - self.total_mass(*self.motor.burn_time) - self.center_of_mass(*self.motor.burn_time) self.mass_flow_rate(*self.motor.burn_time) self.exhaust_velocity(*self.motor.burn_time) + self.total_mass(*self.motor.burn_time) + self.propellant_mass(*self.motor.burn_time) + self.center_of_mass(*self.motor.burn_time) self.grain_inner_radius(*self.motor.burn_time) self.grain_height(*self.motor.burn_time) self.burn_rate(self.motor.burn_time[0], self.motor.grain_burn_out)