pyFDTDKernel.pyFDTDSolver.pyFDTDSolver
- class pyFDTDKernel.pyFDTDSolver.pyFDTDSolver
Bases:
object
Interface for running simulations in pyFDTD.
ATTENTION: All external TIME, SPACE, FREQUENCY and WAVELENGTH attributes should be passed in terms of global units! Check pyFDTDSolver()’s GetGlobalUnits() method for more details on the units. Internal to pyFDTDSolver() they are treated in SI units.
Methods
AddDFTMonitor
([mon_type, lmin, lmax, name, ...])This method adds a Time Monitor to the simulation object.
AddTimeMonitor
([mon_type, name, npts, xmin, ...])This method adds a Time Monitor to the simulation object.
GetGlobalUnits
([print_units])This method returns the global units for the pyFDTDSolver() class.
Run
([queue])SetBoundaries
([xn, yn, zn, xp, yp, zp])Currently supported boundaries are only "cpml", convolutional perfect matched layer.
SetPorts
([profile, lcenter, t0, sigma, ...])Set the mode port settings.
SetSimSettings
(device_geometry[, sim_type, ...])This method set the higher level simulation settings.
- class DFTMonitor
Bases:
Monitor
Class for instantiating multiple DFTMonitor()’s in the pyFDTD simulation. Each time this class is instantiated a new unique name is created so that multiple monitors can be integrated in the simulation file through their own dict of settings.
- class PortSettings
Bases:
object
Base port class for specifying the S-parameter port settings. It comprises settings for a mode source and mode monitor.
- class TimeMonitor
Bases:
Monitor
Class for instantiating multiple TimeMonitor()’s in the pyFDTD simulation. Each time this class is instantiated a new unique name is created so that multiple monitors can be integrated in the simulation file through their own dict of settings.
- AddDFTMonitor(mon_type: str = '2d-x-normal', lmin: float = 1.5, lmax: float = 1.6, name: str | None = None, npts: int = 11, xmin: float = -100000000.0, xmax: float = 100000000.0, ymin: float = -100000000.0, ymax: float = 100000000.0, zmin: float = -100000000.0, zmax: float = 100000000.0, x0: float = 0.0, y0: float = 0.0, z0: float = 0.0, save_hx: bool = False, save_hy: bool = False, save_hz: bool = False, save_ex: bool = False, save_ey: bool = False, save_ez: bool = False, t_subsampling: int = 1, x_subsampling: int = 1, y_subsampling: int = 1, z_subsampling: int = 1)
This method adds a Time Monitor to the simulation object.
- Parameters:
mon_type (str, optional) – “2d-x-normal”, “2d-y-normal”, “2d-z-normal”. Defaults to “2d-x-normal”. x-normal corresponds a plane in the YoZ-plane, for example.
name (str | None, optional) – Name of the manoitor. Defaults to f”time_monitor{unique_number}”.
npts (int, optional) – Number of frequency points to save. Defaults to 11. PS: Even though we set lmin and lmax the DFT monitor will store linear spaced frequency samples from C0/lmin to C0/lmax.
xmin (float, optional) – Minimum x value. Defaults to -100e6. -100e6 to 100e6 usualy covers the entire simulation region for the defaults units.
xmax (float, optional) – Maximum x value. Defaults to 100e6.
ymin (float, optional) – Minimum y value. Defaults to -100e6.
ymax (float, optional) – Maximum y value. Defaults to 100e6.
zmin (float, optional) – Minimum z value. Defaults to -100e6.
zmax (float, optional) – Maximum z value. Defaults to 100e6.
x0 (float, optional) – Location along X for x-normal. Defaults to 0.0.
y0 (float, optional) – Location along Y for y-normal. Defaults to 0.0.
z0 (float, optional) – Location along Z for z-normal. Defaults to 0.0.
save_hx (bool, optional) – If True, saves the Hx field component. Defaults to False.
save_hy (bool, optional) – If True, saves the Hy field component. Defaults to False.
save_hz (bool, optional) – If True, saves the Hz field component. Defaults to False.
save_ex (bool, optional) – If True, saves the Ex field component. Defaults to False.
save_ey (bool, optional) – If True, saves the Ey field component. Defaults to False.
save_ez (bool, optional) – If True, saves the Ez field component. Defaults to False.
t_subsampling (int, optional) – Time subsampling. Defaults to 1. Subsampling means the number of times that axis will be undersampled. Thus, 1 means all samples are collected.
x_subsampling (int, optional) – X subsampling. Defaults to 1.
y_subsampling (int, optional) – Y subsampling. Defaults to 1.
z_subsampling (int, optional) – Z subsampling. Defaults to 1.
- AddTimeMonitor(mon_type: str = '2d-x-normal', name: str | None = None, npts: int = 11, xmin: float = -100000000.0, xmax: float = 100000000.0, ymin: float = -100000000.0, ymax: float = 100000000.0, zmin: float = -100000000.0, zmax: float = 100000000.0, x0: float = 0.0, y0: float = 0.0, z0: float = 0.0, save_hx: bool = False, save_hy: bool = False, save_hz: bool = False, save_ex: bool = False, save_ey: bool = False, save_ez: bool = False, t_subsampling: int = 1, x_subsampling: int = 1, y_subsampling: int = 1, z_subsampling: int = 1)
This method adds a Time Monitor to the simulation object.
- Parameters:
mon_type (str, optional) – “2d-x-normal”, “2d-y-normal”, “2d-z-normal”. Defaults to “2d-x-normal”. x-normal corresponds a plane in the YoZ-plane, for example.
name (str | None, optional) – Name of the manoitor. Defaults to f”time_monitor{unique_number}”.
npts (int, optional) – Number of time points to save. Defaults to 11.
xmin (float, optional) – Minimum x value. Defaults to -100e6. -100e6 to 100e6 usualy covers the entire simulation region for the defaults units.
xmax (float, optional) – Maximum x value. Defaults to 100e6.
ymin (float, optional) – Minimum y value. Defaults to -100e6.
ymax (float, optional) – Maximum y value. Defaults to 100e6.
zmin (float, optional) – Minimum z value. Defaults to -100e6.
zmax (float, optional) – Maximum z value. Defaults to 100e6.
x0 (float, optional) – Location along X for x-normal. Defaults to 0.0.
y0 (float, optional) – Location along Y for y-normal. Defaults to 0.0.
z0 (float, optional) – Location along Z for z-normal. Defaults to 0.0.
save_hx (bool, optional) – If True, saves the Hx field component. Defaults to False.
save_hy (bool, optional) – If True, saves the Hy field component. Defaults to False.
save_hz (bool, optional) – If True, saves the Hz field component. Defaults to False.
save_ex (bool, optional) – If True, saves the Ex field component. Defaults to False.
save_ey (bool, optional) – If True, saves the Ey field component. Defaults to False.
save_ez (bool, optional) – If True, saves the Ez field component. Defaults to False.
t_subsampling (int, optional) – Time subsampling. Defaults to 1. Subsampling means the number of times that axis will be undersampled. Thus, 1 means all samples are collected.
x_subsampling (int, optional) – X subsampling. Defaults to 1.
y_subsampling (int, optional) – Y subsampling. Defaults to 1.
z_subsampling (int, optional) – Z subsampling. Defaults to 1.
- GetGlobalUnits(print_units: bool = False) dict
This method returns the global units for the pyFDTDSolver() class. It prints the units and their scale, and returns a dictionary with only the units. Every external quantity should be passed on this units. Then, internally thery will be treate in SI units. (s, m, Hz, m) -> (time, space, freq, wavelength)
- SetBoundaries(xn: str = 'cpml', yn: str = 'cpml', zn: str = 'cpml', xp: str = 'cpml', yp: str = 'cpml', zp: str = 'cpml') None
Currently supported boundaries are only “cpml”, convolutional perfect matched layer.
- Parameters:
xn (str, optional) – Boundary for the negative face along X. Defaults to “cpml”.
yn (str, optional) – Boundary for the negative face along Y. Defaults to “cpml”.
zn (str, optional) – Boundary for the negative face along Z. Defaults to “cpml”.
xp (str, optional) – Boundary for the positive face along X. Defaults to “cpml”.
yp (str, optional) – Boundary for the positive face along Y. Defaults to “cpml”.
zp (str, optional) – Boundary for the positive face along Z. Defaults to “cpml”.
- SetPorts(profile: str = 'gaussian-pw', lcenter: float = 1.55, t0: float = 25, sigma: float = 6.8, mode_indices: int | list[int] = [0], symmetries: dict[str, str] | Literal['1x1', '1x2', '2x2', '4x'] = None, lmin: float = 1.5, lmax: float = 1.6, npts: int = 11, t_subsampling: int = 1, x_subsampling: int = 1, y_subsampling: int = 1, z_subsampling: int = 1) None
Set the mode port settings. For proper units check GetGlobalUnits().
- Parameters:
profile (str, optional) – Modulating profile of the source. Defaults to “gaussian-pw”.
lcenter (float, optional) – Center wavelength of the source. Defaults to 1.55.
t0 (float, optional) – Time shift of the modulating signal. Defaults to 25.
sigma (float, optional) – Standard deviation of themodulating signal. Defaults to 6.8.
mode_indices (int | list[int], optional) – Mode indices to be used in each port. Defaults to 0. If a single integer, it will be used for all ports. If a list it must match the number of ports in the device, otherwise it will append 0 (fundamental modes to the list). If the list is larger than the number of ports, then it will remove item until it matches the number of ports.
symmetries (dict[str,str]|literal['1x1','1x2','2x2','4x'], optional) – This tells the solver symmetries between ports. It is a dictionary where the keys are the S-parameters and the values their respective symmetric s_parameters. Key and Value should be strings contanin port numbers separated by an underscore (“i_j”, where i and j are port numbers) or strings can be used for predefined symmetries. 1x1 - Straight, s-bend, 90 degree bend 1x2 - Splitter or 1x2 MMI 2x2 - Directional coupler, ring resonator 4x - Waveguide crossing A symmetric dielectric waveguide with two ports can have the following symmetries: 1) symmetries = {“1_2”:”2_1”,”2_2”:”1_1”} or 2) symmetries = {“2_1”:”1_2”,”1_1”:”2_2”} Case 1) excites only port 1 (because 2 never appears as j in the values.) Case 2) excites only port 2 (because 1 never appears as j in the values.)
lmin (float, optional) – Minimum wavelength to monitor. Defaults to 1.5.
lmax (float, optional) – Maximum wavelength to monitor. Defaults to 1.6.
npts (int, optional) – Number of points to monitor. Defaults to 11.
t_subsampling (int, optional) – Monitor time subsampling. Defaults to 1.
x_subsampling (int, optional) – Monitor x subsampling. Defaults to 1.
y_subsampling (int, optional) – Monitor y subsampling. Defaults to 1.
z_subsampling (int, optional) – Monitor z subsampling. Defaults to 1.
- SetSimSettings(device_geometry: DeviceGeometry, sim_type: str = 'nportsparam', sim_time: float = 10000, sim_size: float | list[float, float, float] = [10, 10, 3], space_step: float = 0.025, kernel_type: str = 'cuda', auto_shutoff_flag: bool = True, auto_shutoff_limit: float = 0.0001, export_mat_grid: bool = False, round_buffers: bool = True, subpixel_level: int = 2, save_path: str = None, results_filename: str = None, show_modes: bool = False, show_permittivity: bool = False) None
This method set the higher level simulation settings. Check GetGlobalUnits() methods for units.
- Parameters:
sim_type (str, optional) – Type of simulation. Defaults to “nportsparam”. PS: Currently supported is nportsparam, only.
sim_time (float, optional) – Simulation time. Defaults to 10_000.
sim_size (float | list[float, float, float], optional) – The dimension of the simulation region. Defaults to [10, 10, 3]. Usualy this is overriden by the DeviceGeometry() object.
space_step (float, optional) – Space step. Uniform for X, Y and Z. Defaults to 0.025 (25nm).
kernel_type (str, optional) – Defines the type of kernel. Either “cuda” or “numpy”. Defaults to “cuda”.
auto_shutoff_flag (bool, optional) – If True will end the simulation using autoshutoff. Defaults to True. Autoshutoff triggers when the total simulation power gets below its maximum by a factor of auto_shutoff_limit.
auto_shutoff_limit (float, optional) – The relative threshold to trigger autoshutoff. Defaults to 1e-4.
export_mat_grid (bool, optional) – If True exports the material grid to the results file. Defaults to False.
round_buffers (bool, optional) – If True it rounds the buffers of the DeviceGeometry() to multiples of the space_step. Defaults to True.
subpixel_level (int, optional) – Dielectric material averaging level. Defaults to 2. PS: It oversamples the geometry by this many folds and then averages out the permittivity profile.
save_path (str, optional) – A path to save the results file (.hdf5 and .snp). Defaults to None. If not provided it will save directly in the current working directory.
results_filename (str, optional) – If None the solver will use information in the Device Geometry, date and time to create a filename.
show_modes (bool, optional) – Displays the modes before running the simulation. Defaults to False.
show_permittivity (bool, optional) – Displays the permittivity profile before running the simulation. Defaults to False.