Backfill some tests for the LinearMagnet which show that it's behaving POORLY
This commit is contained in:
@@ -87,6 +87,11 @@ mod test {
|
|||||||
|
|
||||||
mag.step_b(&CellState::default(), Vec3::uniform(1.0));
|
mag.step_b(&CellState::default(), Vec3::uniform(1.0));
|
||||||
assert_float_eq!(mag.m().x(), 1591231.12, abs <= 1.0);
|
assert_float_eq!(mag.m().x(), 1591231.12, abs <= 1.0);
|
||||||
|
|
||||||
|
mag.step_b(&CellState::default(), Vec3::uniform(-1.0));
|
||||||
|
assert_float_eq!(mag.m().x(), 795615.56, abs <= 1.0);
|
||||||
|
mag.step_b(&CellState::default(), Vec3::uniform(-1.0));
|
||||||
|
assert_float_eq!(mag.m().x(), 0.0, abs <= 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -99,4 +104,24 @@ mod test {
|
|||||||
mag.step_b(&CellState::default(), Vec3::uniform(-3.0));
|
mag.step_b(&CellState::default(), Vec3::uniform(-3.0));
|
||||||
assert_float_eq!(mag.m().x(), -795774.72, abs <= 1.0);
|
assert_float_eq!(mag.m().x(), -795774.72, abs <= 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn linear_magnet_accuracy() {
|
||||||
|
let mut mag = LinearMagnet::<f32>::new(5000.0);
|
||||||
|
|
||||||
|
let mut b = Vec3::zero();
|
||||||
|
while b.x() < 1.0 {
|
||||||
|
let delta_b = Vec3::uniform(0.00002);
|
||||||
|
mag.step_b(&CellState::default(), delta_b);
|
||||||
|
b += delta_b;
|
||||||
|
}
|
||||||
|
while b.x() > 0.0 {
|
||||||
|
let delta_b = Vec3::uniform(-0.00001);
|
||||||
|
mag.step_b(&CellState::default(), delta_b);
|
||||||
|
b += delta_b;
|
||||||
|
}
|
||||||
|
// TODO: This error is WAY too big!
|
||||||
|
// Need to make sure that M+H == mu0*B always
|
||||||
|
assert_float_eq!(mag.m().x(), b.x() * f32::mu0_inv(), abs <= 900.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user