Tools to integrate Langevin equations for directed-percolation and absorbing phase transition models
Project description
langevin
Tools to integrate Langevin equations of absorbing phase transition (APT) type — with a focus on solution of the directed percolation (DP) Langevin equation.
The langevin package implements the operator-splitting method originally developed by Dornic et al (2005), Pechenik & Levine (1999) and others, and improved upon by Weissmann et al (2018).
It provides a Python wrapper around core C++ heavily adapted from a code base written by Paula Villa Martín, extended by Victor Buendía ("VMB"), and arising from earlier efforts by Ivan Dornic and Juan Bonachela. The wrapper provides easy access to the Langevin integrator, and broad opportunity to experiment, adapt, and extend it further.
The current C++ implementation extends the VMB code to allow run-time specification of grid dimension and size, boundary topology (bounded or periodic), boundary conditions, and initial conditions. It further provides tools for running model integration in batches, time-slicing the Langevin field grid, and recording of time-series of grid properties.
The equation solved in the demo here is the DP Langevin for a 2D grid with initial values sampled from U[0, 0.3]:
where ρ(x,t) is the order parameter field, a and b are rate constants, D is the diffusion rate over x, ξ(x,t) is Gaussian white noise (uncorrelated, zero mean, unit variance), and η is the "demographic" noise amplitude.
See Victor Buendía's fork of Paula Villa Martín's repo for details on more general applications and on how the integration scheme is implemented.
Installation
In most circumstances, pip install langevin should suffice to get things up and running.
See below more comprehensive installation notes, or here in the main documentation.
Optional: Python environment
First, set up a suitable Python environment. This is optional, but recommended.
The simplest tool is uv, but there are several other options.
If you use conda or miniconda, take a look at the environment.yml file provided.
Using uv, all that's needed is to create an
appropriately named folder (within which you want to use the environment), navigate to it, and execute:
uv venv --python=3.14
source .venv/bin/activate
where the --python option forces uv to choose version 3.14 of the Python interpreter (recommended).
Package from PyPI
Then, install the langevin package from PyPI:
[uv] pip install langevin
where uv is needed only if you are using that tool.
This step should automatically install all the dependencies as well.
If it does not, see below.
Usage
Simple demonstration scripts are provided in demos/. More complete examples are provided in the simulation/ directory. The easiest route is to git clone the repo to get these files, or you can download one-by-one.
Platform support
All major platforms (Linux, macOS, Windows) are supported: binary wheels are provided for all the recent releases. If you have a different vintage OS, you can build from source (using pip — see below), and the code should work fine.
Software design
The structure of the DP/APT Langevin-equation integrator package is broadly as follows (detailed documentation is available here).
First, there is a wrapper file called cplusplus/dp/wrapper_dplvn.cpp that uses pybind11 to link the C++ code to a Python runtime.
Next, the code is split into a hierarchy of three groups, with each corresponding file denoted by one of following prefixes: (1) sim_dplangevin_, (2) dplangevin_ and (3) langevin_:
-
The
cplusplus/dp/sim_dplangevin_*files provide aSimDPclass, made available through the wrapper at the Python level, required to manage and execute DP Langevin model integration. ThisSimDPclass instantiates aDPLangevinclass integrator to do the hard work of numerical integration of the stochastic differential equation. Langevin field density grids are returned to Python (via the wrapper) asnumpyarrays as are time series of the mean density field and its corresponding epochs. -
The
cplusplus/dp/dplangevin_*files define thisDPLangevinintegrator class. They inherit the generalBaseLangevinintegrator class and implement several methods left undefined by that parent; most important, they define methods implementing the particular functional form of the directed-percolation Langevin equation and its corresponding nonlinear, deterministic integration step in the split operator scheme.Other types of absorbing-phase transition-type Langevin equation could be implemented with alternate subclasses of
BaseLangevinand alternate versions of theSimDPclass. -
The
cplusplus/langevin_*source files provide the baseBaseLangevinclass that implements the operator-splitting integration method in a fairly general fashion. Grid geometry and topology, boundary conditions, initial conditions, the integration scheme, and a general form of the Langevin equation are all coded here. The core Dornic-style integrator is a heavily altered version of the Villa-Martín and Buendía code.
Build from source
Dependencies
At minimum, langevin needs Python≥3.12 and the package pybind11. To run the demos, you will also need numpy, matplotlib, jupyter, ipython, along with pandas, tqdm, and ffmpeg-python.
If you are using conda or miniconda, it would be best to install them using
the environment.yml file, instead of relying on pip to do the job (mixing pip and conda is not a great idea anyway, but langevin is not yet available on conda).
If you want to build locally, you will also need meson-python, wheel, pybind11, and ninja.
To turn density field image sequences into animations, langevin uses ffmpeg-python, which assumes that ffmpeg is itself installed on your system.
On Linux platforms, matplotlib has a tendency to complain about missing fonts, e.g., Arial, generating large numbers of warnings in some of the notebooks. This can be fixed by installing the missing fonts and ensuring that matplotlib's cache is refreshed.
Build using pip install
If your platform is not explicitly supported with a pre-built binary, the following will force a build from source:
[uv] pip install -v langevin --no-binary langevin
Alternative: build by hand
The package can also be built "by hand."
Some build info is provided in the cplusplus/ directory. The build system is meson-python, using pybind11 as the C++ wrapper.
References
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 langevin-2025.12.16a4.tar.gz.
File metadata
- Download URL: langevin-2025.12.16a4.tar.gz
- Upload date:
- Size: 52.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da6e6aaf42b7e8e6312789b12bb20ba3c1477e2955cf79c9fef18a7511b1ac8f
|
|
| MD5 |
ec7e1c9fa4b86de2c57279972d8b383e
|
|
| BLAKE2b-256 |
a526619d8fcaea2b1783054c68c2f43ae09e1aeb778c253715a77a212f8fe314
|
Provenance
The following attestation bundles were made for langevin-2025.12.16a4.tar.gz:
Publisher:
publish-pypi.yml on cstarkjp/Langevin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langevin-2025.12.16a4.tar.gz -
Subject digest:
da6e6aaf42b7e8e6312789b12bb20ba3c1477e2955cf79c9fef18a7511b1ac8f - Sigstore transparency entry: 767047476
- Sigstore integration time:
-
Permalink:
cstarkjp/Langevin@50e276a1a95eb4b1afdb2bd9c0539920a5a7c987 -
Branch / Tag:
refs/tags/v2025.12.16a4 - Owner: https://github.com/cstarkjp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@50e276a1a95eb4b1afdb2bd9c0539920a5a7c987 -
Trigger Event:
release
-
Statement type:
File details
Details for the file langevin-2025.12.16a4-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: langevin-2025.12.16a4-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 158.4 kB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
676d34d977495e11b50fc92cc705fcd480df3e0d4eeb2698ac27495e757d9d6f
|
|
| MD5 |
f717000bb226b72f6d91fb083f412c35
|
|
| BLAKE2b-256 |
e2676bb0a077e04bc6ddfb71dd23545eb3ab71455a15ba32719adec1005a189c
|
Provenance
The following attestation bundles were made for langevin-2025.12.16a4-cp314-cp314-win_amd64.whl:
Publisher:
publish-pypi.yml on cstarkjp/Langevin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langevin-2025.12.16a4-cp314-cp314-win_amd64.whl -
Subject digest:
676d34d977495e11b50fc92cc705fcd480df3e0d4eeb2698ac27495e757d9d6f - Sigstore transparency entry: 767047490
- Sigstore integration time:
-
Permalink:
cstarkjp/Langevin@50e276a1a95eb4b1afdb2bd9c0539920a5a7c987 -
Branch / Tag:
refs/tags/v2025.12.16a4 - Owner: https://github.com/cstarkjp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@50e276a1a95eb4b1afdb2bd9c0539920a5a7c987 -
Trigger Event:
release
-
Statement type:
File details
Details for the file langevin-2025.12.16a4-cp314-cp314-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: langevin-2025.12.16a4-cp314-cp314-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 9.9 MB
- Tags: CPython 3.14, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9864aa2c01cc6b12604232dabace45df5ded70e69437c848eee6bbc3204c4b87
|
|
| MD5 |
e25b5a549aba20d73a681be68f39ce8d
|
|
| BLAKE2b-256 |
1682de45e9600ca079ea3ff135784a1419b0617772f34a9606de3278c9813070
|
Provenance
The following attestation bundles were made for langevin-2025.12.16a4-cp314-cp314-manylinux_2_39_x86_64.whl:
Publisher:
publish-pypi.yml on cstarkjp/Langevin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langevin-2025.12.16a4-cp314-cp314-manylinux_2_39_x86_64.whl -
Subject digest:
9864aa2c01cc6b12604232dabace45df5ded70e69437c848eee6bbc3204c4b87 - Sigstore transparency entry: 767047483
- Sigstore integration time:
-
Permalink:
cstarkjp/Langevin@50e276a1a95eb4b1afdb2bd9c0539920a5a7c987 -
Branch / Tag:
refs/tags/v2025.12.16a4 - Owner: https://github.com/cstarkjp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@50e276a1a95eb4b1afdb2bd9c0539920a5a7c987 -
Trigger Event:
release
-
Statement type:
File details
Details for the file langevin-2025.12.16a4-cp314-cp314-macosx_15_0_arm64.whl.
File metadata
- Download URL: langevin-2025.12.16a4-cp314-cp314-macosx_15_0_arm64.whl
- Upload date:
- Size: 194.9 kB
- Tags: CPython 3.14, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f5403bb7bf1e07c741c442222c5e00c5912f4a9e4121fbbc0a0fe15b2b54f06
|
|
| MD5 |
28b60e56a116a13abef85333bce956c1
|
|
| BLAKE2b-256 |
1f4b66cf7ff85e1114613101f8a44be1b2f48d012f63746532255aa8f9282b07
|
Provenance
The following attestation bundles were made for langevin-2025.12.16a4-cp314-cp314-macosx_15_0_arm64.whl:
Publisher:
publish-pypi.yml on cstarkjp/Langevin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langevin-2025.12.16a4-cp314-cp314-macosx_15_0_arm64.whl -
Subject digest:
2f5403bb7bf1e07c741c442222c5e00c5912f4a9e4121fbbc0a0fe15b2b54f06 - Sigstore transparency entry: 767047497
- Sigstore integration time:
-
Permalink:
cstarkjp/Langevin@50e276a1a95eb4b1afdb2bd9c0539920a5a7c987 -
Branch / Tag:
refs/tags/v2025.12.16a4 - Owner: https://github.com/cstarkjp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@50e276a1a95eb4b1afdb2bd9c0539920a5a7c987 -
Trigger Event:
release
-
Statement type:
File details
Details for the file langevin-2025.12.16a4-cp314-cp314-macosx_14_0_arm64.whl.
File metadata
- Download URL: langevin-2025.12.16a4-cp314-cp314-macosx_14_0_arm64.whl
- Upload date:
- Size: 194.5 kB
- Tags: CPython 3.14, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5272cb8b74992efc34be029ce371460dfaefdaa5688892532714cee12964647
|
|
| MD5 |
6aab772d571e65a85ab58288032dfb82
|
|
| BLAKE2b-256 |
3c00e4abac546eca476bdaf3c7158208a05e8edc094f1698f3b0233b61d8bc1d
|
Provenance
The following attestation bundles were made for langevin-2025.12.16a4-cp314-cp314-macosx_14_0_arm64.whl:
Publisher:
publish-pypi.yml on cstarkjp/Langevin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langevin-2025.12.16a4-cp314-cp314-macosx_14_0_arm64.whl -
Subject digest:
e5272cb8b74992efc34be029ce371460dfaefdaa5688892532714cee12964647 - Sigstore transparency entry: 767047493
- Sigstore integration time:
-
Permalink:
cstarkjp/Langevin@50e276a1a95eb4b1afdb2bd9c0539920a5a7c987 -
Branch / Tag:
refs/tags/v2025.12.16a4 - Owner: https://github.com/cstarkjp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@50e276a1a95eb4b1afdb2bd9c0539920a5a7c987 -
Trigger Event:
release
-
Statement type: