12 #include <mcMd/simulation/Simulation.h> 13 #include <simp/species/Species.h> 14 #include <mcMd/chemistry/Molecule.h> 15 #include <mcMd/chemistry/Atom.h> 16 #include <simp/boundary/Boundary.h> 17 #include <util/misc/FileMaster.h> 43 read<int>(in,
"numberOfSlabs", nSlabs_);
49 accumulator_. allocate(nSlabs_);
51 read<int>(in,
"nSamplePerBlock", nSamplePerBlock_);
54 for (i=0; i < nSlabs_; ++i){
55 accumulator_[i].setNSamplePerBlock(nSamplePerBlock_);
58 if (nSamplePerBlock_ != 0) {
75 for (i=0; i < nSlabs_; ++i){
76 accumulator_[i].clear();
90 int imed=int(Lz/(2.0*slabWidth_));
91 double vx, maxvx=-10.0, minvx=10.0, deltaP;
95 for (i=0; i < nSlabs_; ++i){
101 for (iSpec = 0; iSpec < nSpec_; ++iSpec) {
102 for (
system().begin(iSpec, molIter); molIter.
notEnd(); ++molIter) {
103 for (molIter->begin(atomIter); atomIter.
notEnd(); ++atomIter) {
104 zcoord = (atomIter->position())[2];
105 i = int(zcoord/slabWidth_);
106 if(zcoord == Lz) i = nSlabs_-1;
107 vx = (atomIter->velocity())[0];
114 atomPtrmin = &(*atomIter);
120 atomPtrmax = &(*atomIter);
132 for (i=0; i < nSlabs_; ++i){
133 if (nAtomi_[i] != 0 ){
134 velx_[i] = velx_[i]/(double)nAtomi_[i];
139 accumulator_[i].sample(velx_[i], outputFile_);
142 if (iBlock_ == nSamplePerBlock_) {
143 outputFile_ << std::endl;
147 if(atomPtrmin!=0 && atomPtrmax!=0){
148 (atomPtrmin->
velocity())[0] = maxvx;
149 (atomPtrmax->
velocity())[0] = minvx;
150 deltaP = maxvx-minvx;
151 totalMomentum_ += deltaP;
165 if (nSamplePerBlock_ != 0) {
177 for(i=0; i<nSlabs_; ++i){
178 accumulator_[i].output(outputFile_);
182 outputFile_ << std::endl;
183 outputFile_ <<
"Total transferred momentum: " << totalMomentum_ << std::endl;
184 outputFile_ <<
"Total number of steps: " << nSteps << std::endl;
185 outputFile_ <<
"Momentum flux: " << totalMomentum_/(2.0*A*nSteps) << std::endl;
Vector & velocity()
Get atomic velocity Vector by reference.
bool notEnd() const
Is the current pointer not at the end of the array?
const Vector & lengths() const
Get Vector of unit cell lengths 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.
A set of interacting Molecules enclosed by a Boundary.
System & system()
Return reference to parent system.
Classes used by all simpatico molecular simulations.
void readOutputFileName(std::istream &in)
Read outputFileName from file.
virtual void sample(long iStep)
Evaluate and output x-velocity profile as a function of z.
virtual void readParameters(std::istream &in)
Read parameters from file, and allocate data arrays.
virtual void setup()
Empty.
virtual void output()
Output param file at end of simulation.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Simulation & simulation() const
Get the parent Simulation by reference.
virtual void writeParam(std::ostream &out)
Write all parameters to an output stream.
void readInterval(std::istream &in)
Read interval from file, with error checking.
A point particle within a Molecule.
bool notEnd() const
Is the current pointer not at the end of the PArray?
Utility classes for scientific computation.
Forward iterator for an Array or a C array.
Forward iterator for a PArray.
Template for Analyzer associated with one System.
int iStep() const
Get value of step index for main MC or MD loop.
Boundary & boundary() const
Get the Boundary by reference.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
int nSpecies() const
Get the number of Species in this Simulation.
VelProf(System &system)
Constructor.
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.
void allocate(int capacity)
Allocate the underlying C array.