8 #include "IntraPairAutoCorr.h" 9 #include <mcMd/simulation/Simulation.h> 10 #include <mcMd/chemistry/Molecule.h> 11 #include <mcMd/chemistry/Atom.h> 12 #include <simp/species/Species.h> 13 #include <simp/boundary/Boundary.h> 14 #include <util/misc/FileMaster.h> 15 #include <util/archives/Serializable_includes.h> 47 read<int>(in,
"speciesId", speciesId_);
48 read<int>(in,
"atom1Id", atom1Id_);
49 read<int>(in,
"atom2Id", atom2Id_);
50 read<int>(in,
"capacity", capacity_);
59 if (atom2Id_ <= atom1Id_)
63 if (speciesId_ >=
system().simulation().nSpecies())
68 int nAtom = speciesPtr_->
nAtom();
69 if (atom1Id_ >= nAtom)
71 if (atom2Id_ >= nAtom)
75 int speciesCapacity = speciesPtr_->
capacity();
78 data_.allocate(speciesCapacity);
81 accumulator_.setParam(speciesCapacity, capacity_);
83 isInitialized_ =
true;
92 loadParameter<int>(ar,
"speciesId", speciesId_);
93 loadParameter<int>(ar,
"atom1Id", atom1Id_);
94 loadParameter<int>(ar,
"atom2Id", atom2Id_);
95 loadParameter<int>(ar,
"capacity", capacity_);
100 if (speciesId_ < 0)
UTIL_THROW(
"Negative speciesId");
101 if (atom1Id_ < 0)
UTIL_THROW(
"Negative atom1Id");
102 if (atom2Id_ < 0)
UTIL_THROW(
"Negative atom2Id");
103 if (atom2Id_ <= atom1Id_)
UTIL_THROW(
"atom2Id <= atom1Id");
104 if (capacity_ <= 0)
UTIL_THROW(
"Negative capacity");
105 if (speciesId_ >=
system().simulation().nSpecies()) {
110 int nAtom = speciesPtr_->
nAtom();
111 if (atom1Id_ >= nAtom)
UTIL_THROW(
"atom1Id >= nAtom");
112 if (atom2Id_ >= nAtom)
UTIL_THROW(
"atom2Id >= nAtom");
115 int speciesCapacity = speciesPtr_->
capacity();
116 data_.allocate(speciesCapacity);
118 isInitialized_ =
true;
132 if (!isInitialized_) {
138 accumulator_.setNEnsemble(nMolecule_);
139 accumulator_.clear();
153 if (nMolecule_ <= 0) {
156 if (nMolecule_ !=
system().nMolecule(speciesId_)) {
157 UTIL_THROW(
"Number of molecules has changed");
161 for (i = 0; i < nMolecule_; ++i) {
167 for (j = atom1Id_ + 1; j <= atom2Id_; ++j) {
175 accumulator_.sample(data_);
188 outputFile_ << std::endl;
189 outputFile_ <<
"nMolecule " << accumulator_.nEnsemble()
191 outputFile_ <<
"bufferCapacity " << accumulator_.bufferCapacity()
193 outputFile_ <<
"nSample " << accumulator_.nSample()
195 outputFile_ << std::endl;
196 outputFile_ <<
"average " << accumulator_.average()
198 outputFile_ << std::endl;
199 outputFile_ <<
"Format of *.dat file" << std::endl;
200 outputFile_ <<
"[int time in samples] [double autocorrelation function]" 202 outputFile_ << std::endl;
207 accumulator_.output(outputFile_);
virtual void setup()
Set number of molecules and clear accumulator.
A Vector is a Cartesian vector.
virtual void sample(long iStep)
Evaluate separation vector for all chains, add to ensemble.
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 after simulation is completed.
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.
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.
Utility classes for scientific computation.
Template for Analyzer associated with one System.
virtual void save(Serializable::OArchive &ar)
Save state to archive.
Boundary & boundary() const
Get the Boundary by reference.
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
virtual void loadParameters(Serializable::IArchive &ar)
Load state from an archive.
virtual void readParameters(std::istream &in)
Read parameters from file.
IntraPairAutoCorr(System &system)
Constructor.
void setClassName(const char *className)
Set class name string.
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.
bool isAtInterval(long counter) const
Return true iff counter is a multiple of the interval.
const std::string & outputFileName() const
Return outputFileName string.
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.