diff --git a/rocketpy/rocket/aero_surface/nose_cone.py b/rocketpy/rocket/aero_surface/nose_cone.py index bebe63642..b0abacb55 100644 --- a/rocketpy/rocket/aero_surface/nose_cone.py +++ b/rocketpy/rocket/aero_surface/nose_cone.py @@ -235,7 +235,7 @@ def kind(self, value): self.y_nosecone = Function(lambda x: x * self.base_radius / self.length) case "lvhaack": - self.k = 0.563 + self.k = 7 / 16 def theta_lvhaack(x): return np.arccos(1 - 2 * max(min(x / self.length, 1), 0)) @@ -293,7 +293,7 @@ def theta_vonkarman(x): ) ) case "parabolic": - self.k = 0.5 + self.k = 7 / 15 self.y_nosecone = Function( lambda x: ( self.base_radius diff --git a/tests/unit/rocket/aero_surface/test_aero_surfaces.py b/tests/unit/rocket/aero_surface/test_aero_surfaces.py index f264ce40b..7e52d60f4 100644 --- a/tests/unit/rocket/aero_surface/test_aero_surfaces.py +++ b/tests/unit/rocket/aero_surface/test_aero_surfaces.py @@ -1,6 +1,8 @@ from unittest.mock import patch +import numpy as np import pytest +from scipy.integrate import quad from rocketpy import NoseCone @@ -10,6 +12,37 @@ NOSECONE_KIND = "powerseries" +@pytest.mark.parametrize( + "kind, power", + [ + ("conical", None), + ("ogive", None), + ("elliptical", None), + ("vonkarman", None), + ("lvhaack", None), + ("parabolic", None), + ("powerseries", 0.5), + ], +) +def test_nose_cone_center_of_pressure_matches_shape(kind, power): + """Checks the center of pressure against the volume of the nose cone shape. + From slender body theory, it's at L - V / A from the tip, where L is the + length, V is the volume and A is the base area. + """ + length, base_radius = 0.5, 0.06 + nose_cone = NoseCone( + length=length, + base_radius=base_radius, + rocket_radius=base_radius, + kind=kind, + power=power, + ) + volume, _ = quad(lambda x: np.pi * nose_cone.y_nosecone(x) ** 2, 0, length) + base_area = np.pi * base_radius**2 + + assert nose_cone.cpz == pytest.approx(length - volume / base_area, rel=1e-6) + + @pytest.mark.parametrize( "power, bluffness", [ diff --git a/tests/unit/rocket/test_rocket.py b/tests/unit/rocket/test_rocket.py index b14d086e3..fc53bcd15 100644 --- a/tests/unit/rocket/test_rocket.py +++ b/tests/unit/rocket/test_rocket.py @@ -143,7 +143,12 @@ def test_static_margin_internal_use_does_not_warn(calisto_motorless): @pytest.mark.parametrize( "k, type_", - ([2 / 3, "conical"], [0.46469957130675876, "ogive"], [0.563, "lvhaack"]), + ( + [2 / 3, "conical"], + [0.46469957130675876, "ogive"], + [7 / 16, "lvhaack"], + [7 / 15, "parabolic"], + ), ) def test_add_nose_assert_cp_cm_plus_nose(k, type_, calisto, dimensionless_calisto, m): calisto.add_nose(length=0.55829, kind=type_, position=1.160)