From 4ffbc0b8af63274425943fe461c541cd0bb2c5bd Mon Sep 17 00:00:00 2001 From: colin Date: Sun, 2 Oct 2022 03:27:02 -0700 Subject: [PATCH] fix broken tests: - mb_ferromagnet_diff_repro - mb_ferromagnet_diff_minimal_repro as the comment hinted: > these tests probably failed earlier because they were allowing negative mu_r values. > no (ordinary?) material has a negative permeability. > most materials (except superconductors) have >= 1.0 relative permeability > permeability = mu = B/H (or, \Delta B/\Delta H) in fact, the relative permeability was -0.56. it's now 1.39 --- crates/coremem/src/sim/spirv/mod.rs | 9 ++++++--- crates/cross/src/mat/mb_pgram.rs | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/coremem/src/sim/spirv/mod.rs b/crates/coremem/src/sim/spirv/mod.rs index 01e65c6..183b9d5 100644 --- a/crates/coremem/src/sim/spirv/mod.rs +++ b/crates/coremem/src/sim/spirv/mod.rs @@ -759,13 +759,16 @@ mod test { test_same_mb_ferromagnet(0x1234, 10, 5, Index::new(96, 16, 8)); } - // XXX these tests probably failed because they were allowing negative mu_r values + // these tests probably failed earlier because they were allowing negative mu_r values. + // no (ordinary?) material has a negative permeability. + // most materials (except superconductors) have >= 1.0 relative permeability + // permeability = mu = B/H (or, \Delta B/\Delta H) #[test] fn mb_ferromagnet_diff_repro() { let size = Index::new(3, 3, 3); let seed = 0; // 0 => 28, 4 => 28 let steps = 1000; - let mat = mat::MBPgram::new(0e-4.to_r32(), 9.02e-3.to_r32(), 1e4.to_r32()); + let mat = mat::MBPgram::new(0e-4.to_r32(), 9.02e-3.to_r32(), 1e3.to_r32()); let mut ref_state = SpirvSim::, CpuBackend>::new(size, 1e-3); let mut dut_state = SpirvSim::, WgpuBackend>::new(size, 1e-3); ref_state.put_material(Index::new(1, 1, 1), mat.clone()); @@ -781,7 +784,7 @@ mod test { let size = Index::new(3, 3, 1); let seed = 0; // 0 => 28, 4 => 28 let steps = 1000; - let mat = mat::MBPgram::new(0e-4.to_r32(), 9.02e-3.to_r32(), 1e4.to_r32()); + let mat = mat::MBPgram::new(0e-4.to_r32(), 9.02e-3.to_r32(), 1e3.to_r32()); let mut ref_state = SpirvSim::, CpuBackend>::new(size, 1e-3); let mut dut_state = SpirvSim::, WgpuBackend>::new(size, 1e-3); ref_state.put_material(Index::new(1, 1, 0), mat.clone()); diff --git a/crates/cross/src/mat/mb_pgram.rs b/crates/cross/src/mat/mb_pgram.rs index 079aaf2..f2fbbbb 100644 --- a/crates/cross/src/mat/mb_pgram.rs +++ b/crates/cross/src/mat/mb_pgram.rs @@ -33,8 +33,9 @@ pub struct MBPgram { pub max_m: R, } -/// f(x0) = -ymax -/// f(x1) = ymax +/// evaluate `f(x)` at the provided `x`, where `f` is defined by these constraints: +/// 1. f(x0) = -ymax +/// 2. f(x1) = ymax fn eval_bounded_line(x: R, x0: R, x1: R, ymax: R) -> R { let x = x - x0; let x1 = x1 - x0;