Skip to main content

Molecular simulation toolkit

Project description

mstk

A toolkit to make molecular simulation less painful

mstk is a Python toolkit designed to streamline the setup and management of molecular simulations, particularly geared towards non-biological applications in material science and chemical engineering. It simplifies atom typing, force field parameter assignment, and input file generation for major simulation engines.

Features

  • Assign atom types and force field parameters based on local chemical environment
  • Generate input files for LAMMPS, GROMACS, NAMD and OpenMM
  • Set up solvation free energy simulation
  • Support Drude polarizable model, coarse-grained model, virtual site, linear angle...
  • Read/write common topology (PSF, ZMAT, PDB, LAMMPS, ...) and trajectory (GRO, XTC, DCD, LAMMPS, ...) files
  • Access local and remote job schedulers like Slurm

Installation

conda install -c conda-forge numpy pandas rdkit openmm chemfiles packmol pymbar-core
pip install mstk

Quick Example

Example 1 Build a liquid mixture of 100 benzene and 1000 water molecules, ready for simulation.

from mstk.topology import Molecule, Topology
from mstk.forcefield import ForceField, Typer
from mstk.simsys import System
from mstk.wrapper import Packmol

# Create topology from SMILES
benzene = Molecule.from_smiles('c1ccccc1')
water = Molecule.from_smiles('O')
top = Topology([benzene, water])

# Assign atom types as defined in `data/forcefield/primitive.smt`
typer = Typer.open('primitive.smt')
typer.type(top)

# Build a bulk liquid simulation box with Packmol
packmol = Packmol('packmol')
top.cell.set_box([4.0, 4.0, 4.0])
top.scale_with_packmol([100, 1000], packmol=packmol)

# Assign force field parameters as defined in `data/forcefield/primitive.zff`
ff = ForceField.open('primitive.zff')
ff.assign_charge(top)
system = System(top, ff)

# Generate input files for LAMMPS, GROMACS and NAMD
system.export_lammps()
system.export_gromacs()
system.export_namd()

# Generate OpenMM system and topology
omm_sys = system.to_omm_system()
omm_top = top.to_omm_topology()

Important Note: The primitive atom typing and force field used above are for demonstration purpose only and are not well optimized for production use. For reliable simulation, please prepare you own smt and zff files or get them from a validated source.

Example 2 Calculate the hydration free energy of benzene in water

  • 2.1 Build a system containing 1 benzene in 1000 water, following the above example

  • 2.2 Use the mstk sfe run command to perform alchemical simulation under different lambda windows

mstk sfe run -p _namd-top.psf -c _gmx-conf.gro -f primitive.zff --molid 0 -w %WINDOW% --nwindow 16

Run at 16 different windows by change %WINDOW% from 0 to 15. A series of dU values will be saved in dU_%WINDOW%.csv

  • 2.3 Use the mstk sfe mbar command to analyse free energy change
mstk sfe mbar *.csv

Documentation

https://mstk.readthedocs.io/en/latest/index.html

TODO

  • Refactor algorithms across topology and analyzer modules
  • Separate ommhelper module into its own package
  • Remove analyzer module
  • Revise the implementation of Drude polarization and virtual sites

Project details


Download files

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

Source Distribution

mstk-0.4.0.tar.gz (249.0 kB view details)

Uploaded Source

Built Distribution

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

mstk-0.4.0-py3-none-any.whl (296.5 kB view details)

Uploaded Python 3

File details

Details for the file mstk-0.4.0.tar.gz.

File metadata

  • Download URL: mstk-0.4.0.tar.gz
  • Upload date:
  • Size: 249.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mstk-0.4.0.tar.gz
Algorithm Hash digest
SHA256 a5973a0425b233a899c98226c1be7116e718e9158dcbdf1861f25ae49efce474
MD5 3c596d774897434fc189504d3e6e8e83
BLAKE2b-256 cf274ed2850da444caeda92ad6a84dce11e0928ab967c1d8de9f594f18a64e05

See more details on using hashes here.

Provenance

The following attestation bundles were made for mstk-0.4.0.tar.gz:

Publisher: python-publish.yml on z-gong/mstk

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

File details

Details for the file mstk-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: mstk-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 296.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mstk-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79ba339da079e2344a62e9590979e22f85daf5a2f9ef4022c7e1e9083be9f2e3
MD5 fda08d7275e70af26464fbebbf70f99d
BLAKE2b-256 27b220b9c8f6993b25711c4dfc54f1ffa7d42d4fe3cc23f9b751f013e5157dd8

See more details on using hashes here.

Provenance

The following attestation bundles were made for mstk-0.4.0-py3-none-any.whl:

Publisher: python-publish.yml on z-gong/mstk

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