Particles in Molecular Dynamics

The examples in Minimal Simulation and its Minimal Simulation OOP illustrate point particle simulations. The Glotzilla API is capable of simulations involving more complex particles. Specifically, Glotzilla can handle rigid collections of point particles, polymers connected by springs, or combinations of these two. This tutorial will describe particle building blocks in Glotzilla, as well as how to contruct complex particles.

  • Created 10-23-07; code revision 490

Particle Building Blocks

For molecular dynamics simulations, the following objects are used to build particles: MdBead, MdSpring?, and MdRigidBody?. Their functionality is described below. For more information, consult the Glotzilla Documentation Website.

MdBead

The fundamental interacting object in an MdSimulation is the MdBead. This object is analagous to Atom in LAMMPS. Beads store their position, velocity, virial, and other quantities pertaining to analysis, manipulation, and simulation. Important functionality of the MdBead class includes setting its position and type.

MdSpring?

Springs are objects which allow for the simulation of non-rigid objects. MdSpring? serves as the base class, from which standard springs such as MdHarmonicSpring and MdFeneSpring are derived. Note that springs are not meant to simulate elastic bodies, a functionality that does not yet exist in Glotzilla. MdSpring? objects link MdBead objects. The value of the spring constant, or maximum length can also be set.

MdRigidBody?

Rigid bodies are collections of beads whose relative position to each other do not change. Rigid bodies in Glotzilla are implemented in MdRigidBody?. Adding beads to a rigid body, setting the rigid body position and orientation are functions that are available to the particle designer.

Building Particles

As seen in the Minimal Simulation Tutorial, point particle objects are defined in Glotzilla as MdPointParticle objects. This section of the tutorial will describe how to generate purely rigid particles, and polymers which are built from a collection of springs, beads, and rigid bodies.

Rigid Particles

To generate a rigid particle, we first derive a new object from MdRigidParticle?. In the constructor of our new particle, we define the particle geometry and composition by adding beads in the constructor, followed by setting their position and type.

#include <glotzilla++.h>

class MdExampleRigidParticle : MdRigidParticle
{
        MdExampleRigidParticle()
        {
                MdBead *bead1 = new MdBead;             //Define a new bead
                bead1->SetPosition(0.0, 0.0, 0.0);              //Set the bead position
                bead1->SetType(type::A);                                //Set the bead type
                AddBead(bead1);                                 //Add the bead to our particle
                
                MdBead *bead2 = new MdBead;
                bead2->SetPosition(1.0, 0.0, 0.0);
                bead2->SetType(type::B);
                AddBead(bead2);
                
                MdBead *bead3 = new MdBead;
                bead3->SetPosition(-1.0, 0.0, 0.0);
                bead3->SetType(type::C);
                AddBead(bead3);
                
                MdBead *bead4 = new MdBead;
                bead4->SetPosition(0.0, 1.0, 0.0);
                bead4->SetType(type::D)
                AddBead(bead4);
        }
};

Here we have declared a rigid particle made of four MdBeads? in the shape of a Tetris piece. The important idea to consider is that we use functionality defined in MdBead to define the bead positions, and then use the functionality of MdRigidParticle? to add them to the particle.

Polymers

Polymers are more sophisticated than rigid particles and introduce springs. One important concept to remember is that springs can only connect beads, and not rigid bodies. However, by linking a bead in a rigid body to another bead in a rigid body (or another bead) we define an "anchor bead" in the rigid body that can be used to connect a rigid body. To generate a polymer, we derive a new object from MdPolymer.

#include <glotzilla++.h>

class MdExamplePolymer : MdPolymer
{
        MdExamplePolymer()
        {
                //Let's define a rigid body.
                MdRigidBody *rigid = new MdRigidBody;
                
                MdBead *bead1 = new MdBead;                             
                bead1->SetPosition(0.0, 0.0, 0.0);              
                bead1->SetType(type::A);                                
                rigid->AddBead(bead1);                                                  
                
                MdBead *bead2 = new MdBead;
                bead2->SetPosition(1.0, 0.0, 0.0);
                bead2->SetType(type::B);
                rigid->AddBead(bead2);
                
                MdBead *bead3 = new MdBead;
                bead3->SetPosition(-1.0, 0.0, 0.0);
                bead3->SetType(type::C);
                rigid->AddBead(bead3);
                
                MdBead *bead4 = new MdBead;
                bead4->SetPosition(0.0, 1.0, 0.0);
                bead4->SetType(type::D)
                rigid->AddBead(bead4);
                
                //Add the rigid body to our particle
                AddRigidBody(rigid);
                
                //Define some "flexible" beads
                MdBead *bead5 = new MdBead;
                bead5->SetPosition(0.0, 2.0, 0.0);
                //Note that this step adds the bead to the particle, not a rigid body
                AddBead(bead5);                                                 
                
                MdBead *bead6 = new MdBead;
                bead6->SetPosition(0.0, 3.0, 0.0);
                AddBead(bead6);
                
                //Lets define some springs
                MdHarmonicSpring *spring1 = new MdHarmonicSpring;
                //This connects our "tether" to our rigid body
                spring1->Connect(bead4, bead5);                 
                //Add the spring to the particle
                AddSpring(spring1);                                             
                
                MdHarmonicSpring *spring2 = new MdHarmonicSpring;
                spring2->Connect(bead5, bead6);
                AddSpring(spring2);
        }
};

Again we have used functionality built into MdRigidBody? and MdSpring? to help construct our particle. Now we can simply use the AddParticle? function in MdSimulation to simulate our new particle.