Files
fdtd-coremem/examples/em_reflection.rs
Colin b7716d2dea Repurpose mat::Conductor to mat::Static
This will allow taking a material-independent snapshot of the SimState.
2020-09-06 12:18:31 -07:00

45 lines
1.7 KiB
Rust

use coremem::{Driver, mat};
fn main() {
let width = 201;
let mut driver = Driver::new(width, 101, 1e-3 /* feature size */)
.with_y4m_renderer("em_reflection.y4m")
.with_term_renderer();
for inset in 0..20 {
for x in 0..width {
*driver.state.get_mut(x, inset).mat_mut() = mat::Static::conductor(0.1*(20.0 - inset as f64)).into();
}
for y in 0..100 {
*driver.state.get_mut(inset, y).mat_mut() = mat::Static::conductor(0.1*(20.0 - inset as f64)).into();
*driver.state.get_mut(width-1 - inset, y).mat_mut() = mat::Static::conductor(0.1*(20.0 - inset as f64)).into();
}
}
for y in 75..100 {
for x in 0..width {
// from https://www.thoughtco.com/table-of-electrical-resistivity-conductivity-608499
// NB: different sources give pretty different values for this
// NB: Simulation misbehaves for values > 10... Proably this model isn't so great.
// Maybe use \eps or \xi instead of conductivity.
*driver.state.get_mut(x, y).mat_mut() = mat::Static::conductor(2.17).into();
}
}
loop {
let imp = if driver.state.step_no() < 50 {
30000.0 * ((driver.state.step_no() as f64)*0.04*std::f64::consts::PI).sin()
} else {
0.0
};
// state.impulse_ex(50, 50, imp);
// state.impulse_ey(50, 50, imp);
// state.impulse_bz(20, 20, (imp / 3.0e8) as _);
// state.impulse_bz(80, 20, (imp / 3.0e8) as _);
for x in 0..width {
driver.state.impulse_bz(x, 20, (imp / 3.0e8) as _);
}
driver.step();
//thread::sleep(time::Duration::from_millis(67));
}
}