Skip to content

Commit c098f93

Browse files
CopilotaZira371
andcommitted
Fix critical rocket radius and floating-point comparison issues
Co-authored-by: aZira371 <[email protected]>
1 parent ec63322 commit c098f93

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

tests/acceptance/test_3dof_flight.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,14 @@ def test_3dof_flight_different_weathercock_coefficients(
466466
# Verify that different coefficients produce different results
467467
# This confirms the weathercocking physics is being applied
468468
apogees = [f.apogee for f in flights]
469-
unique_apogees = set(apogees)
470469

471-
# At least some coefficients should produce different apogees
472-
# (not all will necessarily be different, but there should be variation)
473-
assert len(unique_apogees) > 1, (
470+
# Check if there's meaningful variation in apogees (use range instead of set
471+
# to avoid floating-point precision issues)
472+
apogee_range = max(apogees) - min(apogees)
473+
apogee_tolerance = 0.01 # meters - meaningful physical difference
474+
assert apogee_range > apogee_tolerance, (
474475
f"Different weathercock coefficients should produce different apogees. "
475-
f"All simulations resulted in the same apogee: {apogees[0]:.2f} m"
476+
f"Range of apogees: {apogee_range:.4f} m (threshold: {apogee_tolerance} m)"
476477
)
477478

478479
# Verify lateral displacements also vary with coefficients
@@ -483,8 +484,10 @@ def test_3dof_flight_different_weathercock_coefficients(
483484
lateral = (x**2 + y**2) ** 0.5
484485
lateral_displacements.append(lateral)
485486

486-
unique_laterals = set(lateral_displacements)
487-
assert len(unique_laterals) > 1, (
487+
# Check if there's meaningful variation in lateral displacements
488+
lateral_tolerance = 0.001 # meters - meaningful physical difference
489+
lateral_range = max(lateral_displacements) - min(lateral_displacements)
490+
assert lateral_range > lateral_tolerance, (
488491
"Different weathercock coefficients should produce different lateral displacements. "
489-
f"All simulations resulted in the same lateral displacement: {lateral_displacements[0]:.2f} m"
492+
f"Range of lateral displacements: {lateral_range:.4f} m (threshold: {lateral_tolerance} m)"
490493
)

tests/fixtures/flight/flight_fixtures.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def acceptance_point_mass_rocket(acceptance_point_mass_motor):
419419
"""Create a realistic point mass rocket for acceptance testing.
420420
421421
Based on Bella Lui rocket parameters:
422-
- Radius: 156 mm (diameter 312 mm)
422+
- Radius: 78 mm (156 mm diameter)
423423
- Dry mass (without motor): ~17.227 kg
424424
- Power-off drag coefficient: ~0.43
425425
- Power-on drag coefficient: ~0.43
@@ -435,7 +435,7 @@ def acceptance_point_mass_rocket(acceptance_point_mass_motor):
435435
A point mass rocket with Bella Lui parameters.
436436
"""
437437
rocket = PointMassRocket(
438-
radius=0.156, # 156 mm radius
438+
radius=0.078, # 78 mm radius (156 mm diameter)
439439
mass=17.227, # kg without motor
440440
center_of_mass_without_motor=0,
441441
power_off_drag=0.43,

0 commit comments

Comments
 (0)