ModeSolverFullyVectorial

class modesolverpy.mode_solver.ModeSolverFullyVectorial(n_eigs, tol=0.001, boundary='0000', initial_mode_guess=None, n_eff_guess=None)[source]

Bases: modesolverpy.mode_solver._ModeSolver

A fully-vectorial mode solver object used to setup and run a mode solving simulation.

Parameters:
  • n_eigs (int) – The number of eigen-values to solve for.
  • tol (float) – The precision of the eigen-value/eigen-vector solver. Default is 0.001.
  • boundary (str) – The boundary conditions to use. This is a string that identifies the type of boundary conditions applied. The following options are available: ‘A’ - Hx is antisymmetric, Hy is symmetric, ‘S’ - Hx is symmetric and, Hy is antisymmetric, and ‘0’ - Hx and Hy are zero immediately outside of the boundary. The string identifies all four boundary conditions, in the order: North, south, east, west. For example, boundary=‘000A’. Default is ‘0000’.
  • initial_mode_guess (list) – An initial mode guess for the modesolver.
  • initial_n_eff_guess (list) – An initial effective index guess for the modesolver.

Methods Summary

solve(structure) Find the modes of a given structure.
solve_ng(structure[, wavelength_step, filename]) Solve for the group index, \(n_g\), of a structure at a particular wavelength.
solve_sweep_structure(structures, …[, …]) Find the modes of many structures.
solve_sweep_wavelength(structure, wavelengths) Solve for the effective indices of a fixed structure at different wavelengths.
write_modes_to_file([filename, plot, …]) Writes the mode fields to a file and optionally plots them.

Methods Documentation

solve(structure)

Find the modes of a given structure.

Parameters:structure (Structure) – The target structure to solve for modes.
Returns:The ‘n_effs’ key gives the effective indices of the modes. The ‘modes’ key exists of mode profiles were solved for; in this case, it will return arrays of the mode profiles.
Return type:dict
solve_ng(structure, wavelength_step=0.01, filename='ng.dat')

Solve for the group index, \(n_g\), of a structure at a particular wavelength.

Parameters:
  • structure (Structure) – The target structure to solve for modes.
  • wavelength_step (float) – The step to take below and above the nominal wavelength. This is used for approximating the gradient of \(n_\mathrm{eff}\) at the nominal wavelength. Default is 0.01.
  • filename (str) – The nominal filename to use when saving the effective indices. Defaults to ‘ng.dat’.
Returns:

A list of the group indices found for each mode.

Return type:

list

solve_sweep_structure(structures, sweep_param_list, filename='structure_n_effs.dat', plot=True, x_label='Structure number', fraction_mode_list=[])

Find the modes of many structures.

Parameters:
  • structures (list) – A list of Structures to find the modes of.
  • sweep_param_list (list) – A list of the parameter-sweep sweep that was used. This is for plotting purposes only.
  • filename (str) – The nominal filename to use when saving the effective indices. Defaults to ‘structure_n_effs.dat’.
  • plot (bool) – True if plots should be generates, otherwise False. Default is True.
  • x_label (str) – x-axis text to display in the plot.
  • fraction_mode_list (list) – A list of mode indices of the modes that should be included in the TE/TM mode fraction plot. If the list is empty, all modes will be included. The list is empty by default.
Returns:

A list of the effective indices found for each structure.

Return type:

list

solve_sweep_wavelength(structure, wavelengths, filename='wavelength_n_effs.dat', plot=True)

Solve for the effective indices of a fixed structure at different wavelengths.

Parameters:
  • structure (Slabs) – The target structure to solve for modes.
  • wavelengths (list) – A list of wavelengths to sweep over.
  • filename (str) – The nominal filename to use when saving the effective indices. Defaults to ‘wavelength_n_effs.dat’.
  • plot (bool) – True if plots should be generates, otherwise False. Default is True.
Returns:

A list of the effective indices found for each wavelength.

Return type:

list

write_modes_to_file(filename='mode.dat', plot=True, fields_to_write=('Ex', 'Ey', 'Ez', 'Hx', 'Hy', 'Hz'))[source]

Writes the mode fields to a file and optionally plots them.

Parameters:
  • filename (str) – The nominal filename to use for the saved data. The suffix will be automatically be changed to identifiy each field and mode number. Default is ‘mode.dat’
  • plot (bool) – True if plots should be generates, otherwise False. Default is True.
  • fields_to_write (tuple) – A tuple of strings where the strings can be ‘Ex’, ‘Ey’, ‘Ez’, ‘Hx’, ‘Hy’ and ‘Hz’ defining what part of the mode should be saved and plotted. By default, all six components are written and plotted.
Returns:

A dictionary containing the effective indices and mode field profiles (if solved for).

Return type:

dict