Skip to main content

Logo mdinterface: Build Interface Systems for Molecular Dynamics Simulations

PyPI version GitHub version Documentation

mdinterface is a Python package for building systems for Molecular Dynamics (MD) simulations. Initially developed for electrolyte/electrode solid-liquid interfaces, it is equally suited for pure solvent boxes, mixed-solvent electrolytes, and polymer networks.

Features

  • Layer-by-layer SimCell builder: add slabs, solvent regions, and vacuum gaps one step at a time; call .build() when done.
  • ASE & MDAnalysis integration: the assembled box converts to ase.Atoms or mda.Universe with a single call, ready for any downstream tool.
  • Multi-solvent support: mix solvents by molar ratio + density, ratio + total count, or explicit per-species molecule counts.
  • Ion placement: dissolve ions by count, molar concentration, or a spatially-varying concentration profile.
  • PACKMOL integration: handles molecular packing automatically; tolerance and dilation are tunable per layer.
  • Configurable stacking axis: build along Z (default) and permute to X or Y at the end.
  • Polymer builder: generate chains of arbitrary length from a monomer Specie.
  • Relaxation and MD with any ASE calculator: relax a Specie or run Langevin dynamics, e.g. with FAIRChem UMA (optional).
  • RESP charges: estimate partial charges with PySCF / gpu4pyscf (optional).
  • Force-field database: pre-defined parameters for common metals, noble gases, water models, and ions; or generate OPLS-AA parameters on the fly with LigParGen.
  • LAMMPS output: writes data files and force-field coefficient blocks ready to run.
  • GROMACS output (experimental): write .gro, .top, and per-species .itp files directly from SimCell.write_gromacs() or Specie.write_gromacs_itp().

Requirements

Mandatory dependencies are declared in pyproject.toml. pip install mdinterface installs them automatically, including RDKit and the upstream PACKMOL package and executable.

Optional packages

Molecular volume estimation

Specie.estimate_specie_volume() and Specie.estimate_specie_radius() require libarvo:

pip install libarvo

LigParGen (automatic OPLS-AA parameters)

Install the mdinterface-compatible LigParGen fork in the same environment and verify that ligpargen -h works:

python -m pip install "git+https://github.com/roncofaber/ligpargen.git@ad78036842318f166531be41cfcbc3563d7c5476"
conda install -c conda-forge openbabel
ligpargen -h
obabel -V

The pinned LigParGen revision preserves molecular chemistry during atom reordering. Open Babel is needed for coordinate-only ASE inputs; RDKit-backed inputs use MOL files.

Point mdinterface to your BOSS backend via config.ini:

# ~/.config/mdinterface/config.ini  (path is OS-dependent)
[settings]
BOSSdir = /path/to/boss          # native directory
# BOSSdir = /path/to/boss.sif   # Apptainer/Singularity container
# BOSSdir = boss-container:latest  # Docker image

The configuration file is read when LigParGen is invoked. An existing BOSSdir environment variable takes precedence over the file value.

BOSS is a 32-bit binary that can be awkward to run on modern systems. The boss-container repo provides a ready-to-build Docker/Apptainer image that handles the 32-bit library setup.

The container recipe does not distribute BOSS. Each licensed user builds a private image from their own BOSS installation. The resulting Docker image or Apptainer file contains BOSS and must not be published or shared beyond what the BOSS license permits.

Full parameterization development environment

The reproducible development environment combines mdinterface, LigParGen, Open Babel, AmberTools, and the CPU-only OpenFF stack. It uses Python 3.12 and NumPy 1.x to satisfy the current AmberTools dependency stack; the core package still supports Python 3.11-3.14.

mamba env create -f environment-full.yml
mamba activate mdinterface-full

OpenFF-to-mdinterface parameter import has been validated on Python 3.14, but OpenFF is not yet exposed as a supported Specie parameterization backend. The environment exists for developing and testing that integration. The normal mdinterface installation remains pip-installable and does not require OpenFF.

RESP charges with PySCF

Install the resp extra for PySCF and PyMBXAS. RESP fitting currently also requires the platform-specific gpu4pyscf, which is not installed by the extra.

FAIRChem UMA for relaxation and MD

Specie.relax_structure() and Specie.run_aimd() work with any ASE calculator. For the FAIRChem UMA example in the documentation:

pip install fairchem-core

Installation

  • Python 3.11-3.14
# Stable release
pip install mdinterface

# Development version
git clone https://github.com/roncofaber/mdinterface.git
cd mdinterface
pip install -e .

