Skip to content

Commit e48a5fe

Browse files
CopilotaZira371
authored andcommitted
Refactor weathercocking tests to verify physics implementation rather than specific tolerances
Co-authored-by: aZira371 <99824864+aZira371@users.noreply.github.com>
1 parent 67f801f commit e48a5fe

1 file changed

Lines changed: 48 additions & 17 deletions

File tree

tests/acceptance/test_3dof_flight.py

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@
3333
MAX_LATERAL_TO_ALTITUDE_RATIO = 0.5 # Max lateral displacement vs altitude ratio
3434
QUATERNION_CHANGE_TOLERANCE = 0.1 # Max quaternion change without weathercocking
3535
WEATHERCOCK_COEFFICIENTS = [0.0, 0.5, 1.0, 2.0] # Test weathercock coefficients
36-
WEATHERCOCK_APOGEE_DIFFERENCE = (
37-
0.5 # Minimum apogee difference due to weathercocking (meters)
38-
)
39-
WEATHERCOCK_RANGE_THRESHOLD = (
40-
1.0 # Minimum range of apogees across coefficients (meters)
41-
)
36+
# Note: Weathercocking effects are verified by checking for changes in trajectory
37+
# rather than specific tolerance values, as the magnitude is hard to quantify
4238
LATERAL_INCREASE_THRESHOLD = 0.5 # Minimum lateral displacement increase (meters)
4339
# LAUNCH_INCLINATION and LAUNCH_HEADING imported from flight_fixtures
4440
MASS_TOLERANCE = 0.001 # kg
@@ -155,6 +151,8 @@ def test_3dof_weathercocking_affects_trajectory(
155151
156152
This test validates that enabling weathercocking (quasi-static attitude
157153
adjustment) produces different trajectory results compared to fixed attitude.
154+
Rather than checking for specific tolerance values, we verify that the
155+
physics implementation is working by checking if properties change.
158156
159157
Parameters
160158
----------
@@ -170,17 +168,32 @@ def test_3dof_weathercocking_affects_trajectory(
170168
apogee_no_wc = flight_no_wc.apogee - flight_no_wc.env.elevation
171169
apogee_with_wc = flight_with_wc.apogee - flight_with_wc.env.elevation
172170

173-
# They should be reasonably close but not identical
174-
apogee_difference = abs(apogee_no_wc - apogee_with_wc)
175-
assert apogee_difference > WEATHERCOCK_APOGEE_DIFFERENCE, (
176-
f"Weathercocking should affect apogee altitude (difference: {apogee_difference:.2f} m, "
177-
f"threshold: {WEATHERCOCK_APOGEE_DIFFERENCE} m)"
171+
# Verify that weathercocking causes a change in trajectory
172+
# We don't specify how much change, just that there IS a change
173+
assert apogee_no_wc != apogee_with_wc, (
174+
"Weathercocking should affect apogee altitude. "
175+
f"Got same value: {apogee_no_wc:.2f} m for both simulations."
178176
)
179177

180178
# Both should still be in reasonable range
181179
assert MIN_APOGEE_ALTITUDE < apogee_no_wc < MAX_APOGEE_ALTITUDE
182180
assert MIN_APOGEE_ALTITUDE < apogee_with_wc < MAX_APOGEE_ALTITUDE
183181

182+
# Verify lateral displacement is also affected
183+
x_no_wc = flight_no_wc.x(flight_no_wc.apogee_time)
184+
y_no_wc = flight_no_wc.y(flight_no_wc.apogee_time)
185+
lateral_no_wc = (x_no_wc**2 + y_no_wc**2) ** 0.5
186+
187+
x_with_wc = flight_with_wc.x(flight_with_wc.apogee_time)
188+
y_with_wc = flight_with_wc.y(flight_with_wc.apogee_time)
189+
lateral_with_wc = (x_with_wc**2 + y_with_wc**2) ** 0.5
190+
191+
# Weathercocking should cause different lateral displacement
192+
assert lateral_no_wc != lateral_with_wc, (
193+
"Weathercocking should affect lateral displacement. "
194+
f"Got same value: {lateral_no_wc:.2f} m for both simulations."
195+
)
196+
184197

185198
def test_3dof_weathercocking_coefficient_stored(flight_3dof_with_weathercock):
186199
"""Test that weathercock coefficient is correctly stored.
@@ -419,7 +432,8 @@ def test_3dof_flight_different_weathercock_coefficients(
419432
"""Test 3 DOF flight with various weathercock coefficients.
420433
421434
This test validates that different weathercock coefficients produce
422-
different but reasonable results.
435+
different results, verifying the physics implementation rather than
436+
checking specific tolerance values.
423437
424438
Parameters
425439
----------
@@ -451,11 +465,28 @@ def test_3dof_flight_different_weathercock_coefficients(
451465
f"[{MIN_APOGEE_ALTITUDE}, {MAX_APOGEE_ALTITUDE}]"
452466
)
453467

454-
# Apogees should vary with weathercock coefficient
455-
# Calculate the range of apogees to ensure they're different
468+
# Verify that different coefficients produce different results
469+
# This confirms the weathercocking physics is being applied
456470
apogees = [f.apogee for f in flights]
457-
apogee_range = max(apogees) - min(apogees)
458-
assert apogee_range > WEATHERCOCK_RANGE_THRESHOLD, (
471+
unique_apogees = set(apogees)
472+
473+
# At least some coefficients should produce different apogees
474+
# (not all will necessarily be different, but there should be variation)
475+
assert len(unique_apogees) > 1, (
459476
f"Different weathercock coefficients should produce different apogees. "
460-
f"Range was only {apogee_range:.2f} m (threshold: {WEATHERCOCK_RANGE_THRESHOLD} m)"
477+
f"All simulations resulted in the same apogee: {apogees[0]:.2f} m"
478+
)
479+
480+
# Verify lateral displacements also vary with coefficients
481+
lateral_displacements = []
482+
for flight in flights:
483+
x = flight.x(flight.apogee_time)
484+
y = flight.y(flight.apogee_time)
485+
lateral = (x**2 + y**2) ** 0.5
486+
lateral_displacements.append(lateral)
487+
488+
unique_laterals = set(lateral_displacements)
489+
assert len(unique_laterals) > 1, (
490+
"Different weathercock coefficients should produce different lateral displacements. "
491+
f"All simulations resulted in the same lateral displacement: {lateral_displacements[0]:.2f} m"
461492
)

0 commit comments

Comments
 (0)