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()
    if simulation.steps % 50 == 0:
        simulation.rescale_velocities(300)
    simulation.sample()
    if simulation.steps % 100 == 0:
        viewer.update(simulation)

step() advances one timestep, 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.0b2

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.0b2
File Size Uploaded Provenance Actions
pylj-2.0.0b2.tar.gz 70.8 kB With provenance Details for pylj-2.0.0b2.tar.gz

Built distribution (wheel)

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

Total release size: 154.9 kB

Release files / pylj-2.0.0b2.tar.gz

Download URL pylj-2.0.0b2.tar.gz
Size 70.8 kB
Tags Source
SHA-256 checksum
How to use checksums
644490d453e7a3769a2ae0ba98b8af83b61f923e428713a81b8e8233d07ac217
BLAKE2b-256 checksum
How to use checksums
413faf9982a98a1025242bc052d23bd311d6f39cbba65798cfade0ade96e6f26
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 7, 2026.

Transparency log

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

Download URL pylj-2.0.0b2-py3-none-any.whl
Size 84.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1bd8188f79fac0637335cdd2d2b8755926ecf1dfe6770ca561740791c7f91726
BLAKE2b-256 checksum
How to use checksums
7877f6b936dd59c801adab056fb60934650549e575c45de63711d846c0d2e223
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 7, 2026.

Transparency log

Security for pylj 2.0.0b2

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.0b2.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 7, 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