Misc measurement improvements
This commit is contained in:
19
src/meas.rs
19
src/meas.rs
@@ -56,7 +56,7 @@ impl<R: Region + Display + Sync> AbstractMeasurement for Current<R> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mz
|
/// M
|
||||||
pub struct Magnetization(pub u32, pub u32);
|
pub struct Magnetization(pub u32, pub u32);
|
||||||
|
|
||||||
impl AbstractMeasurement for Magnetization {
|
impl AbstractMeasurement for Magnetization {
|
||||||
@@ -66,23 +66,32 @@ impl AbstractMeasurement for Magnetization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Bz
|
/// B
|
||||||
pub struct MagneticFlux(pub u32, pub u32);
|
pub struct MagneticFlux(pub u32, pub u32);
|
||||||
|
|
||||||
impl AbstractMeasurement for MagneticFlux {
|
impl AbstractMeasurement for MagneticFlux {
|
||||||
fn eval(&self, state: &SimSnapshot) -> String {
|
fn eval(&self, state: &SimSnapshot) -> String {
|
||||||
let b = state.get(self.0, self.1).b();
|
let b = state.get(self.0, self.1).b();
|
||||||
format!("Bz({}, {}): ({:.2e}, {:.2e}, {:.2e})", self.0, self.1, b.x(), b.y(), b.z())
|
format!("B({}, {}): ({:.2e}, {:.2e}, {:.2e})", self.0, self.1, b.x(), b.y(), b.z())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hz
|
/// H
|
||||||
pub struct MagneticStrength(pub u32, pub u32);
|
pub struct MagneticStrength(pub u32, pub u32);
|
||||||
|
|
||||||
impl AbstractMeasurement for MagneticStrength {
|
impl AbstractMeasurement for MagneticStrength {
|
||||||
fn eval(&self, state: &SimSnapshot) -> String {
|
fn eval(&self, state: &SimSnapshot) -> String {
|
||||||
let h = state.get(self.0, self.1).h();
|
let h = state.get(self.0, self.1).h();
|
||||||
format!("Hz({}, {}): ({:.2e}, {:.2e}, {:.2e})", self.0, self.1, h.x(), h.y(), h.z())
|
format!("H({}, {}): ({:.2e}, {:.2e}, {:.2e})", self.0, self.1, h.x(), h.y(), h.z())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ElectricField(pub u32, pub u32);
|
||||||
|
|
||||||
|
impl AbstractMeasurement for ElectricField {
|
||||||
|
fn eval(&self, state: &SimSnapshot) -> String {
|
||||||
|
let e = state.get(self.0, self.1).e();
|
||||||
|
format!("E({}, {}): ({:.2e}, {:.2e}, {:.2e})", self.0, self.1, e.x(), e.y(), e.z())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -63,7 +63,7 @@ impl<'a> RenderSteps<'a> {
|
|||||||
let mut me = Self::new(state, measurements);
|
let mut me = Self::new(state, measurements);
|
||||||
me.render_scalar_field(10.0, false, 2, |cell| cell.mat().conductivity().mag());
|
me.render_scalar_field(10.0, false, 2, |cell| cell.mat().conductivity().mag());
|
||||||
me.render_scalar_field(100.0, true, 0, |cell| cell.mat().m().mag());
|
me.render_scalar_field(100.0, true, 0, |cell| cell.mat().m().mag());
|
||||||
if true {
|
if false {
|
||||||
me.render_b_z_field();
|
me.render_b_z_field();
|
||||||
me.render_e_xy_field();
|
me.render_e_xy_field();
|
||||||
} else {
|
} else {
|
||||||
@@ -97,10 +97,10 @@ impl<'a> RenderSteps<'a> {
|
|||||||
|
|
||||||
////////////// Bx/By/Ez configuration ////////////
|
////////////// Bx/By/Ez configuration ////////////
|
||||||
fn render_e_z_field(&mut self) {
|
fn render_e_z_field(&mut self) {
|
||||||
self.render_scalar_field(100.0, true, 1, |cell| cell.e().z());
|
self.render_scalar_field(1e4, true, 1, |cell| cell.e().z());
|
||||||
}
|
}
|
||||||
fn render_b_xy_field(&mut self) {
|
fn render_b_xy_field(&mut self) {
|
||||||
self.render_vector_field(Rgb([0xff, 0xff, 0xff]), 1.0e-4, |cell| cell.b().xy());
|
self.render_vector_field(Rgb([0xff, 0xff, 0xff]), 1.0e-9, |cell| cell.b().xy());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_vector_field<F: Fn(&Cell<mat::Static>) -> Point>(&mut self, color: Rgb<u8>, typical: Flt, measure: F) {
|
fn render_vector_field<F: Fn(&Cell<mat::Static>) -> Point>(&mut self, color: Rgb<u8>, typical: Flt, measure: F) {
|
||||||
|
@@ -256,7 +256,7 @@ impl<M: Material> Cell<M> {
|
|||||||
let delta_ex_y = inv_feature_size * (down.ex() - self.ex());
|
let delta_ex_y = inv_feature_size * (down.ex() - self.ex());
|
||||||
let nabla_e = Vec3::from((delta_ez_y - delta_ey_z, delta_ex_z - delta_ez_x, delta_ey_x - delta_ex_y));
|
let nabla_e = Vec3::from((delta_ez_y - delta_ey_z, delta_ex_z - delta_ez_x, delta_ey_x - delta_ex_y));
|
||||||
|
|
||||||
let delta_b = -nabla_e * delta_t;
|
let delta_b = -nabla_e * delta_t; // TODO: should scale delta_t by 2?
|
||||||
let h = self.mat.step_h(&self.state, delta_b);
|
let h = self.mat.step_h(&self.state, delta_b);
|
||||||
Cell {
|
Cell {
|
||||||
state: CellState {
|
state: CellState {
|
||||||
|
Reference in New Issue
Block a user