This release is a pre-release and may not be stable for production use.
pylj runs molecular dynamics and Metropolis Monte Carlo simulations of atoms interacting through pair potentials, in two dimensions, and draws and animates the atoms. It is a teaching code, written in Python and NumPy.
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.
Example
Twenty-five argon atoms at 300 K, run with molecular dynamics and then drawn:
import matplotlib.pyplot as plt
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)
for _ in range(2000):
simulation.step()
if simulation.steps % 50 == 0:
simulation.rescale_velocities(300)
simulation.sample()
simulation.view()
plt.show()
step() advances one timestep. sample() records the configuration in simulation.trajectory and 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
In a Jupyter notebook, simulation.animate() plays the recorded configurations as an animation. In a script, save simulation.animate().data to an .html file and open it in a web browser.
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)
for _ in range(5000):
simulation.step()
if simulation.steps % 10 == 0:
simulation.sample()
simulation.view()
plt.show()
Custom pair potentials are subclasses of PairPotential with an energies method and a forces method. The documentation describes building, running and sampling a simulation, pictures and animations, custom potentials, units, 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.0b3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pylj-2.0.0b3.tar.gz | 68.3 kB | With provenance | Details for pylj-2.0.0b3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pylj-2.0.0b3-py3-none-any.whl | Python 3 | none | any | Details for pylj-2.0.0b3-py3-none-any.whl |
Total release size: 148.6 kB
Release files / pylj-2.0.0b3.tar.gz
| Download URL | pylj-2.0.0b3.tar.gz |
|---|---|
| Size | 68.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf0c6843e2586616a30c1b764d3a1e9b9adaba2ed96fe4479d5655d92cb05355
|
|
BLAKE2b-256 checksum How to use checksums |
c39b0e3188ba63e6590d9e7f48954917e9ec88f206dae08240f6ff78ce3b5ada
|
| 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 14, 2026.
Transparency logRelease files / pylj-2.0.0b3-py3-none-any.whl
| Download URL | pylj-2.0.0b3-py3-none-any.whl |
|---|---|
| Size | 80.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b7cca2792caec07ae44f32dbe7b79de7c190686e7077e7501aff179df22ce87b
|
|
BLAKE2b-256 checksum How to use checksums |
8172388d8e54007b7cf88430bf59751fe79fb42ee0629eeebcfcf316e70a663e
|
| 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 14, 2026.
Transparency logSecurity for pylj 2.0.0b3
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.
Attestation for pylj-2.0.0b3.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 14, 2026.
Transparency logA 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.