Metadata-Version: 2.4
Name: photonoxide
Version: 0.6.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Rust
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Typing :: Typed
Requires-Dist: numpy>=2.2.6
Requires-Dist: pdoc==16.0.0 ; extra == 'docs'
Requires-Dist: pytest>=9.1.1 ; extra == 'test'
Provides-Extra: docs
Provides-Extra: test
License-File: licenses/LICENSE-MIT
License-File: licenses/LICENSE-APACHE
Summary: Validated photonics from Rust, for Python: materials with provenance, waveguide modes, jobs and 2D FDFD S-parameters, circuits and Touchstone files, devices
Keywords: photonics,silicon-photonics,waveguide,mode-solver,fdfd,s-parameters,touchstone,electromagnetics
License-Expression: MIT OR Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://github.com/tachsin/photonoxide/blob/main/CHANGELOG.md
Project-URL: Documentation, https://github.com/tachsin/photonoxide/blob/main/docs/python.md
Project-URL: Repository, https://github.com/tachsin/photonoxide

<p align="center">
  <img src="https://raw.githubusercontent.com/tachsin/photonoxide/main/assets/brand/banner.svg" alt="photonoxide: validated photonics for Rust" width="100%">
</p>

# photonoxide for Python

[photonoxide](https://github.com/tachsin/photonoxide) is a photonics library in Rust whose every
method is checked against an analytic solution or a published result, in a
[validation report](https://github.com/tachsin/photonoxide/blob/main/docs/validation.md). This
package brings a part of it to Python:

- the materials catalogue: indices with their source, validity range and conditions;
- waveguide modes: the exact slab, and full-vector modes of a cross-section with their fields;
- jobs (YAML, TOML or JSON, or a dict), run as the photonoxide program runs them, and an FDFD
  job's S-parameters;
- circuits from a netlist given as data, and Touchstone files;
- the devices of the photonoxide studio's component pages (waveguides, bends, couplers, rings,
  MMIs, Y-branches, MZIs): their S-parameters, figures, geometry and jobs, the same numbers as
  the studio's for the same design.

```sh
uv add photonoxide          # with uv, in a uv project
uv pip install photonoxide  # or into the active environment; pip install photonoxide works too
```

Wheels for CPython 3.10 and later on Linux, macOS and Windows; nothing else to install.

```python
import photonoxide as phox

si = phox.refractive_index("si", wavelength_um=1.55).real    # Li 1980
ox = phox.refractive_index("sio2", wavelength_um=1.55).real  # Malitson 1965
for polarization in ("te", "tm"):
    for mode in phox.slab_modes(below=ox, core=si, above=ox, thickness_um=0.22,
                              polarization=polarization, wavelength_um=1.55):
        print(f"{polarization.upper()}{mode.order}: n_eff = {mode.effective_index:.4f}")
```

It prints `TE0: n_eff = 2.8475` and `TM0: n_eff = 2.0531`.

Units are in the names (`wavelength_um`, `thickness_um`), as photonoxide's job files have them;
arrays are NumPy's, in C order, with their coordinates; errors are photonoxide's, with its
messages. The package's version is the Rust crate's it was built from. The guide:
[docs/python.md](https://github.com/tachsin/photonoxide/blob/main/docs/python.md). Every
function and class, from the package's docstrings and type stubs: the
[API reference](https://tachsin.github.io/photonoxide/).

## License

MIT or Apache-2.0, at your option.

