WIP Stimulus system
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use coremem::{consts, Driver, Flt, mat, meas};
|
||||
use coremem::geom::{Coord, CylinderZ, Vec2};
|
||||
use coremem::geom::{Coord, CylinderZ, Vec2, Vec3};
|
||||
use coremem::stim::{Stimulus, Sinusoid};
|
||||
|
||||
fn main() {
|
||||
coremem::init_logging();
|
||||
@@ -35,12 +36,12 @@ fn main() {
|
||||
m_to_um(ferro_inner_rad),
|
||||
m_to_um(ferro_outer_rad),
|
||||
));
|
||||
let conductor_region = CylinderZ::new(
|
||||
Vec2::new(half_width, half_width),
|
||||
conductor_outer_rad);
|
||||
// driver.add_term_renderer();
|
||||
driver.add_measurement(meas::Label(format!("Conductivity: {}, Imax: {:.2e}", conductivity, peak_current)));
|
||||
driver.add_measurement(meas::Current(CylinderZ::new(
|
||||
Vec2::new(half_width, half_width),
|
||||
conductor_outer_rad)
|
||||
));
|
||||
driver.add_measurement(meas::Current(conductor_region.clone()));
|
||||
driver.add_measurement(meas::Magnetization(
|
||||
(half_width + ferro_inner_rad + 2.0*feat_size, half_width, half_depth).into()
|
||||
));
|
||||
@@ -92,28 +93,11 @@ fn main() {
|
||||
let boundary = Coord::new(from_m(boundary_xy), from_m(boundary_xy), 20);
|
||||
driver.add_upml_boundary(boundary);
|
||||
|
||||
driver.add_stimulus(Stimulus::new(
|
||||
conductor_region.clone(),
|
||||
Sinusoid::new(Vec3::new(0.0, 0.0, peak_current * 1e-18), 1e9)));
|
||||
|
||||
loop {
|
||||
// let drive_current = peak_current * match driver.state.step_no() {
|
||||
// 0..=1000 => 1.0,
|
||||
// 3000..=4000 => -1.0,
|
||||
// _ => 0.0,
|
||||
// };
|
||||
let drive_current = peak_current * 1e-18;
|
||||
// J = \sigma*E = [Am^-2]
|
||||
// I = \sigma*E*Area
|
||||
// E = I / \sigma / Area
|
||||
//let e = v/(2.0*feat_size);
|
||||
let area = consts::PI*(conductor_outer_rad*conductor_outer_rad - conductor_inner_rad*conductor_inner_rad);
|
||||
let e = drive_current/conductivity/area;
|
||||
for y_px in from_m(half_width-conductor_outer_rad)..from_m(half_width+conductor_outer_rad) {
|
||||
for x_px in from_m(half_width-conductor_outer_rad)..from_m(half_width+conductor_outer_rad) {
|
||||
let loc = Coord::new(x_px, y_px, 0);
|
||||
let d = Vec2::new(to_m(x_px), to_m(y_px)) - center;
|
||||
if (conductor_inner_rad..conductor_outer_rad).contains(&d.mag()) {
|
||||
driver.state.impulse_ez(loc, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
driver.step();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user