FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
0123 — Duplicated helpers, flag constants and speed floors in the panel laws
ID 0123
Class ARCHITECTURE
Severity 1
Status ready

Models: — (annotated on the fhsim_environment library group)

Found: 2026-10-20, hydrodynamics overview section 7 (doc/hydrodynamics-overview.md in fhsim_workspace), feature m2-hydro-doc-gaps

Evidence

Logic copied between the panel laws in include/fhsim_environment/hydrodynamics/:

  • Lift-direction and drag/lift projection code: TwineFriction.h:121-141 and TwineCrossFlow.h:288-310.
  • Two ZeroLoad helpers: PanelLoadLaw.h:36-45 (in panel_load_law_detail) and TwineCrossFlow.h:181-196.
  • Flag constants re-declared per law: KF2012Common.h:62-68, ScreenMF2022.h:113-115, TwineCrossFlow.h:106-109. Bit 2 (speed below epsilon) has no constant in PanelLoadTypes.h, although its comment lists it (PanelLoadTypes.h:102-105).
  • Speed floors differ: 1e-10 (KF2012Common, TwineCrossFlow, TwineFriction) and 1e-9 (ScreenMF2022.h:111, kSpeedEpsilon).

Effect

None today. Copies can drift (ENV-0121 is an example: one polynomial, two bounds). ADR 0002 asks for one copy of each law.

Possible fix

Step 1, bit for bit: one ZeroLoad, one set of flag constants (including bit 2) in PanelLoadTypes.h, one lift-direction helper in PanelFormulas.h. Step 2, only with the owner's agreement: one speed floor. Unifying 1e-9 and 1e-10 changes results only for |U| below 1e-9 m/s, which no shipped case reaches; check with tools/compare_results.py.

Test that would prove it

The existing hydrodynamics_*_Test files and every net regression, byte compared before and after step 1.

Risk

Low for step 1 (templated on the scalar type, so keep the AD-safe forms). Step 2 is a policy choice.