9 #include <mcMd/simulation/System.h> 10 #include <mcMd/simulation/Simulation.h> 11 #include <mcMd/chemistry/Molecule.h> 12 #include <mcMd/chemistry/Atom.h> 13 #include <simp/boundary/Boundary.h> 14 #include <simp/species/Species.h> 15 #include <util/space/Dimension.h> 16 #include <util/archives/Serializable_includes.h> 50 read<int>(in,
"speciesId", speciesId_);
51 read<int>(in,
"capacity", capacity_);
54 if (speciesId_ < 0)
UTIL_THROW(
"Negative speciesId");
55 if (speciesId_ >=
system().simulation().nSpecies())
57 if (capacity_ <= 0)
UTIL_THROW(
"Negative capacity");
64 truePositions_.allocate(speciesCapacity);
65 oldPositions_.allocate(speciesCapacity);
66 shifts_.allocate(speciesCapacity);
69 accumulator_.setParam(speciesCapacity, capacity_);
74 isInitialized_ =
true;
83 loadParameter<int>(ar,
"speciesId", speciesId_);
84 loadParameter<int>(ar,
"capacity", capacity_);
91 if (speciesId_ >=
system().simulation().nSpecies()) {
97 if (nAtom_ !=
system().simulation().species(speciesId_).nAtom()) {
106 truePositions_.allocate(speciesCapacity);
107 oldPositions_.allocate(speciesCapacity);
108 shifts_.allocate(speciesCapacity);
109 accumulator_.setParam(speciesCapacity, capacity_);
138 accumulator_.setNEnsemble(nMolecule_);
140 accumulator_.clear();
144 for (
int i = 0; i < nMolecule_; ++i) {
147 oldPositions_[i] = r;
161 if (nMolecule_ <= 0) {
164 if (nMolecule_ !=
system().nMolecule(speciesId_)) {
165 UTIL_THROW(
"Number of molecules has changed.");
172 for (i = 0; i < nMolecule_; ++i) {
184 oldPositions_[i] = r;
191 truePositions_[i][j] = r[j] + double(shifts_[i][j])*lengths[j];
195 accumulator_.sample(truePositions_);
208 outputFile_ << std::endl;
209 outputFile_ << std::endl;
210 outputFile_ <<
"nMolecule " << accumulator_.nEnsemble() << std::endl;
211 outputFile_ <<
"bufferCapacity " << accumulator_.bufferCapacity()
213 outputFile_ <<
"nSample " << accumulator_.nSample() << std::endl;
214 outputFile_ << std::endl;
215 outputFile_ <<
"Format of *.dat file:" << std::endl;
216 outputFile_ <<
"[i] [MSD]" 222 accumulator_.output(outputFile_);
229 void ComMSD::moleculeCom(
int iMol,
Vector &R0)
231 Vector R = R0, r1, r2, dr;
234 for (
int i = 1; i < nAtom_-1; ++i) {
243 R0 /= double(nAtom_);
const int Dimension
Dimensionality of space.
A Vector is a Cartesian vector.
int nAtom() const
Get number of atoms per molecule for this Species.
double distanceSq(const Vector &r1, const Vector &r2) const
Return square distance between positions r1 and r2.
virtual void sample(long iStep)
Evaluate center of mass displacement of all chains and add to ensemble.
const Vector & lengths() const
Get Vector of unit cell lengths by const reference.
void openOutputFile(const std::string &filename, std::ofstream &out, std::ios_base::openmode mode=std::ios_base::out) const
Open an output file.
virtual void loadParameters(Serializable::IArchive &ar)
Load parameters from archive.
A set of interacting Molecules enclosed by a Boundary.
System & system()
Return reference to parent system.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
void readOutputFileName(std::istream &in)
Read outputFileName from file.
Saving / output archive for binary ostream.
Molecule & molecule(int speciesId, int moleculeId)
Get a specific Molecule in this System, by integer index.
ComMSD(System &system)
Constructor.
int nMolecule(int speciesId) const
Get the number of molecules of one Species in this System.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Simulation & simulation() const
Get the parent Simulation by reference.
virtual void writeParam(std::ostream &out)
Write all parameters to an output stream.
virtual void readParameters(std::istream &in)
Read parameters from file.
void readInterval(std::istream &in)
Read interval from file, with error checking.
Utility classes for scientific computation.
void shift(Vector &r) const
Shift Cartesian Vector r to its primary image.
Template for Analyzer associated with one System.
Boundary & boundary() const
Get the Boundary by reference.
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
virtual void output()
Output results to file after simulation is completed.
void setClassName(const char *className)
Set class name string.
An IntVector is an integer Cartesian vector.
const Atom & atom(int localId) const
Get a specific Atom in this Molecule.
int capacity() const
Maximum allowed number of molecules for this Species.
virtual void save(Serializable::OArchive &ar)
Save state to archive.
FileMaster & fileMaster()
Get the FileMaster by reference.
virtual void setup()
Determine number of molecules and allocate memory.
bool isAtInterval(long counter) const
Return true iff counter is a multiple of the interval.
const std::string & outputFileName() const
Return outputFileName string.
const Vector & position() const
Get the position Vector by const reference.
virtual void loadParameters(Serializable::IArchive &ar)
Load state from an archive.
Species & species(int i)
Get a specific Species by reference.