Skip to main content

Prepare LAMMPS simulation input files from RASPA3-style JSON force fields

Project description

lammps-prep

Crates.io PyPI GitHub Actions

Prepare LAMMPS simulation input files from RASPA3-style JSON force fields.

Given a force_field.json (pseudo-atom masses, charges, and LJ parameters) plus per-species <name>.json molecule files, lammps_prep packs molecules at a target mass density and writes two files:

  • data.lmp — LAMMPS data file (box dimensions, atom positions, bonds, angles, dihedrals)
  • forcefield.lmp — LAMMPS settings file (masses, pair/bond/angle/dihedral coefficients, charge assignments)

Installation

pip install lammps-prep          # pre-built wheel (Python + CLI binary bundled)

Or build from source:

pip install maturin
git clone https://github.com/JelleLagerweij/ff_creation.git
cd ff_creation
maturin develop

Packmol must be installed separately and available on PATH for the pack packmol backend. The RASPA3 Python interface (raspalib) must be installed for the pack raspa backend:

pip install raspalib

CLI reference

lammps_prep pack packmol — random geometric packing

lammps_prep pack packmol [OPTIONS]

Options:
  --force-field <FORCE_FIELD_JSON>
          Path to force_field.json  [default: force_field.json]
  --species <MOLECULE_JSON>...
          Molecule definition file paths, one per species
          (order sets LAMMPS type numbering)
  --counts <COUNT>...
          Number of molecules per species (same order as --species;
          0 skips a species but keeps its atom/bond types in output)
  --density <DENSITY>
          Target mixture mass density, kg/m³
  --out-dir <DIR>
          Directory to write data.lmp and forcefield.lmp into  [default: .]
  --pair-style <PAIR_STYLE>
          Pair style preset: tip4p | lj_cut | lj_cut_coul_long  [default: lj_cut]
  --explicit-lb
          Write every Lorentz-Berthelot cross-pair explicitly instead of
          relying on `pair_modify mix arithmetic`
  --tolerance <TOLERANCE>
          Packmol packing tolerance in Å (min distance between atoms from
          different molecules)  [default: 2.0]
  -h, --help
          Print help

Example:

lammps_prep pack packmol \
  --species CO2.json heptane.json \
  --counts 200 50 \
  --density 700 \
  --out-dir build/

lammps_prep pack raspa — NVT MC equilibration via RASPA3

lammps_prep pack raspa [OPTIONS]

Options:
  --force-field <FORCE_FIELD_JSON>
          Path to force_field.json  [default: force_field.json]
  --species <MOLECULE_JSON>...
          Molecule definition file paths, one per species
  --counts <COUNT>...
          Number of molecules per species
  --density <DENSITY>
          Target mixture mass density, kg/m³
  --out-dir <DIR>
          Directory to write data.lmp and forcefield.lmp into  [default: .]
  --pair-style <PAIR_STYLE>
          Pair style preset: tip4p | lj_cut | lj_cut_coul_long  [default: lj_cut]
  --explicit-lb
          Write every Lorentz-Berthelot cross-pair explicitly
  --temperature <TEMPERATURE>
          NVT simulation temperature in K  [default: 300.0]
  --init-cycles <INIT_CYCLES>
          Initialization cycles (random placement + overlap removal)  [default: 2000]
  --equil-cycles <EQUIL_CYCLES>
          Equilibration cycles (discarded)  [default: 2000]
  --prod-cycles <PROD_CYCLES>
          Production cycles; the final frame becomes the LAMMPS starting
          config  [default: 1000]
  --cutoff <CUTOFF>
          LJ and Coulomb cutoff radius in Å  [default: 12.0]
  -h, --help
          Print help

Example:

lammps_prep pack raspa \
  --species CO2.json heptane.json \
  --counts 200 50 \
  --density 700 \
  --temperature 300 \
  --out-dir build/

Requires raspalib and python/python3 on PATH.


lammps_prep density — mixture density estimation (stubs)

These subcommands are reserved for future releases. Each currently exits with "not yet implemented".

lammps_prep density pr           # Peng-Robinson EOS
lammps_prep density pc-saft      # PC-SAFT EOS
lammps_prep density epc-saft     # ePC-SAFT EOS (electrolyte)
lammps_prep density laliberte    # Laliberte volumetric correlation

Python API

from lammps_prep.pack import packmol, raspa
from lammps_prep import PairSetup

# --- Packmol packing ---
summary = packmol(
    species=["CO2.json", "heptane.json"],
    counts=[200, 50],
    density=700.0,
    out_dir="build",
    pair_style=PairSetup.LjCut,
)
print(summary)

