OpticalSimulatorFEMWELL
The OpticalSimulatorFEMWELL is a FEM mode solver built around FEMWELL and skfem. With this tool we can calculate the optical modes supported by our structure. We can retrieve the effective index, group index, and field profiles of the modes supported by our waveguide structure.
- class imodulator.OpticalSimulator.OpticalSimulatorFEMWELL(device, simulation_window=None, include_metals=True)
Base class for optical simulation of a PhotonicDevice using FEMWELL. The role of the optical simulator is to:
generate the optical mesh;
apply optical symmetry planes;
Generate field visualizations of the optical modes;
Generate mesh visuals;
Solve for the optical modes;
Transfer the optical modes to a new mesh (for EO calculations)
- __init__(device, simulation_window=None, include_metals=True)
Initializes the simulator with the photonic device, the simulation window and the include_metals flag.
- Parameters:
device (
PhotonicDevice) – ThePhotonicDeviceobject to simulate.simulation_window (
Polygon|None(default:None)) – The simulation window to use for the optical simulation. If None, the entire device is simulated.include_metals (
bool(default:True)) – if True,MetalPolygon`s will be included in the simulation. If `False, they will be ignored and their optical properties assigned to \(\epsilon_{opt} = 1\).
- compute_modes(wavelength=1.55, num_modes=1, order=1, metallic_boundaries=False, n_guess=4.0, return_modes=False)
Compute the electromagnetic RF modes of a photonic device at a given wavelength. The modes are computed via FEMWELL.
- Parameters:
wavelength (
float(default:1.55)) – The wavelength at which to compute the modes. The wavelength must be in um.num_modes (
int(default:1)) – The number of modes to compute.order (
int(default:1)) – Order of the basis functions to use in the EM solver.metallic_boundaries (
list|str|bool(default:False)) – The boundaries to treat as metallic. If False, no boundaries are treated as metallic. If True, all boundaries are treated as metallic. If a list of strings, the boundaries with the given names are treated as metallic. At the moment, the simulation window is treated as a square, therefore, the metallic boundaries can beleft,right,topandbottomboundaries.n_guess (
float(default:4.0)) – Initial guess for the effective index.return_modes (
bool(default:False)) – Whether to return the computed modes.use_charge_transport_data – Whether to use the charge transport data to compute the permittivity tensor. Doing so will yield a \(\sigma(x,y,V)\). Make sure your mesh is appropriate for it.
- Return type:
Modes- Returns:
The computed modes if return_modes is True.
- get_epsilon_optical()
This function will return the \(\epsilon_{opt}\) tensor with the signature
self.epsilon_optical[vertice_idx]wherevertice_idxis the index of the vertice in the mesh
- make_mesh(default_resolution_min=1e-12, default_resolution_max=100, filename=None, gmsh_algorithm=5, global_quad=False, verbose=False, mesh_scaling_factor=1.0)
Returns a gmsh with the geometric information of the photonic device. The mesh generation is currently handled by FEMWELL, but it will later be deprecated in favour of MESHWELL.
- Parameters:
default_resolution_min (
float(default:1e-12)) – The minimum resolution to use for the mesh generation if no resolution is specified for a given entity.default_resolution_max (
float(default:100)) – The maximum resolution to use for the mesh generation if no resolution is specified for a given entity.filename (
str|None(default:None)) – The filename to save the mesh to. If None, the mesh is not saved.gmsh_algorithm (
int(default:5)) – The algorithm to use for the mesh generation.global_quad (
bool(default:False)) – Whether to use global quadrature for the mesh generation.verbose (
bool(default:False)) – Whether to print verbose output during the mesh generation.mesh_scaling_factor (
float(default:1.0)) – The scaling factor to apply to the mesh.
- plot_mesh(plot_polygons=True)
Plots the mesh on a new figure
- Parameters:
plot_polygons (
bool(default:True)) – Whether to plot the polygons over the mesh or not.- Returns:
The figure and axis objects.
- Return type:
fig, ax
- plot_mode(mode, figsize=(10, 3), color_polygons='black')
Plots the electric and magnetic fields components of a given mode. The plotting is handled by skfem.
- Parameters:
mode (
Mode) – The mode object containing the electric and magnetic field data to be plotted.figsize (
tuple[float,float] (default:(10, 3))) – Figure size as (width, height).color_polygons (
str(default:'black')) – Color of the polygons in the plot.
- Returns:
This method does not return any value. It generates a plot.
- Return type:
None
- plot_polygons(color_polygon='black', color_line='green', color_junctions='blue', fig=None, ax=None)
Plots the polygons of the
PhotonicDeviceobject.- Parameters:
color_polygon (default:
'black') – The color to use for the polygons.color_line (default:
'green') – The color to use for the lines.color_junctions (default:
'blue') – The color to use for the junctions.fig (default:
None) – The figure to plot on. IfNone, a new figure is created.ax (default:
None) – The axis to plot on. IfNone, a new axis is created.
- Returns:
The figure and axis objects.
- Return type:
fig, ax
- refine_mesh(mode_for_refinement=None)
Refines the mesh based on the computed optical modes.
- Parameters:
N_nearest_neighbours – Number of nearest neighbors when finding the facets in the new mesh corresponding to the old mesh boundaries. If you have a very fine mesh, it is wise to make this number higher. If it’s not high enough, it may not update the named boundaries in its entirety, and you end up with wrong line integrals. Of course, the higher it is, the slower the algorithm.
mode_for_refinement (
Mode|None(default:None)) – the mode to be used for refinement.
- Returns:
None
- transfer_results_to_device(TE_TM_idx=[0, 1])
Transfers the optical mode to a new mesh. The created objects will be used by the
ElectroOpticalSimulatorto compute the electro-optical response of the device. It creates objects of the shape(3, new_mesh.p.shape[1])where the first axis is the component of the field and the second axis is the vertice index.- Parameters:
mode_idx – The index of the mode to transfer.
new_mesh – The new mesh to transfer the mode to. This object is expected to be the
Mesh.pobject from skfem.
- Returns:
The electric and magnetic field components of the mode in the new mesh.
- Return type:
Eopt, Hopt