Skip to content

Commit 17fc587

Browse files
committed
MNT: refactoring in flight.py and lint corrections to function.py and test_multidim_drag.py
-MNT: removed unused velocity in body frame parameter requirement from all instances of get_drag_coefficient in flight.py - MNT: corrected docstring for get_value_opt_grid in function.py - MNT: shifted import of classes before the definition of functions in test_multidim_drag.py
1 parent efe5cd7 commit 17fc587

3 files changed

Lines changed: 4 additions & 15 deletions

File tree

rocketpy/mathutils/function.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,8 @@ def __get_value_opt_nd(self, *args):
674674

675675
def __get_value_opt_grid(self, *args):
676676
"""Evaluate the Function using RegularGridInterpolator for structured grids.
677+
678+
This method is dynamically assigned in from_grid() class method.
677679
678680
Parameters
679681
----------

rocketpy/simulation/flight.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,9 +1348,7 @@ def lateral_surface_wind(self):
13481348

13491349
return -wind_u * np.cos(heading_rad) + wind_v * np.sin(heading_rad)
13501350

1351-
def __get_drag_coefficient(
1352-
self, drag_function, mach, z, freestream_velocity_body
1353-
):
1351+
def __get_drag_coefficient(self, drag_function, mach, z, freestream_velocity_body):
13541352
"""Calculate drag coefficient, handling both 1D and multi-dimensional functions.
13551353
13561354
Parameters
@@ -1361,8 +1359,6 @@ def __get_drag_coefficient(
13611359
Mach number
13621360
z : float
13631361
Altitude in meters
1364-
velocity_body : Vector or array-like
1365-
Rocket velocity in body frame [vx_b, vy_b, vz_b]
13661362
freestream_velocity_body : Vector or array-like
13671363
Freestream velocity in body frame [stream_vx_b, stream_vy_b, stream_vz_b]
13681364
@@ -1486,7 +1482,6 @@ def udot_rail1(self, t, u, post_processing=False):
14861482
self.rocket.power_on_drag,
14871483
free_stream_mach,
14881484
z,
1489-
[vx_b, vy_b, vz_b],
14901485
[stream_vx_b, stream_vy_b, stream_vz_b],
14911486
)
14921487

@@ -1679,15 +1674,13 @@ def u_dot(self, t, u, post_processing=False): # pylint: disable=too-many-locals
16791674
self.rocket.power_on_drag,
16801675
free_stream_mach,
16811676
z,
1682-
[vx_b, vy_b, vz_b],
16831677
[stream_vx_b, stream_vy_b, stream_vz_b],
16841678
)
16851679
else:
16861680
drag_coeff = self.__get_drag_coefficient(
16871681
self.rocket.power_off_drag,
16881682
free_stream_mach,
16891683
z,
1690-
[vx_b, vy_b, vz_b],
16911684
[stream_vx_b, stream_vy_b, stream_vz_b],
16921685
)
16931686
rho = self.env.density.get_value_opt(z)
@@ -1976,7 +1969,6 @@ def u_dot_generalized(self, t, u, post_processing=False): # pylint: disable=too
19761969
self.rocket.power_on_drag,
19771970
free_stream_mach,
19781971
z,
1979-
velocity_in_body_frame,
19801972
freestream_velocity_body,
19811973
)
19821974
else:
@@ -1985,7 +1977,6 @@ def u_dot_generalized(self, t, u, post_processing=False): # pylint: disable=too
19851977
self.rocket.power_off_drag,
19861978
free_stream_mach,
19871979
z,
1988-
velocity_in_body_frame,
19891980
freestream_velocity_body,
19901981
)
19911982
R3 += -0.5 * rho * (free_stream_speed**2) * self.rocket.area * drag_coeff

tests/integration/test_multidim_drag.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
"""Integration tests for multi-dimensional drag coefficient support."""
22

33
import numpy as np
4-
import pytest
54

6-
from rocketpy import Function
5+
from rocketpy import Environment, Flight, Function, Rocket, SolidMotor
76

87

98
def test_flight_with_1d_drag(example_plain_env, calisto):
109
"""Test that flights with 1D drag curves still work (backward compatibility)."""
11-
from rocketpy import Flight
1210

1311
flight = Flight(
1412
rocket=calisto,
@@ -26,8 +24,6 @@ def test_flight_with_1d_drag(example_plain_env, calisto):
2624

2725
def test_flight_with_3d_drag_basic():
2826
"""Test that a simple 3D drag function works."""
29-
from rocketpy import Environment, Flight, Rocket, SolidMotor
30-
3127
# Create environment
3228
env = Environment(gravity=9.81)
3329
env.set_atmospheric_model(type="standard_atmosphere")

0 commit comments

Comments
 (0)