Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

JOSE PyPI DOI Documentation Build License: MIT

pylj runs molecular dynamics and Metropolis Monte Carlo simulations of atoms interacting through pair potentials, in two dimensions, and draws them as they run. It is a teaching code, written in Python and NumPy. Its viewers redraw in a Jupyter notebook; in a script, a viewer's fig is a matplotlib figure that can be saved.

Installation

pip install --pre pylj

pylj 2.0 is a beta release, so pip needs --pre to install it. Without --pre, pip installs the previous release, 1.5.2.

pylj needs Python 3.12 or later. To watch the figures redraw you need a Jupyter notebook; pip install jupyterlab provides one. Start each notebook with %matplotlib inline.

Example

Twenty-five argon atoms at 300 K, run with molecular dynamics and drawn as they go:

from pylj import sample
from pylj.md import MDSimulation
from pylj.model import Model
from pylj.potentials import LennardJones, Species

argon = Species(mass=39.948, name="argon")
lj = LennardJones(epsilon=0.9497, sigma=3.372)
model = Model.single(argon, lj)
simulation = MDSimulation.initialise(model, number_of_atoms=25, temperature=300, box=40, seed=1)
viewer = sample.Interactions(simulation)
for _ in range(2000):
    simulation.step()
    simulation.heat_bath(300)
    simulation.sample()
    if simulation.steps % 100 == 0:
        viewer.update(simulation)

step() advances one timestep, heat_bath() holds the temperature, and sample() records the temperature, pressure and energies in simulation.samples as NumPy arrays:

simulation.samples.temperature.mean()  # K
simulation.samples.pressure.mean()     # kJ/mol/Angstrom^2, the two-dimensional pressure

The same model runs under Monte Carlo:

from pylj.mc import MCSimulation

simulation = MCSimulation.initialise(model, number_of_atoms=25, temperature=300, box=40, seed=1)
viewer = sample.Energy(simulation)
for _ in range(5000):
    simulation.step()
    if simulation.steps % 10 == 0:
        simulation.sample()
    if simulation.steps % 500 == 0:
        viewer.update(simulation)

Custom pair potentials are subclasses of PairPotential with an energies method and a forces method; custom plots are panes composed into a Viewer. The documentation describes the simulation classes, custom potentials, the viewers, and every module.

Contributing

Bug reports and pull requests are welcome on GitHub. CONTRIBUTING.md describes the development setup and the checks a pull request needs to pass.

Citing pylj

McCluskey, A. R., Morgan, B. J., Edler, K. J., and Parker, S. C. (2018). pylj: A teaching tool for classical atomistic simulation. Journal of Open Source Education, 1(2), 19. https://doi.org/10.21105/jose.00019

pylj.__cite__() opens the paper in a browser.

Metadata

Release files for pylj 2.0.0b1

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

Source distribution (sdist)

Source distribution for pylj 2.0.0b1
File Size Uploaded Provenance Actions
pylj-2.0.0b1.tar.gz 69.6 kB With provenance Details for pylj-2.0.0b1.tar.gz

Built distribution (wheel)

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

Total release size: 152.2 kB

Release files / pylj-2.0.0b1.tar.gz

Download URL pylj-2.0.0b1.tar.gz
Size 69.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bd008a9f8e6b0b1fc391c5987f67e2a1526697a383bace8e27295f41991a1075
BLAKE2b-256 checksum
How to use checksums
ce7ac284c6a9a73213d038a2025867a9ad68ae19e9ea9263b145e2e44ac6e95a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 6, 2026.

Transparency log

Release files / pylj-2.0.0b1-py3-none-any.whl

Download URL pylj-2.0.0b1-py3-none-any.whl
Size 82.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8a8d2011d0bba622140b115e54f6bd4bd95c9b4224b01c2f117aa3fa929226e
BLAKE2b-256 checksum
How to use checksums
934a428bf3ea83ca419538cdf7c53e40330fcad189f396e4ac3303e6b05bb9ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 6, 2026.

Transparency log

Security for pylj 2.0.0b1

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 pylj-2.0.0b1.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 Oct 6, 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
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