# --- RASPA3 NVT equilibration ---
summary = raspa(
    species=["CO2.json", "heptane.json"],
    counts=[200, 50],
    density=700.0,
    out_dir="build",
    temperature=300.0,
    init_cycles=2000,
    equil_cycles=2000,
    prod_cycles=1000,
)
print(summary)

Density stubs raise NotImplementedError:

from lammps_prep.density import pr
pr(...)  # NotImplementedError: Peng-Robinson EOS is not yet implemented.

Force-field file format

lammps_prep reads RASPA3-style JSON files.

force_field.json

{
  "MixingRule": "Lorentz-Berthelot",
  "PseudoAtoms": [
    { "name": "O_h2o", "mass": 15.9994,  "charge": -1.1128 },
    { "name": "H_h2o", "mass":  1.00794, "charge":  0.5564 }
  ],
  "SelfInteractions": [
    { "name": "O_h2o", "type": "lennard-jones", "parameters": [78.0,  3.1589] },
    { "name": "H_h2o", "type": "lennard-jones", "parameters": [ 0.0,  0.0   ] }
  ],
  "BinaryInteractions": [
    { "names": ["O_h2o", "Na"], "type": "lennard-jones",
      "parameters": [140.043, 2.8904], "source": "MadridT2023" }
  ]
}

parameters for LJ are [ε/k_B (K), σ (Å)].
BinaryInteractions override the Lorentz-Berthelot mixing rule for a specific pair.

<species>.json

{
  "pseudoAtoms": [
    ["O_h2o", [0.000,  0.000, 0.0]],
    ["H_h2o", [0.757,  0.586, 0.0]],
    ["H_h2o", [-0.757, 0.586, 0.0]]
  ],
  "Connectivity": [[0,1],[0,2]],
  "Type": "rigid",
  "Bonds": [ [["O_h2o","H_h2o"], "HARMONIC", [450000.0, 0.9572]] ],
  "Bends": [ [["H_h2o","O_h2o","H_h2o"], "HARMONIC", [55000.0, 104.52]] ],
  "CriticalTemperature": 647.1,
  "CriticalPressure": 22064000.0,
  "AcentricFactor": 0.345
}
  • Bonds / Bends are optional for "Type": "rigid" molecules (LAMMPS SHAKE/RIGID placeholders are written with a warning).
  • Torsions follow the TRAPPE potential form: [c0, c1, c2, c3] in K.

Project structure

lammps_prep/
├── Cargo.toml           # Workspace root
├── pyproject.toml       # Python package configuration (maturin)
├── README.md
├── rust/
│   ├── Cargo.toml       # Rust crate (name = "lammps_prep")
│   └── src/
│       ├── lib.rs       # Library exports
│       ├── main.rs      # CLI entry point  (bin = "lammps_prep")
│       ├── cli.rs       # Subcommand parsing and dispatch
│       ├── ff.rs        # Force-field data structures
│       ├── lammps.rs    # LAMMPS file writers
│       ├── packmol.rs   # Packmol interface
│       └── python.rs    # PyO3 bindings (module = "lammps_prep._native")
└── python/
    └── lammps_prep/
        ├── __init__.py   # Package init (exports PairSetup)
        ├── pack.py       # packmol() and raspa() functions
        ├── density.py    # Density stubs (all raise NotImplementedError)
        ├── raspa_init.py # raspalib NVT MC helper
        └── _cli.py       # Console script entry point

Development

# Build Rust library, CLI binary, and Python extension in one step
maturin develop

# Run Rust tests
cd rust && cargo test

# Run Rust linter
cd rust && cargo clippy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

lammps_prep-0.2.6-cp312-cp312-win_amd64.whl (367.0 kB view details)

Uploaded CPython 3.12Windows x86-64

