9 #include "McPairEnergyAverage.h" 11 #include <util/misc/FileMaster.h> 12 #include <mcMd/chemistry/Molecule.h> 13 #include <mcMd/chemistry/Atom.h> 14 #include <mcMd/potentials/pair/McPairPotential.h> 15 #include <util/archives/Serializable_includes.h> 47 read<int>(in,
"nSamplePerBlock", nSamplePerBlock_);
48 read<PairSelector>(in,
"selector", selector_);
53 if (nSamplePerBlock_) {
56 isInitialized_ =
true;
65 loadParameter<int>(ar,
"nSamplePerBlock", nSamplePerBlock_);
66 loadParameter<PairSelector>(ar,
"selector", selector_);
69 if (nSamplePerBlock_ != accumulator_.nSamplePerBlock()) {
70 UTIL_THROW(
"Inconsistent values of nSamplePerBlock");
74 if (nSamplePerBlock_) {
77 isInitialized_ =
true;
90 { accumulator_.
clear(); }
100 Atom *iAtomPtr, *jAtomPtr;
101 int nNeighbor, nInCell;
109 for (ic = 0; ic < nc; ++ic) {
113 nNeighbor = neighbors_.
size();
116 for (i = 0; i < nInCell; ++i) {
117 iAtomPtr = neighbors_[i];
120 for (j = 0; j < nNeighbor; ++j) {
121 jAtomPtr = neighbors_[j];
123 if (selector_.
match(*iAtomPtr, *jAtomPtr)) {
143 accumulator_.
sample(energy, outputFile_);
161 accumulator_.
output(outputFile_);
void clear()
Clear all accumulators, set to empty initial state.
A System for use in a Markov chain Monte Carlo simulation.
virtual void output()
Output results at end of simulation.
const CellList & cellList() const
Get the cellList 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.
Mask & mask()
Get the associated Mask by reference.
McSystem & system()
Return reference to parent system.
void readOutputFileName(std::istream &in)
Read outputFileName from file.
Saving / output archive for binary ostream.
bool isMasked(const Atom &atom) const
True if the atom is in the masked set for the target Atom.
bool match(const Atom &atom1, const Atom &atom2) const
Return true if pair of atoms matches the selector policy.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
int typeId() const
Get type index for this Atom.
void getCellNeighbors(int ic, NeighborArray &neighbors, int &nInCell) const
Fill an array with pointers to atoms in a cell and neighboring cells.
virtual void writeParam(std::ostream &out)
Write all parameters to an output stream.
virtual void save(Serializable::OArchive &ar)
Save state to an archive.
void readInterval(std::istream &in)
Read interval from file, with error checking.
A point particle within a Molecule.
Utility classes for scientific computation.
virtual void sample(long iStep)
Calculate, analyze and/or output a physical quantity.
McPairEnergyAverage(McSystem &system)
Constructor.
int totCells() const
Get total number of cells in this CellList.
virtual void readParameters(std::istream &in)
Read parameters and initialize.
void setAvoidDoubleCounting(bool avoidDoubleCounting)
Set policy to avoid double counting (true) or to not avoid (false).
Template for Analyzer associated with one System.
void output(std::ostream &out) const
Output final statistical properties to file.
McPairPotential & pairPotential() const
Return the McPairPotential by reference.
void setNSamplePerBlock(int nSamplePerBlock)
Set nSamplePerBlock.
Boundary & boundary() const
Get the Boundary by reference.
Saving archive for binary istream.
void sample(double value)
Add a sampled value to the ensemble.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
int nSamplePerBlock() const
Get number of samples per block average.
void setClassName(const char *className)
Set class name string.
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.
virtual void loadParameters(Serializable::IArchive &ar)
Load state from an archive.
const Vector & position() const
Get the position Vector by const reference.
int size() const
Return logical size of this array (i.e., number of elements).
virtual void setup()
Clear accumulator.