8 #include "CfbRingRebridgeMove.h" 9 #include <mcMd/mcSimulation/McSystem.h> 10 #include <mcMd/simulation/Simulation.h> 12 #include <mcMd/potentials/pair/McPairPotential.h> 14 #include <mcMd/chemistry/Molecule.h> 15 #include <mcMd/chemistry/Bond.h> 16 #include <mcMd/chemistry/Atom.h> 17 #include <simp/species/Ring.h> 18 #include <simp/boundary/Boundary.h> 69 loadParameter<int>(ar,
"speciesId",
speciesId_);
70 loadParameter<int>(ar,
"nRegrow",
nRegrow_);
119 int nAtom, sign, beginId, endId, i;
120 double rosen_r, rosen_f;
121 double energy_r, energy_f;
128 nAtom = molPtr->
nAtom();
142 if (
random().uniform(0.0, 1.0) > 0.5) {
144 endId = (beginId + (
nRegrow_ - 1)) % nAtom;
148 for (i = 0; i <
nRegrow_ + 1; ++i) {
151 if (iBond < 0) iBond += nAtom;
156 beginId = (endId + (
nRegrow_ - 1)) % nAtom;
160 if (iBond < 0) iBond += nAtom;
161 for (i = 0; i <
nRegrow_ + 1; ++i) {
164 if (iBond >= nAtom) iBond -= nAtom;
169 tempPtr = &(molPtr->
atom(beginId));
171 thisPtr = tempPtr + modId(beginId + i*sign, nAtom) - beginId;
176 deleteSequence(sign, molPtr, endId, bonds, rosen_r, energy_r);
179 addSequence(sign, molPtr, beginId, bonds, rosen_f, energy_f);
196 tempPtr = &(molPtr->
atom(beginId));
198 thisPtr = tempPtr + modId(beginId + i*sign, nAtom) - beginId;
214 void CfbRingRebridgeMove::deleteSequence(
int sign,
Molecule *molPtr,
215 int endId,
int *bonds,
double &rosenbluth,
double &energy)
221 int prevBType, nextBType, nAtom;
222 double rosen_r, energy_r;
228 nAtom = molPtr->
nAtom();
229 endPtr = &(molPtr->
atom(endId));
234 prevPtr = endPtr + modId(endId - sign,nAtom) - endId;
235 nextPtr = endPtr + modId(endId + sign,nAtom) - endId;
237 nextBType = bonds[0];
238 prevBType = bonds[1];
242 prevBType, nextBType, rosen_r, energy_r);
246 rosenbluth *= rosen_r;
251 for (
int i = 0; i <
nRegrow_ - 1; ++i) {
252 thisPtr = endPtr + modId(endId - (i+1)*sign, nAtom) - endId;
253 prevPtr = endPtr + modId(endId - (i+2)*sign, nAtom) - endId;
255 prevBType = bonds[i+2];
256 deleteEndAtom(thisPtr, prevPtr, prevBType, rosen_r, energy_r);
261 rosenbluth *= rosen_r;
269 void CfbRingRebridgeMove::addSequence(
int sign,
Molecule *molPtr,
270 int beginId,
int *bonds,
double &rosenbluth,
double &energy)
276 int prevBType, nextBType, nAtom;
277 double rosen_f, energy_f;
284 nAtom = molPtr->
nAtom();
285 beginPtr = &(molPtr->
atom(beginId));
287 for (
int i = 0; i <
nRegrow_ - 1; ++i) {
288 thisPtr = beginPtr + modId(beginId+i*sign,nAtom) - beginId;
289 prevPtr = beginPtr + modId(beginId+(i-1)*sign,nAtom) - beginId;
291 prevBType = bonds[nRegrow_ - i];
292 addEndAtom(thisPtr, prevPtr, prevBType, rosen_f, energy_f);
297 rosenbluth *= rosen_f;
303 prevPtr = beginPtr + modId(beginId+(nRegrow_-2)*sign,nAtom) - beginId;
304 thisPtr = beginPtr + modId(beginId+(nRegrow_-1)*sign,nAtom) - beginId;
305 nextPtr = beginPtr + modId(beginId+nRegrow_*sign,nAtom) - beginId;
307 prevBType = bonds[1];
308 nextBType = bonds[0];
312 prevBType, nextBType, rosen_f, energy_f);
317 rosenbluth *= rosen_f;
virtual void setup()
Initialize the arrays for preferential angle, effective spring constant and normalization factor...
Bond & bond(int localId)
Get a specific Bond in this Molecule by non-const reference.
A System for use in a Markov chain Monte Carlo simulation.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
virtual bool move()
Generate and accept or reject configuration bias move.
void addEndAtom(Atom *endPtr, Atom *pvtPtr, int bondType, double &rosenbluth, double &energy)
Configuration bias algorithm for adding an atom to a chain end.
void incrementNAttempt()
Increment the number of attempted moves.
void deleteMiddleAtom(Atom *partPtr, Atom *prevPtr, Atom *nextPtr, int prevBType, int nextBType, double &rosenbluth, double &energy)
Configuration bias algorithm for deleting a particle between two monomers and compute the correspondi...
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
void addAtom(Atom &atom)
Add an Atom to the CellList.
virtual void readParameters(std::istream &in)
Read species type, nTrial, and parameters needed to evaluate the orientation bias.
virtual void readParameters(std::istream &in)
Read species to which displacement is applied.
int typeId() const
Get the typeId for this covalent group.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
Base class configuration bias moves internal segment regrowth moves.
A Species of ring polymers (abstract).
Saving / output archive for binary ostream.
void addMiddleAtom(Atom *partPtr, Atom *prevPtr, Atom *nextPtr, int prevBType, int nextBType, double &rosenbluth, double &energy)
Configuration bias algorithm for adding the last particle with special bias in favor of closing the b...
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
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.
int speciesId_
Integer index for molecular species.
long uniformInt(long range1, long range2)
Return random long int x uniformly distributed in range1 <= x < range2.
DArray< Vector > oldPos_
Array of old positions of temporarily deleted atoms.
Random & random()
Get Random number generator of parent Simulation.
McPairPotential & pairPotential() const
Return the McPairPotential by reference.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
void deleteEndAtom(Atom *endPtr, Atom *pvtPtr, int bondType, double &rosenbluth, double &energy)
CFB algorithm for deleting an end atom from a flexible chain.
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
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 nRegrow_
Number of particles at end to attempt to regrow.
bool metropolis(double ratio)
Metropolis algorithm for whether to accept a MC move.
Simulation & simulation()
Get parent Simulation object.
A physical molecule (a set of covalently bonded Atoms).
const Vector & position() const
Get the position Vector by const reference.
virtual void save(Serializable::OArchive &ar)
Save state to an archive.
Species & species(int i)
Get a specific Species by reference.
void deleteAtom(Atom &atom)
Remove an Atom from the CellList.
virtual void loadParameters(Serializable::IArchive &ar)
Load state from an archive.
void updateAtomCell(Atom &atom)
Update the cell list to reflect a new position.
CfbRingRebridgeMove(McSystem &system)
Constructor.
int nAtom() const
Get the number of Atoms in this Molecule.