# API Reference¶

## legume¶

 set_backend(name) Set the backend for the simulations.

## GuidedModeExp¶

### Creating a simulation¶

 GuidedModeExp(phc[, gmax, truncate_g]) Main simulation class of the guided-mode expansion.

### Attributes¶

 GuidedModeExp.freqs Real part of the frequencies of the eigenmodes computed by the guided-mode expansion. GuidedModeExp.freqs_im Imaginary part of the frequencies of the eigenmodes computed by the guided-mode expansion. GuidedModeExp.eigvecs Eigenvectors of the eigenmodes computed by the guided-mode expansion. GuidedModeExp.kpoints Numpy array of shape (2, Nk) with the [kx, ky] coordinates of the k-vectors over which the simulation is run. GuidedModeExp.gvec Numpy array of shape (2, Ng) with the [gx, gy] coordinates of the reciprocal lattice vectors over which the simulation is run. GuidedModeExp.rad_coup Coupling to TE and TM radiative modes in the claddings. GuidedModeExp.rad_gvec Reciprocal lattice vectos corresponding to the radiation emission direction of the coupling constants stored in GuidedModeExp.rad_coup.

### Methods¶

 GuidedModeExp.run(kpoints, [0]]), **kwargs) Compute the eigenmodes of the photonic crystal structure. GuidedModeExp.run_im() Compute the radiative rates associated to all the eigenmodes that were computed during GuidedModeExp.run(). GuidedModeExp.compute_rad(kind, minds) Compute the radiation losses of the eigenmodes after the dispersion has been computed. GuidedModeExp.get_eps_xy(z[, xgrid, ygrid, …]) Get the xy-plane permittivity of the PhC at a given z as computed from an inverse Fourier transform with the GME reciprocal lattice vectors. GuidedModeExp.ft_field_xy(field, kind, mind, z) Compute the ‘H’, ‘D’ or ‘E’ field Fourier components in the xy-plane at position z. GuidedModeExp.get_field_xy(field, kind, mind, z) Compute the ‘H’, ‘D’ or ‘E’ field components in the xy-plane at position z. GuidedModeExp.get_field_xz(field, kind, mind, y) Compute the ‘H’, ‘D’ or ‘E’ field components in the xz-plane at position y. GuidedModeExp.get_field_yz(field, kind, mind, x) Compute the ‘H’, ‘D’ or ‘E’ field components in the yz-plane at position x. GuidedModeExp.set_run_options([…]) Set multiple options for the guided-mode expansion.

## PlaneWaveExp¶

### Creating a simulation¶

 PlaneWaveExp(layer, gmax, eps_eff) Main simulation class of the plane-wave expansion.

### Attributes¶

 PlaneWaveExp.freqs Frequencies of the eigenmodes computed by the plane-wave expansion. PlaneWaveExp.eigvecs Eigenvectors of the eigenmodes computed by the plane-wave expansion. PlaneWaveExp.kpoints Numpy array of shape (2, Nk) with the [kx, ky] coordinates of the k-vectors over which the simulation is run. PlaneWaveExp.gvec Numpy array of shape (2, Ng) with the [gx, gy] coordinates of the reciprocal lattice vectors over which the simulation is run.

### Methods¶

 PlaneWaveExp.run([kpoints, pol, numeig]) Run the simulation. PlaneWaveExp.get_eps_xy([Nx, Ny, z]) Get the xy-plane permittivity of the layer as computed from an inverse Fourier transform with the PWE reciprocal lattice vectors. PlaneWaveExp.ft_field_xy(field, kind, mind) Compute the ‘H’, ‘D’ or ‘E’ field Fourier components in the xy-plane. PlaneWaveExp.get_field_xy(field, kind, mind) Compute the ‘H’, ‘D’ or ‘E’ field components in the xy-plane at position z.

## Photonic crystal¶

 Lattice(*args) Class for constructing a Bravais lattice Lattice.bz_path(pts, ns) Make a path in the Brillouin zone. PhotCryst(lattice, eps_l, eps_u) Class for a photonic crystal which can contain a number of layers. Layer(lattice, z_min, z_max) Class for a single layer in the potentially multi-layer PhC. ShapesLayer(lattice, z_min, z_max, eps_b) Layer with permittivity defined by Shape objects

## Geometry¶

 Circle([eps, x_cent, y_cent, r]) Circle shape Poly([eps, x_edges, y_edges]) Polygon shape Square([eps, x_cent, y_cent, a]) Square shape Hexagon([eps, x_cent, y_cent, a]) Hexagon shape FourierShape([eps, x_cent, y_cent, f_as, …]) Fourier coefficinets of the polar coordinates

## Visualization¶

 viz.bands(gme[, Q, Q_clip, cone, conecolor, …]) Plot photonic band structure from a GME simulation viz.structure(struct[, Nx, Ny, Nz, …]) Plot permittivity for all cross sections of a photonic crystal viz.shapes(layer[, ax, npts, color, lw, pad]) Plot all shapes of Layer viz.eps_xz(phc[, y, Nx, Nz, ax, clim, cbar, …]) Plot permittivity cross section of a photonic crystal in an xz plane viz.eps_xy(phc[, z, Nx, Ny, ax, clim, cbar, …]) Plot permittivity cross section of a photonic crystal in an xy plane viz.eps_yz(phc[, x, Ny, Nz, ax, clim, cbar, …]) Plot permittivity cross section of a photonic crystal in an yz plane viz.eps_ft(struct[, Nx, Ny, cladding, cbar, …]) Plot a permittivity cross section computed from an inverse FT viz.reciprocal(struct) Plot the reciprocal lattice of a GME or PWE object viz.field(struct, field, kind, mind[, x, y, …]) Visualize mode fields over a 2D slice in x, y, or z

## GDS¶

 gds.generate_gds(phc, filename[, unit, …]) Export a GDS file for all layers of a photonic crystal gds.generate_gds_raster(lattice, raster, …) Traces a rasterization projected onto a lattice to generate a GDS file