pub struct FdtdGrid2D {
pub ez: Vec<f32>,
pub hx: Vec<f32>,
pub hy: Vec<f32>,
pub nx: usize,
pub ny: usize,
pub dx: f32,
pub dt: f32,
pub permittivity: Vec<f32>,
pub permeability: Vec<f32>,
pub conductivity: Vec<f32>,
/* private fields */
}Expand description
2D FDTD grid for TM (Transverse Magnetic) mode: Ez, Hx, Hy.
Fields§
§ez: Vec<f32>§hx: Vec<f32>§hy: Vec<f32>§nx: usize§ny: usize§dx: f32§dt: f32§permittivity: Vec<f32>§permeability: Vec<f32>§conductivity: Vec<f32>Implementations§
Source§impl FdtdGrid2D
impl FdtdGrid2D
pub fn new(nx: usize, ny: usize, dx: f32, dt: f32) -> Self
Sourcepub fn step(&mut self)
pub fn step(&mut self)
Advance one timestep using the leapfrog scheme. Updates H first (half-step), then E (full step).
Sourcepub fn add_source(&mut self, x: usize, y: usize, value: f32)
pub fn add_source(&mut self, x: usize, y: usize, value: f32)
Inject a soft source at point (x, y) into Ez.
Sourcepub fn field_energy(&self) -> f32
pub fn field_energy(&self) -> f32
Total electromagnetic energy in the 2D grid.
Sourcepub fn courant_number(&self) -> f32
pub fn courant_number(&self) -> f32
Courant number for 2D: dt * c / dx. Must be < 1/sqrt(2) for stability.
Sourcepub fn apply_pml_boundary(&mut self, layers: usize)
pub fn apply_pml_boundary(&mut self, layers: usize)
Apply Perfectly Matched Layer absorbing boundary conditions.
layers is the number of PML cells on each side.
Sourcepub fn apply_mur_abc(&mut self)
pub fn apply_mur_abc(&mut self)
Apply first-order Mur absorbing boundary condition.
Auto Trait Implementations§
impl Freeze for FdtdGrid2D
impl RefUnwindSafe for FdtdGrid2D
impl Send for FdtdGrid2D
impl Sync for FdtdGrid2D
impl Unpin for FdtdGrid2D
impl UnsafeUnpin for FdtdGrid2D
impl UnwindSafe for FdtdGrid2D
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.