API Reference

The following section outlines the API of fdtd.py.

Materials

class fdtd.Material(name, eps_r=1, mu_r=1, sigma_e=0, sigma_m=0, color='#000000')[source]

Implement a material.

Parameters
  • name (str) – The name of the material.

  • eps_r (float) – Relative permissivity.

  • mu_r (float) – Relative permeability.

  • sigma_e (float) – Electric condutivity.

  • sigma_m (float) – Magnetic condutivity.

  • color (str) – RGB color.

classmethod from_name(name)[source]

Initialize material from a name.

Parameters

name (str) – Name of material.

Returns

Return type

Material

Raises

MaterialNotFound – If material is not found.

Notes

Material[name] is equivalent to Material.from_name(name).

classmethod load(file_name)[source]

Load materials from a .json file.

Parameters

file_name (str) – Filename in the root directory.

Objects

Brick

class fdtd.Brick(x_min, y_min, z_min, x_max, y_max, z_max, material, name=None)[source]

Implement a brick object.

Sphere

class fdtd.Sphere(x_center, y_center, z_center, radius, material, name=None)[source]

Implement a brick object.

Lumped Elements

Resistor

class fdtd.Resistor(x_min, y_min, z_min, x_max, y_max, z_max, resistance=50)[source]

Model of a resistor element.

Parameters
  • x_min (float) – Minimum x coordinate of the bounding box containing the resistor.

  • y_min (float) – Minimum y coordinate of the bounding box containing the resistor.

  • z_min (float) – Minimum z coordinate of the bounding box containing the resistor.

  • x_max (float) – Maximum x coordinate of the bounding box containing the resistor.

  • y_max (float) – Maximum y coordinate of the bounding box containing the resistor.

  • z_max (float) – Maximum z coordinate of the bounding box containing the resistor.

  • resistance (float) – Internal resistance of the resistor.

Capacitor

class fdtd.Capacitor(x_min, y_min, z_min, x_max, y_max, z_max, capacitance=1e-09)[source]

Model of a capacitor element.

Parameters
  • x_min (float) – Minimum x coordinate of the bounding box containing the capacitor.

  • y_min (float) – Minimum y coordinate of the bounding box containing the capacitor.

  • z_min (float) – Minimum z coordinate of the bounding box containing the capacitor.

  • x_max (float) – Maximum x coordinate of the bounding box containing the capacitor.

  • y_max (float) – Maximum y coordinate of the bounding box containing the capacitor.

  • z_max (float) – Maximum z coordinate of the bounding box containing the capacitor.

  • capacitance (float) – Internal capacitance of the capacitor.

Inductor

class fdtd.Inductor(x_min, y_min, z_min, x_max, y_max, z_max, resistance=50, inductance=1e-06)[source]

Model of a inductor element.

Parameters
  • x_min (float) – Minimum x coordinate of the bounding box containing the inductor.

  • y_min (float) – Minimum y coordinate of the bounding box containing the inductor.

  • z_min (float) – Minimum z coordinate of the bounding box containing the inductor.

  • x_max (float) – Maximum x coordinate of the bounding box containing the inductor.

  • y_max (float) – Maximum y coordinate of the bounding box containing the inductor.

  • z_max (float) – Maximum z coordinate of the bounding box containing the inductor.

  • resistance (float) – Internal resistance of the inductor.

  • capacitance (float) – Internal inductance of the inductor.

Sources

Voltage Source

class fdtd.VoltageSource(x_min, y_min, z_min, x_max, y_max, z_max, waveform, resistance=50, name=None, direction=<Direction.Z: 2>)[source]

Model of a voltage source.

