Skip to content

Commit a126ef6

Browse files
ENH: add structural to total mass ratio for motor and rocket (#713)
* ENH: add structural to total mass ratio for motor and rocket * ENH: adding structural mass ratio as an attribute of Motor * ENH: add structural mass ratio to rocket * ENH: capitalize words on prints * DOC: adding structural mass ratio attribute to docstrings * DOC: fix incorrect documentation names of attributes * Remove erroneous comment Co-authored-by: Gui-FernandesBR <[email protected]> * DOC: modify changelog * ENH: properly testing division by zero when computing the structural mass ratio * MNT: make black --------- Co-authored-by: Gui-FernandesBR <[email protected]>
1 parent 282e54e commit a126ef6

File tree

11 files changed

+59
-1
lines changed

11 files changed

+59
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Attention: The newest changes should be on top -->
3232

3333
### Added
3434

35-
35+
- ENH: add structural to total mass ratio for motor and rocket [#713](https://github.com/RocketPy-Team/RocketPy/pull/713)
3636

3737
### Changed
3838

rocketpy/motors/hybrid_motor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class HybridMotor(Motor):
7272
HybridMotor.propellant_mass : Function
7373
Total propellant mass in kg as a function of time, this includes the
7474
mass of fluids in each tank and the mass of the solid grains.
75+
HybridMotor.structural_mass_ratio: float
76+
Initial ratio between the dry mass and the total mass.
7577
HybridMotor.total_mass_flow_rate : Function
7678
Time derivative of propellant total mass in kg/s as a function
7779
of time as obtained by the thrust source.

rocketpy/motors/liquid_motor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class LiquidMotor(Motor):
4747
LiquidMotor.propellant_mass : Function
4848
Total propellant mass in kg as a function of time, includes fuel
4949
and oxidizer.
50+
LiquidMotor.structural_mass_ratio: float
51+
Initial ratio between the dry mass and the total mass.
5052
LiquidMotor.total_mass_flow_rate : Function
5153
Time derivative of propellant total mass in kg/s as a function
5254
of time as obtained by the tanks mass flow.

rocketpy/motors/motor.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class Motor(ABC):
4949
Motor.propellant_mass : Function
5050
Total propellant mass in kg as a function of time, including solid,
5151
liquid and gas phases.
52+
Motor.structural_mass_ratio: float
53+
Initial ratio between the dry mass and the total mass.
5254
Motor.total_mass_flow_rate : Function
5355
Time derivative of propellant total mass in kg/s as a function
5456
of time as obtained by the thrust source.
@@ -497,6 +499,24 @@ def propellant_initial_mass(self):
497499
Propellant initial mass in kg.
498500
"""
499501

502+
@property
503+
def structural_mass_ratio(self):
504+
"""Calculates the structural mass ratio. The ratio is defined as
505+
the dry mass divided by the initial total mass.
506+
507+
Returns
508+
-------
509+
float
510+
Initial structural mass ratio.
511+
"""
512+
initial_total_mass = self.dry_mass + self.propellant_initial_mass
513+
try:
514+
return self.dry_mass / initial_total_mass
515+
except ZeroDivisionError as e:
516+
raise ValueError(
517+
"Total motor mass (dry + propellant) cannot be zero"
518+
) from e
519+
500520
@funcify_method("Time (s)", "Motor center of mass (m)")
501521
def center_of_mass(self):
502522
"""Position of the center of mass as a function of time. The position
@@ -1502,6 +1522,7 @@ def __init__(self):
15021522
self.nozzle_radius = 0
15031523
self.thrust = Function(0, "Time (s)", "Thrust (N)")
15041524
self.propellant_mass = Function(0, "Time (s)", "Propellant Mass (kg)")
1525+
self.propellant_initial_mass = 0
15051526
self.total_mass = Function(0, "Time (s)", "Total Mass (kg)")
15061527
self.total_mass_flow_rate = Function(
15071528
0, "Time (s)", "Mass Depletion Rate (kg/s)"

rocketpy/motors/solid_motor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class SolidMotor(Motor):
7070
of propellant and dry mass.
7171
SolidMotor.propellant_mass : Function
7272
Total propellant mass in kg as a function of time.
73+
SolidMotor.structural_mass_ratio: float
74+
Initial ratio between the dry mass and the total mass.
7375
SolidMotor.total_mass_flow_rate : Function
7476
Time derivative of propellant total mass in kg/s as a function
7577
of time as obtained by the thrust source.

rocketpy/prints/hybrid_motor_prints.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def motor_details(self):
7777
print(
7878
f"Total Propellant Mass: {self.hybrid_motor.propellant_initial_mass:.3f} kg"
7979
)
80+
print(f"Structural Mass Ratio: {self.hybrid_motor.structural_mass_ratio:.3f}")
8081
avg = self.hybrid_motor.exhaust_velocity.average(*self.hybrid_motor.burn_time)
8182
print(f"Average Propellant Exhaust Velocity: {avg:.3f} m/s")
8283
print(f"Average Thrust: {self.hybrid_motor.average_thrust:.3f} N")

rocketpy/prints/liquid_motor_prints.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def motor_details(self):
4747
print(
4848
f"Total Propellant Mass: {self.liquid_motor.propellant_initial_mass:.3f} kg"
4949
)
50+
print(f"Structural Mass Ratio: {self.liquid_motor.structural_mass_ratio:.3f}")
5051
avg = self.liquid_motor.exhaust_velocity.average(*self.liquid_motor.burn_time)
5152
print(f"Average Propellant Exhaust Velocity: {avg:.3f} m/s")
5253
print(f"Average Thrust: {self.liquid_motor.average_thrust:.3f} N")

rocketpy/prints/motor_prints.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def motor_details(self):
3535
print("Motor Details")
3636
print("Total Burning Time: " + str(self.motor.burn_out_time) + " s")
3737
print(f"Total Propellant Mass: {self.motor.propellant_initial_mass:.3f} kg")
38+
print(f"Structural Mass Ratio: {self.motor.structural_mass_ratio:.3f}")
3839
print(
3940
"Average Propellant Exhaust Velocity: "
4041
f"{self.motor.exhaust_velocity.average(*self.motor.burn_time):.3f} m/s"

rocketpy/prints/rocket_prints.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def inertia_details(self):
3636
print(f"Rocket Mass: {self.rocket.mass:.3f} kg (without motor)")
3737
print(f"Rocket Dry Mass: {self.rocket.dry_mass:.3f} kg (with unloaded motor)")
3838
print(f"Rocket Loaded Mass: {self.rocket.total_mass(0):.3f} kg")
39+
print(f"Rocket Structural Mass Ratio: {self.rocket.structural_mass_ratio:.3f}")
3940
print(
4041
f"Rocket Inertia (with unloaded motor) 11: {self.rocket.dry_I_11:.3f} kg*m2"
4142
)

rocketpy/prints/solid_motor_prints.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def motor_details(self):
6565
print(
6666
f"Total Propellant Mass: {self.solid_motor.propellant_initial_mass:.3f} kg"
6767
)
68+
print(f"Structural Mass Ratio: {self.solid_motor.structural_mass_ratio:.3f}")
6869
average = self.solid_motor.exhaust_velocity.average(*self.solid_motor.burn_time)
6970
print(f"Average Propellant Exhaust Velocity: {average:.3f} m/s")
7071
print(f"Average Thrust: {self.solid_motor.average_thrust:.3f} N")

0 commit comments

Comments
 (0)