1 #ifndef SLIPLINKMOVE_CPP 2 #define SLIPLINKMOVE_CPP 11 #include "SliplinkMove.h" 12 #include <util/misc/FileMaster.h> 13 #include <mcMd/simulation/Simulation.h> 14 #include <mcMd/links/LinkMaster.h> 15 #include <mcMd/mcSimulation/McSystem.h> 16 #include <mcMd/potentials/pair/McPairPotential.h> 17 #include <mcMd/potentials/bond/BondPotential.h> 18 #include <mcMd/chemistry/Molecule.h> 19 #include <mcMd/chemistry/Atom.h> 20 #include <simp/boundary/Boundary.h> 21 #include <util/space/Vector.h> 25 #define MCMD_LINK_TRANSFER 43 read<double>(in,
"cutoff", cutoff_);
44 read<int>(in,
"speciesId", speciesId_);
52 Atom *atom0Ptr, *atom1Ptr;
54 int j, iMolecule0, iMolecule1, n0, nLinks0, endId;
55 int idLink, iAtom0,iAtom1, iAtom, nNeighbor,id0, id1;
56 double rsq, oldEnergy, newEnergy;
57 double dRSq, mindRSq=cutoff_*cutoff_, rnd, norm;
60 double cdf[maxNeighbor], energy, sum;
61 int idneighbors[maxNeighbor];
66 for (idLink = nLinks0-1; idLink >= 0 ; idLink--) {
72 atom0Ptr = &(linkPtr->
atom0());
73 atom1Ptr = &(linkPtr->
atom1());
76 atom0Ptr = &(linkPtr->
atom1());
77 atom1Ptr = &(linkPtr->
atom0());
87 if (iAtom0 != 0 && iAtom0 != mol0Ptr->
nAtom() - 1) {
98 if(iMolecule0==iMolecule1){
99 if(std::fabs(iAtom0-iAtom1)<2) iAtom0 = iAtom;
101 atom0Ptr = &mol0Ptr->
atom(iAtom0);
128 if (iAtom == 0) iAtom0 = 1;
130 if(iMolecule0==iMolecule1){
131 if(std::fabs(iAtom0-iAtom1)<2) iAtom0 = iAtom;
133 atom0Ptr = &mol0Ptr->
atom(iAtom0);
149 #ifdef MCMD_LINK_TRANSFER 151 if (rsq <= mindRSq) {
155 nNeighbor = neighbors_.
size();
158 id0 = atom0Ptr->
id();
163 for (j = 0; j < nNeighbor; ++j) {
164 atom1Ptr = neighbors_[j];
167 id1 = atom1Ptr->
id();
178 if (dRSq <= mindRSq) {
194 norm = 1.0/cdf[n0-1];
195 while (rnd > cdf[j]*norm ){
198 atom1Ptr = neighbors_[idneighbors[j]];
int nLink() const
Get the total number of active Links.
Molecule & molecule() const
Get the parent Molecule by reference.
A System for use in a Markov chain Monte Carlo simulation.
virtual void readParameters(std::istream &in)
Read cutoff and speciesId.
void removeLink(int id)
Remove a Link.
void incrementNAttempt()
Increment the number of attempted moves.
static const int MaxNeighbor
Maximum possible number of neighboring atoms.
void getNeighbors(const Vector &pos, NeighborArray &neighbors) const
Fill a NeighborArray with pointers to atoms near a specified position.
double distanceSq(const Vector &r1, const Vector &r2) const
Return square distance between positions r1 and r2.
const CellList & cellList() const
Get the cellList by const reference.
virtual bool move()
Move slip-springs.
Mask & mask()
Get the associated Mask by reference.
A Link represents a crosslink between two Atoms.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
double uniform()
Return a random floating point number x, uniformly distributed in the range 0 <= x < 1...
SliplinkMove(McSystem &system)
Constructor.
double boltzmann(double energy)
Boltzmann weight associated with an energy difference.
bool isMasked(const Atom &atom) const
True if the atom is in the masked set for the target Atom.
McSystem & system()
Get parent McSystem.
void incrementNAccept()
Increment the number of accepted moves.
A point particle within a Molecule.
Utility classes for scientific computation.
An McMove that acts on one McSystem.
int id() const
Get global index for this Atom within the Simulation.
void reSetAtom(Link &link, Atom &atom, int endId)
Modify one atom attached to a link.
Forward iterator for a PArray.
Random & random()
Get Random number generator of parent Simulation.
McPairPotential & pairPotential() const
Return the McPairPotential by reference.
virtual double energy(double rSq, int type) const =0
Returns potential energy for one bond.
int typeId() const
Get the typeId for this Link.
Boundary & boundary() const
Get the Boundary by reference.
BondPotential & linkPotential() const
Return the McLinkPotential by reference.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
const Atom & atom1() const
Get Atom1 connected to a Link.
void readProbability(std::istream &in)
Read the probability from file.
void setClassName(const char *className)
Set class name string.
const Atom & atom(int localId) const
Get a specific Atom in this Molecule.
int indexInMolecule() const
Get local index for this Atom within the parent molecule;.
Link & link(int id) const
Return an active link by an internal set index.
bool metropolis(double ratio)
Metropolis algorithm for whether to accept a MC move.
A physical molecule (a set of covalently bonded Atoms).
const Vector & position() const
Get the position Vector by const reference.
void addLink(Atom &atom0, Atom &atom1, int typeId)
Add a link betwen two specific Atoms.
int size() const
Return logical size of this array (i.e., number of elements).
const Atom & atom0() const
Get Atom0 connected to a Link.
int nAtom() const
Get the number of Atoms in this Molecule.
int moleculeId(const Molecule &molecule) const
Get the index of a Molecule within its Species in this System.
Boundary & boundary()
Get Boundary object of parent McSystem.
LinkMaster & linkMaster() const
Get the LinkMaster by reference.