11 #include "Sliplinker.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/chemistry/Molecule.h> 17 #include <mcMd/chemistry/Atom.h> 18 #include <simp/boundary/Boundary.h> 19 #include <util/space/Vector.h> 20 #include <util/space/Dimension.h> 40 read<double>(in,
"cutoff", cutoff_);
41 read<double>(in,
"mu", mu_);
42 read<int>(in,
"speciesId", speciesId_);
51 Atom *atom0Ptr, *atom1Ptr;
55 double prob, dRSq, mindRSq=cutoff_*cutoff_, rnd, norm;
56 int i, ntrials, j, nNeighbor, idLink, iAtom, id1, id0;
57 int iAtom0, iAtom1, iMolecule0, iMolecule1, n0;
60 double cdf[maxNeighbor], energy, sum;
61 int idneighbors[maxNeighbor];
65 for (i=0; i < ntrials; ++i){
68 if (
random().uniform(0.0, 1.0) > 0.5){
75 atomPtr = &molIPtr->
atom(iAtom);
80 nNeighbor = neighbors_.
size();
85 for (j = 0; j < nNeighbor; ++j) {
86 atom1Ptr = neighbors_[j];
97 if (dRSq <= mindRSq) {
114 norm = 1.0/cdf[n0-1];
115 while (rnd > cdf[j]*norm ){
118 atom1Ptr = neighbors_[idneighbors[j]];
133 if (
system().linkMaster().nLink() > 0){
137 atom0Ptr = &(linkPtr->
atom0());
141 atom1Ptr = &(linkPtr->
atom1());
148 if (dRSq <= mindRSq) {
150 system().cellList().getNeighbors(atom0Ptr->
position(), neighbors_);
151 nNeighbor = neighbors_.
size();
152 id0 = atom0Ptr->
id();
156 for (j = 0; j < nNeighbor; ++j) {
157 atom1Ptr = neighbors_[j];
160 id1 = atom1Ptr->
id();
168 if (dRSq <= mindRSq) {
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.
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.
double distanceSq(const Vector &r1, const Vector &r2) const
Return square distance between positions r1 and r2.
int atomCapacity() const
Get the total number of Atoms allocated.
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.
virtual void readParameters(std::istream &in)
Read cutoff and probability.
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.
Simulation & simulation() const
Get the parent Simulation by reference.
A point particle within a Molecule.
Utility classes for scientific computation.
Sliplinker(McSystem &system)
Constructor.
An McMove that acts on one McSystem.
int id() const
Get global index for this Atom within the Simulation.
long uniformInt(long range1, long range2)
Return random long int x uniformly distributed in range1 <= x < range2.
Forward iterator for an Array or a C array.
Forward iterator for a PArray.
Random & random()
Get Random number generator of parent Simulation.
virtual double energy(double rSq, int type) const =0
Returns potential energy for one bond.
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 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.
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.
void addLink(Atom &atom0, Atom &atom1, int typeId)
Add a link betwen two specific Atoms.
virtual bool move()
Create or destroy slip-springs.
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.
LinkMaster & linkMaster() const
Get the LinkMaster by reference.