SIGNUM DATA
  • Home
  • DisPol
  • DisPolAir
  • DisSoniq
  • Carbon Tool
  • Seveso Tool
  • PPWR Tool
  • MDsquad
  • Numerics
  • Contact
MDsquad logo
MDsquadby Titus Adrian Beu · Open teaching resource
Molecular dynamics · Graduate & post-graduate

Molecular dynamics, made accessible

MD has matured into one of the most reliable computational tools in research — and, as the models and methods have piled up, into one that risks remaining the preserve of initiates. MDsquad is a concept and a software repository for teaching it at graduate and post-graduate level, built on unifying data structures across Python and C/C++.
Python builds the initial configurations and post-analyses the trajectories. C/C++ builds a suite of simulators that mimic an established MD code, in a sequence of gradually growing complexity — so coding ability is acquired in parallel with the skill of operating a real simulator.
Python C/C++ NAMD · PDB · PSF · PAR · DCD 8 chapters available
Read the chapters Download the code
Created by Titus Adrian Beu, Faculty of Physics, Babeș-Bolyai University — [email protected]
A DNA strand solvated in a box of water molecules, built by the MDsquad Python library
The course

Eight chapters, each with its own code

Every chapter is a PDF and a matching bundle of programs. Fundamental aspects — molecular models, force fields, time propagation, thermodynamic reservoirs, electrostatics in periodic systems and acceleration techniques — are given particular emphasis, and test runs are compared against output from established MD codes.
Chapter 01Introduction to MD simulationsWhat molecular dynamics does, where it is reliable, and how the pieces of a simulation fit together.Read the chapter (PDF) →
Chapter 02Molecular structureBuilding configurations from scratch: clusters, crystals, C60, graphene, nanotubes, DNA, water boxes and solvation.Read the chapter (PDF) →
Chapter 03Basic Molecular DynamicsThe first simulator — Lennard-Jones forces, time propagation and velocity rescaling, written from the ground up.Read the chapter (PDF) →
Chapter 04Simulation of simple fluidsExtending the simulator to fluids, and comparing the results against output from an established MD code.Read the chapter (PDF) →
Chapter 05MeasurementsGetting numbers out of a trajectory: time averages, velocity distributions, the H-Boltzmann function, radial distribution and diffusion coefficients.Read the chapter (PDF) →
Chapter 06Force fieldsBonded and non-bonded terms, and the pair-list optimisation that makes larger systems tractable.Read the chapter (PDF) →
Chapter 07Electrostatics in periodic systemsLong-range Coulomb interactions under periodic boundary conditions.Read the chapter (PDF) →
Chapter 08Simulations with NAMDOperating an established MD code, and reading its input and output with the same Python library.Read the chapter (PDF) →
Under construction. Five further chapters are in preparation: Special numerical techniques, Parallelization, Parameterizing force fields, Rigid-body dynamics and vibrational analysis.
The Python side

MDsquad.py — setting up and looking at systems

One library builds the configurations that go into a run and analyses the trajectories that come out. The numerical and graphical routines it relies on are those of Introduction to Numerical Programming.
mdsquad0.zip
AtomMasses.py
Atomic masses and atomic numbers.
AtomMass · AtomMasses
Constants.py
Basic units and conversion factors.
CoordTrans0.py / CoordTrans.py
Coordinate transformations for atom sets — bounding boxes, centre of mass, radius of gyration, principal axes and rotations. The 0 version is the tutorial one.
GetBBox · GetCM · MoveCM · MoveRel · Center · RadiusGyration · PrincipalAxes · Rotate · RotMatEuler · RotMatAxis · RotMatVec · RotMatVec2Vec · CircleCenter · AlignAtoms2Axes
DataInOut0.py / DataInOut.py
Input/output from and to NAMD and Gromacs files. The tutorial version handles PDB alone; the full version adds PSF, CHARMM parameter files, DCD trajectories and the Gromacs formats.
ReadPDB · WritePDB · GetSetNumPDB · SeekSetPDB · ReadSetPDB · ReadPSF · WritePSF · ReadPar · WritePar · ReadParFF · WriteParFF
DataTypes0.py / DataTypes.py
The core classes shared by every program.
Atom · Bond · Angle · Dihedral · Residue · Pair · IntCoord · BeadType
GetBonded.py
Identifying and measuring bonds, angles and dihedrals.
Measure.py
Trajectory analysis — radial distribution function, radius of gyration, diffusion coefficient.
Residues.py
Residue identification and selection.
SelectAtoms.py
Atom selection by expression, in the style of an established MD front end.
SetupConfig.py
Configuration builders — crystals, graphene, nanotubes, water boxes and solvation.
VecMatR0.py / VecMatR3.py
Vector and matrix operations in R³.
The C/C++ side

