A blazingly fast 4x4 transfer matrix method for simulating reflection though stratified media
Project description
refloxide
CI PyPI version codecov Python 3.13+ uv Ruff ty License: GPL-3.0 Renovate
A blazingly fast 4x4 transfer matrix method for simulating reflection though stratified media.
This project is designed to be a fast core backend for simulating reflectivity using the 4x4 transfer matrix method. We are basing the code on the following pre existing codebases, but this is a ground up rewrite.
- refnx - this library is great for simulation reflectivity though scalar media, but fails at tensor indeces.
- refl1d - again, this works great for scal indeces, but is hard to work with in tensor materials, and with buidling complex structures.
We are basing this library on this paper:
Core philosophy
This library is designed as a pure functional simulation core. A caller defines a structure as fronting medium, backing medium, and a sequence of interior layers with thickness, interfacial roughness, and refractive-index parameterization. The solver then evaluates reflectivity for a requested set of experimental coordinates (for example angle, energy, or wavelength), and returns deterministic numerical arrays with no hidden mutable state.
The design intent is:
- Explicit physical inputs with validation at construction time.
- Predictable outputs for scalar and vectorized evaluation paths.
- Single-threaded execution as the default, so this engine composes cleanly inside larger fitting and orchestration systems that already manage parallelism.
- Strict separation between geometry (
Structure), optical parameterization (n), and propagation numerics (4x4 transfer-matrix kernels).
In short, refloxide should behave like a reliable computational kernel: give it a fully
specified layered system and a measurement grid, and it returns reproducible reflectivity
without side effects.
Features
- Fast and modern Python toolchain using Astral's tools (uv, ruff, ty)
- Type-safe with full type annotations
- Comprehensive documentation with MkDocs — View Docs
Installation
pip install refloxide
Or using uv (recommended):
uv add refloxide
Quick Start
import refloxide
print(refloxide.__version__)
Development
Prerequisites
- Python 3.13+
- uv for package management
Setup
git clone https://github.com/HarlanHeilman/refloxide.git
cd refloxide
make install
Running Tests
make test
# With coverage
make test-cov
# Across all Python versions
make test-matrix
Code Quality
# Run all checks (lint, format, type-check)
make verify
# Auto-fix lint and format issues
make fix
Prek
prek install
prek run --all-files
Documentation
make docs-serve
Dependency Updates
This project uses Renovate to keep dependencies up to date automatically. Renovate will open pull requests when new versions of dependencies are available.
To enable it, install the Renovate GitHub App and grant it access to this repository.
License
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file refloxide-0.1.4.tar.gz.
File metadata
- Download URL: refloxide-0.1.4.tar.gz
- Upload date:
- Size: 223.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fea0022335d390551a6980f266a76c510db2af07668efa9cd86fb672e9e6f7c
|
|
| MD5 |
c71258b91e8d2b245e28fc3321c6079f
|
|
| BLAKE2b-256 |
2fee025ade20c5414747046d69e1be7d59f3daed19a587a6622b99ae0760b33b
|
File details
Details for the file refloxide-0.1.4-cp315-cp315-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: refloxide-0.1.4-cp315-cp315-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 437.2 kB
- Tags: CPython 3.15, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02bd3797ad9849495961e47b3c59cc3052d232b7a83847430cdd51394c87b59c
|
|
| MD5 |
25fb2fc1ba9c041c956038b9e2c663f2
|
|
| BLAKE2b-256 |
342ca053df6affe2f0c12fa24a5586c93bb43b590712475c0282a1c9a993ff37
|
File details
Details for the file refloxide-0.1.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: refloxide-0.1.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 437.2 kB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afa2224a0f24c00eb75fbb44860aeb2f0ae69c358dbd019c6c255731403f25c0
|
|
| MD5 |
b0acc462d8c6805a307338b0471e47e3
|
|
| BLAKE2b-256 |
a23318b1d3775b193e0bd5ff8182aae82dc40e7e7d5eb574e39ebb79f412fe3f
|
File details
Details for the file refloxide-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: refloxide-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 437.0 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20cffd7506e4f823254624795a95af5827e637ecccf6e0ab650a821daf3bef7d
|
|
| MD5 |
7aedd0bba1fd9df048dd0be72e5fc40c
|
|
| BLAKE2b-256 |
65a930863d51002532541ec9546211b7b54c6075afb5a6f5f7b152bd797244a7
|