Remove some unused imports; cleanup
The `Cell` type in sim.rs could be further improved: it doesn't need to be parameterized over Material. It should actually be renamed to `Sample`, and directly encode the magnetization, etc.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
use crate::geom::{Index, Meters, Vec2, Vec3, Vec3u};
|
||||
use crate::{Material as _, MaterialExt as _};
|
||||
use crate::mat;
|
||||
use crate::real::{Real as _, ToFloat as _};
|
||||
use crate::real::ToFloat as _;
|
||||
use crate::sim::{Cell, GenericSim, StaticSim};
|
||||
use crate::meas::AbstractMeasurement;
|
||||
use crossterm::{cursor, QueueableCommand as _};
|
||||
@@ -153,7 +152,8 @@ impl<'a, S: GenericSim> RenderSteps<'a, S> {
|
||||
trace!("rendering at {}x{} with z={}", width, height, z);
|
||||
let mut me = Self::new(state, measurements, width, height, z);
|
||||
me.render_scalar_field(10.0, false, 2, |cell| {
|
||||
cell.mat().conductivity().mag().to_f32() + if cell.mat().is_vacuum() {
|
||||
let is_vacuum = cell.conductivity() != Vec3::zero() || cell.m() != Vec3::zero();
|
||||
cell.conductivity().mag().to_f32() + if is_vacuum {
|
||||
0.0
|
||||
} else {
|
||||
5.0
|
||||
@@ -205,7 +205,7 @@ impl<'a, S: GenericSim> RenderSteps<'a, S> {
|
||||
self.render_vector_field(Rgb([0xff, 0xff, 0xff]), 100.0 * scale, |cell| cell.e().xy().to_f32());
|
||||
// current
|
||||
self.render_vector_field(Rgb([0x00, 0xa0, 0x30]), 1.0e-12 * scale, |cell| {
|
||||
cell.e().elem_mul(cell.mat().conductivity()).xy().to_f32()
|
||||
cell.e().elem_mul(cell.conductivity()).xy().to_f32()
|
||||
});
|
||||
}
|
||||
////////////// Magnitude configuration /////////////
|
||||
@@ -214,7 +214,7 @@ impl<'a, S: GenericSim> RenderSteps<'a, S> {
|
||||
}
|
||||
fn render_current(&mut self, scale: f32) {
|
||||
self.render_scalar_field(1.0e1 * scale, false, 0, |cell| {
|
||||
cell.e().elem_mul(cell.mat().conductivity()).mag().to_f32()
|
||||
cell.e().elem_mul(cell.conductivity()).mag().to_f32()
|
||||
});
|
||||
}
|
||||
|
||||
@@ -227,8 +227,8 @@ impl<'a, S: GenericSim> RenderSteps<'a, S> {
|
||||
}
|
||||
|
||||
fn render_m(&mut self, scale: f32) {
|
||||
self.render_scalar_field(1.0e5 * scale, false, 1, |cell| cell.mat().m().mag().to_f32());
|
||||
self.render_vector_field(Rgb([0xff, 0xff, 0xff]), 1.0e5 * scale, |cell| cell.mat().m().xy().to_f32());
|
||||
self.render_scalar_field(1.0e5 * scale, false, 1, |cell| cell.m().mag().to_f32());
|
||||
self.render_vector_field(Rgb([0xff, 0xff, 0xff]), 1.0e5 * scale, |cell| cell.m().xy().to_f32());
|
||||
}
|
||||
|
||||
fn render_vector_field<F: Fn(&Cell<mat::Static>) -> Vec2<f32>>(&mut self, color: Rgb<u8>, typical: f32, measure: F) {
|
||||
@@ -559,15 +559,16 @@ impl<S: GenericSim> Renderer<S> for PlotlyRenderer {
|
||||
yv.push(y);
|
||||
zv.push(z);
|
||||
// opacities.push((cell.e().mag() * 0.1).min(1.0) as f64)
|
||||
let mat = cell.mat().conductivity().mag().to_f32() + if cell.mat().is_vacuum() {
|
||||
let is_vacuum = cell.conductivity() == Vec3::zero() && cell.m() == Vec3::zero();
|
||||
let mat = cell.conductivity().mag().to_f32() + if is_vacuum {
|
||||
0.0
|
||||
} else {
|
||||
5.0
|
||||
};
|
||||
//let g = scale_unsigned_to_u8(mat, 10.0);
|
||||
//let r = scale_unsigned_to_u8(cell.mat().m().mag(), 100.0);
|
||||
//let r = scale_unsigned_to_u8(cell.m().mag(), 100.0);
|
||||
//let b = scale_unsigned_to_u8(cell.e().mag(), 1e2);
|
||||
let r = scale_unsigned_to_u8(cell.mat().m().mag().to_f32(), 100.0);
|
||||
let r = scale_unsigned_to_u8(cell.m().mag().to_f32(), 100.0);
|
||||
let g = scale_unsigned_to_u8(cell.e().mag().to_f32(), 1e2);
|
||||
let b = scale_unsigned_to_u8(mat, 10.0);
|
||||
let alpha = 1.0;
|
||||
|
Reference in New Issue
Block a user