Four simulators, each one a step further

Rather than one finished program, a sequence — each version adding the theory introduced in its chapter, so nothing arrives as a black box.
01

MDsim0

Chapter 3
The starting point: a Lennard-Jones simulator with its own data types, memory allocation, force routine, propagator and velocity rescaling. Reads mdsim.dat, .pdb, .psf and .par; writes a trajectory and a statistics file.
02

MDsim1

Chapter 4
The same engine extended to simple fluids, with results checked against an established MD code.
03

MDsim2

Chapter 6
Force fields and the pair-list optimisation, added as PairList0.h — the first step towards a simulator that scales.
04

MDsim3

Chapter 7
Electrostatics under periodic boundary conditions, for charged systems.
The programs

List of programs by chapter

What each chapter’s bundle contains: the Python scripts and C/C++ sources, the input files they read, and what they produce. Click any result to see it full size.

Chapter 2 · Molecular structure

p02.zip
ListingSource / inputWhat it doesResult
2.1P02-01-VecOp.pySimple vector operations.--
2.2P02-02-Measure.pymeoh.pdbMove a molecule to the CM system and measure its bounding box.Result of P02-02-Measure.pymeoh_CM.pdb
2.3P02-03-SelectAtoms.py7bz5.pdbRemove spurious H2O atoms from the system and select a semi-space.Result of P02-03-SelectAtoms.py7bz5_select.pdb
2.4P02-04-PrincipalAxes.pymeoh.pdbRotate a molecule to the system of principal axesResult of P02-04-PrincipalAxes.pymeoh_x.pdb
meoh_z.pdb
2.5P02-05-C60cage.pySet up a C60 cage as a truncated icosahedron.Result of P02-05-C60cage.pyc60.pdb
2.6P02-06-AmorphCluster.pyGenerate an amorphous spherical atomic cluster.Result of P02-06-AmorphCluster.pycluster.pdb
2.7P02-07-Crystal.pySet up a cubic atomic (gold) crystal.Result of P02-07-Crystal.pycrystal.pdb
2.8P02-08-CrystalCluster.pyGenerate a spherical crystalline (gold) cluster.Result of P02-08-CrystalCluster.pycrystclus.pdb
2.9P02-09-Graphene.pySet up a graphene sheet.Result of P02-09-Graphene.pygraphene.pdb
2.10P02-10-CarbonNanotube.pySet up an armchair-type carbon nanotube.Result of P02-10-CarbonNanotube.pycnt.pdb
2.11P02-11-DNA-CNT.pydna.pdbWrap a DNA double-helix in a carbon nanotube.Result of P02-11-DNA-CNT.pydna-cnt.pdb
2.12P02-12-AmorphBox.pyGenerate an amorphous box of Ar atoms.Result of P02-12-AmorphBox.pyamorph.pdb
2.13P02-13-WaterMol.pySet up a TIP3P water molecule.Result of P02-13-WaterMol.pywatmol.pdb
2.14P02-14-WaterBox.pySet up a TIP3P water box.Result of P02-14-WaterBox.pywater.pdb
2.15P02-15-SolvateCluster.pySolvate a cluster in a water box.Result of P02-15-SolvateCluster.pysolv_clus.pdb
2.16P02-16-SolvateDNA.pydna.pdbSolvate a DNA double-helix in a water box.Result of P02-16-SolvateDNA.pyResult of P02-16-SolvateDNA.py

Chapter 3 · Basic Molecular Dynamics

p03.zip
ListingSource / inputWhat it doesResult
--MDsim0.cppMDsim0 simulator: main program.Result of MDsim0.cppResult of MDsim0.cpp
BasicTypes.hDefinition of basic real and complex types.
Constants.hDefinition of basic units and conversion factors.
Memalloc0.hDynamic memory allocation of vectors.
DataTypes0.hDefine the main Atom type.
DataInOut0.hRead/write from/to pdb/psf/par files.
Forces0.hCalculate Lennard-Jones interaction forces.
InOut0.hDefine I/O functions for the main simulation parameters.
Propag0.hDefine the time propagation function.
Vrescal0.hDefine functions for rescaling velocities.
mdsim.datMain simulation parameters.
mdsim.pdbSystem (pdb) configuration file.
mdsim.psfSystem (psf) structure file
mdsim.parForce field (par) parameter file.

Chapter 4 · Simulating simple fluids

