ndispers
English | 日本語
ndispers is a Python package for refractive-index dispersion of crystals and glasses used in nonlinear and ultrafast optics. It implements Sellmeier equations and thermo-optic coefficients reported in the literature.
It computes
- refractive index
- group delay, group velocity, group index
- group-velocity dispersion, third-order dispersion
- group-velocity mismatch between two waves
- walk-off angles
- dn/dT, d²n/dT²
as functions of
- wavelength
- polar (θ) or azimuthal (φ) angle of the wavevector with respect to the dielectric principal axes
- temperature
- polarization (ordinary or extraordinary ray)
For non-centrosymmetric crystals it further computes phase mismatch Δk, phase-matching angles, the sinc²(Δk·L/2) factor, acceptance widths (spectral, angular, thermal), quasi-phase-matching periods, OPO tuning curves, and the effective nonlinear coefficient deff with tensor components scaled to the working wavelengths by Miller's rule.
Why ndispers
Existing tools for these calculations are applications: SNLO (as-photonics.com, Windows), refractiveindex.info and toolbox.lightcon.com (web), and iPhasematch (iOS). An application answers the query typed into it; it cannot be called from a program.
ndispers is a Python library. It computes the quantities SNLO's Qmix function reports — refractive indices, group velocities and dispersion, walk-off, phase-matching conditions, acceptance widths, effective nonlinearity — as functions that accept and return numpy arrays, so they can be evaluated over wavelength, angle and temperature grids inside a larger calculation. Every coefficient is traceable: each class docstring cites the paper, the validity range, and separate sources for the Sellmeier equation, the thermo-optic coefficients and the d tensor. Naming the class and the package version specifies a calculation completely.
Because the library is introspectable and its data sources are stated, an AI
assistant can operate it: media are enumerable with dir() or catalog(),
docstrings carry the required metadata, and
llms.txt states the API
on one page.
The scope is wider than SNLO's: linear birefringent crystals (α-BBO, calcite, quartz, MgF₂, YVO₄, sapphire) and isotropic media (glasses, CaF₂, Si, Ge, …) are included under the same interface.
Features
- All methods accept numpy arrays and broadcast over them; the evaluated
functions are pre-generated, so numpy is the only runtime dependency.
Medium objects are picklable and work with
multiprocessing. - Temperature derivatives dn/dT and d²n/dT² are obtained by differentiating the symbolic index expressions, not by finite differences.
- Phase matching: Δk, phase-matching angles, sinc² factor, acceptance widths, QPM period, OPO tuning curves; deff with Miller wavelength scaling for every non-centrosymmetric crystal.
- Several parameterizations of the same crystal are separate classes (LBO has five); disagreement between sources is visible rather than hidden behind one default.
- Coefficients are transcribed from the cited papers and cross-checked by independent re-extraction; regression tests pin the computed values (validation record).
- A new crystal is one file: a point-group base class plus Sellmeier and d coefficients (AGENTS.md). Requests and contributions: GitHub.
- Installation is
pip install ndisperson any platform, Python ≥ 3.10.
Installation
pip install ndispers
Requires Python 3.10 or later; the only dependency is numpy. The dispersion
formulas are written as sympy expressions, but the evaluated functions are
generated ahead of time and shipped. To work with the expressions themselves
(n_expr and related methods), or to evaluate your own subclass of a medium,
install sympy with pip install ndispers[sym].
Quick start
The tutorial notebook covers the workflow from inspecting a Sellmeier equation to phase-matching curves, with plots; it opens on Colab and runs in the browser, no installation needed. The essentials:
>>> import ndispers as nd
>>> bbo = nd.media.crystals.BetaBBO_Eimerl1987()
>>> bbo.n(0.532, 0, 25, pol='o')
1.674884049110459
>>> bbo.n(0.532, 3.1416/2, 25, pol='e')
1.5554658787539917
The four arguments are
- wavelength (µm),
- θ angle (rad),
- temperature (°C),
- polarization (
pol='o'or'e'; default'o').
Scalar input returns a float; numpy-array input broadcasts and returns an
array. The other dispersion methods (GD, GV, ng, GVD, TOD, GVM,
walk-off, dndT) and the phase-matching methods (pmAngles_sfg,
acceptance_sfg, qpm_period_sfg, tuning_dfg, deff_sfg, …) take the
same style of arguments. help(bbo) prints the material data and
references.
Worked examples — dispersion sweeps, phase-matching angles, OPO tuning, deff — are in the documentation and the tutorial notebook.
Available media
Nonlinear crystals: β-BBO, LBO, KTP, BiBO, CLBO, KDP, DKDP, KBBF, RBBF, LB4, LiIO₃, ZGP, AgGaS₂, AgGaSe₂, quartz, LiNbO₃ (undoped congruent, MgO-doped congruent and stoichiometric) and MgO:LiTaO₃. Linear birefringent crystals: α-BBO, calcite, sapphire, MgF₂, YVO₄. Isotropic media: fused silica, CaF₂, LiF, BaF₂, YAG, N-BK7, SF10/11/57, ZnSe, ZnS, Si, Ge, diamond.
Each medium is a class in nd.media.crystals or nd.media.glasses; several
crystals have more than one parameterisation, one class per source. The
media catalog
lists every class with its Sellmeier equation, validity range and references;
nd.catalog() returns the same census as data.
Documentation
- Browser apps — a refractive-index explorer and a phase-matching calculator, running client-side.
- Tutorial notebook — the basic workflow; opens on Colab (source).
- Validation — comparisons against the literature, with numbers, sources and caveats.
- ndispers.readthedocs.io — conventions (units, angles, signs) and the media catalog.
- llms.txt / llms-full.txt — the API reference for AI assistants.
Development
git clone https://github.com/akihiko-shimura/ndispers.git
cd ndispers
uv sync
uv run pytest
To run the tutorial notebook, add the notebook group (matplotlib, IPython,
JupyterLab, marimo):
uv sync --group notebook
uv run jupyter lab examples/basic_usage.ipynb
Releases are published to PyPI by pushing a version tag; see docs/RELEASING.md. AGENTS.md describes how to add a crystal.
License
MIT — see LICENSE.
Metadata
Release files for ndispers 0.20.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ndispers-0.20.0.tar.gz | 293.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ndispers-0.20.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 740.6 kB
Release files / ndispers-0.20.0.tar.gz
| Download URL | ndispers-0.20.0.tar.gz |
|---|---|
| Size | 293.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7858f32be8e3f9604b75d1e4b3fa648eea31e3060aa280b914928d308695dc22
|
|
BLAKE2b-256 checksum How to use checksums |
48f0538d028190a19e64caad776fa6d29f41310116f6b2ae2c6c15469ececdc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / ndispers-0.20.0-py3-none-any.whl
| Download URL | ndispers-0.20.0-py3-none-any.whl |
|---|---|
| Size | 447.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2d92c7ebfa117a73ca5d190f9c20911eecb93f55a9de3a978b5a2b6c6d8d4a88
|
|
BLAKE2b-256 checksum How to use checksums |
9e48d54be8ea30b032bdaa3132ff4ea3f462714f5062f3544027516f6554a28d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency log