8 #include "StressAutoCorr.h" 9 #include <util/accumulators/AutoCorrelation.tpp> 10 #include <util/misc/ioUtil.h> 11 #include <util/format/Int.h> 12 #include <util/format/Dbl.h> 39 read<int>(in,
"bufferCapacity", bufferCapacity_);
42 accumulatorPtr_->
setParam(bufferCapacity_, maxStageId_);
44 isInitialized_ =
true;
59 ar >> *accumulatorPtr_;
62 isInitialized_ =
true;
74 if (!accumulatorPtr_) {
77 ar << *accumulatorPtr_;
86 if (!isInitialized_) {
90 if (!accumulatorPtr_) {
93 accumulatorPtr_->
clear();
103 if (!isInitialized_) {
120 if (!accumulatorPtr_) {
127 total.
add(virial, kinetic);
130 double pressure = 0.0;
133 pressure += total(i,i);
135 pressure = pressure/double(Dimension);
137 total(i,i) -= pressure;
143 total(i,j) *= factor;
147 accumulatorPtr_->
sample(total);
158 if (!accumulatorPtr_) {
164 outputFile_ << std::endl;
165 outputFile_ <<
"bufferCapacity " << accumulatorPtr_->
bufferCapacity() << std::endl;
166 outputFile_ <<
"nSample " << accumulatorPtr_->
nSample() << std::endl;
167 outputFile_ << std::endl;
168 outputFile_ <<
"Format of *.dat file" << std::endl;
169 outputFile_ <<
"[int time delay (samples)] [double autocorrelation function]" 171 outputFile_ << std::endl;
176 accumulatorPtr_->
output(outputFile_);
const int Dimension
Dimensionality of space.
Abstract base for periodic output and/or analysis actions.
Simulation & simulation()
Get the parent Simulation by reference.
void readOutputFileName(std::istream &in)
Read outputFileName from file.
void saveInterval(Serializable::OArchive &ar)
Save interval parameter to an archive.
virtual void sample(long iStep)
Sample virial stress to accumulators.
double volume() const
Return unit cell volume.
void openOutputFile(const std::string &filename, std::ofstream &out, std::ios_base::openmode mode=std::ios_base::out) const
Open an output file.
void readInterval(std::istream &in)
Read parameter interval from file.
void clear()
Clear accumulators and destroy descendants.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
Parallel domain decomposition (DD) MD simulation.
Main object for a domain-decomposition MD simulation.
A Tensor represents a Cartesian tensor.
Tensor & add(const Tensor &t1, const Tensor &t2)
Add tensors t1 and t2.
void output(std::ostream &out)
Output the autocorrelation function, assuming zero mean.
Saving / output archive for binary ostream.
void loadOutputFileName(Serializable::IArchive &ar)
Load output file name to an archive.
virtual void clear()
Clear nSample counter.
FileMaster & fileMaster()
Get the associated FileMaster by reference.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
virtual void setup()
Setup accumulator!
virtual void writeParam(std::ostream &out)
Write all parameters to an output stream.
bool isAtInterval(long counter) const
Return true iff counter is a multiple of the interval.
Utility classes for scientific computation.
void setParam(int bufferCapacity=64, int maxStageId=0, int blockFactor=2)
Set all parameters and allocate to initialize state.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
Tensor kineticStress() const
Return total kinetic stress.
ScalarParam< Type > & loadParameter(Serializable::IArchive &ar, const char *label, Type &value, bool isRequired)
Add and load a new ScalarParam < Type > object.
long nSample() const
Return the number of sampled values.
const std::string & outputFileName() const
Return outputFileName string.
bool isMaster() const
Is this the master processor (gridRank == 0) ?
void computeVirialStress()
Calculate and store all virial stress contributions.
virtual void output()
Dump configuration to file.
Saving archive for binary istream.
int bufferCapacity() const
Return capacity of history buffer.
void setClassName(const char *className)
Set class name string.
void loadInterval(Serializable::IArchive &ar)
Load parameter interval from input archive.
StressAutoCorr(Simulation &simulation)
Constructor.
Boundary & boundary()
Get the Boundary by reference.
void saveOutputFileName(Serializable::OArchive &ar)
Save output file name to an archive.
virtual void sample(Data value)
Sample a value.
Domain & domain()
Get the Domain by reference.
Tensor virialStress() const
Return total virial stress.
void computeKineticStress()
Calculate and store kinetic stress.
virtual void readParameters(std::istream &in)
Read dumpPrefix and interval.