1 #ifndef GC_SLIPLINKMOVE_CPP 2 #define GC_SLIPLINKMOVE_CPP 11 #include "GcSliplinkMove.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/bond/BondPotential.h> 17 #include <mcMd/potentials/pair/McPairPotential.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> 26 #define MCMD_LINK_CREATE 27 #define MCMD_LINK_SHUFFLE 50 read<int>(in,
"nTrial", nTrial_);
51 read<int>(in,
"speciesId", speciesId_);
52 read<double>(in,
"fCreate", fCreate_);
53 read<double>(in,
"cutoff", cutoff_);
54 read<double>(in,
"mu", mu_);
56 cutoffSq_ = cutoff_*cutoff_;
57 fNotCreate_ = 1.0 - fCreate_;
64 double rsq, oldEnergy, newEnergy;
65 double rnd, norm, energy, sum, pci, pdi, ratio;
69 Atom *atom0Ptr, *atom1Ptr;
70 int i, j, iAtom0, iAtom1, linkId, nLink, nNeighbor, n0, endId;
76 for (i=0; i < nTrial_; ++i) {
81 if (
random().uniform(0.0, 1.0) > fCreate_) {
92 atom0Ptr = &(linkPtr->
atom0());
93 atom1Ptr = &(linkPtr->
atom1());
96 atom0Ptr = &(linkPtr->
atom1());
97 atom1Ptr = &(linkPtr->
atom0());
110 if (iAtom0 != 0 && iAtom0 != mol0Ptr->
nAtom() - 1) {
112 #ifdef MCMD_LINK_SHUFFLE 123 atom0Ptr = &mol0Ptr->
atom(iAtom0);
127 if (mol0Ptr == mol1Ptr) {
128 if (std::abs(iAtom0 - iAtom1) < 2) {
155 if (
random().uniform(0.0, 1.0) > 0.5) {
157 #ifdef MCMD_LINK_SHUFFLE 166 assert(iAtom0 == mol0Ptr->
nAtom()-1);
169 atom0Ptr = &mol0Ptr->
atom(iAtom0);
173 if (mol0Ptr == mol1Ptr) {
174 if (std::abs(iAtom0 - iAtom1) < 2) {
200 #ifdef MCMD_LINK_CREATE 202 if (rsq <= cutoffSq_) {
207 nNeighbor = neighbors_.
size();
212 for (j = 0; j < nNeighbor; ++j) {
213 atom1Ptr = neighbors_[j];
216 if (atom0Ptr != atom1Ptr) {
226 if (rsq <= cutoffSq_) {
241 *
boltzmann(-mu_) * cdf[n0-1] / fCreate_;
242 pdi = 4.0 * nLink / fNotCreate_;
244 if (
random().metropolis(ratio)) {
260 #ifdef MCMD_LINK_CREATE 268 iAtom0 = mol0Ptr->
nAtom() - 1;
270 atom0Ptr = &mol0Ptr->
atom(iAtom0);
275 nNeighbor = neighbors_.
size();
280 for (j = 0; j < nNeighbor; ++j) {
281 atom1Ptr = neighbors_[j];
284 if (atom0Ptr != atom1Ptr){
294 if (rsq <= cutoffSq_) {
312 norm = 1.0/cdf[n0-1];
313 while (rnd > cdf[j]*norm ){
316 atom1Ptr = neighbors_[idneighbors[j]];
320 *
boltzmann(-mu_) * cdf[n0-1] / fCreate_;
321 pdi = 4.0 * (nLink + 1.0) / fNotCreate_;
344 #ifdef MCMD_LINK_SHUFFLE 345 #undef MCMD_LINK_SHUFFLE 348 #ifdef MCMD_LINK_CREATE 349 #undef MCMD_LINK_CREATE 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.
GcSliplinkMove(McSystem &system)
Constructor.
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...
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.
int nMolecule(int speciesId) const
Get the number of molecules of one Species in this System.
McSystem & system()
Get parent McSystem.
Molecule & randomMolecule(int speciesId)
Get a random Molecule of a specified species in this System.
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.
virtual void readParameters(std::istream &in)
Read cutoff and speciesId.
long uniformInt(long range1, long range2)
Return random long int x uniformly distributed in range1 <= x < range2.
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.
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.
Boundary & boundary()
Get Boundary object of parent McSystem.
LinkMaster & linkMaster() const
Get the LinkMaster by reference.