lammps_prep-0.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (503.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

lammps_prep-0.2.6-cp312-cp312-macosx_11_0_arm64.whl (437.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lammps_prep-0.2.6-cp311-cp311-win_amd64.whl (369.8 kB view details)

Uploaded CPython 3.11Windows x86-64

lammps_prep-0.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (517.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

lammps_prep-0.2.6-cp311-cp311-macosx_11_0_arm64.whl (445.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

lammps_prep-0.2.6-cp310-cp310-win_amd64.whl (369.6 kB view details)

Uploaded CPython 3.10Windows x86-64

lammps_prep-0.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (517.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

lammps_prep-0.2.6-cp310-cp310-macosx_11_0_arm64.whl (445.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file lammps_prep-0.2.6-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: lammps_prep-0.2.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 367.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lammps_prep-0.2.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b50209adccf2713ff3c54578abc3a553fa941b6b9ff2d2fea9befc3699459a54
MD5 ca43cd64794630c7c9b183c8b5b438f0
BLAKE2b-256 a0926fb965e1ae3df460a440cc59c491beff549f812a760630093755b41ee8a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for lammps_prep-0.2.6-cp312-cp312-win_amd64.whl:

Publisher: release.yml on JelleLagerweij/ff_creation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lammps_prep-0.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lammps_prep-0.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4f19c4570eaf10adbbb063ff4b3f1e4cdd95500d26dd6a2ba7b3387d12234edd
MD5 58bc8e0c8c495744aa6e384ba6fe751a
BLAKE2b-256 2b53637ba93419cb5cb9fef8c111df0f39c8ebe9936fe3bfd045b30819e6b26d

See more details on using hashes here.

Provenance

The following attestation bundles were made for lammps_prep-0.2.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on JelleLagerweij/ff_creation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lammps_prep-0.2.6-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lammps_prep-0.2.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0e314dc898e877a4ecb1e2e446c2ca88d800384fe06ab84f8e6b5ed73d4887e6
MD5 59539a610d6cea8998a914a1a48e3867
BLAKE2b-256 31547078a62a4ff8f256b646b1e94dc88c197e461e67dae7d3289d707252a9bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for lammps_prep-0.2.6-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on JelleLagerweij/ff_creation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lammps_prep-0.2.6-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: lammps_prep-0.2.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 369.8 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lammps_prep-0.2.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7f709d5e5a7d2d254a1d2e5021f4d08c8a6207c5506a38e99329fd473edc7d4c
MD5 725dc7db99635b31d058d6479d41d89d
BLAKE2b-256 c9c76bd96d8ff7eafd971e246ac2fbf99766ca3a576e2e69afa70b691ab38c62

See more details on using hashes here.

Provenance

The following attestation bundles were made for lammps_prep-0.2.6-cp311-cp311-win_amd64.whl:

Publisher: release.yml on JelleLagerweij/ff_creation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lammps_prep-0.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lammps_prep-0.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 59df73f4786c43fcc30ff5e3ebe611b3a2c49faeb7869dcea70ad74844b5e0f6
MD5 46c6f2be841b1e8dd2e316114367ccc8
BLAKE2b-256 d70956df952e1d2430e302925cc2037f9a507215bb964230a5e099b09b0071ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for lammps_prep-0.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on JelleLagerweij/ff_creation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lammps_prep-0.2.6-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lammps_prep-0.2.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 def981a2f06d1e93cb6a8a4a9d62340a6b6e638696c1c5accc03ada7fa5f39a6
MD5 4fdcdeb3414049399013d4a013bb13bc
BLAKE2b-256 c422e46ae5679799614af821e312c05e14b380d06e6d9f4bf8127d400a2264a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for lammps_prep-0.2.6-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on JelleLagerweij/ff_creation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lammps_prep-0.2.6-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: lammps_prep-0.2.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 369.6 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lammps_prep-0.2.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1b0c71c5a4c12f3470c51f872f73699c22c81df349f396092b8a70072b8291ca
MD5 3e125a92b59249dc1569361122422edb
BLAKE2b-256 e81da53bf4325a58b9ee3ba175add68de44f4ca7fd9524c9f74c5f76e336aad5

See more details on using hashes here.

Provenance

The following attestation bundles were made for lammps_prep-0.2.6-cp310-cp310-win_amd64.whl:

Publisher: release.yml on JelleLagerweij/ff_creation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lammps_prep-0.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lammps_prep-0.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 af7c9386948e15388f6a26678e299c43e568bf68d1ee2f3842672f6519f4eca8
MD5 149d5fbc4541dfe5d7829d4cd11f9ca9
BLAKE2b-256 5033a441c02ce3f27539cbfcb20435a89206119ad324f52dbb7bc979d1f3a69e

See more details on using hashes here.

Provenance

The following attestation bundles were made for lammps_prep-0.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on JelleLagerweij/ff_creation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lammps_prep-0.2.6-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lammps_prep-0.2.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 657560b4b0f7ea627982a7d390c563ce06322c691961f766fd2ed4926ee65388
MD5 2d6fec4122b5923c1123f504e4b98a90
BLAKE2b-256 80d9dd9adaa76fca18d6ed62f631ea11a12d22030a30b9a25b94e1124aac519f

See more details on using hashes here.

Provenance

The following attestation bundles were made for lammps_prep-0.2.6-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on JelleLagerweij/ff_creation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page