p04.zip
ListingSource / inputWhat it doesResult
--MDsim1.cppMDsim1 simulator: main program.Result of MDsim1.cppResult of MDsim1.cppResult of MDsim1.cpp
BasicTypes.hDefinition of basic real and complex types.
Constants.hDefinition of basic units and conversion factors.
Memalloc0.hDynamic memory allocation of vectors.
DataTypes0.hDefine the main Atom type.
DataInOut1.hRead/write from/to pdb/psf/par files.
Forces1.hCalculate Lennard-Jones interaction forces.
InOut1.hDefine I/O functions for the main simulation parameters.
Propag1.hDefine the time propagation function.
Vrescal1.hDefine functions for rescaling velocities.
mdsim.datMain simulation parameters.
mdsim.pdbSystem (pdb) configuration file.
mdsim.psfSystem (psf) structure file
mdsim.parForce field (par) parameter file.

Chapter 5 · Measurements

p05.zip
ListingSource / inputWhat it doesResult
5.1P05-01-Statistics.pymdsim.outCalculate for an Ar gas time averages of basic parameters (energies and pressure) from an MDsim output file.--
5.2P05-02-TimeDep.pymdsim.outPlot for an Ar gas time dependences of basic parameters from an MDsim output file.Result of P05-02-TimeDep.py
5.3P05-03-ReadSetPDB.pyDataInOut1.pymdsim_trj.pdbRead/write a particular frame (set) from an MDsim trajectory file.Result of P05-03-ReadSetPDB.pymdsim_set.pdb
5.4P05-04-Vdistrib.pymdsim_trj.pdbPlot for an Ar gas the average velocity distribution from an MDsim trajectory file.Result of P05-04-Vdistrib.pyvhisto.out
5.5P05-05-HBoltz.pymdsim.outmdsim_trj.pdbPlot the H-Boltzmann function, averaged over sequences of MDsim trajectory frames.Result of P05-05-HBoltz.pyhboltz.out
5.6P05-06-Rdistrib.pymdsim_trj.pdbPlot the radial distribution function, averaged over sequences of MDsim frames.Result of P05-06-Rdistrib.pyrhisto.out
5.7P05-07-DiffCoef.pymdsim_100ps.outmdsim_trj_100ps.pdbCalculate the diffusion coefficient for Ar gas, based on Einstein's formula.Result of P05-07-DiffCoef.py

Chapter 6 · Force fields

p06.zip
ListingSource / inputWhat it doesResult
6.1P06-GenBoxCO.pyDataInOut2.pySet up a CO gas box of normal density; generate pdb and psf files.Result of P06-GenBoxCO.pyResult of P06-GenBoxCO.py
--MDsim2.cppMDsim2 simulator: main program.Result of MDsim2.cppResult of MDsim2.cppResult of MDsim2.cppResult of MDsim2.cpp
BasicTypes.hDefinition of basic real and complex types.
Constants.hDefinition of basic units and conversion factors.
Memalloc0.hDynamic memory allocation of vectors.
DataTypes1.hDefine the main Atom type.
DataInOut2.hRead/write from/to pdb/psf/par files.
Forces2.hCalculate Lennard-Jones interaction forces.
InOut2.hDefine I/O functions for the main simulation parameters.
PairList0.hDefine functions for setting up pair lists.
Propag2.hDefine the time propagation function.
Vrescal2.hDefine functions for rescaling velocities.
mdsim.datMain simulation parameters.
mdsim.pdbSystem (pdb) configuration file.
mdsim.psfSystem (psf) structure file
mdsim.parForce field (par) parameter file.

Chapter 7 · Electrostatics in periodic systems

p07.zip
ListingSource / inputWhat it doesResult
--MDsim3.cppMDsim3 simulator: main program.Result of MDsim3.cppResult of MDsim3.cppResult of MDsim3.cppResult of MDsim3.cpp
BasicTypes.hDefinition of basic real and complex types.
Constants.hDefinition of basic units and conversion factors.
Memalloc0.hDynamic memory allocation of vectors.
DataTypes1.hDefine the main Atom type.
DataInOut2.hRead/write from/to pdb/psf/par files.
Forces3.hCalculate Lennard-Jones interaction forces.
InOut3.hDefine I/O functions for the main simulation parameters.
PairList0.hDefine functions for setting up pair lists.
Propag3.hDefine the time propagation function.
Vrescal2.hDefine functions for rescaling velocities.
mdsim.datMain simulation parameters.
mdsim.pdbSystem (pdb) configuration file.
mdsim.psfSystem (psf) structure file
mdsim.parForce field (par) parameter file.
Open teaching resource. MDsquad is made available for study, teaching and research, with the request that the authorship is mentioned. It is a learning repository, not a production MD package — for production work it points you at an established code, and shows you how to check one against the other.
Signum Data
MDsquadMolecular dynamics made accessible·[email protected]·+40 752 441 608·Privacy Policy·Cookie Policy
  • Home
  • DisPol
  • DisPolAir
  • DisSoniq
  • Carbon Tool
  • Seveso Tool
  • PPWR Tool
  • MDsquad
  • Numerics
  • Contact