Skip to main content
BornSim — vector wave scattering in refractive media

BornSim

Simulate how light scatters through three-dimensional refractive media.

BornSim status

Python

Python 3.11 or newer

Release

Latest release tag

License

MIT License

Tests

Test status

Documentation

Documentation build status

BornSim is a Python toolkit for finite-volume, vector Born-series calculations. Build random or structured samples, calculate their scattering response, and inspect results with BornSim’s interactive Plotly 3D plotting methods.

A sample and its calculated directional scattering
Plotly isosurfaces of a seeded three-dimensional refractive-index sample. Directional phase-function density rendered radially on a three-dimensional surface.

Real-space medium Plotly isosurfaces show the refractive-index field in physical coordinates.

Angular scattering Surface radius and color show the phase density in each observation direction.

These figures are static exports of BornSim’s own Plotly figures, generated from a seeded calculation. Regenerate them with docs/images/generate_readme_plots.py. Static image export requires Kaleido; the checked-in figures were generated with Kaleido 0.2.1. Volume opacity is a display setting, not a measure of material absorption.

What you can model

  • Gaussian, exponential, and Whittle–Matérn random fields.

  • Seeded random sphere collections and structured particle geometries.

  • Arbitrary incident directions and linear, circular, elliptical, or unpolarized illumination.

  • Finite-volume vector scattering through configurable Born order.

  • Directional phase functions, differential scattering, cross sections, anisotropy, absorption, ensemble uncertainty, and saved provenance.

  • Grid, angular, ensemble, and integral-equation residual diagnostics.

Quick start

Install BornSim and run a seeded calculation:

$ python -m pip install BornSim
from bornsim import AngularSampling, Grid, Solver, Source
from bornsim.medium.random_medium import GaussianMedium
from bornsim.units import ureg

grid = Grid(
    shape=(14, 14, 14),
    spacing=35 * ureg.nanometer,
)

medium = GaussianMedium(
    background_refractive_index=1.33,
    refractive_index_std=0.018,
    correlation_length=70 * ureg.nanometer,
)

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

source = Source(
    wavelength=532 * ureg.nanometer,
)

sampling = AngularSampling(
    n_points=61,
    azimuth_samples=16,
)

solver = Solver(
    source=source,
    sampling=sampling,
    order=2,
)

result = solver.solve(
    target=volume,
)

print(f"Scattering coefficients: {result.mu_s.to('1 / millimeter')}")

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

phase_figure = result.plot_phase_function(
    order=2,
)

medium_figure.show()

phase_figure.show()

For random-medium statistics across independent realizations, use solver.ensemble(medium=..., grid=..., ensemble_sampling=...). For a fixed geometry, compose shapes with StructuredMedium and pass its voxelized volume to solver.solve.

Plotting

BornSim uses Plotly exclusively to render three-dimensional media and directional phase functions. Rotate, zoom, and hover to inspect values. 2D plots are reserved for curves and diagnostics, never spatial views of a 3D sample. Plotly figures open no window during construction and can be saved as self-contained HTML:

phase_figure.write_html(
    file="phase-function.html",
    include_plotlyjs=True,
)

Use result.plot() for a Matplotlib curve of differential scattering, or result.plot_phase_function() for its default directional 3D phase surface. Choose view="angular" or view="polar" for 2D Matplotlib phase views. Spatial media are always shown as Plotly 3D figures; inspect voxelization effects through 3D views and grid refinement.

Model and interpretation

BornSim solves a finite-sample volume-integral model with the linearized dielectric contrast \(\delta\varepsilon \approx 2 n_0 \delta n\). It does not include the quadratic \(\delta n^2\) term. Decreasing successive field terms do not prove convergence of the Born series.

Reported scattering coefficients are finite-sample cross sections divided by the simulated voxel-box volume. They are not automatically intrinsic, infinite-medium transport coefficients. Check grid, angular, sample-size, synthesis-box, and ensemble convergence before quantitative interpretation. Wavelengths, lengths, angles, and dimensional outputs carry explicit units; refractive indices are plain numbers.

Learn more

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

  • Examples — runnable studies of random media, structures, ensembles, and Born orders.

  • Reliability guide — numerical validation and convergence checks.

  • Source and issues — code, questions, and contributions.

BornSim requires Python 3.11 or newer. For development, install the testing and documentation extras with python -m pip install -e ".[testing,documentation]".

License

BornSim is released under the MIT License. See LICENSE.

Metadata

Release files for BornSim 0.11.2

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.11.2
File Size Uploaded Provenance Actions
bornsim-0.11.2.tar.gz 12.0 MB Without provenance Details for bornsim-0.11.2.tar.gz

Built distribution (wheel)

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

Total release size: 12.1 MB

Release files / bornsim-0.11.2.tar.gz

Download URL bornsim-0.11.2.tar.gz
Size 12.0 MB
Tags Source
SHA-256 checksum
How to use checksums
7bdbe12e658f4f38fa5ee0e01986fd897159bc206910103089e4e44270396456
BLAKE2b-256 checksum
How to use checksums
f9f747442c904c970af7dd77f54b491bec1721ee355f82e056207311b2573adc
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.11.2-py3-none-any.whl

Download URL bornsim-0.11.2-py3-none-any.whl
Size 87.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebaf33d382324a476392f9559da533551d39953d91ddd41dd0007dc6fe42b332
BLAKE2b-256 checksum
How to use checksums
ffb7ea20e33e5e4302cd6eaab681035170bdaf09b02ff00cd887098b0f17dbba
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.11.2

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