Skip to content

Commit db6e9f6

Browse files
CopilotMateusStano
andcommitted
ENH: Restore power_off/on_drag as Function, add _input attributes for raw user input
Co-authored-by: MateusStano <69485049+MateusStano@users.noreply.github.com>
1 parent 017210c commit db6e9f6

2 files changed

Lines changed: 29 additions & 7 deletions

File tree

rocketpy/rocket/point_mass_rocket.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ class PointMassRocket(Rocket):
4141
center_of_mass_without_motor : float
4242
Position, in meters, of the rocket's center of mass without motor
4343
relative to the rocket's coordinate system.
44+
power_off_drag : Function
45+
Rocket's drag coefficient as a function of Mach number when the
46+
motor is off. Alias for ``power_off_drag_by_mach``.
47+
power_on_drag : Function
48+
Rocket's drag coefficient as a function of Mach number when the
49+
motor is on. Alias for ``power_on_drag_by_mach``.
50+
power_off_drag_input : int, float, callable, array, string, Function
51+
Original user input for the drag coefficient with motor off.
52+
Preserved for reconstruction and Monte Carlo workflows.
53+
power_on_drag_input : int, float, callable, array, string, Function
54+
Original user input for the drag coefficient with motor on.
55+
Preserved for reconstruction and Monte Carlo workflows.
4456
power_off_drag_7d : Function
4557
Drag coefficient function with seven inputs in the order:
4658
alpha, beta, mach, reynolds, pitch_rate, yaw_rate, roll_rate.
@@ -53,6 +65,7 @@ class PointMassRocket(Rocket):
5365
Convenience wrapper for power-on drag as a Mach-only function.
5466
"""
5567

68+
5669
def __init__(
5770
self,
5871
radius: float,

rocketpy/rocket/rocket.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,18 @@ class Rocket:
147147
Rocket.static_margin : float
148148
Float value corresponding to rocket static margin when
149149
loaded with propellant in units of rocket diameter or calibers.
150-
Rocket.power_off_drag : int, float, callable, string, array, Function
150+
Rocket.power_off_drag : Function
151+
Rocket's drag coefficient as a function of Mach number when the
152+
motor is off. Alias for ``power_off_drag_by_mach``.
153+
Rocket.power_on_drag : Function
154+
Rocket's drag coefficient as a function of Mach number when the
155+
motor is on. Alias for ``power_on_drag_by_mach``.
156+
Rocket.power_off_drag_input : int, float, callable, string, array, Function
151157
Original user input for rocket's drag coefficient when the motor is
152-
off. This is preserved for reconstruction and Monte Carlo workflows.
153-
Rocket.power_on_drag : int, float, callable, string, array, Function
158+
off. Preserved for reconstruction and Monte Carlo workflows.
159+
Rocket.power_on_drag_input : int, float, callable, string, array, Function
154160
Original user input for rocket's drag coefficient when the motor is
155-
on. This is preserved for reconstruction and Monte Carlo workflows.
161+
on. Preserved for reconstruction and Monte Carlo workflows.
156162
Rocket.power_off_drag_7d : Function
157163
Rocket's drag coefficient with motor off as a 7D function of
158164
(alpha, beta, mach, reynolds, pitch_rate, yaw_rate, roll_rate).
@@ -375,9 +381,12 @@ def __init__( # pylint: disable=too-many-statements
375381
interpolation="linear",
376382
extrapolation="constant",
377383
)
378-
# Saving user input for monte carlo
379-
self.power_off_drag = power_off_drag
380-
self.power_on_drag = power_on_drag
384+
# Saving raw user input for reconstruction and Monte Carlo
385+
self.power_off_drag_input = power_off_drag
386+
self.power_on_drag_input = power_on_drag
387+
# Public API attributes: keep as Function (Mach-only) for backward compatibility
388+
self.power_off_drag = self.power_off_drag_by_mach
389+
self.power_on_drag = self.power_on_drag_by_mach
381390

382391
# Create a, possibly, temporary empty motor
383392
# self.motors = Components() # currently unused, only 1 motor is supported

0 commit comments

Comments
 (0)