cross: step: backfill step_h material-free test
This commit is contained in:
@@ -213,6 +213,7 @@ impl<'a, R: Real, M: Material<R>> StepHContext<'a, R, M> {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::compound::Optional;
|
||||
use crate::mat::Vacuum;
|
||||
use float_eq::assert_float_eq;
|
||||
|
||||
@@ -256,6 +257,41 @@ mod test {
|
||||
assert_vec_eq(new_h, Vec3::new(-2.0, 0.0, 2.0));
|
||||
assert_vec_eq(new_m, Vec3::zero());
|
||||
}
|
||||
#[test]
|
||||
fn step_h_understands_nabla_e() {
|
||||
let mid = Vec3::new(4.0, 8.0, 12.0);
|
||||
let ctx = StepHContext {
|
||||
inv_feature_size: 1.0,
|
||||
time_step: 1.0,
|
||||
stim_h: Vec3::zero(),
|
||||
mat: &Vacuum,
|
||||
in_e: VolumeSamplePos {
|
||||
mid,
|
||||
xp1: Optional::some(mid + Vec3::new(1.0, 2.0, 3.0)),
|
||||
yp1: Optional::some(mid + Vec3::new(4.0, 5.0, 6.0)),
|
||||
zp1: Optional::some(mid + Vec3::new(7.0, 8.0, 9.0)),
|
||||
},
|
||||
in_h: Vec3::zero(),
|
||||
in_m: Vec3::zero(),
|
||||
};
|
||||
|
||||
//```tex
|
||||
// $\nabla x E$:
|
||||
// $[ \Delta\!E_z/\Delta\!y - \Delta\!E_y/\Delta\!z$
|
||||
// $ \Delta\!E_x/\Delta\!z - \Delta\!E_z/\Delta\!x$
|
||||
// $ \Delta\!E_y/\Delta\!x - \Delta\!E_x/\Delta\!y ]$
|
||||
// we take these values from `in_e`:
|
||||
// $[ 6.0 - 8.0 $
|
||||
// $ 7.0 - 3.0$
|
||||
// $ 2.0 - 4.0 ]$
|
||||
// this gets negated, and then scaled by $\mu_0^{-1}$
|
||||
//```
|
||||
|
||||
let (new_h, new_m) = ctx.step_h();
|
||||
let b = -Vec3::new(-2.0, 4.0, -2.0);
|
||||
assert_vec_eq(new_h, b * f32::mu0_inv());
|
||||
assert_vec_eq(new_m, Vec3::zero());
|
||||
}
|
||||
// TODO: backfill step_h tests
|
||||
// TODO: backfill step_e tests
|
||||
}
|
||||
|
Reference in New Issue
Block a user