MolPy
Parameterize
Typed and relaxed¶
Coordinates, force-field types, and a minimized geometry in a few calls.
import molpy as mp
# SMILES → 3D
mol = mp.io.smiles.SmilesIr("CCO").to_atomistic()
mol, _ = mp.conformer.Conformer(seed=42).generate(mol)
# OPLS-AA typing
typifier = mp.ff.typifier.OplsAaTypifier()
frame = typifier.typify(mol).to_frame()
ff = typifier.forcefield()
# minimize
potentials = mp.ff.compile.PotentialCompiler(ff).compile(frame)
frame, report = mp.optimize.Lbfgs(potentials, fmax=0.05).minimize(frame)
Assemble
Any architecture¶
Define a unit once; a CGsmiles string sets the shape — chain, ring, star.
# a unit with two ports
eo = mp.conformer.Conformer(seed=42).generate(
mp.io.smiles.SmilesIr.from_fragment("[<]OCC[>]").to_template()
)[0]
assembler = mp.builder.Assembler({"EO": eo}, mp.builder.GrowthPlacer())
def build(cgsmiles):
sites = mp.io.cgsmiles.CgSmilesIr(cgsmiles).to_coarsegrain()
return assembler.assemble(sites, mp.Atomistic)
# shape from CGsmiles
chain = build("{[#EO]|10}")
ring = build("{[#EO]1[#EO][#EO][#EO][#EO][#EO]1}")
Simulate
Engine-ready inputs¶
LAMMPS, GROMACS, CP2K, and OpenMM inputs from one system and force field.
frame.box = mp.Box.cube(30.0)
# molecule IDs
frame["atoms"]["mol_id"] = (
mp.Topology.from_frame(frame).connected_components() + 1
)
# cutoffs
ff.get_style("pair", "lj/cut")["cutoff"] = 10.0
ff.get_style("pair", "coul/cut")["cutoff"] = 10.0
lammps = mp.engine.LammpsEngine(check_executable=False)
lammps.generate_inputs(frame, ff, "./lammps")
gromacs = mp.engine.GromacsEngine(check_executable=False)
gromacs.generate_inputs(frame, ff, "./gromacs")
Figure 1. Aspirin in molvis.
Where to start
Start here¶
- Quickstart
- SMILES to LAMMPS input, end to end.
- Tutorials
- The data model, chapter by chapter.
- Guides
- One recipe per task.
- Compute
- Trajectory analysis and its theory.
- API Reference
- Every public class and function.