From 7253f86bac0dadff2e90d235ea55654790917463 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Thu, 23 May 2024 22:22:50 +0200 Subject: [PATCH 1/5] ENH: add prandtl-glauert rule to nose cone and tail --- rocketpy/rocket/aero_surface.py | 53 +++++++++++++++++---------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/rocketpy/rocket/aero_surface.py b/rocketpy/rocket/aero_surface.py index 2e71c3210..0a371fd78 100644 --- a/rocketpy/rocket/aero_surface.py +++ b/rocketpy/rocket/aero_surface.py @@ -34,6 +34,30 @@ def __init__(self, name): self.name = name return None + # Defines beta parameter + def _beta(_, mach): + """Defines a parameter that is often used in aerodynamic + equations. It is commonly used in the Prandtl factor which + corrects subsonic force coefficients for compressible flow. + + Parameters + ---------- + mach : int, float + Number of mach. + + Returns + ------- + beta : int, float + Value that characterizes flow speed based on the mach number. + """ + + if mach < 0.8: + return np.sqrt(1 - mach**2) + elif mach < 1.1: + return np.sqrt(1 - 0.8**2) + else: + return np.sqrt(mach**2 - 1) + @abstractmethod def evaluate_center_of_pressure(self): """Evaluates the center of pressure of the aerodynamic surface in local @@ -465,7 +489,7 @@ def evaluate_lift_coefficient(self): # It must be set as a Function because it will be called and treated # as a function of mach in the simulation. self.clalpha = Function( - lambda mach: 2 * self.radius_ratio**2, + lambda mach: 2 / self._beta(mach) * self.radius_ratio**2, "Mach", f"Lift coefficient derivative for {self.name}", ) @@ -781,7 +805,7 @@ def evaluate_lift_coefficient(self): clalpha2D_incompressible *= 180 / np.pi # Correcting for compressible flow (apply Prandtl-Glauert correction) - clalpha2D = Function(lambda mach: clalpha2D_incompressible / self.__beta(mach)) + clalpha2D = Function(lambda mach: clalpha2D_incompressible / self._beta(mach)) # Diederich's Planform Correlation Parameter FD = 2 * np.pi * self.AR / (clalpha2D * np.cos(self.gamma_c)) @@ -857,30 +881,6 @@ def evaluate_roll_parameters(self): self.roll_parameters = [clf_delta, cld_omega, self.cant_angle_rad] return self.roll_parameters - # Defines beta parameter - def __beta(_, mach): - """Defines a parameter that is often used in aerodynamic - equations. It is commonly used in the Prandtl factor which - corrects subsonic force coefficients for compressible flow. - - Parameters - ---------- - mach : int, float - Number of mach. - - Returns - ------- - beta : int, float - Value that characterizes flow speed based on the mach number. - """ - - if mach < 0.8: - return np.sqrt(1 - mach**2) - elif mach < 1.1: - return np.sqrt(1 - 0.8**2) - else: - return np.sqrt(mach**2 - 1) - # Defines number of fins factor def __fin_num_correction(_, n): """Calculates a correction factor for the lift coefficient of multiple @@ -1748,6 +1748,7 @@ def evaluate_lift_coefficient(self): # as a function of mach in the simulation. self.clalpha = Function( lambda mach: 2 + / self._beta(mach) * ( (self.bottom_radius / self.rocket_radius) ** 2 - (self.top_radius / self.rocket_radius) ** 2 From f78498cf7166869bda1848d8f1c9f2bc38b7c09e Mon Sep 17 00:00:00 2001 From: MateusStano Date: Thu, 23 May 2024 22:24:42 +0200 Subject: [PATCH 2/5] TST: fix test values --- tests/test_flight.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_flight.py b/tests/test_flight.py index d4ed1e114..fb203b3af 100644 --- a/tests/test_flight.py +++ b/tests/test_flight.py @@ -640,10 +640,10 @@ def test_rail_buttons_forces(flight_calisto_custom_wind): """ test = flight_calisto_custom_wind atol = 5e-3 - assert pytest.approx(3.80358, abs=atol) == test.max_rail_button1_normal_force - assert pytest.approx(1.63602, abs=atol) == test.max_rail_button1_shear_force - assert pytest.approx(1.19353, abs=atol) == test.max_rail_button2_normal_force - assert pytest.approx(0.51337, abs=atol) == test.max_rail_button2_shear_force + assert pytest.approx(3.833613, abs=atol) == test.max_rail_button1_normal_force + assert pytest.approx(1.648938, abs=atol) == test.max_rail_button1_shear_force + assert pytest.approx(1.165307, abs=atol) == test.max_rail_button2_normal_force + assert pytest.approx(0.501229, abs=atol) == test.max_rail_button2_shear_force @pytest.mark.parametrize( @@ -690,7 +690,7 @@ def test_accelerations(flight_calisto_custom_wind, flight_time, expected_values) [ ("t_initial", (0, 0, 0)), ("out_of_rail_time", (0, 2.248727, 25.703072)), - ("apogee_time", (-13.209436, 16.05115, -0.000257)), + ("apogee_time", (-13.204789, 15.990903, -0.000138)), ("t_final", (5, 2, -5.65998)), ], ) @@ -728,7 +728,7 @@ def test_velocities(flight_calisto_custom_wind, flight_time, expected_values): [ ("t_initial", (1.6542528, 0.65918, -0.067107)), ("out_of_rail_time", (5.05334, 2.01364, -1.7541)), - ("apogee_time", (2.35291, -1.8275, -0.87851)), + ("apogee_time", (2.366258, -1.830744, -0.875342)), ("t_final", (0, 0, 159.2212)), ], ) @@ -766,7 +766,7 @@ def test_aerodynamic_forces(flight_calisto_custom_wind, flight_time, expected_va "flight_time, expected_values", [ ("t_initial", (0.17179073815516033, -0.431117, 0)), - ("out_of_rail_time", (0.547026, -1.3727895, 0)), + ("out_of_rail_time", (0.543760, -1.364593, 0)), ("apogee_time", (-0.5874848151271623, -0.7563596, 0)), ("t_final", (0, 0, 0)), ], From f6117546192f032a96f82afe2df364fbd0d5f3be Mon Sep 17 00:00:00 2001 From: MateusStano Date: Thu, 23 May 2024 22:40:09 +0200 Subject: [PATCH 3/5] DEV: changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2ed4ad75..dc38c3120 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added +- ENH: Add Prandtl-Gauss transformation to NoseCone and Tail [#609](https://github.com/RocketPy-Team/RocketPy/pull/609) - ENH: Pre-calculate attributes in Rocket class [#595](https://github.com/RocketPy-Team/RocketPy/pull/595) - ENH: Complex step differentiation [#594](https://github.com/RocketPy-Team/RocketPy/pull/594) - ENH: Exponential backoff decorator (fix #449) [#588](https://github.com/RocketPy-Team/RocketPy/pull/588) From 0b44194de7ad19d6f914ce84b0ef1a4e5c8c7ea5 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Thu, 13 Jun 2024 15:49:26 +0200 Subject: [PATCH 4/5] ENH: _beta to staticmethod --- rocketpy/rocket/aero_surface.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rocketpy/rocket/aero_surface.py b/rocketpy/rocket/aero_surface.py index 0a371fd78..8b0cf7d08 100644 --- a/rocketpy/rocket/aero_surface.py +++ b/rocketpy/rocket/aero_surface.py @@ -35,7 +35,8 @@ def __init__(self, name): return None # Defines beta parameter - def _beta(_, mach): + @staticmethod + def _beta(mach): """Defines a parameter that is often used in aerodynamic equations. It is commonly used in the Prandtl factor which corrects subsonic force coefficients for compressible flow. From ec3ec82e6205110439ec785f53f2cb78c823afb7 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Thu, 13 Jun 2024 15:55:10 +0200 Subject: [PATCH 5/5] DOC: add references to beta --- rocketpy/rocket/aero_surface.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rocketpy/rocket/aero_surface.py b/rocketpy/rocket/aero_surface.py index 8b0cf7d08..65cc58fb3 100644 --- a/rocketpy/rocket/aero_surface.py +++ b/rocketpy/rocket/aero_surface.py @@ -40,6 +40,8 @@ def _beta(mach): """Defines a parameter that is often used in aerodynamic equations. It is commonly used in the Prandtl factor which corrects subsonic force coefficients for compressible flow. + This is applied to the lift coefficient of the nose cone, + fins and tails/transitions as in [1]. Parameters ---------- @@ -50,6 +52,10 @@ def _beta(mach): ------- beta : int, float Value that characterizes flow speed based on the mach number. + + References + ---------- + [1] Barrowman, James S. https://arc.aiaa.org/doi/10.2514/6.1979-504 """ if mach < 0.8: