8 #include "CfbDoubleRebridgeMove.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> 18 #include <simp/species/Linear.h> 19 #include <simp/boundary/Boundary.h> 75 loadParameter<int>(ar,
"speciesId",
speciesId_);
76 loadParameter<int>(ar,
"nRegrow",
nRegrow_);
84 UTIL_THROW(
"Species is not a subclass of Linear");
124 int iMol, jMol, sign, beginId, nEnd, i;
130 double rosenbluth, rosen_r, rosen_f;
131 double energy, energy_r, energy_f;
138 if (
random().uniform(0.0, 1.0) > 0.5)
144 found = forwardScan(sign, iMol, jMol, beginId, po2n);
145 if (!found)
return found;
151 thisPtr = &(iPtr->
atom(beginId));
152 tempPtr = &(jPtr->
atom(beginId));
164 bonds =
new int[nRegrow_ + 1];
166 for (i = 0; i < nRegrow_ + 1; ++i)
167 bonds[i] = iPtr->
bond(beginId - 1 + nRegrow_ - i).
typeId();
169 for (i = 0; i < nRegrow_ + 1; ++i)
170 bonds[i] = iPtr->
bond(beginId - nRegrow_ + i).
typeId();
177 thisPtr = &(iPtr->
atom(beginId + (nRegrow_-1)*sign));
178 deleteSequence(nRegrow_, sign, thisPtr, bonds, rosenbluth, energy);
179 rosen_r *= rosenbluth;
182 thisPtr = &(jPtr->
atom(beginId + (nRegrow_-1)*sign));
183 deleteSequence(nRegrow_, sign, thisPtr, bonds, rosenbluth, energy);
184 rosen_r *= rosenbluth;
193 thisPtr = &(iPtr->
atom(beginId + nRegrow_*sign));
194 tempPtr = &(jPtr->
atom(beginId + nRegrow_*sign));
195 for (i = 0; i < nEnd; ++i) {
216 thisPtr = &(jPtr->
atom(beginId));
217 addSequence(nRegrow_, sign, thisPtr, bonds, rosenbluth, energy);
218 rosen_f *= rosenbluth;
221 thisPtr = &(iPtr->
atom(beginId));
222 addSequence(nRegrow_, sign, thisPtr, bonds, rosenbluth, energy);
223 rosen_f *= rosenbluth;
227 found = reverseScan(sign, iMol, jMol, beginId - sign, pn2o);
243 thisPtr = &(iPtr->
atom(beginId));
244 tempPtr = &(jPtr->
atom(beginId));
262 thisPtr = &(iPtr->
atom(beginId + nRegrow_*sign));
263 tempPtr = &(jPtr->
atom(beginId + nRegrow_*sign));
264 for (i = 0; i < nEnd; ++i) {
311 bool CfbDoubleRebridgeMove::forwardScan(
int sign,
int &iMol,
312 int &jMol,
int &beginId,
double &prob)
315 Vector iPos1, jPos1, iPos2, jPos2;
316 int nMol, nAtom, maxPair;
317 int signRegrow, nPairs, k, choice;
318 int *molBuf, *atomBuf;
319 double lengthSq, bridgeLengthSq;
330 nAtom = iPtr->
nAtom();
338 maxPair = (nMol - 1) * (nAtom - 1 -
nRegrow_);
339 molBuf =
new int[maxPair];
340 atomBuf =
new int[maxPair];
343 beginId = (sign == -1) ? (nAtom-1) : 0;
354 for (jMol = 0; jMol < nMol; ++jMol) {
360 for (k = 0; k < nAtom - 1 -
nRegrow_; ++k) {
364 jPos2 = jPtr->
atom(beginId + signRegrow + k*sign).
position();
367 if (lengthSq < bridgeLengthSq) {
370 iPos2 = iPtr->
atom(beginId + signRegrow + k*sign).
position();
373 if (lengthSq < bridgeLengthSq) {
374 molBuf[nPairs] = jMol;
375 atomBuf[nPairs] = beginId + k*sign;
384 if (nPairs > 0) found =
true;
389 jMol = molBuf[choice];
390 beginId = atomBuf[choice] + sign;
391 prob = 1.0 / double(nPairs);
417 bool CfbDoubleRebridgeMove::reverseScan(
int sign,
int iMol,
418 int jMol,
int beginId,
double &prob)
421 Vector iPos1, jPos1, iPos2, jPos2;
423 int signRegrow, nPairs, headId, k;
424 double lengthSq, bridgeLengthSq;
435 nAtom = iPtr->
nAtom();
449 if (lengthSq < bridgeLengthSq) {
455 if (lengthSq < bridgeLengthSq) {
467 headId = (sign == -1) ? (nAtom-1) : 0;
474 for (j = 0; j < nMol; ++j) {
480 for (k = 0; k < nAtom - 1 -
nRegrow_; ++k) {
484 jPos2 = jPtr->
atom(headId + signRegrow + k*sign).
position();
487 if (lengthSq < bridgeLengthSq) {
490 iPos2 = iPtr->
atom(headId + signRegrow + k*sign).
position();
493 if (lengthSq < bridgeLengthSq) nPairs += 1;
501 prob = 1.0 / double(nPairs);
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.
A Vector is a Cartesian vector.
void incrementNAttempt()
Increment the number of attempted moves.
DArray< Vector > jOldPos_
Array of old positions of temporarily deleted atoms (jMol).
double distanceSq(const Vector &r1, const Vector &r2) const
Return square distance between positions r1 and r2.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
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.
DArray< Vector > iOldPos_
Array of old positions of temporarily deleted atoms (iMol).
Saving / output archive for binary ostream.
Molecule & molecule(int speciesId, int moleculeId)
Get a specific Molecule in this System, by integer index.
int nMolecule(int speciesId) const
Get the number of molecules of one Species in this System.
void addSequence(int nActive, int sign, Atom *beginPtr, int *bonds, double &rosenbluth, double &energy)
Configuration bias algorithm for adding a consequtive sequence of atoms.
#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.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
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.
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.
CfbDoubleRebridgeMove(McSystem &system)
Constructor.
void deleteSequence(int nActive, int sign, Atom *endPtr, int *bonds, double &rosenbluth, double &energy)
Configuration bias algorithm for deleting a consequtive sequence of atoms.
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.
double bridgeLength_
upper bound for trial lenght of a bridge.
bool metropolis(double ratio)
Metropolis algorithm for whether to accept a MC move.
virtual bool move()
Generate and accept or reject configuration bias 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.
Species & species(int i)
Get a specific Species by reference.
void updateAtomCell(Atom &atom)
Update the cell list to reflect a new position.
A Species of linear polymers (abstract).
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.
int nRegrow_
Number of particles at end to attempt to regrow.