72 lines
2.3 KiB
Rust
72 lines
2.3 KiB
Rust
use coremem::{Driver, mat, meas};
|
|
|
|
fn main() {
|
|
coremem::init_logging();
|
|
let width = 500;
|
|
let height = 500;
|
|
let feat_size = 1e-5; // feature size
|
|
let peak_current = 2.5e10;
|
|
let conductivity = 1.0e6;
|
|
let mut driver = Driver::new(width, height, feat_size);
|
|
driver.set_steps_per_frame(8);
|
|
//driver.set_steps_per_frame(40);
|
|
driver.add_y4m_renderer("ferromagnet.y4m");
|
|
// driver.add_term_renderer();
|
|
driver.add_measurement(meas::Current(225, 250));
|
|
driver.add_measurement(meas::Current(300, 250));
|
|
driver.add_measurement(meas::Magnetization(265, 250));
|
|
driver.add_measurement(meas::Current(190, 250));
|
|
|
|
for y in 0..height {
|
|
let resistor_inset = if y < 160 || y > height - 160 {
|
|
0
|
|
} else {
|
|
2
|
|
};
|
|
// left metal
|
|
for x in 200..250 {
|
|
*driver.state.get_mut(x, y).mat_mut() = mat::Static::conductor(conductivity).into();
|
|
}
|
|
for x in 180..200-resistor_inset {
|
|
*driver.state.get_mut(x, y).mat_mut() = mat::Static::conductor(1.0e3).into();
|
|
}
|
|
// right metal
|
|
for x in 280..330 {
|
|
*driver.state.get_mut(x, y).mat_mut() = mat::Static::conductor(conductivity).into();
|
|
}
|
|
for x in 330+resistor_inset..350 {
|
|
*driver.state.get_mut(x, y).mat_mut() = mat::Static::conductor(1.0e3).into();
|
|
}
|
|
}
|
|
for y in 200..300 {
|
|
for x in 260..270 {
|
|
*driver.state.get_mut(x, y).mat_mut() = mat::db::ferroxcube_3r1();
|
|
}
|
|
}
|
|
driver.add_boundary(100, 0.02);
|
|
|
|
loop {
|
|
// let v = if driver.state.step_no() < 50 {
|
|
// 2.5 * ((driver.state.step_no() as f64)*0.02*std::f64::consts::PI).sin()
|
|
// } else {
|
|
// 0.0
|
|
// };
|
|
let drive_current = peak_current * match driver.state.step_no() {
|
|
0..=1000 => 1.0,
|
|
3000..=4000 => -1.0,
|
|
_ => 0.0,
|
|
};
|
|
// E = V/M
|
|
//let e = v/(2.0*feat_size);
|
|
let e = drive_current/conductivity;
|
|
for x in 200..250 {
|
|
for y in 100..height-100 {
|
|
// driver.state.impulse_ey(x, 102, e);
|
|
// driver.state.impulse_ey(x, height - 103, e);
|
|
driver.state.impulse_ey(x, y, e);
|
|
}
|
|
}
|
|
driver.step();
|
|
}
|
|
}
|