# lightsmith

> The open photonics suite: one typed JSON problem spec solved by Mie, T-matrix, BEM, DDA, FDTD, TMM, RCWA, FDE, EME, BPM, FDFD, PWE and circuit solvers on CPU or GPU, with differentiable inverse design and JSON-first Python, CLI and MCP interfaces.

Units: nm, vacuum wavelengths. Time convention exp(-i omega t) (Im eps > 0 = loss). Problem kinds: scattering, layer_stack, periodic, mode, device, bands, circuit, optimization.

## Docs

- [README](README.md): install, quick start, solver table
- [AGENTS.md](AGENTS.md): conventions and workflow for agents (estimate -> solve -> check warnings)
- [Example spec](examples/drude_sphere.json): a complete scattering problem in JSON
- [MCP server](docs/mcp.md): tools, resources, prompts, jobs, budget, remote mode, client configuration
- [3D inverse design](examples/inverse_design_3d_mode_converter.json): an `optimization` problem on a 3D SOI device (extruded design region), run by examples/inverse_design_3d_mode_converter.py
- [Library landscape](docs/landscape.md): survey of existing solvers and backend choices

## API

- `lightsmith.problems.parse_problem(obj)` / `problem_json_schema()`: any problem kind from JSON
- `lightsmith.solve(problem, method="auto", device="auto")`
- `lightsmith.estimate(problem, method, device) -> dict` (no solve)
- `lightsmith.compare(problem, methods=None, device="auto") -> dict`
- `lightsmith.doctor() -> dict` (frameworks and GPUs)
- CLI: `lightsmith {doctor,backends,schema,estimate,solve,compare}`
- MCP server: `lightsmith-mcp` (stdio, or `--http`). See [docs/mcp.md](docs/mcp.md).
  - Tools: `list_problem_kinds`, `get_schema`, `list_backends`, `check_environment`, `validate_problem`,
    `estimate`, `solve`, `start_solve`, `compare`, `get_job`, `list_jobs`, `cancel_job`, `get_result`,
    `search_materials`, `get_material`, `fit_drude_lorentz`.
  - Resources: `lightsmith://schema/{kind}`, `lightsmith://examples/{kind}` and `lightsmith://jobs/{id}/result`
    (also `.csv` and `/plot.png`).
- Scattering methods (auto order): mie (spheres) > tmatrix (sphere clusters) > bem (surface integral equation: spheroids, cylinders, layered spheres, clusters; accurate for metals; no substrate) > dda > fdtd. BEM options: `{"bem": {"mesh_size_nm": ...}}`; `estimate` reports unknowns and memory (dense, grows as unknowns^2).
- Device solvers: `eme` (bidirectional, exact for piecewise-uniform sections), `bpm` (one-way beam propagation: no reflections, S between ports on the same plane = 0; best for long, slowly varying devices; options under `options["bpm"]`), `fdfd` (2D full-wave)
- PDK flow: `lightsmith.pdk.get_component(cell, **params)` -> layout/GDS/DeviceProblem; `lightsmith.pdk.flow.component_model(cell, flow, **params)` -> fitted, cached S-parameter model; netlists use `"pdk:<cell>"` instances
