1 #ifndef MCMD_INTRA_BOND_STRESS_AUTO_CORR_INC_H 2 #define MCMD_INTRA_BOND_STRESS_AUTO_CORR_INC_H 11 #include "IntraBondStressAutoCorr.h" 12 #include <mcMd/simulation/Simulation.h> 13 #include <mcMd/simulation/stress.h> 14 #include <mcMd/chemistry/Molecule.h> 15 #include <mcMd/chemistry/Bond.h> 16 #include <mcMd/chemistry/Atom.h> 17 #include <simp/species/Species.h> 18 #include <simp/boundary/Boundary.h> 19 #include <util/misc/FileMaster.h> 32 template <
class SystemType>
47 template <
class SystemType>
54 template <
class SystemType>
59 read(in,
"speciesId", speciesId_);
60 read(in,
"capacity", capacity_);
65 if (speciesId_ >=
system().simulation().nSpecies())
70 speciesPtr_ = &
system().simulation().species(speciesId_);
71 nBond_ = speciesPtr_->
nBond();
73 UTIL_THROW(
"Number of bonds per molecule <= 0");
76 int speciesCapacity = speciesPtr_->
capacity();
77 data_.allocate(speciesCapacity);
78 accumulator_.setParam(speciesCapacity, capacity_);
83 isInitialized_ =
true;
89 template <
class SystemType>
void 100 if (speciesId_ < 0) {
103 if (speciesId_ >=
system().simulation().nSpecies()) {
106 if (capacity_ <= 0) {
110 UTIL_THROW(
"Number of bonds per molecule <= 0");
112 speciesPtr_ = &
system().simulation().species(speciesId_);
113 if (nBond_ != speciesPtr_->
nBond()) {
118 int speciesCapacity = speciesPtr_->
capacity();
119 if (speciesCapacity <= 0) {
122 data_.allocate(speciesCapacity);
124 isInitialized_ =
true;
130 template <
class SystemType>
void 137 template <
class SystemType>
141 if (!isInitialized_) {
146 nMolecule_ =
system().nMolecule(speciesId_);
149 accumulator_.setNEnsemble(nMolecule_);
150 accumulator_.clear();
156 template <
class SystemType>
163 double rsq, pressure;
167 if (nMolecule_ !=
system().nMolecule(speciesId_)) {
168 UTIL_THROW(
"Number of molecules has changed.");
175 system().begin(speciesId_, molIter);
176 for ( ; molIter.
notEnd(); ++ molIter) {
179 molIter->begin(bondIter);
180 for ( ; bondIter.
notEnd(); ++bondIter) {
181 rsq =
system().boundary().distanceSq(
182 bondIter->atom(0).position(),
183 bondIter->atom(1).position(), dr);
185 f *=
system().bondPotential()
186 .forceOverR(rsq, bondIter->typeId());
187 incrementPairStress(f, dr, data_[i]);
191 pressure = data_[i].trace() / double(
Dimension);
193 data_[i](j, j) -= pressure;
199 accumulator_.sample(data_);
206 template <
class SystemType>
217 accumulator_.output(outputFile_);
const int Dimension
Dimensionality of space.
A Vector is a Cartesian vector.
virtual void readParameters(std::istream &in)
Read parameters from file.
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.
IntraBondStressAutoCorr(SystemType &system)
Constructor.
SystemType & system()
Return reference to parent system.
Forward iterator for a PArray.
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
void readOutputFileName(std::istream &in)
Read outputFileName from file.
A Tensor represents a Cartesian tensor.
Forward const iterator for an Array or a C array.
Saving / output archive for binary ostream.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
virtual void writeParam(std::ostream &out)
Write all parameters to an output stream.
virtual void save(Serializable::OArchive &ar)
Save internal state to archive.
void readInterval(std::istream &in)
Read interval from file, with error checking.
Utility classes for scientific computation.
virtual void output()
Output results after simulation is completed.
ScalarParam< Type > & loadParameter(Serializable::IArchive &ar, const char *label, Type &value, bool isRequired)
Add and load a new ScalarParam < Type > object.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from archive.
Template for Analyzer associated with one System.
bool notEnd() const
Is the current pointer not at the end of the array?
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
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.
virtual void setup()
Set number of molecules and clear accumulator.
const std::string & outputFileName() const
Return outputFileName string.
bool notEnd() const
Is this not the end of the array?
virtual ~IntraBondStressAutoCorr()
Destructor.
ScalarParam< Type > & read(std::istream &in, const char *label, Type &value)
Add and read a new required ScalarParam < Type > object.
int nBond() const
Get number of bonds per molecule for this Species.
virtual void sample(long iStep)
Evaluate end-to-end vectors of all chains, add to ensemble.