From 7e806b2c2fc637d2c68abfda094ca432a8a77618 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Sat, 19 Nov 2022 06:32:43 +0100 Subject: [PATCH 1/8] TST: conftest.py refactored to dist. vs posit. --- tests/conftest.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index b08ad8752..298425648 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -19,6 +19,7 @@ def solid_motor(): example_motor = SolidMotor( thrustSource="data/motors/Cesaroni_M1670.eng", burnOut=3.9, + grainsCenterOfMassPosition=0.39796, grainNumber=5, grainSeparation=5 / 1000, grainDensity=1815, @@ -26,8 +27,11 @@ def solid_motor(): grainInitialInnerRadius=15 / 1000, grainInitialHeight=120 / 1000, nozzleRadius=33 / 1000, + nozzlePosition=0, throatRadius=11 / 1000, + reshapeThrustCurve=False, interpolationMethod="linear", + coordinateSystemOrientation="nozzleToCombustionChamber", ) return example_motor @@ -35,16 +39,16 @@ def solid_motor(): @pytest.fixture def rocket(solid_motor): example_rocket = Rocket( - motor=solid_motor, radius=127 / 2000, mass=19.197 - 2.956, inertiaI=6.60, inertiaZ=0.0351, - distanceRocketNozzle=-1.255, - distanceRocketPropellant=-0.85704, powerOffDrag="data/calisto/powerOffDragCurve.csv", powerOnDrag="data/calisto/powerOnDragCurve.csv", + centerOfDryMassPosition=0, + coordinateSystemOrientation="tailToNose", ) + example_rocket.addMotor(solid_motor, position=-1.255) return example_rocket @@ -72,6 +76,8 @@ def dimensionless_solid_motor(kg, m): nozzleRadius=33 / 1000 * m, throatRadius=11 / 1000 * m, interpolationMethod="linear", + grainsCenterOfMassPosition=0.39796 * m, + coordinateSystemOrientation="nozzleToCombustionChamber", ) return example_motor @@ -79,16 +85,16 @@ def dimensionless_solid_motor(kg, m): @pytest.fixture def dimensionless_rocket(kg, m, dimensionless_solid_motor): example_rocket = Rocket( - motor=dimensionless_solid_motor, radius=127 / 2000 * m, mass=(19.197 - 2.956) * kg, inertiaI=6.60 * (kg * m**2), inertiaZ=0.0351 * (kg * m**2), - distanceRocketNozzle=-1.255 * m, - distanceRocketPropellant=-0.85704 * m, powerOffDrag="data/calisto/powerOffDragCurve.csv", powerOnDrag="data/calisto/powerOnDragCurve.csv", + centerOfDryMassPosition=0 * m, + coordinateSystemOrientation="tailToNose", ) + example_rocket.addMotor(dimensionless_solid_motor, position=-1.255 * m) return example_rocket From c88fb136f265d52d6d99383f6cb1dce461e269d9 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Sat, 19 Nov 2022 06:37:42 +0100 Subject: [PATCH 2/8] TST: solidmotor tests refactored dist vs pos --- tests/test_solidmotor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_solidmotor.py b/tests/test_solidmotor.py index da8b6411d..abae42249 100644 --- a/tests/test_solidmotor.py +++ b/tests/test_solidmotor.py @@ -31,6 +31,8 @@ def test_motor(mock_show): nozzleRadius=33 / 1000, throatRadius=11 / 1000, interpolationMethod="linear", + grainsCenterOfMassPosition=0.39796, + coordinateSystemOrientation="nozzleToCombustionChamber", ) assert example_motor.allInfo() == None @@ -225,6 +227,8 @@ def test_reshape_thrust_curve_asserts_resultant_thrust_curve_correct(): throatRadius=11 / 1000, reshapeThrustCurve=(5, 3000), interpolationMethod="linear", + grainsCenterOfMassPosition=0.39796, + coordinateSystemOrientation="nozzleToCombustionChamber", ) thrust_reshaped = example_motor.thrust.getSource() From 0b4667c022a95ac8b0468cb37e5c42a9aae207ed Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Sat, 19 Nov 2022 18:39:41 +0100 Subject: [PATCH 3/8] TST: Fix 80% of test_rocket tests --- tests/test_rocket.py | 79 ++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/tests/test_rocket.py b/tests/test_rocket.py index 29710c044..90babd5ce 100644 --- a/tests/test_rocket.py +++ b/tests/test_rocket.py @@ -1,9 +1,9 @@ from unittest.mock import patch -import pytest import numpy as np +import pytest -from rocketpy import Environment, SolidMotor, Rocket, Flight, Parachute +from rocketpy import Rocket, SolidMotor @patch("matplotlib.pyplot.show") @@ -20,30 +20,33 @@ def test_rocket(mock_show): nozzleRadius=33 / 1000, throatRadius=11 / 1000, interpolationMethod="linear", + grainsCenterOfMassPosition=0.39796, + coordinateSystemOrientation="nozzleToCombustionChamber", ) test_rocket = Rocket( - motor=test_motor, radius=127 / 2000, mass=19.197 - 2.956, inertiaI=6.60, inertiaZ=0.0351, - distanceRocketNozzle=-1.255, - distanceRocketPropellant=-0.85704, powerOffDrag="data/calisto/powerOffDragCurve.csv", powerOnDrag="data/calisto/powerOnDragCurve.csv", + centerOfDryMassPosition=0, + coordinateSystemOrientation="tailToNose", ) + test_rocket.addMotor(test_motor, position=-1.255) + test_rocket.setRailButtons([0.2, -0.5]) NoseCone = test_rocket.addNose( - length=0.55829, kind="vonKarman", distanceToCM=0.71971 + length=0.55829, kind="vonKarman", position=1.278, name="NoseCone" ) FinSet = test_rocket.addTrapezoidalFins( - 4, span=0.100, rootChord=0.120, tipChord=0.040, distanceToCM=-1.04956 + 4, span=0.100, rootChord=0.120, tipChord=0.040, position=-1.04956 ) Tail = test_rocket.addTail( - topRadius=0.0635, bottomRadius=0.0435, length=0.060, distanceToCM=-1.194656 + topRadius=0.0635, bottomRadius=0.0435, length=0.060, position=-1.194656 ) def drogueTrigger(p, y): @@ -95,30 +98,33 @@ def test_elliptical_fins(mock_show): nozzleRadius=33 / 1000, throatRadius=11 / 1000, interpolationMethod="linear", + grainsCenterOfMassPosition=0.39796, + coordinateSystemOrientation="nozzleToCombustionChamber", ) test_rocket = Rocket( - motor=test_motor, radius=127 / 2000, mass=19.197 - 2.956, inertiaI=6.60, inertiaZ=0.0351, - distanceRocketNozzle=-1.255, - distanceRocketPropellant=-0.85704, powerOffDrag="data/calisto/powerOffDragCurve.csv", powerOnDrag="data/calisto/powerOnDragCurve.csv", + centerOfDryMassPosition=0, + coordinateSystemOrientation="tailToNose", ) + test_rocket.addMotor(test_motor, position=-1.255) + test_rocket.setRailButtons([0.2, -0.5]) NoseCone = test_rocket.addNose( - length=0.55829, kind="vonKarman", distanceToCM=0.71971 + length=0.55829, kind="vonKarman", position=1.278, name="NoseCone" ) FinSet = test_rocket.addEllipticalFins( - 4, span=0.100, rootChord=0.120, distanceToCM=-1.04956 + 4, span=0.100, rootChord=0.120, position=-1.04956 ) Tail = test_rocket.addTail( - topRadius=0.0635, bottomRadius=0.0435, length=0.060, distanceToCM=-1.194656 + topRadius=0.0635, bottomRadius=0.0435, length=0.060, position=-1.194656 ) def drogueTrigger(p, y): @@ -170,31 +176,34 @@ def test_airfoil(mock_show): nozzleRadius=33 / 1000, throatRadius=11 / 1000, interpolationMethod="linear", + grainsCenterOfMassPosition=0.39796, + coordinateSystemOrientation="nozzleToCombustionChamber", ) test_rocket = Rocket( - motor=test_motor, radius=127 / 2000, mass=19.197 - 2.956, inertiaI=6.60, inertiaZ=0.0351, - distanceRocketNozzle=-1.255, - distanceRocketPropellant=-0.85704, powerOffDrag="data/calisto/powerOffDragCurve.csv", powerOnDrag="data/calisto/powerOnDragCurve.csv", + centerOfDryMassPosition=0, + coordinateSystemOrientation="tailToNose", ) + test_rocket.addMotor(test_motor, position=-1.255) + test_rocket.setRailButtons([0.2, -0.5]) NoseCone = test_rocket.addNose( - length=0.55829, kind="vonKarman", distanceToCM=0.71971 + length=0.55829, kind="vonKarman", position=1.278, name="NoseCone" ) FinSetNACA = test_rocket.addTrapezoidalFins( 2, span=0.100, rootChord=0.120, tipChord=0.040, - distanceToCM=-1.04956, + position=-1.04956, airfoil=("tests/fixtures/airfoils/NACA0012-radians.txt", "radians"), ) FinSetE473 = test_rocket.addTrapezoidalFins( @@ -202,11 +211,11 @@ def test_airfoil(mock_show): span=0.100, rootChord=0.120, tipChord=0.040, - distanceToCM=-1.04956, + position=-1.04956, airfoil=("tests/fixtures/airfoils/e473-10e6-degrees.csv", "degrees"), ) Tail = test_rocket.addTail( - topRadius=0.0635, bottomRadius=0.0435, length=0.060, distanceToCM=-1.194656 + topRadius=0.0635, bottomRadius=0.0435, length=0.060, position=-1.194656 ) def drogueTrigger(p, y): @@ -269,8 +278,8 @@ def test_evaluate_static_margin_assert_cp_equals_cm(kg, m, dimensionless_rocket) ), ) def test_add_nose_assert_cp_cm_plus_nose(k, type, rocket, dimensionless_rocket, m): - rocket.addNose(length=0.55829, kind=type, distanceToCM=0.71971) - cpz = 0.71971 + k * 0.55829 + rocket.addNose(length=0.55829, kind=type, position=1.278) + cpz = 0.71971 + k * 0.55829 # Relative to the center of dry mass clalpha = 2 static_margin_initial = (rocket.centerOfMass(0) - cpz) / (2 * rocket.radius) @@ -282,9 +291,7 @@ def test_add_nose_assert_cp_cm_plus_nose(k, type, rocket, dimensionless_rocket, assert clalpha == pytest.approx(rocket.totalLiftCoeffDer, 1e-12) assert rocket.cpPosition == pytest.approx(cpz, 1e-12) - dimensionless_rocket.addNose( - length=0.55829 * m, kind=type, distanceToCM=0.71971 * m - ) + dimensionless_rocket.addNose(length=0.55829 * m, kind=type, position=1.278 * m) assert pytest.approx(dimensionless_rocket.staticMargin(0), 1e-12) == pytest.approx( rocket.staticMargin(0), 1e-12 ) @@ -304,7 +311,7 @@ def test_add_tail_assert_cp_cm_plus_tail(rocket, dimensionless_rocket, m): topRadius=0.0635, bottomRadius=0.0435, length=0.060, - distanceToCM=-1.194656, + position=-1.194656, ) clalpha = -2 * (1 - (0.0635 / 0.0435) ** (-2)) * (0.0635 / (rocket.radius)) ** 2 @@ -324,7 +331,7 @@ def test_add_tail_assert_cp_cm_plus_tail(rocket, dimensionless_rocket, m): topRadius=0.0635 * m, bottomRadius=0.0435 * m, length=0.060 * m, - distanceToCM=-1.194656 * m, + position=-1.194656 * m, ) assert pytest.approx(dimensionless_rocket.staticMargin(0), 1e-12) == pytest.approx( rocket.staticMargin(0), 1e-12 @@ -348,7 +355,7 @@ def test_add_trapezoidal_fins_sweep_angle( rocket, sweep_angle, expected_fin_cpz, expected_clalpha, expected_cpz_cm ): # Reference values from OpenRocket - Nose = rocket.addNose(length=0.55829, kind="vonKarman", distanceToCM=0.71971) + Nose = rocket.addNose(length=0.55829, kind="vonKarman", position=1.278) FinSet = rocket.addTrapezoidalFins( n=3, @@ -356,12 +363,12 @@ def test_add_trapezoidal_fins_sweep_angle( rootChord=0.100, tipChord=0.050, sweepAngle=sweep_angle, - distanceToCM=-1.182, + position=-1.182, ) # Check center of pressure translate = 0.55829 + 0.71971 - cpz = FinSet.cp[2] + cpz = -1.182 - FinSet.cpz # Should be - 1.232 assert translate - cpz == pytest.approx(expected_fin_cpz, 0.01) # Check lift coefficient derivative @@ -380,7 +387,7 @@ def test_add_trapezoidal_fins_sweep_length( rocket, sweep_length, expected_fin_cpz, expected_clalpha, expected_cpz_cm ): # Reference values from OpenRocket - Nose = rocket.addNose(length=0.55829, kind="vonKarman", distanceToCM=0.71971) + Nose = rocket.addNose(length=0.55829, kind="vonKarman", position=1.278) FinSet = rocket.addTrapezoidalFins( n=3, @@ -388,12 +395,12 @@ def test_add_trapezoidal_fins_sweep_length( rootChord=0.100, tipChord=0.050, sweepLength=sweep_length, - distanceToCM=-1.182, + position=-1.182, ) # Check center of pressure translate = 0.55829 + 0.71971 - cpz = FinSet.cp[2] + cpz = -FinSet.cp[2] - 1.182 assert translate - cpz == pytest.approx(expected_fin_cpz, 0.01) # Check lift coefficient derivative @@ -410,7 +417,7 @@ def test_add_fins_assert_cp_cm_plus_fins(rocket, dimensionless_rocket, m): span=0.100, rootChord=0.120, tipChord=0.040, - distanceToCM=-1.04956, + position=-1.04956, ) cpz = -1.04956 - ( @@ -442,7 +449,7 @@ def test_add_fins_assert_cp_cm_plus_fins(rocket, dimensionless_rocket, m): span=0.100 * m, rootChord=0.120 * m, tipChord=0.040 * m, - distanceToCM=-1.04956 * m, + position=-1.04956 * m, ) assert pytest.approx(dimensionless_rocket.staticMargin(0), 1e-12) == pytest.approx( rocket.staticMargin(0), 1e-12 From 4a0dc3d7aedee998a202a00ae703cb71bcb993b5 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Sat, 19 Nov 2022 16:17:16 -0300 Subject: [PATCH 4/8] tst: fixed rocket nosecone tests --- rocketpy/AeroSurfaces.py | 2 ++ tests/test_rocket.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/rocketpy/AeroSurfaces.py b/rocketpy/AeroSurfaces.py index 48a9d93c4..9d3c718ab 100644 --- a/rocketpy/AeroSurfaces.py +++ b/rocketpy/AeroSurfaces.py @@ -114,7 +114,9 @@ def __init__( self.k = 0.563 else: self.k = 0.5 + # Calculate cp position in local coordinates + # Local coordinate origin is found at the tip of the nose cone self.cpz = self.k * length self.cpy = 0 self.cpx = 0 diff --git a/tests/test_rocket.py b/tests/test_rocket.py index 90babd5ce..6b7295358 100644 --- a/tests/test_rocket.py +++ b/tests/test_rocket.py @@ -270,16 +270,16 @@ def test_evaluate_static_margin_assert_cp_equals_cm(kg, m, dimensionless_rocket) @pytest.mark.parametrize( "k, type", ( - [1 - 1 / 3, "conical"], - [1 - 0.534, "ogive"], - [1 - 0.437, "lvhaack"], + [2 / 3, "conical"], + [0.466, "ogive"], + [0.563, "lvhaack"], [0.5, "default"], [0.5, "not a mapped string, to show default case"], ), ) def test_add_nose_assert_cp_cm_plus_nose(k, type, rocket, dimensionless_rocket, m): rocket.addNose(length=0.55829, kind=type, position=1.278) - cpz = 0.71971 + k * 0.55829 # Relative to the center of dry mass + cpz = 1.278 - k * 0.55829 # Relative to the center of dry mass clalpha = 2 static_margin_initial = (rocket.centerOfMass(0) - cpz) / (2 * rocket.radius) From b1f90a74fa96125a662097fc8030edaa52636742 Mon Sep 17 00:00:00 2001 From: MateusStano Date: Sat, 19 Nov 2022 17:06:10 -0300 Subject: [PATCH 5/8] tst: fixed flight tests --- tests/test_flight.py | 135 ++++++++++++++++++++++++------------------- 1 file changed, 76 insertions(+), 59 deletions(-) diff --git a/tests/test_flight.py b/tests/test_flight.py index 6038d1807..ef665bb9f 100644 --- a/tests/test_flight.py +++ b/tests/test_flight.py @@ -7,6 +7,7 @@ from scipy import optimize from rocketpy import Environment, Flight, Function, Rocket, SolidMotor +from rocketpy.AeroSurfaces import AeroSurfaces plt.rcParams.update({"figure.max_open_warning": 0}) @@ -31,21 +32,21 @@ def setup_rocket_with_given_static_margin(rocket, static_margin): Rocket with the given static margin. """ - def compute_static_margin_error_given_distance(distanceToCM, static_margin, rocket): - rocket.aerodynamicSurfaces = [] - rocket.addNose(length=0.5, kind="vonKarman", distanceToCM=1.0) + def compute_static_margin_error_given_distance(position, static_margin, rocket): + rocket.aerodynamicSurfaces = AeroSurfaces() + rocket.addNose(length=0.5, kind="vonKarman", position=1.0 + 0.5) rocket.addTrapezoidalFins( 4, span=0.100, rootChord=0.100, tipChord=0.100, - distanceToCM=distanceToCM, + position=position, ) rocket.addTail( topRadius=0.0635, bottomRadius=0.0435, length=0.060, - distanceToCM=-1.194656, + position=-1.194656, ) return rocket.staticMargin(0) - static_margin @@ -76,6 +77,7 @@ def test_flight(mock_show): test_motor = SolidMotor( thrustSource="data/motors/Cesaroni_M1670.eng", burnOut=3.9, + grainsCenterOfMassPosition=-0.85704, grainNumber=5, grainSeparation=5 / 1000, grainDensity=1815, @@ -85,30 +87,31 @@ def test_flight(mock_show): nozzleRadius=33 / 1000, throatRadius=11 / 1000, interpolationMethod="linear", + nozzlePosition=-1.255, + coordinateSystemOrientation="nozzleToCombustionChamber", ) test_rocket = Rocket( - motor=test_motor, radius=127 / 2000, mass=19.197 - 2.956, inertiaI=6.60, inertiaZ=0.0351, - distanceRocketNozzle=-1.255, - distanceRocketPropellant=-0.85704, powerOffDrag="data/calisto/powerOffDragCurve.csv", powerOnDrag="data/calisto/powerOnDragCurve.csv", ) test_rocket.setRailButtons([0.2, -0.5]) + test_rocket.addMotor(test_motor, position=-1.255) + NoseCone = test_rocket.addNose( - length=0.55829, kind="vonKarman", distanceToCM=0.71971 + length=0.55829, kind="vonKarman", position=0.71971 + 0.558291 ) FinSet = test_rocket.addTrapezoidalFins( - 4, span=0.100, rootChord=0.120, tipChord=0.040, distanceToCM=-1.04956 + 4, span=0.100, rootChord=0.120, tipChord=0.040, position=-1.04956 ) Tail = test_rocket.addTail( - topRadius=0.0635, bottomRadius=0.0435, length=0.060, distanceToCM=-1.194656 + topRadius=0.0635, bottomRadius=0.0435, length=0.060, position=-1.194656 ) def drogueTrigger(p, y): @@ -165,6 +168,7 @@ def test_initial_solution(mock_show): test_motor = SolidMotor( thrustSource="data/motors/Cesaroni_M1670.eng", burnOut=3.9, + grainsCenterOfMassPosition=-0.85704, grainNumber=5, grainSeparation=5 / 1000, grainDensity=1815, @@ -174,30 +178,31 @@ def test_initial_solution(mock_show): nozzleRadius=33 / 1000, throatRadius=11 / 1000, interpolationMethod="linear", + nozzlePosition=-1.255, + coordinateSystemOrientation="nozzleToCombustionChamber", ) test_rocket = Rocket( - motor=test_motor, radius=127 / 2000, mass=19.197 - 2.956, inertiaI=6.60, inertiaZ=0.0351, - distanceRocketNozzle=-1.255, - distanceRocketPropellant=-0.85704, powerOffDrag="data/calisto/powerOffDragCurve.csv", powerOnDrag="data/calisto/powerOnDragCurve.csv", ) test_rocket.setRailButtons([0.2, -0.5]) + test_rocket.addMotor(test_motor, position=-1.255) + NoseCone = test_rocket.addNose( - length=0.55829, kind="vonKarman", distanceToCM=0.71971 + length=0.55829, kind="vonKarman", position=0.71971 + 0.558291 ) FinSet = test_rocket.addTrapezoidalFins( - 4, span=0.100, rootChord=0.120, tipChord=0.040, distanceToCM=-1.04956 + 4, span=0.100, rootChord=0.120, tipChord=0.040, position=-1.04956 ) Tail = test_rocket.addTail( - topRadius=0.0635, bottomRadius=0.0435, length=0.060, distanceToCM=-1.194656 + topRadius=0.0635, bottomRadius=0.0435, length=0.060, position=-1.194656 ) def drogueTrigger(p, y): @@ -289,6 +294,7 @@ def test_stability_static_margins(wind_u, wind_v, static_margin, max_time): DummyMotor = SolidMotor( thrustSource=1e-300, burnOut=1e-10, + grainsCenterOfMassPosition=-0.85704, grainNumber=5, grainSeparation=5 / 1000, grainDensity=1e-300, @@ -297,21 +303,21 @@ def test_stability_static_margins(wind_u, wind_v, static_margin, max_time): grainInitialHeight=120 / 1000, nozzleRadius=33 / 1000, throatRadius=11 / 1000, + nozzlePosition=-1.255, ) # Create a rocket with ZERO drag and HUGE mass to keep the rocket's speed constant DummyRocket = Rocket( - motor=DummyMotor, radius=127 / 2000, mass=1e16, inertiaI=1, inertiaZ=0.0351, - distanceRocketNozzle=-1.255, - distanceRocketPropellant=-0.85704, powerOffDrag=0, powerOnDrag=0, ) DummyRocket.setRailButtons([0.2, -0.5]) + DummyRocket.addMotor(DummyMotor, position=-1.255) + setup_rocket_with_given_static_margin(DummyRocket, static_margin) # Simulate @@ -363,6 +369,7 @@ def test_rolling_flight(mock_show): test_motor = SolidMotor( thrustSource="data/motors/Cesaroni_M1670.eng", burnOut=3.9, + grainsCenterOfMassPosition=-0.85704, grainNumber=5, grainSeparation=5 / 1000, grainDensity=1815, @@ -372,35 +379,31 @@ def test_rolling_flight(mock_show): nozzleRadius=33 / 1000, throatRadius=11 / 1000, interpolationMethod="linear", + nozzlePosition=-1.255, + coordinateSystemOrientation="nozzleToCombustionChamber", ) test_rocket = Rocket( - motor=test_motor, radius=127 / 2000, mass=19.197 - 2.956, inertiaI=6.60, inertiaZ=0.0351, - distanceRocketNozzle=-1.255, - distanceRocketPropellant=-0.85704, powerOffDrag="data/calisto/powerOffDragCurve.csv", powerOnDrag="data/calisto/powerOnDragCurve.csv", ) test_rocket.setRailButtons([0.2, -0.5]) + test_rocket.addMotor(test_motor, position=-1.255) + NoseCone = test_rocket.addNose( - length=0.55829, kind="vonKarman", distanceToCM=0.71971 + length=0.55829, kind="vonKarman", position=0.71971 + 0.558291 ) FinSet = test_rocket.addTrapezoidalFins( - 4, - span=0.100, - rootChord=0.120, - tipChord=0.040, - distanceToCM=-1.04956, - cantAngle=0.5, + 4, span=0.100, rootChord=0.120, tipChord=0.040, position=-1.04956, cantAngle=0.5 ) Tail = test_rocket.addTail( - topRadius=0.0635, bottomRadius=0.0435, length=0.060, distanceToCM=-1.194656 + topRadius=0.0635, bottomRadius=0.0435, length=0.060, position=-1.194656 ) def drogueTrigger(p, y): @@ -452,8 +455,9 @@ def test_export_data(): ) test_motor = SolidMotor( - thrustSource=1000, + thrustSource="data/motors/Cesaroni_M1670.eng", burnOut=3.9, + grainsCenterOfMassPosition=-0.85704, grainNumber=5, grainSeparation=5 / 1000, grainDensity=1815, @@ -463,27 +467,28 @@ def test_export_data(): nozzleRadius=33 / 1000, throatRadius=11 / 1000, interpolationMethod="linear", + nozzlePosition=-1.255, + coordinateSystemOrientation="nozzleToCombustionChamber", ) test_rocket = Rocket( - motor=test_motor, radius=127 / 2000, mass=19.197 - 2.956, inertiaI=6.60, inertiaZ=0.0351, - distanceRocketNozzle=-1.255, - distanceRocketPropellant=-0.85704, powerOffDrag=0.5, powerOnDrag=0.5, ) test_rocket.setRailButtons([0.2, -0.5]) + test_rocket.addMotor(test_motor, position=-1.255) + NoseCone = test_rocket.addNose( - length=0.55829, kind="vonKarman", distanceToCM=0.71971 + length=0.55829, kind="vonKarman", position=0.71971 + 0.558291 ) FinSet = test_rocket.addTrapezoidalFins( - 4, span=0.100, rootChord=0.120, tipChord=0.040, distanceToCM=-1.04956 + 4, span=0.100, rootChord=0.120, tipChord=0.040, position=-1.04956 ) test_flight = Flight( @@ -544,8 +549,9 @@ def test_export_KML(): ) test_motor = SolidMotor( - thrustSource=1000, - burnOut=1, + thrustSource="data/motors/Cesaroni_M1670.eng", + burnOut=3.9, + grainsCenterOfMassPosition=-0.85704, grainNumber=5, grainSeparation=5 / 1000, grainDensity=1815, @@ -555,27 +561,28 @@ def test_export_KML(): nozzleRadius=33 / 1000, throatRadius=11 / 1000, interpolationMethod="linear", + nozzlePosition=-1.255, + coordinateSystemOrientation="nozzleToCombustionChamber", ) test_rocket = Rocket( - motor=test_motor, radius=127 / 2000, mass=19.197 - 2.956, inertiaI=6.60, inertiaZ=0.0351, - distanceRocketNozzle=-1.255, - distanceRocketPropellant=-0.85704, powerOffDrag=0.5, powerOnDrag=0.5, ) test_rocket.setRailButtons([0.2, -0.5]) + test_rocket.addMotor(test_motor, position=-1.255) + NoseCone = test_rocket.addNose( - length=0.55829, kind="vonKarman", distanceToCM=0.71971 + length=0.55829, kind="vonKarman", position=0.71971 + 0.558291 ) FinSet = test_rocket.addTrapezoidalFins( - 4, span=0.100, rootChord=0.120, tipChord=0.040, distanceToCM=-1.04956 + 4, span=0.100, rootChord=0.120, tipChord=0.040, position=-1.04956 ) test_flight = Flight( @@ -620,38 +627,43 @@ def test_latlon_conversions(mock_show): ) test_motor = SolidMotor( - thrustSource=1545.218, + thrustSource="data/motors/Cesaroni_M1670.eng", burnOut=3.9, + grainsCenterOfMassPosition=-0.85704, grainNumber=5, grainSeparation=5 / 1000, grainDensity=1815, grainOuterRadius=33 / 1000, grainInitialInnerRadius=15 / 1000, grainInitialHeight=120 / 1000, + nozzleRadius=33 / 1000, + throatRadius=11 / 1000, + interpolationMethod="linear", + nozzlePosition=-1.255, + coordinateSystemOrientation="nozzleToCombustionChamber", ) test_rocket = Rocket( - motor=test_motor, radius=127 / 2000, mass=19.197 - 2.956, inertiaI=6.60, inertiaZ=0.0351, - distanceRocketNozzle=-1.255, - distanceRocketPropellant=-0.85704, powerOffDrag=0.5, powerOnDrag=0.5, ) test_rocket.setRailButtons([0.2, -0.5]) + test_rocket.addMotor(test_motor, position=-1.255) + NoseCone = test_rocket.addNose( - length=0.55829, kind="vonKarman", distanceToCM=0.71971 + length=0.55829, kind="vonKarman", position=0.71971 + 0.558291 ) FinSet = test_rocket.addTrapezoidalFins( - 4, span=0.100, rootChord=0.120, tipChord=0.040, distanceToCM=-1.04956 + 4, span=0.100, rootChord=0.120, tipChord=0.040, position=-1.04956 ) Tail = test_rocket.addTail( - topRadius=0.0635, bottomRadius=0.0435, length=0.060, distanceToCM=-1.194656 + topRadius=0.0635, bottomRadius=0.0435, length=0.060, position=-1.194656 ) def drogueTrigger(p, y): @@ -700,38 +712,43 @@ def mainTrigger(p, y): def test_latlon_conversions2(mock_show): "additional tests to capture incorrect behaviors during lat/lon conversions" test_motor = SolidMotor( - thrustSource=1000, - burnOut=3, + thrustSource="data/motors/Cesaroni_M1670.eng", + burnOut=3.9, + grainsCenterOfMassPosition=-0.85704, grainNumber=5, grainSeparation=5 / 1000, grainDensity=1815, grainOuterRadius=33 / 1000, grainInitialInnerRadius=15 / 1000, grainInitialHeight=120 / 1000, + nozzleRadius=33 / 1000, + throatRadius=11 / 1000, + interpolationMethod="linear", + nozzlePosition=-1.255, + coordinateSystemOrientation="nozzleToCombustionChamber", ) test_rocket = Rocket( - motor=test_motor, radius=127 / 2000, mass=19.197 - 2.956, inertiaI=6.60, inertiaZ=0.0351, - distanceRocketNozzle=-1.255, - distanceRocketPropellant=-0.85704, powerOffDrag=0.5, powerOnDrag=0.5, ) test_rocket.setRailButtons([0.2, -0.5]) + test_rocket.addMotor(test_motor, position=-1.255) + NoseCone = test_rocket.addNose( - length=0.55829, kind="vonKarman", distanceToCM=0.71971 + length=0.55829, kind="vonKarman", position=0.71971 + 0.558291 ) FinSet = test_rocket.addTrapezoidalFins( - 4, span=0.100, rootChord=0.120, tipChord=0.040, distanceToCM=-1.04956 + 4, span=0.100, rootChord=0.120, tipChord=0.040, position=-1.04956 ) Tail = test_rocket.addTail( - topRadius=0.0635, bottomRadius=0.0435, length=0.060, distanceToCM=-1.194656 + topRadius=0.0635, bottomRadius=0.0435, length=0.060, position=-1.194656 ) test_env = Environment( From 6c4a306a596b98b96ab1a7772097826b77a3197d Mon Sep 17 00:00:00 2001 From: MateusStano Date: Sat, 19 Nov 2022 17:18:10 -0300 Subject: [PATCH 6/8] tst: fixed acceptance tests --- tests/acceptance/test_bella_lui_rocket.py | 13 +++++++------ tests/acceptance/test_ndrt_2020_rocket.py | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/acceptance/test_bella_lui_rocket.py b/tests/acceptance/test_bella_lui_rocket.py index 8ca5d9034..457ab5cc9 100644 --- a/tests/acceptance/test_bella_lui_rocket.py +++ b/tests/acceptance/test_bella_lui_rocket.py @@ -74,6 +74,7 @@ def test_bella_lui_rocket_data_asserts_acceptance(): K828FJ = SolidMotor( thrustSource="tests/fixtures/acceptance/EPFL_Bella_Lui/bella_lui_motor_AeroTech_K828FJ.eng", burnOut=parameters.get("burnOut")[0], + grainsCenterOfMassPosition=parameters.get("distanceRocketPropellant")[0], grainNumber=3, grainSeparation=parameters.get("grainSeparation")[0], grainDensity=parameters.get("grainDensity")[0], @@ -83,38 +84,38 @@ def test_bella_lui_rocket_data_asserts_acceptance(): nozzleRadius=parameters.get("nozzleRadius")[0], throatRadius=parameters.get("throatRadius")[0], interpolationMethod="linear", + nozzlePosition=parameters.get("distanceRocketNozzle")[0], ) # Rocket information BellaLui = Rocket( - motor=K828FJ, radius=parameters.get("radius")[0], mass=parameters.get("rocketMass")[0], inertiaI=parameters.get("inertiaI")[0], inertiaZ=parameters.get("inertiaZ")[0], - distanceRocketNozzle=parameters.get("distanceRocketNozzle")[0], - distanceRocketPropellant=parameters.get("distanceRocketPropellant")[0], powerOffDrag=0.43, powerOnDrag=0.43, ) BellaLui.setRailButtons([0.1, -0.5]) + BellaLui.addMotor(K828FJ, parameters.get("distanceRocketNozzle")[0]) NoseCone = BellaLui.addNose( length=parameters.get("noseLength")[0], kind="tangent", - distanceToCM=parameters.get("noseDistanceToCM")[0], + position=parameters.get("noseDistanceToCM")[0] + + parameters.get("noseLength")[0], ) FinSet = BellaLui.addTrapezoidalFins( 3, span=parameters.get("finSpan")[0], rootChord=parameters.get("finRootChord")[0], tipChord=parameters.get("finTipChord")[0], - distanceToCM=parameters.get("finDistanceToCM")[0], + position=parameters.get("finDistanceToCM")[0], ) Tail = BellaLui.addTail( topRadius=parameters.get("tailTopRadius")[0], bottomRadius=parameters.get("tailBottomRadius")[0], length=parameters.get("tailLength")[0], - distanceToCM=parameters.get("tailDistanceToCM")[0], + position=parameters.get("tailDistanceToCM")[0], ) # Parachute set-up diff --git a/tests/acceptance/test_ndrt_2020_rocket.py b/tests/acceptance/test_ndrt_2020_rocket.py index 3df866e11..b790d729c 100644 --- a/tests/acceptance/test_ndrt_2020_rocket.py +++ b/tests/acceptance/test_ndrt_2020_rocket.py @@ -86,6 +86,7 @@ def test_ndrt_2020_rocket_data_asserts_acceptance(): L1395 = SolidMotor( thrustSource="tests/fixtures/acceptance/NDRT_2020/ndrt_2020_motor_Cesaroni_4895L1395-P.eng", burnOut=parameters.get("burnOut")[0], + grainsCenterOfMassPosition=parameters.get("distanceRocketPropellant")[0], grainNumber=5, grainSeparation=parameters.get("grainSeparation")[0], grainDensity=parameters.get("grainDensity")[0], @@ -95,38 +96,38 @@ def test_ndrt_2020_rocket_data_asserts_acceptance(): nozzleRadius=parameters.get("nozzleRadius")[0], throatRadius=parameters.get("throatRadius")[0], interpolationMethod="linear", + nozzlePosition=parameters.get("distanceRocketNozzle")[0], ) # Rocket information NDRT2020 = Rocket( - motor=L1395, radius=parameters.get("radius")[0], mass=parameters.get("rocketMass")[0], inertiaI=parameters.get("inertiaI")[0], inertiaZ=parameters.get("inertiaZ")[0], - distanceRocketNozzle=parameters.get("distanceRocketNozzle")[0], - distanceRocketPropellant=parameters.get("distanceRocketPropellant")[0], powerOffDrag=parameters.get("dragCoefficient")[0], powerOnDrag=parameters.get("dragCoefficient")[0], ) NDRT2020.setRailButtons([0.2, -0.5], 45) + NDRT2020.addMotor(L1395, parameters.get("distanceRocketNozzle")[0]) NoseCone = NDRT2020.addNose( length=parameters.get("noseLength")[0], kind="tangent", - distanceToCM=parameters.get("noseDistanceToCM")[0], + position=parameters.get("noseDistanceToCM")[0] + + parameters.get("noseLength")[0], ) FinSet = NDRT2020.addTrapezoidalFins( 3, span=parameters.get("finSpan")[0], rootChord=parameters.get("finRootChord")[0], tipChord=parameters.get("finTipChord")[0], - distanceToCM=parameters.get("finDistanceToCM")[0], + position=parameters.get("finDistanceToCM")[0], ) Transition = NDRT2020.addTail( topRadius=parameters.get("transitionTopRadius")[0], bottomRadius=parameters.get("transitionBottomRadius")[0], length=parameters.get("transitionLength")[0], - distanceToCM=parameters.get("transitiondistanceToCM")[0], + position=parameters.get("transitiondistanceToCM")[0], ) # Parachute set-up From 06344e02dd8c97467efbd23f8b4feeffe8006749 Mon Sep 17 00:00:00 2001 From: Giovani Hidalgo Ceotto Date: Mon, 28 Nov 2022 23:13:11 -0300 Subject: [PATCH 7/8] TST: add nozzlePosition argument value for consistency --- tests/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/conftest.py b/tests/conftest.py index 298425648..2983734d4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -77,6 +77,7 @@ def dimensionless_solid_motor(kg, m): throatRadius=11 / 1000 * m, interpolationMethod="linear", grainsCenterOfMassPosition=0.39796 * m, + nozzlePosition=0*m, coordinateSystemOrientation="nozzleToCombustionChamber", ) return example_motor From 94cd379339198b16772cbbdd059a940b319e6e86 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Tue, 29 Nov 2022 02:13:47 +0000 Subject: [PATCH 8/8] Fix code style issues with Black --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 2983734d4..b53ee8475 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -77,7 +77,7 @@ def dimensionless_solid_motor(kg, m): throatRadius=11 / 1000 * m, interpolationMethod="linear", grainsCenterOfMassPosition=0.39796 * m, - nozzlePosition=0*m, + nozzlePosition=0 * m, coordinateSystemOrientation="nozzleToCombustionChamber", ) return example_motor