API Reference

This page provides an auto-generated summary of legume’s API.

legume

set_backend(name)

Set the backend for the simulations.

set_print_backend(name)

Set the print backend for legume.

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 vectors corresponding to the radiation emission direction of the coupling constants stored in GuidedModeExp.rad_coup.

GuidedModeExp.unbalance_sp

Unbalance between the two addends in the summation of the imaginary part of the energy.

Methods

GuidedModeExp.run([kpoints, angles])

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.compute_rad_sp(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.

ExcitonSchroedEq

Creating a simulation

ExcitonSchroedEq(phc, z, V_shapes, a, M, E0, ...)

Main simulation class of the excitonic Schroedinger equation.

Attributes

ExcitonSchroedEq.eners

Energies of the eigenmodes computed by the Schroedinger equation.

ExcitonSchroedEq.eigvecs

Eigenvectors of the eigenmodes computed by the by the Schroedinger equation.

ExcitonSchroedEq.kpoints

Numpy array of shape (2, Nk) with the [kx, ky] coordinates of the k-vectors over which the simulation is run.

ExcitonSchroedEq.gvec

Numpy array of shape (2, Ng) with the [gx, gy] coordinates of the reciprocal lattice vectors over which the simulation is run.

Methods

ExcitonSchroedEq.run([kpoints])

Run the simulation.

ExcitonSchroedEq.get_pot_xy([Nx, Ny])

Get the xy-plane potential of the layer as computed from an inverse Fourier transform with the Schr Eq.

ExcitonSchroedEq.ft_wavef_xy(kind, mind)

Compute the wavefunction Fourier components in the xy-plane

ExcitonSchroedEq.get_wavef_xy(kind, mind[, ...])

Compute the wavefunction in the xy-plane.

HopfieldPol

Creating a simulation

HopfieldPol(phc, gmax[, truncate_g])

Main simulation class of the generalized Hopfield matrix method.

Attributes

HopfieldPol.eners

Energies of the eigenmodes computed by the Hopfield matrix diagonalisation.

HopfieldPol.eners_im

Imaginary part of the frequencies of the eigenmodes computed by the Hopfield matrix diagonalisation.

HopfieldPol.eigvecs

Eigenvectors of the eigenmodes computed by the by the Hopfield matrix diagonalisation.

HopfieldPol.fractions_ex

Excitonic fractions of the polaritonic eigenmodes.

HopfieldPol.fractions_ph

Photonic fractions of the polaritonic eigenmodes.

HopfieldPol.kpoints

Numpy array of shape (2, Nk) with the [kx, ky] coordinates of the k-vectors over which the simulation is run.

HopfieldPol.gvec

Numpy array of shape (2, Ng) with the [gx, gy] coordinates of the reciprocal lattice vectors over which the simulation is run.

Methods

HopfieldPol.run([gme_options, exc_options, ...])

Compute the eigenmodes of the photonic crystal taking into account light-matter interaction.

Photonic crystal

Lattice(*args)

Class for constructing a Bravais lattice

Lattice.bz_path(pts, ns[, symm_g])

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.

PhotCryst.add_layer(d[, eps_b, layer_type])

Add a layer to the photonic crystal, on top of all currently existing layers.

PhotCryst.add_qw(z, V_shapes, a, M, E0, ...)

Add an active layer to in the photonic crystal.

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

Ellipse([eps, x_cent, y_cent, rx, ry, phi])

Ellipse shape

Ring([eps, x_cent, y_cent, r_i, r_o])

Ring 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 or PWE simulation

viz.pol_bands(pol[, Q, fraction, Q_clip, ...])

Plot polaritonic band structure from a polaritonic 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.pot_ft(struct[, Nx, Ny, cbar, cmap, ...])

Plot a potentail cross section computed from an inverse FT

viz.reciprocal(struct)

Plot the reciprocal lattice of a GME, PWE, ESE or HP object

viz.field(struct, field, kind, mind[, x, y, ...])

Visualize mode fields over a 2D slice in x, y, or z

viz.wavef(struct, kind, mind[, val, N1, N2, ...])

Visualize wafeunction over a 2D slice in xy plane

viz.calculate_x(kpoints, num_eig, k_units)

Calculates x-axis coordinates (wavevector axis) for photonic and polaritonic bands plotting.

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