The purpose of this library is to provide methods to produce any MD simulation, with any type of integrator, any type of particles, and any type of force in 2D or 3D.
It is currently single-core only, and provides objects for many different integrators, and many different forces, which can be composed together for simulations from a few particles bouncing around in a box to a full protein simulation.
There are several examples in C++ in the src/bin
folder, all with good comments:
LJatoms.cpp
(\ref LJatoms.cpp): a simulation of a Lennard-Jones simulation (2D, or 3D)packer.cpp
(\ref packer.cpp): Generates packings (2D or 3D)hardspheres.cpp
(\ref hardspheres.cpp): for a more unconventional example of collision-driven dynamics
See pyparm/examples/LJ.py
(\ref LJ.py) for an example of a simple Lennard-Jones
simulation, with data analysis included.
See pyparm/packmin.py
for an example of how to make a packing.
-
Vec
: this is a "vector" in the physics sense, having either 2 or 3 dimensions. -
Atom
: anAtom
is the basic unit of the simulation; it represents a particle with mass, position, velocity, etc. -
AtomGroup
: anAtomGroup
is a set of atoms, grouped together for the sake of utility.- Note that
AtomVec
is a concrete type, andAtomGroup
is an abstract class
- Note that
-
Interaction
: anInteraction
is a definition of a force and energy, such as a Lennard-Jones potential (useNListed<IEpsSigCutAtom, LJAttractRepulsePair>
), springs for bonds (BondPairs
), etc.- Note that the neighbor list has been "abstracted" to work with
many potentials; to use it, you create a
NeighborList
, then useNListed<FooAtom, FooPair>
as the Interaction
- Note that the neighbor list has been "abstracted" to work with
many potentials; to use it, you create a
-
Box
: a box is either infinite (InfiniteBox
) or periodic (OriginBox
), and takes care of the boundary conditions -
Collection
: a grouping together of aBox
,AtomGroup
, andInteraction
s, with an integrator (such as velocity Verlet,CollectionVerlet
, or brownian motion,CollectionSol
).
- Make a
Box
.OriginBox
is a good standard choice for periodic boundary conditions. - Make an
AtomVec
. - Set masses, positions and velocities
- Positions might be set using
box.rand_loc()
, for a random point inside the box - Velocities may be set using
rand_vec()
, which generates a Gaussian distribution, like the expected Boltzmann distribution
- Positions might be set using
- Make
Interaction
s. For neighborlisted interactions, makeNeighborList
first, then make interactions.NListed<EpsSigAtom, LJRepulsivePair>
(LJRepulsive
in Python) is a repulsive Lennard-Jones InteractionNListed<EpsSigExpAtom, RepulsionPair>
(Repulsion
in Python) is a Repulsion or Harmonic Interaction (exponent can be chosen)- Add atoms / pairs to Interaction
- Make a
Collection
. Note that the NeighborList has to be added totrackers
CollectionVerlet
is a good NVE Collection
- Run
Collection.timestep()
many, many times- Use methods such as
Collection.kinetic_energy()
orCollection.temp()
to get statistics - Or use
tracker
s likeRsqTracker
to track running statistics
- Use methods such as
- Write output to files
- STL, the C++ Standard Template Library
- Boost: primarily for random numbers, also a few odds and ends
- (optional) SWIG: for generating Python bindings
- (optional) Python: for generating Python bindings
- Known to compile for python 3.2-3.4, and probably with 2.6-2.7
On Ubuntu, the following packages should suffice for Python 3:
build-essential
libeigen3-dev
libboost-all-dev
swig
python3-dev
python3-numpy
python3-nose
python3-setuptools
python3-pip
For Python 2, simply use the same packages but with the python-
prefix instead
of python3-
.
Note that you will need to make sure you include Boost and Eigen in you "include" path. On Ubuntu, Boost will be by default, but you may need to add Eigen:
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/usr/include/eigen3"
Note that the attached .travis.yml
file are computer-readable instructions for
automatically building and testing this module on an Ubuntu machine, so that
should always be up to date.
This library includes a sim.i
file for use with SWIG for generating
Python bindings.
- Make sure you have the dependencies and include paths set, as above.
- Run
make wraps
to generate the SWIG wrappers. - Run
python3 setup.py build_ext --inplace
to build it in place, orpython3 setup.py install
to install.- There are many option for Python
setup.py
files; runpython3 setup.py --help
to see more options.
- There are many option for Python
Use import pyparm.d2 as sim
or import pyparm.d3 as sim
to import
the module. Then use it freely.
This module uses the equation \f$V\left(r\right)=\varepsilon\left(1-\frac{\sigma^{6}}{r^{6}}\right)^{2}\f$
The other standard form is \f$V\left(r\right)=4\varepsilon\left(\frac{\sigma^{\prime12}}{r^{12}}-\frac{\sigma^{12}}{r^{6}}\right)\f$
To convert, use \f$\sigma=2^{\frac{1}{6}}\sigma^{\prime}\f$.