gplugins.gmeep.write_sparameters_meep

gplugins.gmeep.write_sparameters_meep#

gplugins.gmeep.write_sparameters_meep(component: ComponentSpec, port_source_names: list[str] | None = None, port_source_modes: dict[str, list] = None, port_modes: list[int] = None, port_symmetries: dict[str, list[str]] | None = None, resolution: int = 30, wavelength_start: float = 1.5, wavelength_stop: float = 1.6, wavelength_points: int = 50, dirpath: str | Path | None = None, layer_stack: LayerStack | None = None, port_margin: float = 2, port_monitor_offset: float = -0.1, port_source_offset: float = -0.1, filepath: Path | None = None, overwrite: bool = False, animate: bool = False, animate_center: tuple = None, animate_size: tuple = None, lazy_parallelism: bool = False, run: bool = True, dispersive: bool = False, xmargin: float = 0, ymargin: float = 0, zmargin: float = 0, xmargin_left: float = 0, xmargin_right: float = 0, ymargin_top: float = 0, ymargin_bot: float = 0, zmargin_top: float = 0, zmargin_bot: float = 0, decay_by: float = 0.001, is_3d: bool = False, z: float = 0, plot_args: dict | None = None, only_return_filepath_sim_settings=False, verbosity: int = 0, **settings) dict[str, ndarray][source]#

Returns Sparameters and writes them to npz filepath.

Simulates each time using a different input port (by default, all of them) unless you specify port_symmetries:

port_symmetries_crossing = {
    "o1@0,o1@0": ["o2@0,o2@0", "o3@0,o3@0", "o4@0,o4@0"],
    "o2@0,o1@0": ["o1@0,o2@0", "o3@0,o4@0", "o4@0,o3@0"],
    "o3@0,o1@0": ["o1@0,o3@0", "o2@0,o4@0", "o4@0,o2@0"],
    "o4@0,o1@0": ["o1@0,o4@0", "o2@0,o3@0", "o3@0,o2@0"],
}
  • Only simulations using the outer key port names will be run

  • The associated value is another dict whose keys are the S-parameters computed

    when this source is active

  • The values of this inner Dict are lists of s-parameters whose values are copied

 top view
      ________________________________
     |                               |
     | xmargin_left                  | port_extension
     |<--------->       port_margin ||<-->
  o2_|___________          _________||_o3
     |           \        /          |
     |            \      /           |
     |             ======            |
     |            /      \           |
  o1_|___________/        \__________|_o4
     |   |                 <-------->|
     |   |ymargin_bot   xmargin_right|
     |   |                           |
     |___|___________________________|

side view
      ________________________________
     |                     |         |
     |                     |         |
     |                   zmargin_top |
     |xmargin_left         |         |
     |<---> _____         _|___      |
     |     |     |       |     |     |
     |     |     |       |     |     |
     |     |_____|       |_____|     |
     |       |                       |
     |       |                       |
     |       |zmargin_bot            |
     |       |                       |
     |_______|_______________________|
Parameters:
  • component – to simulate.

  • resolution – in pixels/um (30: for coarse, 100: for fine).

  • port_source_names – list of ports to excite. Defaults to all.

  • port_symmetries – Dict to specify port symmetries, to save number of simulations.

  • dirpath – directory to store Sparameters.

  • layer_stack – contains layer to thickness, zmin and material. Defaults to active pdk.layer_stack.

  • port_margin – margin on each side of the port.

  • port_monitor_offset – offset between Component and monitor port in um.

  • port_source_offset – offset between Component and source port in um.

  • filepath – to store pandas Dataframe with Sparameters in npz format. Defaults to dirpath/component_.npz.

  • overwrite – overwrites stored Sparameter npz results.

  • animate – saves a MP4 images of the simulation for inspection, and also outputs during computation. The name of the file is the source index.

  • lazy_parallelism – toggles the flag “meep.divide_parallel_processes” to perform the simulations with different sources in parallel. By default MPI just runs the same copy of the Python script everywhere, with the C++ under MEEP actually being parallelized. divide_parallel_processes allows us to logically split this one calculation into (in this case “cores”) subdivisions. The only difference in the scripts is that a different integer n is returned depending on the subdivision it is running in. So we use that n to select different sources, and each subdivision calculates its own Sparams independently. Afterwards, we collect all results in one of the subdivisions (if rank == 0).

  • run – runs simulation, if False, only plots simulation.

  • dispersive – use dispersive models for materials (requires higher resolution).

  • xmargin – left and right distance from component to PML.

  • xmargin_left – west distance from component to PML.

  • xmargin_right – east distance from component to PML.

  • ymargin – top and bottom distance from component to PML.

  • ymargin_top – north distance from component to PML.

  • ymargin_bot – south distance from component to PML.

  • zmargin_top – +z distance from component to PML.

  • zmargin_bot – -z distance from component to PML.

  • is_3d – if True runs in 3D (much slower).

  • z – for 2D plot.

  • plot_args – if animate or not run, customization keyword arguments passed to plot2D() (i.e. labels, eps_parameters, boundary_parameters, field_parameters, etc.)

Keyword Arguments:
  • extend_ports_length – to extend ports beyond the PML (um).

  • zmargin_top – thickness for cladding above core (um).

  • zmargin_bot – thickness for cladding below core (um).

  • tpml – PML thickness (um).

  • clad_material – material for cladding.

  • wavelength_start – wavelength min (um).

  • wavelength_stop – wavelength max (um).

  • wavelength_points – wavelength steps.

  • dfcen – delta frequency.

  • port_source_name – input port name.

  • port_margin – margin on each side of the port (um).

  • distance_source_to_monitors – in (um).

  • port_source_offset – offset between source Component port and source MEEP port.

  • port_monitor_offset – offset between Component and MEEP port monitor.

  • material_name_to_meep – map layer_stack names with meep material database name or refractive index. dispersive materials have a wavelength dependent index.

Returns:

sparameters in a Dict (wavelengths, s11a, o1@0,o2@0, …)

where a is the angle in radians and m the module.