research: VIV driver — fail closed on any non-finite recorded output

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-10-30 15:39:19 +00:00
co-authored by Claude Opus 5.5
parent a9ca6a9a16
commit fb507aa1f2
3 changed files with 18 additions and 4 deletions
+5 -4
View File
@@ -96,12 +96,13 @@ def main():
d = sim.moving_diagnostics()[0] d = sim.moving_diagnostics()[0]
f_obs = sim.read_force(body)[1] f_obs = sim.read_force(body)[1]
f_rhs = float(d[1] + d[3]) # CME + Wen (y) f_rhs = float(d[1] + d[3]) # CME + Wen (y)
if not math.isfinite(f_rhs): row = (n, y1, v1, f_rhs, float(d[1]), float(d[3]), float(f_obs),
status = "fail_nonfinite_force" float(d[7] - d[10]), float(d[13]))
if not viv.finite(row): # every recorded output, not only the RHS
status = "fail_nonfinite_output"
break break
s.y, s.v, f_last = y1, v1, f_rhs # commit only after a successful step s.y, s.v, f_last = y1, v1, f_rhs # commit only after a successful step
rows.append((n, s.y, s.v, f_rhs, float(d[1]), float(d[3]), float(f_obs), rows.append(row)
float(d[7] - d[10]), float(d[13])))
if args.smoke: if args.smoke:
continue # no settle / score in the plumbing smoke continue # no settle / score in the plumbing smoke
if cyc.update(s.y) == "scored": if cyc.update(s.y) == "scored":
+5
View File
@@ -16,6 +16,11 @@ WINDOW_TOL, LAST5_TOL = 0.02, 0.01
CYCLE_CAP, STEP_CAP_TN, SEED_TN, Y_LIMIT = 150, 200, 40, 1.0 CYCLE_CAP, STEP_CAP_TN, SEED_TN, Y_LIMIT = 150, 200, 40, 1.0
def finite(values):
"""True iff every recorded value is finite (fail-closed output check)."""
return all(math.isfinite(float(v)) for v in values)
class Structure: class Structure:
"""Undamped spring-mass, exact harmonic update over dt = 1 with constant force.""" """Undamped spring-mass, exact harmonic update over dt = 1 with constant force."""
+8
View File
@@ -86,3 +86,11 @@ def test_viv_config_passes_the_real_loader(tmp_path):
assert (cfg.nx, cfg.ny) == (nx, ny) == (3000, 2400) assert (cfg.nx, cfg.ny) == (nx, ny) == (3000, 2400)
assert cfg.collision == "MRT" and cfg.y_wall_bc == "free_slip" and cfg.velocity == .04 assert cfg.collision == "MRT" and cfg.y_wall_bc == "free_slip" and cfg.velocity == .04
assert math.isclose(cfg.viscosity, .04 * 40 / 150) assert math.isclose(cfg.viscosity, .04 * 40 / 150)
def test_finite_rejects_any_nonfinite_recorded_output():
row = (3, .1, .2, .3, .4, .5, .6, .7, 0.0)
assert viv.finite(row)
for i in range(len(row)):
for bad in (float("nan"), float("inf"), -float("inf")):
assert not viv.finite(row[:i] + (bad,) + row[i + 1:])