From a94413c9a293e6075957b6b3d560985feabd46c5 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Mon, 13 Jul 2026 08:24:06 -0400 Subject: [PATCH] test: bound magnetic flux balance by ULPs Compare the reconstructed connector flux balance against an absolute four-ULP bound derived from the simulated flux scale. Co-Authored-By: Chris Rackauckas --- test/magnetic.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/magnetic.jl b/test/magnetic.jl index 17b396f0..eb286885 100644 --- a/test/magnetic.jl +++ b/test/magnetic.jl @@ -63,5 +63,12 @@ using OrdinaryDiffEqRosenbrock: Rodas4 @test SciMLBase.successful_retcode(sol) @test sol[r_mFe.Phi] == sol[r_mAirPar.Phi] - @test all(sol[coil.port_p.Phi] + sol[r_mLeak.Phi] + sol[r_mAirPar.Phi] .== 0) + coil_flux = sol[coil.port_p.Phi] + leakage_flux = sol[r_mLeak.Phi] + air_flux = sol[r_mAirPar.Phi] + flux_balance = coil_flux + leakage_flux + air_flux + flux_scale = maximum(maximum(abs, flux) for flux in (coil_flux, leakage_flux, air_flux)) + # Exact cancellation is lost when observables are reconstructed; four ULPs covers that + # roundoff and the two additions. + @test maximum(abs, flux_balance) <= 4 * eps(flux_scale) end