File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -585,14 +585,17 @@ function find_center_of_pressure(
585585 body_aero:: BodyAerodynamics ,
586586 force_array,
587587 moment_array,
588- reference_point
588+ reference_point;
589+ force_tol:: Float64 = 1e-12
589590)
590591 F = force_array
591592 M0 = moment_array
592593 r0 = reference_point
593594 F_norm_sq = dot3 (F, F)
594- F_norm_sq == 0 && throw (ArgumentError (
595- " Force vector must not be zero." ))
595+ # Treat near-zero forces as "CoP undefined"
596+ if ! (isfinite (F_norm_sq)) || F_norm_sq ≤ force_tol^ 2
597+ return nothing
598+ end
596599
597600 wv = body_aero. work_vectors
598601 r0_moment = wv[1 ]
@@ -659,6 +662,12 @@ function compute_panel_center_of_pressures(
659662 span_dir = panel. y_airf
660663 c = panel. chord
661664
665+ # Guard against non-finite forces and near-zero forces
666+ if ! all (isfinite, F) || dot3 (F, F) ≤ 1e-24
667+ panel_cp_locations[i] = MVec3 (ac)
668+ continue
669+ end
670+
662671 # cross(r, F) where r = ac - reference_point
663672 rx = ac[1 ]- reference_point[1 ]
664673 ry = ac[2 ]- reference_point[2 ]
You can’t perform that action at this time.
0 commit comments