Parameters
  • x_min (float) – Minimum x coordinate of the bounding box containing the source.

  • y_min (float) – Minimum y coordinate of the bounding box containing the source.

  • z_min (float) – Minimum z coordinate of the bounding box containing the source.

  • x_max (float) – Maximum x coordinate of the bounding box containing the source.

  • y_max (float) – Maximum y coordinate of the bounding box containing the source.

  • z_max (float) – Maximum z coordinate of the bounding box containing the source.

  • waveform (Union[Waveform, Callable]) – Waveform type.

  • resistance (float) – Internal resistance of the source.

  • name (Optional[str]) – Name of the source.

  • direction (Direction) – Direction of the source.

Electric Field Source

class fdtd.EFieldSource(x_min, y_min, z_min, x_max, y_max, z_max, waveform, resistance=50, name=None, direction=<Direction.Z: 2>)[source]

Model of an electric field source.

Parameters
  • x_min (float) – Minimum x coordinate of the bounding box containing the source.

  • y_min (float) – Minimum y coordinate of the bounding box containing the source.

  • z_min (float) – Minimum z coordinate of the bounding box containing the source.

  • x_max (float) – Maximum x coordinate of the bounding box containing the source.

  • y_max (float) – Maximum y coordinate of the bounding box containing the source.

  • z_max (float) – Maximum z coordinate of the bounding box containing the source.

  • waveform (Union[Waveform, Callable]) – Waveform type.

  • resistance (float) – Internal resistance of the source.

  • name (Optional[str]) – Name of the source.

  • direction (Direction) – Direction of the source.

Impressed Electric Current Source

class fdtd.ImpressedElectricCurrentSource(x_min, y_min, z_min, x_max, y_max, z_max, waveform, resistance=50, name=None, direction=<Direction.Z: 2>)[source]

Model of an impressed electric current source.

Parameters
  • x_min (float) – Minimum x coordinate of the bounding box containing the source.

  • y_min (float) – Minimum y coordinate of the bounding box containing the source.

  • z_min (float) – Minimum z coordinate of the bounding box containing the source.

  • x_max (float) – Maximum x coordinate of the bounding box containing the source.

  • y_max (float) – Maximum y coordinate of the bounding box containing the source.

  • z_max (float) – Maximum z coordinate of the bounding box containing the source.

  • waveform (Union[Waveform, Callable]) – Waveform type.

  • resistance (float) – Internal resistance of the source.

  • name (Optional[str]) – Name of the source.

  • direction (Direction) – Direction of the source.

Impressed Magnetic Current Source

class fdtd.ImpressedMagneticCurrentSource(x_min, y_min, z_min, x_max, y_max, z_max, waveform, resistance=50, name=None, direction=<Direction.Z: 2>)[source]

Model of an impressed magnetic current source.

Parameters
  • x_min (float) – Minimum x coordinate of the bounding box containing the source.

  • y_min (float) – Minimum y coordinate of the bounding box containing the source.

  • z_min (float) – Minimum z coordinate of the bounding box containing the source.

  • x_max (float) – Maximum x coordinate of the bounding box containing the source.

  • y_max (float) – Maximum y coordinate of the bounding box containing the source.

  • z_max (float) – Maximum z coordinate of the bounding box containing the source.

  • waveform (Union[Waveform, Callable]) – Waveform type.

  • resistance (float) – Internal resistance of the source.

  • name (Optional[str]) – Name of the source.

  • direction (Direction) – Direction of the source.

Waveforms

Sine Waveform

class fdtd.SineWaveform(frequency, offset=0, amplitude=1)[source]

Model of a sine waveform.

Represent a function A*sin(2*pi*freq*t-offset) This model should be attached to a source.

Parameters
  • frequency (float) – Frequency [Hz].

  • offset (float) – Phase offset.

  • amplitude (float) – Amplitude.

Step Waveform

class fdtd.StepWaveform(t_0=0, amplitude=1)[source]

Model of a step waveform.

Represent a function A*step(t-t0). This model should be attached to a source.

Parameters
  • t_0 (float) – Initial time.

  • amplitude (float) – Amplitude.

Gaussian Waveform

