Skip to content

Commit 116f327

Browse files
CopilotMateusStanoGui-FernandesBR
committed
ENH: Restore power_off/on_drag as Function objects; add _input attributes for raw user input and update changelog (#941)
* Initial plan * 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> * DOC: Add PR #941 compatibility fix to changelog Co-authored-by: MateusStano <69485049+MateusStano@users.noreply.github.com> * Update rocketpy/rocket/rocket.py Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com> * MNT: ruff pylint --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: MateusStano <69485049+MateusStano@users.noreply.github.com> Co-authored-by: Gui-FernandesBR <63590233+Gui-FernandesBR@users.noreply.github.com> Co-authored-by: MateusStano <mateusstano@usp.br>
1 parent 8d49e5f commit 116f327

3 files changed

Lines changed: 31 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Attention: The newest changes should be on top -->
4040

4141
### Fixed
4242

43-
- BUG: Add explicit timeouts to ThrustCurve API requests [#935](https://github.com/RocketPy-Team/RocketPy/pull/935)
43+
-
4444

4545
## [v1.12.0] - 2026-03-08
4646

@@ -73,6 +73,8 @@ Attention: The newest changes should be on top -->
7373

7474
### Fixed
7575

76+
- BUG: Restore `Rocket.power_off_drag` and `Rocket.power_on_drag` as `Function` objects while preserving raw inputs in `power_off_drag_input` and `power_on_drag_input` [#941](https://github.com/RocketPy-Team/RocketPy/pull/941)
77+
- BUG: Add explicit timeouts to ThrustCurve API requests [#935](https://github.com/RocketPy-Team/RocketPy/pull/935)
7678
- BUG: Fix hard-coded radius value for parachute added mass calculation [#889](https://github.com/RocketPy-Team/RocketPy/pull/889)
7779
- DOC: Fix documentation build [#908](https://github.com/RocketPy-Team/RocketPy/pull/908)
7880
- BUG: energy_data plot not working for 3 dof sims [[#906](https://github.com/RocketPy-Team/RocketPy/issues/906)]

rocketpy/rocket/point_mass_rocket.py

Lines changed: 12 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.

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)