Optional extras:

pip install mdinterface[resp]   # RESP charge analysis
pip install mdinterface[aimd]   # FAIRChem for UMA relaxation and MD
pip install mdinterface[all]    # everything

The resp and all extras do not install gpu4pyscf; install the compatible build separately when using RESP fitting.

Contributors working on every parameterization backend can instead create the full environment described above with mamba env create -f environment-full.yml.

Quick start

from mdinterface import SimCell
from mdinterface.database import Water, Metal111

water = Water()
gold  = Metal111("Au")

simbox = SimCell(xysize=[15, 15])
simbox.add_slab(gold, nlayers=3)
simbox.add_solvent(water, zdim=20, density=1.0)
simbox.build()

atoms = simbox.to_ase()    # ase.Atoms, ready for AIMD, ML-MD, or any other tool

For LAMMPS, add ions and call write_lammps() instead:

from mdinterface.database import Ion

na = Ion("Na", ffield="Cheatham")
cl = Ion("Cl", ffield="Cheatham")

simbox = SimCell(xysize=[15, 15], verbose=True)
simbox.add_slab(gold, nlayers=3)
simbox.add_solvent(water, solute=[na, cl], nsolute=[5, 5], zdim=25, density=1.0)
simbox.add_slab(gold, nlayers=3)
simbox.build(padding=0.5)
simbox.write_lammps("data.lammps", atom_style="full", write_coeff=True)

More complete scripts are in the examples/ directory:

Script What it shows
electrode_interface.py Au / NaCl electrolyte / Au sandwich
smiles_box.py Unparameterized ethanol packing from SMILES
solvent_box.py Pure solvent + dissolved species
multisolvent_box.py Mixed-solvent box with ratio/density/count modes
multilayer.py Five-layer multi-slab system
sandwich_from_traj.py Electrode / membrane / electrode sandwich from an equilibrated MD trajectory
polymer/polymer_from_smiles.py Mapped-SMILES attachment sites, charged polymer preparation, and neutralized LAMMPS export
polymer/polymer_piperion.py RDKit chain geometry, LigParGen junction refinement with charge audit, and hydrated membrane packing

Full API reference and user guide: roncofaber.github.io/mdinterface

Development setup and contribution guidance are in CONTRIBUTING.md.

Version 2.0.0 removes SimulationBox and BoxBuilder; use SimCell. See the 2.0 migration guide for API replacements and coordinate changes.

For molecular and polymer preparation, parameterized monomers carry their force-field data into the chain:

from mdinterface import Specie, Polymer

monomer = Specie(smiles="[CH3:1][CH3:2]")
monomer.parameterize()
monomer.mark_attachment_sites(head_map=1, tail_map=2)
chain = Polymer(monomer, nrep=3)
chain.generate_conformer(seed=42, minimize=True)
report = chain.refine_junctions(charge_correction="uniform")

See the polymer guide for preparation, charge auditing, and export validation. Parameterization requires LigParGen and BOSS.

Roadmap

Since the original idea was to make a package to build MD boxes layer by layer, I am strongly debating renaming everything as "Workflow for Easy Molecular DYnamics Simulations", aka WEMDYS.

Questions & Issues

Sir, this is a WEMDY'S. Please contact me or open an issue, glad to talk about ideas and improvements!

Metadata

Release files for mdinterface 2.1.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 mdinterface 2.1.0
File Size Uploaded Provenance Actions
mdinterface-2.1.0.tar.gz 867.6 kB With provenance Details for mdinterface-2.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 991.9 kB

Release files / mdinterface-2.1.0.tar.gz

Download URL mdinterface-2.1.0.tar.gz
Size 867.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1052b15c85492aa49d5731a3897675954f66dbd01013b3323a9bab1d0ea2c272
BLAKE2b-256 checksum
How to use checksums
c20c305244863b949ad33b99674b9b7b5efe85aaa820d04186aec8148f3dfcec
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 Dec 1, 2026.

Transparency log

Release files / mdinterface-2.1.0-py3-none-any.whl

Download URL mdinterface-2.1.0-py3-none-any.whl
Size 124.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e2fc9c8752666175f7770abae815739588adb13558235439cb76a21058801cb
BLAKE2b-256 checksum
How to use checksums
e1f18474314604292ae69c19cc12bff086166c03373bdd138ec1078e82815f03
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 Dec 1, 2026.

Transparency log

Security for mdinterface 2.1.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 mdinterface-2.1.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 Dec 1, 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