MdBead
SimulationBuilder > Shared > ParticleBuildingBlocks?
MdBeads are the basic building blocks of polymers and rigid body? objects in molecular dynamics (MD) simulations. To create a polymer, beads should be joined using Fene springs or harmonic springs.
Synopsis
class SixtyFourBeadPolymer : public MdPolymer
{
public:
SixtyFourBeadPolymer()
{
//declare a vector to save all beads (for connecting them later
std::vector <MdBead *> bead;
//make beads in a loop
for(int i=0; i<4; i++)
for(int j=0; j<4; j++)
for(int k=0; k<4; k++)
{
MdBead *b = new MdBead;
b -> SetPosition(i, j, k);
AddBead(b);
bead.push_back(b);
}
//connect the beads using harmonic springs
for(int i=0; i< bead.size() -1; i++)
{
MdHarmonicSpring *s = new MdHarmonicSpring;
s -> Connect(bead[i], bead[i+1]);
AddSpring(s);
}
}
};