From 39c97f02e776544b8d5ad50bb58ba5d8a284205d Mon Sep 17 00:00:00 2001 From: Lucas Prates Date: Thu, 17 Oct 2024 11:15:51 -0300 Subject: [PATCH 01/10] ENH: add structural to total mass ratio for motor and rocket --- rocketpy/prints/rocket_prints.py | 2 ++ rocketpy/prints/solid_motor_prints.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/rocketpy/prints/rocket_prints.py b/rocketpy/prints/rocket_prints.py index c9f5585ac..ef5e850c0 100644 --- a/rocketpy/prints/rocket_prints.py +++ b/rocketpy/prints/rocket_prints.py @@ -36,6 +36,8 @@ def inertia_details(self): print(f"Rocket Mass: {self.rocket.mass:.3f} kg (without motor)") print(f"Rocket Dry Mass: {self.rocket.dry_mass:.3f} kg (with unloaded motor)") print(f"Rocket Loaded Mass: {self.rocket.total_mass(0):.3f} kg") + mass_ratio = self.rocket.dry_mass / self.rocket.total_mass(0) + print(f"Rocket Structural to total mass ratio: {mass_ratio:.3f}") print( f"Rocket Inertia (with unloaded motor) 11: {self.rocket.dry_I_11:.3f} kg*m2" ) diff --git a/rocketpy/prints/solid_motor_prints.py b/rocketpy/prints/solid_motor_prints.py index c37a9b69e..31c50e6e8 100644 --- a/rocketpy/prints/solid_motor_prints.py +++ b/rocketpy/prints/solid_motor_prints.py @@ -65,6 +65,8 @@ def motor_details(self): print( f"Total Propellant Mass: {self.solid_motor.propellant_initial_mass:.3f} kg" ) + mass_ratio = self.solid_motor.dry_mass / self.solid_motor.total_mass(0) + print(f"Structural to total mass ratio: {mass_ratio:.3f}") average = self.solid_motor.exhaust_velocity.average(*self.solid_motor.burn_time) print(f"Average Propellant Exhaust Velocity: {average:.3f} m/s") print(f"Average Thrust: {self.solid_motor.average_thrust:.3f} N") From 4633584a8284dad0b7761e64172c04dabd00ee90 Mon Sep 17 00:00:00 2001 From: Lucas de Oliveira Prates Date: Tue, 29 Oct 2024 19:08:52 -0300 Subject: [PATCH 02/10] ENH: adding structural mass ratio as an attribute of Motor --- rocketpy/motors/motor.py | 15 +++++++++++++++ rocketpy/prints/hybrid_motor_prints.py | 1 + rocketpy/prints/liquid_motor_prints.py | 1 + rocketpy/prints/motor_prints.py | 1 + rocketpy/prints/solid_motor_prints.py | 3 +-- 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/rocketpy/motors/motor.py b/rocketpy/motors/motor.py index 5fa154d88..ea495e524 100644 --- a/rocketpy/motors/motor.py +++ b/rocketpy/motors/motor.py @@ -49,6 +49,8 @@ class Motor(ABC): Motor.propellant_mass : Function Total propellant mass in kg as a function of time, including solid, liquid and gas phases. + Motor.structural_mass_ratio: float + Initial ratio between the dry mass and the total mass. Motor.total_mass_flow_rate : Function Time derivative of propellant total mass in kg/s as a function of time as obtained by the thrust source. @@ -497,6 +499,19 @@ def propellant_initial_mass(self): Propellant initial mass in kg. """ + @property + def structural_mass_ratio(self): + """Calculates the structural mass ratio. The ratio is defined as + the dry mass divided by the initial total mass. + + Returns + ------- + float + Initial structural mass ratio. + """ + initial_total_mass = self.dry_mass + self.propellant_initial_mass + return self.dry_mass / initial_total_mass + @funcify_method("Time (s)", "Motor center of mass (m)") def center_of_mass(self): """Position of the center of mass as a function of time. The position diff --git a/rocketpy/prints/hybrid_motor_prints.py b/rocketpy/prints/hybrid_motor_prints.py index 4dcd7b113..986f43806 100644 --- a/rocketpy/prints/hybrid_motor_prints.py +++ b/rocketpy/prints/hybrid_motor_prints.py @@ -77,6 +77,7 @@ def motor_details(self): print( f"Total Propellant Mass: {self.hybrid_motor.propellant_initial_mass:.3f} kg" ) + print(f"Structural to total mass ratio: {self.hybrid_motor.structural_mass_ratio:.3f}") avg = self.hybrid_motor.exhaust_velocity.average(*self.hybrid_motor.burn_time) print(f"Average Propellant Exhaust Velocity: {avg:.3f} m/s") print(f"Average Thrust: {self.hybrid_motor.average_thrust:.3f} N") diff --git a/rocketpy/prints/liquid_motor_prints.py b/rocketpy/prints/liquid_motor_prints.py index fb493ed0a..752ba3247 100644 --- a/rocketpy/prints/liquid_motor_prints.py +++ b/rocketpy/prints/liquid_motor_prints.py @@ -47,6 +47,7 @@ def motor_details(self): print( f"Total Propellant Mass: {self.liquid_motor.propellant_initial_mass:.3f} kg" ) + print(f"Structural to total mass ratio: {self.liquid_motor.structural_mass_ratio:.3f}") avg = self.liquid_motor.exhaust_velocity.average(*self.liquid_motor.burn_time) print(f"Average Propellant Exhaust Velocity: {avg:.3f} m/s") print(f"Average Thrust: {self.liquid_motor.average_thrust:.3f} N") diff --git a/rocketpy/prints/motor_prints.py b/rocketpy/prints/motor_prints.py index d9b7fbc98..15b9e42f8 100644 --- a/rocketpy/prints/motor_prints.py +++ b/rocketpy/prints/motor_prints.py @@ -35,6 +35,7 @@ def motor_details(self): print("Motor Details") print("Total Burning Time: " + str(self.motor.burn_out_time) + " s") print(f"Total Propellant Mass: {self.motor.propellant_initial_mass:.3f} kg") + print(f"Structural to total mass ratio: {self.motor.structural_mass_ratio:.3f}") print( "Average Propellant Exhaust Velocity: " f"{self.motor.exhaust_velocity.average(*self.motor.burn_time):.3f} m/s" diff --git a/rocketpy/prints/solid_motor_prints.py b/rocketpy/prints/solid_motor_prints.py index 31c50e6e8..859eb02bd 100644 --- a/rocketpy/prints/solid_motor_prints.py +++ b/rocketpy/prints/solid_motor_prints.py @@ -65,8 +65,7 @@ def motor_details(self): print( f"Total Propellant Mass: {self.solid_motor.propellant_initial_mass:.3f} kg" ) - mass_ratio = self.solid_motor.dry_mass / self.solid_motor.total_mass(0) - print(f"Structural to total mass ratio: {mass_ratio:.3f}") + print(f"Structural to total mass ratio: {self.solid_motor.structural_mass_ratio:.3f}") average = self.solid_motor.exhaust_velocity.average(*self.solid_motor.burn_time) print(f"Average Propellant Exhaust Velocity: {average:.3f} m/s") print(f"Average Thrust: {self.solid_motor.average_thrust:.3f} N") From 7c151601486d1e40899c4bd9b032da98d5fa5bb5 Mon Sep 17 00:00:00 2001 From: Lucas de Oliveira Prates Date: Wed, 30 Oct 2024 10:11:44 -0300 Subject: [PATCH 03/10] ENH: add structural mass ratio to rocket --- rocketpy/motors/motor.py | 3 +++ rocketpy/prints/rocket_prints.py | 3 +-- rocketpy/rocket/rocket.py | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/rocketpy/motors/motor.py b/rocketpy/motors/motor.py index ea495e524..54b9cb751 100644 --- a/rocketpy/motors/motor.py +++ b/rocketpy/motors/motor.py @@ -510,6 +510,8 @@ def structural_mass_ratio(self): Initial structural mass ratio. """ initial_total_mass = self.dry_mass + self.propellant_initial_mass + if initial_total_mass == 0: + raise ValueError("Motor total mass is zero!") return self.dry_mass / initial_total_mass @funcify_method("Time (s)", "Motor center of mass (m)") @@ -1517,6 +1519,7 @@ def __init__(self): self.nozzle_radius = 0 self.thrust = Function(0, "Time (s)", "Thrust (N)") self.propellant_mass = Function(0, "Time (s)", "Propellant Mass (kg)") + self.propellant_initial_mass = 0 self.total_mass = Function(0, "Time (s)", "Total Mass (kg)") self.total_mass_flow_rate = Function( 0, "Time (s)", "Mass Depletion Rate (kg/s)" diff --git a/rocketpy/prints/rocket_prints.py b/rocketpy/prints/rocket_prints.py index ef5e850c0..7b768ea2f 100644 --- a/rocketpy/prints/rocket_prints.py +++ b/rocketpy/prints/rocket_prints.py @@ -36,8 +36,7 @@ def inertia_details(self): print(f"Rocket Mass: {self.rocket.mass:.3f} kg (without motor)") print(f"Rocket Dry Mass: {self.rocket.dry_mass:.3f} kg (with unloaded motor)") print(f"Rocket Loaded Mass: {self.rocket.total_mass(0):.3f} kg") - mass_ratio = self.rocket.dry_mass / self.rocket.total_mass(0) - print(f"Rocket Structural to total mass ratio: {mass_ratio:.3f}") + print(f"Rocket Structural Mass Ratio: {self.rocket.structural_mass_ratio:.3f}") print( f"Rocket Inertia (with unloaded motor) 11: {self.rocket.dry_I_11:.3f} kg*m2" ) diff --git a/rocketpy/rocket/rocket.py b/rocketpy/rocket/rocket.py index 758447fde..5a0b1f669 100644 --- a/rocketpy/rocket/rocket.py +++ b/rocketpy/rocket/rocket.py @@ -361,6 +361,7 @@ def __init__( # pylint: disable=too-many-statements # calculate dynamic inertial quantities self.evaluate_dry_mass() + self.evaluate_structural_mass_ratio() self.evaluate_total_mass() self.evaluate_center_of_dry_mass() self.evaluate_center_of_mass() @@ -433,6 +434,26 @@ def evaluate_dry_mass(self): return self.dry_mass + def evaluate_structural_mass_ratio(self): + """Calculates and returns the rocket's structural mass ratio. + It is defined as the ratio between of the dry mass + (Motor + Rocket) and the initial total mass + (Motor + Propellant + Rocket). + + Returns + ------- + self.structural_mass_ratio: float + Initial structural mass ratio dry mass (Rocket + Motor) (kg) + divided by total mass (Rocket + Motor + Propellant) (kg). + """ + # Make sure there is a motor associated with the rocket + + self.structural_mass_ratio = self.dry_mass / ( + self.dry_mass + self.motor.propellant_initial_mass + ) + + return self.structural_mass_ratio + def evaluate_center_of_mass(self): """Evaluates rocket center of mass position relative to user defined rocket reference system. @@ -951,6 +972,7 @@ def add_motor(self, motor, position): # pylint: disable=too-many-statements self.nozzle_position = self.motor.nozzle_position * _ + self.motor_position self.total_mass_flow_rate = self.motor.total_mass_flow_rate self.evaluate_dry_mass() + self.evaluate_structural_mass_ratio() self.evaluate_total_mass() self.evaluate_center_of_dry_mass() self.evaluate_nozzle_to_cdm() From 01b2fff8392a340c288ed3d1e402152436f6009e Mon Sep 17 00:00:00 2001 From: Lucas de Oliveira Prates Date: Wed, 30 Oct 2024 10:12:13 -0300 Subject: [PATCH 04/10] ENH: capitalize words on prints --- rocketpy/prints/hybrid_motor_prints.py | 2 +- rocketpy/prints/liquid_motor_prints.py | 2 +- rocketpy/prints/motor_prints.py | 2 +- rocketpy/prints/solid_motor_prints.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rocketpy/prints/hybrid_motor_prints.py b/rocketpy/prints/hybrid_motor_prints.py index 986f43806..e69d291f5 100644 --- a/rocketpy/prints/hybrid_motor_prints.py +++ b/rocketpy/prints/hybrid_motor_prints.py @@ -77,7 +77,7 @@ def motor_details(self): print( f"Total Propellant Mass: {self.hybrid_motor.propellant_initial_mass:.3f} kg" ) - print(f"Structural to total mass ratio: {self.hybrid_motor.structural_mass_ratio:.3f}") + print(f"Structural Mass Ratio: {self.hybrid_motor.structural_mass_ratio:.3f}") avg = self.hybrid_motor.exhaust_velocity.average(*self.hybrid_motor.burn_time) print(f"Average Propellant Exhaust Velocity: {avg:.3f} m/s") print(f"Average Thrust: {self.hybrid_motor.average_thrust:.3f} N") diff --git a/rocketpy/prints/liquid_motor_prints.py b/rocketpy/prints/liquid_motor_prints.py index 752ba3247..4c80326ab 100644 --- a/rocketpy/prints/liquid_motor_prints.py +++ b/rocketpy/prints/liquid_motor_prints.py @@ -47,7 +47,7 @@ def motor_details(self): print( f"Total Propellant Mass: {self.liquid_motor.propellant_initial_mass:.3f} kg" ) - print(f"Structural to total mass ratio: {self.liquid_motor.structural_mass_ratio:.3f}") + print(f"Structural Mass Ratio: {self.liquid_motor.structural_mass_ratio:.3f}") avg = self.liquid_motor.exhaust_velocity.average(*self.liquid_motor.burn_time) print(f"Average Propellant Exhaust Velocity: {avg:.3f} m/s") print(f"Average Thrust: {self.liquid_motor.average_thrust:.3f} N") diff --git a/rocketpy/prints/motor_prints.py b/rocketpy/prints/motor_prints.py index 15b9e42f8..f5efff8e0 100644 --- a/rocketpy/prints/motor_prints.py +++ b/rocketpy/prints/motor_prints.py @@ -35,7 +35,7 @@ def motor_details(self): print("Motor Details") print("Total Burning Time: " + str(self.motor.burn_out_time) + " s") print(f"Total Propellant Mass: {self.motor.propellant_initial_mass:.3f} kg") - print(f"Structural to total mass ratio: {self.motor.structural_mass_ratio:.3f}") + print(f"Structural Mass Ratio: {self.motor.structural_mass_ratio:.3f}") print( "Average Propellant Exhaust Velocity: " f"{self.motor.exhaust_velocity.average(*self.motor.burn_time):.3f} m/s" diff --git a/rocketpy/prints/solid_motor_prints.py b/rocketpy/prints/solid_motor_prints.py index 859eb02bd..6f4c28d5b 100644 --- a/rocketpy/prints/solid_motor_prints.py +++ b/rocketpy/prints/solid_motor_prints.py @@ -65,7 +65,7 @@ def motor_details(self): print( f"Total Propellant Mass: {self.solid_motor.propellant_initial_mass:.3f} kg" ) - print(f"Structural to total mass ratio: {self.solid_motor.structural_mass_ratio:.3f}") + print(f"Structural Mass Ratio: {self.solid_motor.structural_mass_ratio:.3f}") average = self.solid_motor.exhaust_velocity.average(*self.solid_motor.burn_time) print(f"Average Propellant Exhaust Velocity: {average:.3f} m/s") print(f"Average Thrust: {self.solid_motor.average_thrust:.3f} N") From 3051605abc083b4df972c6d92289864f14531491 Mon Sep 17 00:00:00 2001 From: Lucas de Oliveira Prates Date: Wed, 30 Oct 2024 10:22:41 -0300 Subject: [PATCH 05/10] DOC: adding structural mass ratio attribute to docstrings --- rocketpy/motors/hybrid_motor.py | 2 ++ rocketpy/motors/liquid_motor.py | 2 ++ rocketpy/motors/solid_motor.py | 2 ++ rocketpy/rocket/rocket.py | 2 ++ 4 files changed, 8 insertions(+) diff --git a/rocketpy/motors/hybrid_motor.py b/rocketpy/motors/hybrid_motor.py index 1a1bbb3db..dbaa6ee26 100644 --- a/rocketpy/motors/hybrid_motor.py +++ b/rocketpy/motors/hybrid_motor.py @@ -72,6 +72,8 @@ class HybridMotor(Motor): HybridMotor.propellant_mass : Function Total propellant mass in kg as a function of time, this includes the mass of fluids in each tank and the mass of the solid grains. + Motor.structural_mass_ratio: float + Initial ratio between the dry mass and the total mass. HybridMotor.total_mass_flow_rate : Function Time derivative of propellant total mass in kg/s as a function of time as obtained by the thrust source. diff --git a/rocketpy/motors/liquid_motor.py b/rocketpy/motors/liquid_motor.py index 9ec3d1130..6839e2395 100644 --- a/rocketpy/motors/liquid_motor.py +++ b/rocketpy/motors/liquid_motor.py @@ -47,6 +47,8 @@ class LiquidMotor(Motor): LiquidMotor.propellant_mass : Function Total propellant mass in kg as a function of time, includes fuel and oxidizer. + Motor.structural_mass_ratio: float + Initial ratio between the dry mass and the total mass. LiquidMotor.total_mass_flow_rate : Function Time derivative of propellant total mass in kg/s as a function of time as obtained by the tanks mass flow. diff --git a/rocketpy/motors/solid_motor.py b/rocketpy/motors/solid_motor.py index 81faf453f..09f22a59f 100644 --- a/rocketpy/motors/solid_motor.py +++ b/rocketpy/motors/solid_motor.py @@ -70,6 +70,8 @@ class SolidMotor(Motor): of propellant and dry mass. SolidMotor.propellant_mass : Function Total propellant mass in kg as a function of time. + Motor.structural_mass_ratio: float + Initial ratio between the dry mass and the total mass. SolidMotor.total_mass_flow_rate : Function Time derivative of propellant total mass in kg/s as a function of time as obtained by the thrust source. diff --git a/rocketpy/rocket/rocket.py b/rocketpy/rocket/rocket.py index 5a0b1f669..9ceba3894 100644 --- a/rocketpy/rocket/rocket.py +++ b/rocketpy/rocket/rocket.py @@ -89,6 +89,8 @@ class Rocket: Function of time expressing the total mass of the rocket, defined as the sum of the propellant mass and the rocket mass without propellant. + Rocket.structural_mass_ratio: float + Initial ratio between the dry mass and the total mass. Rocket.total_mass_flow_rate : Function Time derivative of rocket's total mass in kg/s as a function of time as obtained by the thrust source of the added motor. From 2143ed396fe7264a3838cf9f8d4142423d99512e Mon Sep 17 00:00:00 2001 From: Lucas de Oliveira Prates Date: Wed, 30 Oct 2024 10:28:59 -0300 Subject: [PATCH 06/10] DOC: fix incorrect documentation names of attributes --- rocketpy/motors/hybrid_motor.py | 2 +- rocketpy/motors/liquid_motor.py | 2 +- rocketpy/motors/solid_motor.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rocketpy/motors/hybrid_motor.py b/rocketpy/motors/hybrid_motor.py index dbaa6ee26..2916486d0 100644 --- a/rocketpy/motors/hybrid_motor.py +++ b/rocketpy/motors/hybrid_motor.py @@ -72,7 +72,7 @@ class HybridMotor(Motor): HybridMotor.propellant_mass : Function Total propellant mass in kg as a function of time, this includes the mass of fluids in each tank and the mass of the solid grains. - Motor.structural_mass_ratio: float + HybridMotor.structural_mass_ratio: float Initial ratio between the dry mass and the total mass. HybridMotor.total_mass_flow_rate : Function Time derivative of propellant total mass in kg/s as a function diff --git a/rocketpy/motors/liquid_motor.py b/rocketpy/motors/liquid_motor.py index 6839e2395..cde0e9d03 100644 --- a/rocketpy/motors/liquid_motor.py +++ b/rocketpy/motors/liquid_motor.py @@ -47,7 +47,7 @@ class LiquidMotor(Motor): LiquidMotor.propellant_mass : Function Total propellant mass in kg as a function of time, includes fuel and oxidizer. - Motor.structural_mass_ratio: float + LiquidMotor.structural_mass_ratio: float Initial ratio between the dry mass and the total mass. LiquidMotor.total_mass_flow_rate : Function Time derivative of propellant total mass in kg/s as a function diff --git a/rocketpy/motors/solid_motor.py b/rocketpy/motors/solid_motor.py index 09f22a59f..f6f09967e 100644 --- a/rocketpy/motors/solid_motor.py +++ b/rocketpy/motors/solid_motor.py @@ -70,7 +70,7 @@ class SolidMotor(Motor): of propellant and dry mass. SolidMotor.propellant_mass : Function Total propellant mass in kg as a function of time. - Motor.structural_mass_ratio: float + SolidMotor.structural_mass_ratio: float Initial ratio between the dry mass and the total mass. SolidMotor.total_mass_flow_rate : Function Time derivative of propellant total mass in kg/s as a function From 234e10d7861cd399030b2fbbc9616a0a56e9db5c Mon Sep 17 00:00:00 2001 From: Lucas Prates <57069366+Lucas-Prates@users.noreply.github.com> Date: Fri, 1 Nov 2024 11:44:29 -0300 Subject: [PATCH 07/10] Remove erroneous comment Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com> --- rocketpy/rocket/rocket.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rocketpy/rocket/rocket.py b/rocketpy/rocket/rocket.py index 9ceba3894..fd7ef8a2a 100644 --- a/rocketpy/rocket/rocket.py +++ b/rocketpy/rocket/rocket.py @@ -448,7 +448,6 @@ def evaluate_structural_mass_ratio(self): Initial structural mass ratio dry mass (Rocket + Motor) (kg) divided by total mass (Rocket + Motor + Propellant) (kg). """ - # Make sure there is a motor associated with the rocket self.structural_mass_ratio = self.dry_mass / ( self.dry_mass + self.motor.propellant_initial_mass From 0f4503dbde751f15390d27c9b86df4888f8f5ff3 Mon Sep 17 00:00:00 2001 From: Lucas de Oliveira Prates Date: Fri, 1 Nov 2024 21:17:45 -0300 Subject: [PATCH 08/10] DOC: modify changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f68f10b8c..bc4f552b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,7 +32,7 @@ Attention: The newest changes should be on top --> ### Added - +- ENH: add structural to total mass ratio for motor and rocket [#713](https://github.com/RocketPy-Team/RocketPy/pull/713) ### Changed From ed2ae39327575781dfea459e6f05edab15329e5d Mon Sep 17 00:00:00 2001 From: Lucas de Oliveira Prates Date: Tue, 5 Nov 2024 11:17:09 -0300 Subject: [PATCH 09/10] ENH: properly testing division by zero when computing the structural mass ratio --- rocketpy/motors/motor.py | 7 ++++--- rocketpy/rocket/rocket.py | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/rocketpy/motors/motor.py b/rocketpy/motors/motor.py index 54b9cb751..027a3c104 100644 --- a/rocketpy/motors/motor.py +++ b/rocketpy/motors/motor.py @@ -510,9 +510,10 @@ def structural_mass_ratio(self): Initial structural mass ratio. """ initial_total_mass = self.dry_mass + self.propellant_initial_mass - if initial_total_mass == 0: - raise ValueError("Motor total mass is zero!") - return self.dry_mass / initial_total_mass + try: + return self.dry_mass / initial_total_mass + except ZeroDivisionError as e: + raise ValueError("Total motor mass (dry + propellant) cannot be zero") from e @funcify_method("Time (s)", "Motor center of mass (m)") def center_of_mass(self): diff --git a/rocketpy/rocket/rocket.py b/rocketpy/rocket/rocket.py index fd7ef8a2a..06c556810 100644 --- a/rocketpy/rocket/rocket.py +++ b/rocketpy/rocket/rocket.py @@ -448,11 +448,12 @@ def evaluate_structural_mass_ratio(self): Initial structural mass ratio dry mass (Rocket + Motor) (kg) divided by total mass (Rocket + Motor + Propellant) (kg). """ - - self.structural_mass_ratio = self.dry_mass / ( - self.dry_mass + self.motor.propellant_initial_mass - ) - + try: + self.structural_mass_ratio = self.dry_mass / ( + self.dry_mass + self.motor.propellant_initial_mass + ) + except ZeroDivisionError as e: + raise ValueError("Total rocket mass (dry + propellant) cannot be zero") from e return self.structural_mass_ratio def evaluate_center_of_mass(self): From e532489b5fd2e17b9f1d1c618ab83cb7df88d396 Mon Sep 17 00:00:00 2001 From: Lucas de Oliveira Prates Date: Tue, 5 Nov 2024 11:25:00 -0300 Subject: [PATCH 10/10] MNT: make black --- rocketpy/motors/motor.py | 4 +++- rocketpy/rocket/rocket.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rocketpy/motors/motor.py b/rocketpy/motors/motor.py index 027a3c104..e0e6dfc9a 100644 --- a/rocketpy/motors/motor.py +++ b/rocketpy/motors/motor.py @@ -513,7 +513,9 @@ def structural_mass_ratio(self): try: return self.dry_mass / initial_total_mass except ZeroDivisionError as e: - raise ValueError("Total motor mass (dry + propellant) cannot be zero") from e + raise ValueError( + "Total motor mass (dry + propellant) cannot be zero" + ) from e @funcify_method("Time (s)", "Motor center of mass (m)") def center_of_mass(self): diff --git a/rocketpy/rocket/rocket.py b/rocketpy/rocket/rocket.py index 06c556810..ed376f582 100644 --- a/rocketpy/rocket/rocket.py +++ b/rocketpy/rocket/rocket.py @@ -453,7 +453,9 @@ def evaluate_structural_mass_ratio(self): self.dry_mass + self.motor.propellant_initial_mass ) except ZeroDivisionError as e: - raise ValueError("Total rocket mass (dry + propellant) cannot be zero") from e + raise ValueError( + "Total rocket mass (dry + propellant) cannot be zero" + ) from e return self.structural_mass_ratio def evaluate_center_of_mass(self):