8 #include "CfbEndBase.h" 9 #include <mcMd/mcSimulation/McSystem.h> 12 #include <mcMd/chemistry/getAtomGroups.h> 13 #include <mcMd/chemistry/Molecule.h> 14 #include <mcMd/chemistry/Bond.h> 15 #include <mcMd/chemistry/Atom.h> 16 #include <simp/boundary/Boundary.h> 17 #include <util/space/Vector.h> 36 UTIL_THROW(
"CfbEndBase is unusable with dihedrals");
52 read<int>(in,
"nTrial",
nTrial_);
63 double &rosenbluth,
double &energy)
67 double trialEnergy, lengthSq, length;
71 length = sqrt(lengthSq);
82 const Angle *anglePtr;
83 const Atom *pvtPtr2(NULL);
85 int iAngle, angleTypeId(0);
86 double rsq1, rsq2, cosTheta;
88 if (
system().hasAnglePotential()) {
92 for (iAngle = 0; iAngle < angles.
size(); ++iAngle) {
93 anglePtr = angles[iAngle];
94 if (&anglePtr->
atom(1) == pvtPtr) {
95 if (&anglePtr->
atom(0) == endPtr) {
96 pvtPtr2 = &anglePtr->
atom(2);
98 pvtPtr2 = &anglePtr->
atom(0);
100 angleTypeId = anglePtr->
typeId();
109 cosTheta = dr1.
dot(dr2) / sqrt(rsq1 * rsq2);
117 if (
system().hasExternalPotential()) {
130 for (
int iTrial=0; iTrial <
nTrial_ - 1; ++iTrial) {
144 if (
system().hasAnglePotential()) {
148 for (iAngle = 0; iAngle < angles.
size(); ++iAngle) {
149 anglePtr = angles[iAngle];
150 if (&anglePtr->
atom(1) == pvtPtr) {
151 if (&anglePtr->
atom(0) == endPtr) {
152 pvtPtr2 = &anglePtr->
atom(2);
154 pvtPtr2 = &anglePtr->
atom(0);
156 angleTypeId = anglePtr->
typeId();
165 cosTheta = dr1.
dot(dr2) / sqrt(rsq1 * rsq2);
168 .
energy(cosTheta, angleTypeId);
173 if (
system().hasExternalPotential()) {
190 double &rosenbluth,
double &energy)
201 const Angle *anglePtr;
202 const Atom *pvtPtr2(NULL);
204 int iAngle, angleTypeId(0);
205 double rsq1, rsq2, cosTheta;
215 for (iTrial=0; iTrial <
nTrial_; ++iTrial) {
219 trialPos[iTrial].
add(pvtPos, bondVec);
221 endPtr->
position() = trialPos[iTrial];
225 trialEnergy[iTrial] = 0.0;
229 if (
system().hasAnglePotential()) {
232 for (iAngle = 0; iAngle < angles.
size(); ++iAngle) {
233 anglePtr = angles[iAngle];
234 if (&anglePtr->
atom(1) == pvtPtr) {
235 if (&anglePtr->
atom(0) == endPtr) {
236 pvtPtr2 = &anglePtr->
atom(2);
238 pvtPtr2 = &anglePtr->
atom(0);
240 angleTypeId = anglePtr->
typeId();
249 cosTheta = dr1.
dot(dr2) / sqrt(rsq1 * rsq2);
252 energy(cosTheta, angleTypeId);
257 if (
system().hasExternalPotential()) {
258 trialEnergy[iTrial] +=
263 trialProb[iTrial] =
boltzmann(trialEnergy[iTrial]);
264 rosenbluth += trialProb[iTrial];
268 for (iTrial = 0; iTrial <
nTrial_; ++iTrial) {
269 trialProb[iTrial] = trialProb[iTrial]/rosenbluth;
277 energy += trialEnergy[iTrial];
280 endPtr->
position() = trialPos[iTrial];
static const int MaxTrial_
Maximum allowed number of trial positions for a regrown atom.
A System for use in a Markov chain Monte Carlo simulation.
A Vector is a Cartesian vector.
virtual double atomEnergy(const Atom &atom) const =0
Calculate the external energy for one Atom.
void addEndAtom(Atom *endPtr, Atom *pvtPtr, int bondType, double &rosenbluth, double &energy)
Configuration bias algorithm for adding an atom to a chain end.
Vector & add(const Vector &v1, const Vector &v2)
Add vectors v1 and v2.
double distanceSq(const Vector &r1, const Vector &r2) const
Return square distance between positions r1 and r2.
Include this file to include all MC potential energy classes at once.
BondPotential & bondPotential() const
Return the BondPotential by reference.
bool hasDihedralPotential() const
Does a dihedral potential exist?.
double dot(const Vector &v) const
Return dot product of this vector and vector v.
int typeId() const
Get the typeId for this covalent group.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
long drawFrom(double probability[], long size)
Choose one of several outcomes with a specified set of probabilities.
double boltzmann(double energy)
Boltzmann weight associated with an energy difference.
A fixed capacity (static) contiguous array with a variable logical size.
double beta() const
Return the inverse temperature.
void getAtomAngles(const Atom &atom, AtomAngleArray &groups)
Fill an array of pointers to Angles that contain an Atom.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
McSystem & system()
Get parent McSystem.
ExternalPotential & externalPotential() const
Return ExternalPotential by reference.
A point particle within a Molecule.
Utility classes for scientific computation.
An McMove that acts on one McSystem.
void shift(Vector &r) const
Shift Cartesian Vector r to its primary image.
Random & random()
Get Random number generator of parent Simulation.
Atom & atom(int i)
Get a specific Atom in the Group by reference.
McPairPotential & pairPotential() const
Return the McPairPotential by reference.
virtual double energy(double cosTheta, int type) const =0
Returns potential energy for one angle.
virtual double energy(double rSq, int type) const =0
Returns potential energy for one bond.
void deleteEndAtom(Atom *endPtr, Atom *pvtPtr, int bondType, double &rosenbluth, double &energy)
CFB algorithm for deleting an end atom from a flexible chain.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
CfbEndBase(McSystem &system)
Constructor.
virtual ~CfbEndBase()
Destructor.
A sequence of NAtom covalently interacting atoms.
int nTrial_
Actual number of trial positions for each regrown atom.
virtual void readParameters(std::istream &in)
Read parameter nTrial.
AnglePotential & anglePotential() const
Return AnglePotential by reference.
const Vector & position() const
Get the position Vector by const reference.
virtual double randomBondLength(Util::Random *random, double beta, int type) const =0
Return bond length chosen from equilibrium distribution.
int size() const
Return logical size of this array (i.e., number of elements).
EnergyEnsemble & energyEnsemble()
Get EnergyEnsemble object of parent McSystem.
virtual double atomEnergy(const Atom &atom) const =0
Calculate the nonbonded pair energy for one Atom.
void unitVector(Vector &v)
Generate unit vector with uniform probability over the unit sphere.
Boundary & boundary()
Get Boundary object of parent McSystem.