examples: em_reflection: get this to compile
This commit is contained in:
@@ -1,51 +1,35 @@
|
|||||||
use coremem::{GenericSim, SampleableSim as _, Driver};
|
use coremem::{mat, GenericSim, SampleableSim as _, Driver};
|
||||||
use coremem::geom::Index;
|
use coremem::geom::{Coord as _, Cube, Index};
|
||||||
|
use coremem::real::{Real as _, R32};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
coremem::init_logging();
|
coremem::init_logging();
|
||||||
let width = 401;
|
let width = 401;
|
||||||
let height = 401;
|
let height = 401;
|
||||||
let size = Index((width, height, 1).into());
|
let size = Index((width, height, 1).into());
|
||||||
let mut driver: Driver = Driver::new(size, 1e-6 /* feature size */);
|
let feat_size = 1e-6;
|
||||||
driver.add_y4m_renderer("em_reflection.y4m", 1);
|
let mut driver: Driver = Driver::new(size, feat_size);
|
||||||
// driver.add_term_renderer();
|
|
||||||
|
|
||||||
// driver.add_pml_boundary(Index((20, 40, 0).into()));
|
let _ = std::fs::create_dir_all("out/examples/em_reflection");
|
||||||
// for y in 75..100 {
|
driver.add_y4m_renderer("out/examples/em_reflection/rendered.y4m", 1, None);
|
||||||
// for x in 0..width {
|
driver.add_term_renderer(4, None);
|
||||||
// // from https://www.thoughtco.com/table-of-electrical-resistivity-conductivity-608499
|
|
||||||
// // NB: different sources give pretty different values for this
|
let reflector = Cube::new(
|
||||||
// // NB: Simulation misbehaves for values > 10... Proably this model isn't so great.
|
Index::new(0, 0, 0).to_meters(feat_size), Index::new(width/10, height, 1).to_meters(feat_size)
|
||||||
// // Maybe use \eps or \xi instead of conductivity.
|
);
|
||||||
// let loc = Index((x, y, 0).into());
|
driver.fill_region(&reflector, mat::IsomorphicConductor::new(200f32.cast::<R32>()));
|
||||||
// *driver.state.get_mut(loc).mat_mut() = mat::Static::conductor(2.17).into();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let imp = if driver.state.step_no() < 50 {
|
let imp = if driver.state.step_no() < 50 {
|
||||||
1e4 * ((driver.state.step_no() as f64)*0.04*std::f64::consts::PI).sin()
|
1e5 * ((driver.state.step_no() as f64)*0.04*std::f64::consts::PI).sin()
|
||||||
} else {
|
} else {
|
||||||
0.0
|
0.0
|
||||||
};
|
};
|
||||||
// let t = 4e12 * driver.state.time();
|
|
||||||
// let imp = 1e4 * (-t*t).exp();
|
|
||||||
// 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 y in height/4..height*3/4 {
|
for y in height/4..height*3/4 {
|
||||||
//for y in 0..height {
|
|
||||||
let loc = Index((200, y, 0).into());
|
let loc = Index((200, y, 0).into());
|
||||||
driver.state.impulse_ez(loc, imp as _);
|
driver.state.impulse_ex(loc, imp as _);
|
||||||
driver.state.impulse_hy(loc, (imp/376.730) as _);
|
driver.state.impulse_hz(loc, (imp/376.730) as _);
|
||||||
}
|
}
|
||||||
// for x in 0..width {
|
|
||||||
// let loc = Index((x, 200, 0).into());
|
|
||||||
// driver.dyn_state().impulse_ez(loc, imp as _);
|
|
||||||
// driver.dyn_state().impulse_hx(loc, (imp/376.730) as _);
|
|
||||||
// }
|
|
||||||
driver.step();
|
driver.step();
|
||||||
//thread::sleep(time::Duration::from_millis(67));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user