Skip to main content
BornSim logo

BornSim

Vector Born-series scattering from continuous, isotropic random media.

Python

Python 3.11 or newer

Documentation

Documentation build status

Tests

Test status

Quality

Static quality check status

Coverage

Test coverage

Release

Latest release tag

License

MIT license

BornSim models how light scatters from three-dimensional refractive-index fluctuations. Build a random or structured medium, solve its coherent Born series, and inspect angular scattering, phase functions, \(\mu_s\), anisotropy \(g\), and reduced scattering \(\mu_s'\).

3D medium opacity

3D SPF surface

Three-dimensional random medium rendered with increasing opacity Three-dimensional scattering phase-function surface

The left view shows the simulated refractive-index volume; opacity is a visual encoding, not absorption. The right view shows the normalized scattering phase function in direction space. Both figures are generated from the same BornSim-style workflow below.

Quick start

from bornsim import EnsembleSampling, Grid, Solver, Source
from bornsim.medium.random_medium import GaussianMedium
from bornsim.units import ureg

grid = Grid(
    shape=(16, 16, 16),
    spacing=50 * ureg.nanometer,
)

medium = GaussianMedium(
    background_refractive_index=1.33,
    refractive_index_std=0.01,
    correlation_length=100 * ureg.nanometer,
)

source = Source(wavelength=633 * ureg.nanometer)

solver = Solver(
    source=source,
    order=3,
)

ensemble_sampling = EnsembleSampling(
    realizations=4,
    seed=42,
)

result = solver.ensemble(
    medium=medium,
    grid=grid,
    ensemble_sampling=ensemble_sampling,
)

print(f"mu_s = {result.mu_s.to('1 / millimeter')}")

print(f"g = {result.g}")

print(f"mu_s_prime = {result.mu_s_prime.to('1 / millimeter')}")

result.plot()

For one fixed structured sample, use solver.solve(target=volume). The result can also be visualized directly with Plotly:

volume = medium.to_volume(
    grid=grid,
    seed=42,
)

medium_figure = volume.plot_3d(
    field="refractive_index",
)

result = solver.solve(target=volume)

phase_figure = result.plot_phase_function(view="3d")

medium_figure.show()

phase_figure.show()

All 3D views use Plotly exclusively. Two-dimensional plots use Matplotlib. Plotly figures support figure.show() and offline figure.write_html() exports.

What BornSim models

  • Media: Gaussian, exponential, and Whittle–Matérn random fields, seeded random spheres, and composable structured geometry.

  • Illumination: arbitrary incident direction and linear, circular, or elliptical polarization, with unpolarized illumination as the default.

  • Numerics: vector volume-integral propagation with configurable Born order, angular quadrature, grid spacing, and ensemble sampling.

  • Results: differential scattering, full directional phase functions, cross sections, uncertainty estimates, saved provenance, and Matplotlib or Plotly visualizations.

  • Reliability: integral-equation residuals, explicit refinement reports, and weak-contrast absorbing-sphere validation against Mie theory.

  • Absorption and ensembles: passive absorbing materials and random fields, absorption uncertainty, and coherent/diffuse scattering decomposition.

  • Units: explicit physical units for wavelengths, lengths, angles, and scattering coefficients through bornsim.units.ureg.

Installation

BornSim requires Python 3.11 or newer.

$ python -m pip install BornSim

For development:

$ git clone https://github.com/MartinPdeS/BornSim.git
$ cd BornSim
$ python -m pip install -e ".[testing,documentation]"
$ python -m pytest tests

Learn more

  • Documentation — theory, API reference, numerical conventions, and visualization guidance.

  • Examples — random media, structured samples, Born orders, validation, and result plots.

  • Medium visualization guide — interactive 3D volume and phase-function views.

  • Repository — issues and contributions.

Scientific scope

BornSim uses the linearized dielectric contrast \(\delta\varepsilon \approx 2 n_0 \delta n\). Its coefficients describe finite numerical samples and are not automatically intrinsic infinite-medium transport coefficients. Check grid, angular, sample-size, synthesis-box, and ensemble convergence before interpreting results quantitatively.

License

BornSim is released under the MIT License. See LICENSE.

Metadata

Release files for BornSim 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for BornSim 0.10.0
File Size Uploaded Provenance Actions
bornsim-0.10.0.tar.gz 10.1 MB Without provenance Details for bornsim-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for BornSim 0.10.0
File Interpreter ABI Platform Actions
bornsim-0.10.0-py3-none-any.whl Python 3 none any Details for bornsim-0.10.0-py3-none-any.whl

Total release size: 10.2 MB

Release files / bornsim-0.10.0.tar.gz

Download URL bornsim-0.10.0.tar.gz
Size 10.1 MB
Tags Source
SHA-256 checksum
How to use checksums
c301466ad8dfa0946b6e9eb1e30b7c3261ad8823dda24284a4cafd9da081c18f
BLAKE2b-256 checksum
How to use checksums
9d356941ce0a868a6d37d2c34deb6c5796f0435386886659f67803b0df148dd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / bornsim-0.10.0-py3-none-any.whl

Download URL bornsim-0.10.0-py3-none-any.whl
Size 86.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0933d651f595cea8d5117f2928e5e5be677aa05969f8c2850e6adc0f39d690cc
BLAKE2b-256 checksum
How to use checksums
44a0b84e0fb74b11926f0a48136bd9990a52ad4f6565f4d46601090d20d496ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Security for BornSim 0.10.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page