Skip to main content

PyPI License

pyLSET logo

pyLSET: A Python Package for Level Set Simulations

polycrystal

pyLSET is a Python package for level set simulations of interface networks in 2D and 3D, with grain boundaries in polycrystals as the primary application. It runs on CPUs or GPUs through PyTorch. pyLSET is the level set sibling of the Python-based phase field crystal code pyPFC.

Features

  • Fixed Cartesian grids in 2D and 3D, with the dimensionality set by the input data.
  • Periodic or mirror boundary conditions, set independently along each axis.
  • One signed distance function phi per domain, positive inside, or optional coloring that stores domains that are not neighbors in shared fields to reduce memory use, with dynamic recoloring that prevents domains sharing a field from merging.
  • Signed distance fields from pixel or voxel label arrays (for example grain maps from diffraction contrast tomography) with the methods 'EDT', 'FMM', 'FSM' and 'Brute'.
  • Curvature driven evolution with explicit strong stability preserving Runge–Kutta schemes and an automatic time step.
  • Interface mobility and energy as constants, fields or functions of the two domains and the interface normal, with neighbor identification at junctions, misorientation utilities (Read–Shockley energy, sigmoidal mobility) and 'Heterogeneous', 'Gradient' and 'Stiffness' (inclination dependent, 2D) formulations.
  • Reinitialization by a second order reinitialization equation with subcell resolution ('PDE'), fast sweeping ('FSM'), fast marching ('FMM') or exact distances to the extracted interface ('Brute').
  • Interaction correction of voids and overlaps by projection ('MBO', 'Losasso') or by source terms ('Lagrange' with a global multiplier, 'Source' with per domain weights). With an energy function, the 'Source' weights near junctions follow from the local pair energies, which reproduces the equilibrium junction angles and the junction speed of unequal energies (see example 02).
  • Stored energy per domain as an additional driving force, so that domains grow into neighbors with higher stored energy, as in recrystallization.
  • Advection of the interfaces by a prescribed velocity field, given as arrays or as a function of position and time, with first order upwind, second order ENO or fifth order WENO differences (with the weights of Jiang and Peng or, by default, of Borges et al.).
  • A flag per domain stating whether its level set is evolved or immobile, for free surfaces, particles or inclusions, with a Neumann contact condition (zero normal derivative, so that interfaces meet immobile surfaces at 90 degrees) or a Dirichlet contact condition (interfaces pinned where they meet immobile surfaces).
  • CPU or GPU execution and selectable floating point precision.
  • Output of grid data (.vti), interfaces (.vtp) and time series (.pvd) for post-processing in software handling VTK-formatted files, and a pyLSET HDF5 format.

Installation

From the repository folder:

pip install -e .

Optional dependencies are installed with pip install -e ".[fmm]" (scikit-fmm for the 'FMM' method), ".[edt]" (a faster multilabel EDT), ".[mesh]" (Gmsh for mesh_domain()), ".[test]" and ".[docs]".

Quick start

import pylset

sim = pylset.setup_simulation([128.0, 128.0], [128, 128], device_type='CPU', use_coloring=True)
labels = sim.do_voronoi_labels(60, seed=7)   # or a grain map from experiments
sim.set_phi(sim.do_sdf(labels))

for step in range(1, 2001):
    sim.do_step_update()
    if step % 20 == 0:
        sim.do_reinitialization()
        sim.do_interaction_correction()
        sim.do_reinitialization()
        sim.do_recoloring()

sim.write_vtk_image('grains', [sim.get_phi_max(), sim.get_domain_map()], ['phi_max', 'grain_id'])
sim.write_vtk_interfaces('grain_boundaries')

See examples/ for Jupyter notebooks and docs/ for the documentation, which is built with mkdocs serve.

Tests

python -m unittest discover -s tests -v

The tests run on the CPU by default. Set PYLSET_TEST_DEVICE=gpu:1 to run them on GPU 1 and PYLSET_TEST_DTYPE=float32 for single precision.

License

pyLSET is distributed under the GNU General Public License v3.0 or later. See LICENSE.

References

Further details on level set modeling and example applications can be found in:

Metadata

Release files for pylset 0.0.1

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

Source distribution (sdist)

Source distribution for pylset 0.0.1
File Size Uploaded Provenance Actions
pylset-0.0.1.tar.gz 104.2 kB With provenance Details for pylset-0.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 196.6 kB

Release files / pylset-0.0.1.tar.gz

Download URL pylset-0.0.1.tar.gz
Size 104.2 kB
Tags Source
SHA-256 checksum
How to use checksums
857eeafcb743efd2031288e74ab4c648576c79643cba7b263b8b9b4b08cb9b4d
BLAKE2b-256 checksum
How to use checksums
c3224ff072ba3f809f14d4033ed006ad5a5a960ff34bfcfd27b847be9fd220c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 27, 2026.

Transparency log

Release files / pylset-0.0.1-py3-none-any.whl

Download URL pylset-0.0.1-py3-none-any.whl
Size 92.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
276686ca46ab6f321b361960cce4f76f0fa807bb4b193acc19883020fcd52698
BLAKE2b-256 checksum
How to use checksums
78a127b06687fa64b2cb1f27d4d92f6c8b7f08319c21fe4790828aee35be862c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 27, 2026.

Transparency log

Security for pylset 0.0.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pylset-0.0.1.tar.gz

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 Nov 27, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files Full provenance

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