Skip to main content

PeriodicPlaneWave

Struct PeriodicPlaneWave 

Source
pub struct PeriodicPlaneWave { /* private fields */ }
Expand description

Plane-wave source for a periodic unit cell at fixed transverse wavevector; see the module docs.

use ems::engine::{Engine, FaceCondition, FaceConditions, Grid};
use ems::engine::bloch_wave::{PeriodicPlaneWave, PeriodicPlaneWaveSpec, WavePart};
use ems::{Axis, Face};

let g = Grid::uniform([4, 4, 40], [1e-3; 3])?;
let faces = FaceConditions::default()
    .with(Face::XMin, FaceCondition::Periodic)
    .with(Face::XMax, FaceCondition::Periodic)
    .with(Face::YMin, FaceCondition::Periodic)
    .with(Face::YMax, FaceCondition::Periodic);
let mut e = Engine::builder(g).faces(faces).threads(1).build()?;
// Normal incidence along +z, E along x, total field from plane 10 on.
let spec = PeriodicPlaneWaveSpec::new(Axis::Z, 10, 39, true, [0.0; 3], [1.0, 0.0, 0.0]);
let pw = PeriodicPlaneWave::new(&e, &spec, WavePart::Real, |t| (-((t - 5e-11) / 1.5e-11).powi(2)).exp())?;
let h = e.add_operator(pw);
e.run(20);
assert_eq!(e.operator(&h).incident().len(), 20);

Implementations§

Source§

impl PeriodicPlaneWave

Source

pub fn new( engine: &Engine, spec: &PeriodicPlaneWaveSpec, part: WavePart, amplitude: impl Fn(f64) -> f64 + Send + 'static, ) -> Result<Self>

Sets up the source for engine’s grid, time step and coefficients (take them as final: build after any operator that changes coefficients on the injection planes), injecting part of the complex incident field. amplitude(t) drives the auxiliary grid’s hard source.

§Errors

Error::Invalid for planes outside the mesh or start ≥ stop, an entry plane on the domain boundary (no room for the source), a non-finite or normal k_t, a polarisation that is zero, non-finite or has a normal component, or an invalid background.

Source

pub fn spec(&self) -> &PeriodicPlaneWaveSpec

The settings.

Source

pub fn part(&self) -> WavePart

The part of the complex field this operator injects.

Source

pub fn corrections(&self) -> (usize, usize)

Number of E and H edge corrections applied per step.

Source

pub fn discrete_wavevector(&self) -> [f64; 3]

The discrete transverse wavenumbers k̃ used by the auxiliary grid [rad/m].

Source

pub fn incident(&self) -> &[[Complex64; 3]]

The complex incident E [V/m] on the entry plane at the phase reference (the first mesh line of every transverse axis), one value per step at the E times (n + 1)·dt: the tangential components as computed, the normal component averaged from the two half cells around the plane.

Trait Implementations§

Source§

impl Debug for PeriodicPlaneWave

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Operator for PeriodicPlaneWave

Source§

fn hooks(&self) -> Hooks

The serial hooks this operator implements (default Hooks::ALL). Queried once, at registration; undeclared hooks are never called. Declaring fewer hooks only saves time: an operator whose hooks are all empty may return Hooks::NONE.
Source§

fn post_h(&mut self, fields: &mut Fields<'_>, _ctx: &StepContext<'_>)

After the H update (i is at ctx.h_time()).
Source§

fn post_e(&mut self, fields: &mut Fields<'_>, ctx: &StepContext<'_>)

After the E update (u is at ctx.e_time()).
Source§

fn pre_h(&mut self, _fields: &mut Fields<'_>, _ctx: &StepContext<'_>)

Before the H update of step ctx.step.
Source§

fn pre_e(&mut self, _fields: &mut Fields<'_>, _ctx: &StepContext<'_>)

Before the E update.
Source§

fn slab_hooks( &mut self, _partition: &SlabPartition<'_>, ) -> Option<Arc<dyn SlabHooks>>

Slab-parallel work for the engine’s x-slab partition (default none). Called once, at registration; the returned object is run by the worker threads (see SlabHooks). The operator may keep a clone of the Arc to read results back.
Source§

fn energy(&self) -> f64

Energy [J] held in the operator’s own state at t = n·dt, the time of the E voltages after n completed steps (default 0). Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.