Skip to main content

lattice_mc: A Python Lattice-Gas Monte Carlo Module

PyPI version DOI JOSS status Documentation Status

lattice_mc is a Python module for performing (kinetic) lattice-gas Monte Carlo (LGMC) simulations of ionic transport in solid electrolytes.

In solid electrolytes, ionic motion is typically effected by a series of discrete “jumps” where ions move between adjacent lattice sites [1]. For dilute mobile ions, ionic trajectories are random walks, and simple analytical expressions exist that relate macroscopic transport coefficients, i.e. diffusion coefficients and ionic conductivities, to the microscopic jump frequency of individual ions [2,3]. Practical solid electrolytes have high mobile ion concentrations, with significant interparticle interactions producing deviations from the dilute limit random walk behaviour. In general, the quantitative effect of interparticle interactions cannot be determined analytically. As an alternative, numerical simulations, such as lattice-gas Monte Carlo methods, can be used to directly calculate these relationships. Lattice-gas Monte Carlo methods are particularly suited to studying how varying properties across broad classes of materials give quantitative differences in macroscopic ionic transport, and can be used to understand the different transport properties of materials with, for example, different crystal structures or mobile ion stoichiometries.

lattice_mc has been written to allow materials scientists and solid-state chemists to model how the microscopic physics of solid electrolytes (crystal structure, stoichiometry, interaction models) determine macroscopic transport behaviour (diffusion and ionic conduction), with the goal of understanding the factors that make different materials more or less useful for specific applications (e.g. Li-ion batteries or fuel cells).

lattice_mc builds square, honeycomb and cubic lattices, and reads lattices of any geometry from a sites file that defines the sites and their connectivity. Atoms jump between neighbouring sites, with volume exclusion: no two atoms occupy the same site [4]. Site energies, a nearest-neighbour interaction, and coordination-number energies, which depend on the number of occupied neighbours with each label, can be added in any combination. Simulations use a rejection-free kinetic Monte Carlo scheme [5]; the algorithms are described in more detail in Ref. [6]. A simulation reports the tracer and collective diffusion coefficients, the reduced ionic conductivity, the tracer and collective correlation factors, f and fI [7], and the time-averaged number of atoms on the sites with each label.

Installation

pip install lattice_mc

Or install the latest development version directly from GitHub:

pip install git+https://github.com/bjmorgan/lattice_mc.git

For development, clone the repository and install in editable mode with dev dependencies:

git clone git@github.com:bjmorgan/lattice_mc.git
cd lattice_mc
pip install -e ".[dev]"

Usage

import lattice_mc as lmc

lattice = lmc.cubic_lattice(4, 4, 4, spacing=1.0)

simulation = lmc.Simulation(
    lattice,
    params=lmc.SimulationParameters(temperature=298.0, rate_prefactor=1e13),
    n_atoms=16,
    nn_energy=0.1,
    lookup_table=True,
    seed=42,
)
simulation.run(n_jumps=1_000)  # equilibration
simulation.reset()
simulation.run(n_jumps=10_000)
results = simulation.results

print(f"D* = {results.tracer_diffusion_coefficient:.3e}")
print(f"f  = {results.tracer_correlation:.3f}")

Documentation

Documentation, including a user guide and API reference, is at lattice-mc.readthedocs.io.

Tests

Tests can be run using

pytest

The code requires Python 3.12 or above.

References

  1. C. R. A. Catlow, Sol. Stat. Ionics 8, 89 (1983).
  2. R. E. Howard and A. B. Lidiard, Rep. Prog. Phys. 27, 161 (1964).
  3. J. H. Harding, Defects and Transport in Ionic Solids, in Ionic Solids at High Temperatures ed. A. M. Stoneham, World Scientific (1989).
  4. R. Kutner Phys. Lett. 81A, 239 (1981).
  5. A. F. Voter, Introduction to the Kinetic Monte Carlo Method, in Radiation Effects in Solids, ed. K. E. Sickafus et al., Springer (2007).
  6. B. J. Morgan, R. Soc. Open Sci. 4, 170824 (2017).
  7. G. E. Murch Sol. Stat. Ionics 7, 177 (1982).

Metadata

Release files for lattice-mc 2.0.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 lattice-mc 2.0.0
File Size Uploaded Provenance Actions
lattice_mc-2.0.0.tar.gz 55.7 kB With provenance Details for lattice_mc-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lattice-mc 2.0.0
File Interpreter ABI Platform Actions
lattice_mc-2.0.0-py3-none-any.whl Python 3 none any Details for lattice_mc-2.0.0-py3-none-any.whl

Total release size: 85.3 kB

Release files / lattice_mc-2.0.0.tar.gz

Download URL lattice_mc-2.0.0.tar.gz
Size 55.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b4443ded59b4c4b470c587332d54b3a3871301196a6de95db7f99b9cfe5e286f
BLAKE2b-256 checksum
How to use checksums
98031e2f93f1be474598cf4a2067353fac1443fc3a0776d64061814f751e5880
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 3, 2026.

Transparency log

Release files / lattice_mc-2.0.0-py3-none-any.whl

Download URL lattice_mc-2.0.0-py3-none-any.whl
Size 29.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed28585c1f0ed8c4f5ff0a8091244082db9f1f947fdd83832a9bcabfe3275d55
BLAKE2b-256 checksum
How to use checksums
c3b34e24d39bf8e1c71dcefc0ab2734f828b3d7b1a5a85333912094c15a791cf
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 3, 2026.

Transparency log

Security for lattice-mc 2.0.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.

Full provenance

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

Select from 2 files

Attestation for lattice_mc-2.0.0.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 3, 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.

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