8 #include "MdVirialStressTensorAverage.h" 10 #include <mcMd/simulation/Simulation.h> 11 #include <util/misc/ioUtil.h> 12 #include <util/format/Int.h> 13 #include <util/format/Dbl.h> 48 read<int>(in,
"nSamplePerBlock", nSamplePerBlock_);
64 isInitialized_ =
true;
74 loadParameter<int>(ar,
"nSamplePerBlock", nSamplePerBlock_);
86 if (nSamplePerBlock_) {
89 isInitialized_ =
true;
104 if (!isInitialized_) {
110 sxxAccumulator_.
clear();
111 sxyAccumulator_.
clear();
112 sxzAccumulator_.
clear();
113 syxAccumulator_.
clear();
114 syyAccumulator_.
clear();
115 syzAccumulator_.
clear();
116 szxAccumulator_.
clear();
117 szyAccumulator_.
clear();
118 szzAccumulator_.
clear();
131 sxxAccumulator_.
sample(virial(0,0));
132 sxyAccumulator_.
sample(virial(0,1));
133 sxzAccumulator_.
sample(virial(0,2));
134 syxAccumulator_.
sample(virial(1,0));
135 syyAccumulator_.
sample(virial(1,1));
136 syzAccumulator_.
sample(virial(1,2));
137 szxAccumulator_.
sample(virial(2,0));
138 szyAccumulator_.
sample(virial(2,1));
139 szzAccumulator_.
sample(virial(2,2));
152 "Sxx=" <<
Dbl(sxxAccumulator_.
average(), 17)<<
" +- " <<
Dbl(sxxAccumulator_.
error(), 9, 8) <<
"\n" <<
153 "Sxy=" <<
Dbl(sxyAccumulator_.
average(), 17)<<
" +- " <<
Dbl(sxyAccumulator_.
error(), 9, 8) <<
"\n" <<
154 "Sxz=" <<
Dbl(sxzAccumulator_.
average(), 17)<<
" +- " <<
Dbl(sxzAccumulator_.
error(), 9, 8) <<
"\n" <<
155 "Syx=" <<
Dbl(syxAccumulator_.
average(), 17)<<
" +- " <<
Dbl(syxAccumulator_.
error(), 9, 8) <<
"\n" <<
156 "Syy=" <<
Dbl(syyAccumulator_.
average(), 17)<<
" +- " <<
Dbl(syyAccumulator_.
error(), 9, 8) <<
"\n" <<
157 "Syz=" <<
Dbl(syzAccumulator_.
average(), 17)<<
" +- " <<
Dbl(syzAccumulator_.
error(), 9, 8) <<
"\n" <<
158 "Szx=" <<
Dbl(szxAccumulator_.
average(), 17)<<
" +- " <<
Dbl(szxAccumulator_.
error(), 9, 8) <<
"\n" <<
159 "Szy=" <<
Dbl(szyAccumulator_.
average(), 17)<<
" +- " <<
Dbl(szyAccumulator_.
error(), 9, 8) <<
"\n" <<
160 "Szz=" <<
Dbl(szzAccumulator_.
average(), 17)<<
" +- " <<
Dbl(szzAccumulator_.
error(), 9, 8) <<
"\n" <<
void clear()
Clear all accumulators, set to empty initial state.
MdVirialStressTensorAverage(MdSystem &system)
Constructor.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
FileMaster & fileMaster() const
Get the associated FileMaster by reference.
double average() const
Return the average of all sampled values.
virtual void output()
Dump configuration to 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.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
MdSystem & system()
Return reference to parent system.
Wrapper for a double precision number, for formatted ostream output.
void readOutputFileName(std::istream &in)
Read outputFileName from file.
A Tensor represents a Cartesian tensor.
Saving / output archive for binary ostream.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
void computeVirialStress(T &stress) const
Compute total virial stress, from all forces.
void readInterval(std::istream &in)
Read interval from file, with error checking.
Utility classes for scientific computation.
virtual void sample(long iStep)
Sample virial stress to accumulators.
Template for Analyzer associated with one System.
void setNSamplePerBlock(int nSamplePerBlock)
Set nSamplePerBlock.
Saving archive for binary istream.
virtual void clear()
Clear nSample counter.
void sample(double value)
Add a sampled value to the ensemble.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
void setClassName(const char *className)
Set class name string.
FileMaster & fileMaster()
Get the FileMaster by reference.
A System for Molecular Dynamics simulation.
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 readParameters(std::istream &in)
Read dumpPrefix and interval.
double error() const
Return a naive estimate for the std deviation of the average.