9 #include <mcMd/simulation/Simulation.h> 10 #include <simp/species/Species.h> 11 #include <mcMd/chemistry/Molecule.h> 12 #include <mcMd/chemistry/Atom.h> 13 #include <simp/boundary/Boundary.h> 14 #include <util/space/Dimension.h> 15 #include <util/archives/Serializable_includes.h> 51 read<int>(in,
"speciesId", speciesId_);
52 read<int>(in,
"atomId", atomId_);
53 read<int>(in,
"capacity", capacity_);
58 if (speciesId_ >=
system().simulation().nSpecies())
67 if (atomId_ >= speciesPtr->
nAtom())
71 int speciesCapacity = speciesPtr->
capacity();
74 truePositions_.allocate(speciesCapacity);
75 oldPositions_.allocate(speciesCapacity);
76 shifts_.allocate(speciesCapacity);
79 accumulator_.setParam(speciesCapacity, capacity_);
81 isInitialized_ =
true;
91 loadParameter<int>(ar,
"speciesId", speciesId_);
92 loadParameter<int>(ar,
"atomId", atomId_);
93 loadParameter<int>(ar,
"capacity", capacity_);
98 if (speciesId_ >=
system().simulation().nSpecies()) {
101 if (atomId_ < 0)
UTIL_THROW(
"Negative atomId");
102 if (capacity_ <= 0)
UTIL_THROW(
"Negative capacity");
106 if (atomId_ >= speciesPtr->
nAtom()) {
111 int speciesCapacity = speciesPtr->
capacity();
114 truePositions_.allocate(speciesCapacity);
115 oldPositions_.allocate(speciesCapacity);
116 shifts_.allocate(speciesCapacity);
119 accumulator_.setParam(speciesCapacity, capacity_);
127 isInitialized_ =
true;
141 if (!isInitialized_) {
142 UTIL_THROW(
"Error: object is not initialized");
147 accumulator_.setNEnsemble(nMolecule_);
148 accumulator_.clear();
153 for (
int i = 0; i < nMolecule_; ++i) {
156 oldPositions_[i] = r;
169 if (nMolecule_ <= 0) {
172 if (nMolecule_ !=
system().nMolecule(speciesId_)) {
173 UTIL_THROW(
"Number of molecules has changed.");
180 for (i = 0; i < nMolecule_; ++i) {
193 truePositions_[i][j] = r[j] + shifts_[i][j]*lengths[j];
197 oldPositions_[i] = r;
200 accumulator_.sample(truePositions_);
211 outputFile_ << std::endl;
212 outputFile_ << std::endl;
213 outputFile_ <<
"nMolecule " << accumulator_.nEnsemble()
215 outputFile_ <<
"buffercapacity " << accumulator_.bufferCapacity()
217 outputFile_ <<
"nSample " << accumulator_.nSample()
219 outputFile_ << std::endl;
226 accumulator_.output(outputFile_);
const int Dimension
Dimensionality of space.
A Vector is a Cartesian vector.
virtual void setup()
Determine number of molecules and allocate memory.
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 output()
Output results to file after simulation is completed.
virtual void save(Serializable::OArchive &ar)
Save state to archive.
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.
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.
virtual void loadParameters(Serializable::IArchive &ar)
Load state from an archive.
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.
#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.
void readInterval(std::istream &in)
Read interval from file, with error checking.
virtual void sample(long iStep)
Evaluate end-to-end vectors of all chains, add to ensemble.
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).
void setClassName(const char *className)
Set class name string.
An IntVector is an integer Cartesian vector.
virtual void readParameters(std::istream &in)
Read parameters from file.
const Atom & atom(int localId) const
Get a specific Atom in this Molecule.
int capacity() const
Maximum allowed number of molecules for this Species.
FileMaster & fileMaster()
Get the FileMaster by reference.
void loadInterval(Serializable::IArchive &ar)
Load interval from archive, with error checking.
bool isAtInterval(long counter) const
Return true iff counter is a multiple of the interval.
const std::string & outputFileName() const
Return outputFileName string.
void loadOutputFileName(Serializable::IArchive &ar)
Load output file name from archive.
const Vector & position() const
Get the position Vector by const reference.
A Species represents a set of chemically similar molecules.
Species & species(int i)
Get a specific Species by reference.
AtomMSD(System &system)
Constructor.