class fdtd.GaussianWaveform(t_0, tau, amplitude=1)[source]

Model of a gaussian waveform.

Represent a function A*exp(-(t-t0)^2/tau^2). This model should be attached to a source.

Parameters
  • t_0 (float) – Initial time.

  • tau (float) – Tau parameter.

  • amplitude (float) – Amplitude.

Custom Waveform

Waveforms can also be custom callable functions:

def waveform(time: float | numpy.ndarray):
"""Square wavefunction."""
    return time**2

Detectors

Voltage Detector

class fdtd.VoltageDetector(x_min, y_min, z_min, x_max, y_max, z_max, name=None, direction=<Direction.Z: 2>, plot=False)[source]

Model of a voltage detector.

Parameters
  • x_min (float) – Minimum x coordinate of the bounding box containing the detector.

  • y_min (float) – Minimum y coordinate of the bounding box containing the detector.

  • z_min (float) – Minimum z coordinate of the bounding box containing the detector.

  • x_max (float) – Maximum x coordinate of the bounding box containing the detector.

  • y_max (float) – Maximum y coordinate of the bounding box containing the detector.

  • z_max (float) – Maximum z coordinate of the bounding box containing the detector.

  • name (Optional[str]) – Name of the source.

  • plot (bool) – Flag to enable plotting.

Magnetic Field Detector

class fdtd.HFieldDetector(x_min, y_min, z_min, x_max, y_max, z_max, name=None, direction=<Direction.Z: 2>, plot=False)[source]

Model of a magnetic field detector.

Parameters
  • x_min (float) – Minimum x coordinate of the bounding box containing the detector.

  • y_min (float) – Minimum y coordinate of the bounding box containing the detector.

  • z_min (float) – Minimum z coordinate of the bounding box containing the detector.

  • x_max (float) – Maximum x coordinate of the bounding box containing the detector.

  • y_max (float) – Maximum y coordinate of the bounding box containing the detector.

  • z_max (float) – Maximum z coordinate of the bounding box containing the detector.

  • name (Optional[str]) – Name of the source.

  • plot (bool) – Flag to enable plotting.

Electric Field Detector

class fdtd.EFieldDetector(x_min, y_min, z_min, x_max, y_max, z_max, name=None, direction=<Direction.Z: 2>, plot=False)[source]

Model of an electric field detector.

Parameters
  • x_min (float) – Minimum x coordinate of the bounding box containing the detector.

  • y_min (float) – Minimum y coordinate of the bounding box containing the detector.

  • z_min (float) – Minimum z coordinate of the bounding box containing the detector.

  • x_max (float) – Maximum x coordinate of the bounding box containing the detector.

  • y_max (float) – Maximum y coordinate of the bounding box containing the detector.

  • z_max (float) – Maximum z coordinate of the bounding box containing the detector.

  • name (Optional[str]) – Name of the source.

  • plot (bool) – Flag to enable plotting.

Boundaries

Periodic Boundary

class fdtd.PeriodicBoundary(x_direction=False, y_direction=False, z_direction=False)[source]

Model of a periodic boundary condition.

Parameters
  • x_direction (bool) – Flag to enable the boundary condition along the x axis.

  • y_direction (bool) – Flag to enable the boundary condition along the y axis.

  • z_direction (bool) – Flag to enable the boundary condition along the z axis.

Periodic Bloch Boundary

class fdtd.PeriodicBlochBoundary(b_vec=(0, 0, 0), x_direction=False, y_direction=False, z_direction=False)[source]

Model of a periodic Bloch boundary condition.

Parameters
  • b_vec (Tuple[float,..]) –

  • wave vector. (Bloch) –

  • x_direction (bool) – Flag to enable the boundary condition along the x axis.

  • y_direction (bool) – Flag to enable the boundary condition along the y axis.

  • z_direction (bool) – Flag to enable the boundary condition along the z axis.