Skip to content

Commit 23ac66f

Browse files
aZira371Gui-FernandesBR
authored andcommitted
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 560ef80 commit 23ac66f

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
@@ -1379,9 +1379,7 @@ def lateral_surface_wind(self):
13791379

13801380
return -wind_u * np.cos(heading_rad) + wind_v * np.sin(heading_rad)
13811381

1382-
def __get_drag_coefficient(
1383-
self, drag_function, mach, z, freestream_velocity_body
1384-
):
1382+
def __get_drag_coefficient(self, drag_function, mach, z, freestream_velocity_body):
13851383
"""Calculate drag coefficient, handling both 1D and multi-dimensional functions.
13861384
13871385
Parameters
@@ -1392,8 +1390,6 @@ def __get_drag_coefficient(
13921390
Mach number
13931391
z : float
13941392
Altitude in meters
1395-
velocity_body : Vector or array-like
1396-
Rocket velocity in body frame [vx_b, vy_b, vz_b]
13971393
freestream_velocity_body : Vector or array-like
13981394
Freestream velocity in body frame [stream_vx_b, stream_vy_b, stream_vz_b]
13991395
@@ -1517,7 +1513,6 @@ def udot_rail1(self, t, u, post_processing=False):
15171513
self.rocket.power_on_drag,
15181514
free_stream_mach,
15191515
z,
1520-
[vx_b, vy_b, vz_b],
15211516
[stream_vx_b, stream_vy_b, stream_vz_b],
15221517
)
15231518

@@ -1712,15 +1707,13 @@ def u_dot(self, t, u, post_processing=False): # pylint: disable=too-many-locals
17121707
self.rocket.power_on_drag,
17131708
free_stream_mach,
17141709
z,
1715-
[vx_b, vy_b, vz_b],
17161710
[stream_vx_b, stream_vy_b, stream_vz_b],
17171711
)
17181712
else:
17191713
drag_coeff = self.__get_drag_coefficient(
17201714
self.rocket.power_off_drag,
17211715
free_stream_mach,
17221716
z,
1723-
[vx_b, vy_b, vz_b],
17241717
[stream_vx_b, stream_vy_b, stream_vz_b],
17251718
)
17261719
rho = self.env.density.get_value_opt(z)
@@ -2125,7 +2118,6 @@ def u_dot_generalized(self, t, u, post_processing=False): # pylint: disable=too
21252118
self.rocket.power_on_drag,
21262119
free_stream_mach,
21272120
z,
2128-
velocity_in_body_frame,
21292121
freestream_velocity_body,
21302122
)
21312123
else:
@@ -2134,7 +2126,6 @@ def u_dot_generalized(self, t, u, post_processing=False): # pylint: disable=too
21342126
self.rocket.power_off_drag,
21352127
free_stream_mach,
21362128
z,
2137-
velocity_in_body_frame,
21382129
freestream_velocity_body,
21392130
)
21402131
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)