Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Python API

Workflow

mesh

lumi.mesh(path, component, layer_stack, materials, zmin, zmax)

Writes .obj meshes of gdsfactory component extruded by layer_stack, clipped to [zmin, zmax], into simulation folder path. Call before setup.

setup

lumi.setup(path, sources, monitors, nres=6, wls=None, wl=None, f=None, fs=None, c0=None, targets=[], designs=[], approx_2D_mode=None, **kwargs)

Writes simulation problem to folder path. Call mesh first, then solve.

Args:

solve

lumi.solve(path)

Run simulation in folder path prepared by setup. Writes solution.json. Runs on a Luminescent server if env LUMI_API is set (see remote_solve). Runs the Julia source instead of the compiled binary if env LUMIDEV is set.

load

lumi.load(path, show=True)

Load solution dict from path. Monitor results in sol[“monitors”][name], eg [“modes”][mode number][“+” or “-”] as array over wavelengths (or frequencies if setup with fs).

movie

lumi.movie(path, views=None, fps=None, src='frames')

Show simulation movie in path, rendered by solve. views (overrides views from setup) or fps re-render it from field snapshots, which cloud solves don’t keep. Also re-renders if snapshots are newer than the movie. src: “frames” for time snapshots, “history” for peak snapshot per optimization iteration.

view

lumi.view(field, name='', prop='n', x=None, y=None, z=None, field_color_intensity=1.0, show_grid=False, show_box=True, labels='auto', mirrors=[])

Movie view: slices of field overlaid on material property prop, for setup(views=...).

Args:

Materials

material

lumi.material(n=None, epsilon=None, mu=1, sigma=0, chi2=0, chi3=0, dispersion=[], placeholder=False)

Define material properties in relative units

Args:

PEC_material

lumi.PEC_material(n)

Perfect electric conductor material for modeling metals

placeholder_material

lumi.placeholder_material(n)

placeholder material contributes to meshing but not to physical properties, eg used for design region

Sources & monitors

source

lumi.source(name, origin, basis=None, frame=None, dim=None, mirrored=False, wl=None, f=None, bandwidth=None, duration=None, modenums=[0])

Modulated Gaussian pulse source with gradual spectral roll off at bandwidth limits. Becomes continuous wave if bandwidth=0.

Args:

monitor

lumi.monitor(name, origin, basis=None, frame=None, dim=None, mirrored=False, t0=0, x=None, y=None, z=None, direction='+', layer=None)

Monitor recording results of frame at origin in basis.

Args:

gf_source

lumi.gf_source(port, c, layer_stack, offset=0, name=None, **kwargs)

source at gdsfactory port port of component c, offset along outward normal. name defaults to port name. kwargs go to source.

gf_monitor

lumi.gf_monitor(port, c, layer_stack, offset=0, name=None, **kwargs)

monitor at gdsfactory port port of component c. name defaults to port name. kwargs go to monitor.

gaussian_mode

lumi.gaussian_mode(D, n, dx, wl, theta=0, half=None, Dlim=None)

Tilted Gaussian beam mode for plane_frame(modes=...), eg fiber.

Args:

Frames

plane_frame

lumi.plane_frame(name, start, stop, fs_mode_solver=[], wls_mode_solver=[], modes='auto', nmodes=1, metallic_boundaries=None, boundaries=('PML', 'PML'), time_domain=None, frequency_domain=None)

Plane port frame between local start, stop (2 coords in 3D). Mode solutions at given frequencies or wavelengths; sources and monitors use (or interpolate) modes at closest wavelengths. Results: modes, flux, power. Records frequency-domain results by default, or time-domain signals if time_domain=True (or frequency_domain=False).

Args:

points_frame

lumi.points_frame(name, points, sensor=None, time_domain=None, frequency_domain=None)

Points in monitor basis. Records frequency-domain results by default, or time-domain signals if time_domain=True (or frequency_domain=False).

Args:

box_frame

lumi.box_frame(name, start, stop, dr, time_domain=None, frequency_domain=None)

Box volume frame between local start, stop (3 coords in 3D), sampled every dr (scalar or per axis). Results: fields in monitor basis. Records frequency-domain results by default, or time-domain signals if time_domain=True (or frequency_domain=False).

cage_frame

lumi.cage_frame(name, start, stop, dr, theta=3.141592653589793, phi=6.283185307179586, dtheta=np.float64(0.08726646259971647), dphi=np.float64(0.08726646259971647), time_domain=None, frequency_domain=None)

Cage: closed surface of box between local start, stop (3D only), faces sampled every dr (scalar or per axis). Results: flux per face (outward), power, farfield intensity and directivity on (theta, phi) grid. theta, phi: max angle (range from 0) or [min, max]. Records frequency-domain results by default, or time-domain signals if time_domain=True (or frequency_domain=False).

spherical_frame

lumi.spherical_frame(name, r, theta=3.141592653589793, phi=6.283185307179586, dtheta=np.float64(0.08726646259971647), dphi=np.float64(0.08726646259971647), time_domain=None, frequency_domain=None)

Sphere (circle in 2D) of radius r about monitor origin, in monitor basis. theta, phi: max angle (range from 0) or [min, max]. Results: flux (radial), power, and if closed (full theta, phi), farfield intensity and directivity on (theta, phi) grid. Records frequency-domain results by default, or time-domain signals if time_domain=True (or frequency_domain=False).

Inverse design

design

lumi.design(name, layer, lmin, fill_material, void_material, component, layer_stack, materials, symdims=[], repdims=[3], anchordims=[], dependent=False, topopt=True, contour_layer=None)

Design region to be optimized

Args:

target

lumi.target(src, dst, target, target_func='abs2', error_func='abs', weight=1, f=None, wl=None)

optimizer

lumi.optimizer(iters, stoploss, startloss=1, lowloss=None, highiter=None, momentum=0.7, contrast=0.7, init_dA=0.03, ckptat=None, gradckptat=None)

Args:

apply_design

lumi.apply_design(c0, sol)

Replace design regions of component c0 with optimized designs from solution sol.

design_from_gds

lumi.design_from_gds(path, i=1)

Import ith optimized design from path as gdsfactory component.

Utilities

straight

lumi.straight(length=10, width: float = 1, layer=(1, 0))

Rectangular gdsfactory component with ports “o1” (west) and “o2” (east).

remote_solve

lumi.remote_solve(path, api=None, token=None, poll=3)

Run simulation in folder path on a Luminescent server. Uploads inputs, streams the log, downloads results into path. The server renders the movie; field snapshots are not downloaded. api and token default to env LUMI_API and LUMI_TOKEN (or JUPYTERHUB_API_TOKEN in hosted notebooks). Run from your own machine, a copy is also kept in your Lumi Colab home at ~/local/runs/.

load_sparams

lumi.load_sparams(sparams)

Convert {“re”, “im”} dicts to complex values.

version

lumi.version()

Installed luminescent python package version. Its X.Y must match the solver binary’s X.Y.0.