Skip to content

Commit d369822

Browse files
test: bound magnetic flux balance by ULPs (#484)
Compare the reconstructed connector flux balance against an absolute four-ULP bound derived from the simulated flux scale. Co-authored-by: ChrisRackauckas-Claude <accounts@chrisrackauckas.com>
1 parent d0243bd commit d369822

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

test/magnetic.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,12 @@ using OrdinaryDiffEqRosenbrock: Rodas4
6363

6464
@test SciMLBase.successful_retcode(sol)
6565
@test sol[r_mFe.Phi] == sol[r_mAirPar.Phi]
66-
@test all(sol[coil.port_p.Phi] + sol[r_mLeak.Phi] + sol[r_mAirPar.Phi] .== 0)
66+
coil_flux = sol[coil.port_p.Phi]
67+
leakage_flux = sol[r_mLeak.Phi]
68+
air_flux = sol[r_mAirPar.Phi]
69+
flux_balance = coil_flux + leakage_flux + air_flux
70+
flux_scale = maximum(maximum(abs, flux) for flux in (coil_flux, leakage_flux, air_flux))
71+
# Exact cancellation is lost when observables are reconstructed; four ULPs covers that
72+
# roundoff and the two additions.
73+
@test maximum(abs, flux_balance) <= 4 * eps(flux_scale)
6774
end

0 commit comments

Comments
 (0)