1414
1515Note: These tests are designed for the 3 DOF feature implemented in issue #882.
1616They will be skipped until PointMassMotor and PointMassRocket are available.
17+ All fixtures are defined in tests/fixtures/flight/flight_fixtures.py.
1718"""
1819
1920import numpy as np
2021import pytest
2122
22- from rocketpy import Environment , Flight
23+ from rocketpy import Flight
2324
2425# Try to import 3DOF-specific classes, skip tests if not available
2526try :
2930 THREEDOF_AVAILABLE = True
3031except ImportError :
3132 THREEDOF_AVAILABLE = False
32- PointMassMotor = None
33- PointMassRocket = None
3433
3534# Skip all tests in this module if 3DOF is not available
3635pytestmark = pytest .mark .skipif (
4039)
4140
4241
43- @pytest .fixture
44- def acceptance_environment ():
45- """Create a realistic environment for acceptance testing.
46-
47- Returns
48- -------
49- rocketpy.Environment
50- An environment with realistic atmospheric conditions.
51- """
52- env = Environment (
53- gravity = 9.81 ,
54- latitude = 32.99 ,
55- longitude = - 106.975 ,
56- elevation = 1400 ,
57- )
58- # Use standard atmosphere
59- env .set_atmospheric_model (type = "standard_atmosphere" )
60- env .max_expected_height = 3000
61- return env
62-
63-
64- @pytest .fixture
65- def acceptance_point_mass_motor ():
66- """Create a realistic point mass motor for acceptance testing.
67-
68- Returns
69- -------
70- rocketpy.PointMassMotor
71- A point mass motor with realistic thrust and mass properties.
72- """
73- return PointMassMotor (
74- thrust_source = 1500 , # 1500 N constant thrust
75- dry_mass = 2.5 , # 2.5 kg dry mass
76- propellant_initial_mass = 3.0 , # 3.0 kg propellant
77- burn_time = 3.5 , # 3.5 s burn time
78- )
79-
80-
81- @pytest .fixture
82- def acceptance_point_mass_rocket (acceptance_point_mass_motor ):
83- """Create a realistic point mass rocket for acceptance testing.
84-
85- Parameters
86- ----------
87- acceptance_point_mass_motor : rocketpy.PointMassMotor
88- The motor to be added to the rocket.
89-
90- Returns
91- -------
92- rocketpy.PointMassRocket
93- A point mass rocket with realistic dimensions and properties.
94- """
95- rocket = PointMassRocket (
96- radius = 0.0635 , # 127 mm diameter (5 inches)
97- mass = 5.0 , # 5 kg without motor
98- center_of_mass_without_motor = 0.5 ,
99- power_off_drag = 0.45 ,
100- power_on_drag = 0.50 ,
101- )
102- rocket .add_motor (acceptance_point_mass_motor , position = 0 )
103- return rocket
104-
105-
106- @pytest .fixture
107- def flight_3dof_no_weathercock (acceptance_environment , acceptance_point_mass_rocket ):
108- """Create a 3 DOF flight without weathercocking.
109-
110- Returns
111- -------
112- rocketpy.Flight
113- A 3 DOF flight simulation with weathercock_coeff=0.0.
114- """
115- return Flight (
116- rocket = acceptance_point_mass_rocket ,
117- environment = acceptance_environment ,
118- rail_length = 5.0 ,
119- inclination = 85 , # 85 degrees from horizontal (5 degrees from vertical)
120- heading = 0 ,
121- simulation_mode = "3 DOF" ,
122- weathercock_coeff = 0.0 ,
123- )
124-
125-
126- @pytest .fixture
127- def flight_3dof_with_weathercock (acceptance_environment , acceptance_point_mass_rocket ):
128- """Create a 3 DOF flight with weathercocking enabled.
129-
130- Returns
131- -------
132- rocketpy.Flight
133- A 3 DOF flight simulation with weathercock_coeff=1.0.
134- """
135- return Flight (
136- rocket = acceptance_point_mass_rocket ,
137- environment = acceptance_environment ,
138- rail_length = 5.0 ,
139- inclination = 85 ,
140- heading = 0 ,
141- simulation_mode = "3 DOF" ,
142- weathercock_coeff = 1.0 ,
143- )
144-
145-
14642def test_3dof_flight_basic_trajectory (flight_3dof_no_weathercock ):
14743 """Test that 3 DOF flight produces reasonable trajectory.
14844
@@ -452,23 +348,23 @@ def test_3dof_flight_thrust_profile(flight_3dof_no_weathercock):
452348
453349
454350def test_3dof_flight_reproducibility (
455- acceptance_environment , acceptance_point_mass_rocket
351+ example_spaceport_env , acceptance_point_mass_rocket
456352):
457353 """Test that 3 DOF flights are reproducible.
458354
459355 Running the same simulation multiple times should produce identical results.
460356
461357 Parameters
462358 ----------
463- acceptance_environment : rocketpy.Environment
464- Environment fixture for testing .
359+ example_spaceport_env : rocketpy.Environment
360+ Environment fixture for Spaceport America .
465361 acceptance_point_mass_rocket : rocketpy.PointMassRocket
466362 Rocket fixture for testing.
467363 """
468364 # Run simulation twice with same parameters
469365 flight1 = Flight (
470366 rocket = acceptance_point_mass_rocket ,
471- environment = acceptance_environment ,
367+ environment = example_spaceport_env ,
472368 rail_length = 5.0 ,
473369 inclination = 85 ,
474370 heading = 0 ,
@@ -478,7 +374,7 @@ def test_3dof_flight_reproducibility(
478374
479375 flight2 = Flight (
480376 rocket = acceptance_point_mass_rocket ,
481- environment = acceptance_environment ,
377+ environment = example_spaceport_env ,
482378 rail_length = 5.0 ,
483379 inclination = 85 ,
484380 heading = 0 ,
@@ -499,7 +395,7 @@ def test_3dof_flight_reproducibility(
499395
500396
501397def test_3dof_flight_different_weathercock_coefficients (
502- acceptance_environment , acceptance_point_mass_rocket
398+ example_spaceport_env , acceptance_point_mass_rocket
503399):
504400 """Test 3 DOF flight with various weathercock coefficients.
505401
@@ -508,8 +404,8 @@ def test_3dof_flight_different_weathercock_coefficients(
508404
509405 Parameters
510406 ----------
511- acceptance_environment : rocketpy.Environment
512- Environment fixture for testing .
407+ example_spaceport_env : rocketpy.Environment
408+ Environment fixture for Spaceport America .
513409 acceptance_point_mass_rocket : rocketpy.PointMassRocket
514410 Rocket fixture for testing.
515411 """
@@ -519,7 +415,7 @@ def test_3dof_flight_different_weathercock_coefficients(
519415 for coeff in coefficients :
520416 flight = Flight (
521417 rocket = acceptance_point_mass_rocket ,
522- environment = acceptance_environment ,
418+ environment = example_spaceport_env ,
523419 rail_length = 5.0 ,
524420 inclination = 85 ,
525421 heading = 0 ,
0 commit comments