8 #include "VirialStressTensorAverage.h" 10 #include <util/misc/ioUtil.h> 11 #include <util/format/Int.h> 12 #include <util/format/Dbl.h> 46 read<int>(in,
"nSamplePerBlock", nSamplePerBlock_);
57 isInitialized_ =
true;
68 loadParameter<int>(ar,
"nSamplePerBlock", nSamplePerBlock_);
81 ar >> sxxAccumulator_;
82 ar >> sxyAccumulator_;
83 ar >> sxzAccumulator_;
84 ar >> syxAccumulator_;
85 ar >> syyAccumulator_;
86 ar >> syzAccumulator_;
87 ar >> szxAccumulator_;
88 ar >> szyAccumulator_;
89 ar >> szzAccumulator_;
92 isInitialized_ =
true;
103 ar << nSamplePerBlock_;
104 ar << sxxAccumulator_;
105 ar << sxyAccumulator_;
106 ar << sxzAccumulator_;
107 ar << syxAccumulator_;
108 ar << syyAccumulator_;
109 ar << syzAccumulator_;
110 ar << szxAccumulator_;
111 ar << szyAccumulator_;
112 ar << szzAccumulator_;
121 if (!isInitialized_) {
126 sxxAccumulator_.
clear();
127 sxyAccumulator_.
clear();
128 sxzAccumulator_.
clear();
129 syxAccumulator_.
clear();
130 syyAccumulator_.
clear();
131 syzAccumulator_.
clear();
132 szxAccumulator_.
clear();
133 szyAccumulator_.
clear();
134 szzAccumulator_.
clear();
151 total.
add(virial, kinetic);
152 sxxAccumulator_.
sample(virial(0,0));
153 sxyAccumulator_.
sample(virial(0,1));
154 sxzAccumulator_.
sample(virial(0,2));
155 syxAccumulator_.
sample(virial(1,0));
156 syyAccumulator_.
sample(virial(1,1));
157 syzAccumulator_.
sample(virial(1,2));
158 szxAccumulator_.
sample(virial(2,0));
159 szyAccumulator_.
sample(virial(2,1));
160 szzAccumulator_.
sample(virial(2,2));
175 "Sxx=" <<
Dbl(sxxAccumulator_.
average(), 17)<<
" +- " <<
Dbl(sxxAccumulator_.
error(), 9, 8) <<
"\n" <<
176 "Sxy=" <<
Dbl(sxyAccumulator_.
average(), 17)<<
" +- " <<
Dbl(sxyAccumulator_.
error(), 9, 8) <<
"\n" <<
177 "Sxz=" <<
Dbl(sxzAccumulator_.
average(), 17)<<
" +- " <<
Dbl(sxzAccumulator_.
error(), 9, 8) <<
"\n" <<
178 "Syx=" <<
Dbl(syxAccumulator_.
average(), 17)<<
" +- " <<
Dbl(syxAccumulator_.
error(), 9, 8) <<
"\n" <<
179 "Syy=" <<
Dbl(syyAccumulator_.
average(), 17)<<
" +- " <<
Dbl(syyAccumulator_.
error(), 9, 8) <<
"\n" <<
180 "Syz=" <<
Dbl(syzAccumulator_.
average(), 17)<<
" +- " <<
Dbl(syzAccumulator_.
error(), 9, 8) <<
"\n" <<
181 "Szx=" <<
Dbl(szxAccumulator_.
average(), 17)<<
" +- " <<
Dbl(szxAccumulator_.
error(), 9, 8) <<
"\n" <<
182 "Szy=" <<
Dbl(szyAccumulator_.
average(), 17)<<
" +- " <<
Dbl(szyAccumulator_.
error(), 9, 8) <<
"\n" <<
183 "Szz=" <<
Dbl(szzAccumulator_.
average(), 17)<<
" +- " <<
Dbl(szzAccumulator_.
error(), 9, 8) <<
"\n" <<
virtual void clear()
Clear nSample counter.
Abstract base for periodic output and/or analysis actions.
void clear()
Clear all accumulators, set to empty initial state.
Simulation & simulation()
Get the parent Simulation by reference.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
void readOutputFileName(std::istream &in)
Read outputFileName from file.
void saveInterval(Serializable::OArchive &ar)
Save interval parameter to an archive.
double average() const
Return the average of all sampled values.
void openOutputFile(const std::string &filename, std::ofstream &out, std::ios_base::openmode mode=std::ios_base::out) const
Open an output file.
VirialStressTensorAverage(Simulation &simulation)
Constructor.
void readInterval(std::istream &in)
Read parameter interval from file.
Wrapper for a double precision number, for formatted ostream output.
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.
Saving / output archive for binary ostream.
void loadOutputFileName(Serializable::IArchive &ar)
Load output file name to an archive.
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 output()
Dump configuration to file.
virtual void readParameters(std::istream &in)
Read dumpPrefix and interval.
virtual void sample(long iStep)
Sample virial stress to accumulators.
bool isAtInterval(long counter) const
Return true iff counter is a multiple of the interval.
Utility classes for scientific computation.
Tensor kineticStress() const
Return total kinetic stress.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
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.
void setNSamplePerBlock(int nSamplePerBlock)
Set nSamplePerBlock.
Saving archive for binary istream.
void sample(double value)
Add a sampled value to the ensemble.
void setClassName(const char *className)
Set class name string.
void loadInterval(Serializable::IArchive &ar)
Load parameter interval from input archive.
void saveOutputFileName(Serializable::OArchive &ar)
Save output file name to an archive.
Domain & domain()
Get the Domain by reference.
Tensor virialStress() const
Return total virial stress.
void computeKineticStress()
Calculate and store kinetic stress.
double error() const
Return a naive estimate for the std deviation of the average.