50#include "applications/staticProps/PositionZ.hpp" 
   55#include "brains/Thermo.hpp" 
   58#include "types/FixedChargeAdapter.hpp" 
   59#include "types/FluctuatingChargeAdapter.hpp" 
   60#include "utils/simError.h" 
   64  PositionZ::PositionZ(
SimInfo* info, 
const std::string& filename,
 
   65                       const std::string& sele, 
int nzbins, 
int axis) :
 
   67      selectionScript_(sele), evaluator_(info), seleMan_(info), thermo_(info),
 
   69    evaluator_.loadScriptString(sele);
 
   70    if (!evaluator_.isDynamic()) {
 
   71      seleMan_.setSelectionSet(evaluator_.evaluate());
 
   76    sliceSDCount_.resize(nBins_);
 
   77    flucSliceSDCount_.resize(nBins_);
 
   78    std::fill(sliceSDCount_.begin(), sliceSDCount_.end(), 0);
 
   79    std::fill(flucSliceSDCount_.begin(), flucSliceSDCount_.end(), 0);
 
   81    positionZ_.resize(nBins_);
 
   96    setOutputName(
getPrefix(filename) + 
".CountZ");
 
   99  void PositionZ::process() {
 
  103    bool usePeriodicBoundaryConditions_ =
 
  104        info_->getSimParams()->getUsePeriodicBoundaryConditions();
 
  107    int nFrames = reader.getNFrames();
 
  108    nProcessed_ = nFrames / step_;
 
  110    for (
int istep = 0; istep < nFrames; istep += step_) {
 
  111      reader.readFrame(istep);
 
  115      zBox_.push_back(hmat(axis_, axis_));
 
  117      RealType halfBoxZ_ = hmat(axis_, axis_) / 2.0;
 
  120        seleMan_.setSelectionSet(evaluator_.evaluate());
 
  127        if (usePeriodicBoundaryConditions_) currentSnapshot_->
wrapVector(pos);
 
  136        int binNo = int(nBins_ * (halfBoxZ_ + pos[axis_]) / hmat(axis_, axis_));
 
  137        sliceSDCount_[binNo]++;
 
  143    for (
int istep = 0; istep < nFrames; istep += step_) {
 
  144      std::map<int, RealType> countInBin;
 
  146      reader.readFrame(istep);
 
  149      RealType halfBoxZ_ = hmat(axis_, axis_) / 2.0;
 
  156        int binNo = int(nBins_ * (halfBoxZ_ + pos[axis_]) / hmat(axis_, axis_));
 
  162      for (
unsigned int index = 0; index < flucSliceSDCount_.size(); ++index) {
 
  164            (countInBin[index] - (sliceSDCount_[index] / nProcessed_));
 
  165        flucSliceSDCount_[index] += flucCount * flucCount;
 
  172  void PositionZ::writePositionZ() {
 
  174    std::vector<RealType>::iterator j;
 
  176    for (j = zBox_.begin(); j != zBox_.end(); ++j) {
 
  179    RealType zAve = zSum / zBox_.size();
 
  181    std::ofstream rdfStream(outputFilename_.c_str());
 
  182    if (rdfStream.is_open()) {
 
  183      rdfStream << 
"#position count " 
  185      rdfStream << 
"#selection: (" << selectionScript_ << 
")\n";
 
  186      rdfStream << 
"#" << axisLabel_
 
  187                << 
"\tAverage Number\tFluctations_in_count\n";
 
  188      for (
unsigned int i = 0; i < positionZ_.size(); ++i) {
 
  189        RealType z = zAve * (i + 0.5) / positionZ_.size();
 
  190        rdfStream << z << 
"\t" << sliceSDCount_[i] / nProcessed_ << 
"\t" 
  191                  << sqrt(flucSliceSDCount_[i]) / nProcessed_ << 
"\n";
 
  195      snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
 
  196               "ChargeZ: unable to open %s\n", outputFilename_.c_str());
 
  197      painCave.isFatal = 1;
 
bool isDynamic()
Tests if the result from evaluation of script is dynamic.
 
StuntDouble * nextSelected(int &i)
Finds the next selected StuntDouble in the selection.
 
StuntDouble * beginSelected(int &i)
Finds the first selected StuntDouble in the selection.
 
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
 
SnapshotManager * getSnapshotManager()
Returns the snapshot manager.
 
Mat3x3d getHmat()
Returns the H-Matrix.
 
void wrapVector(Vector3d &v)
Wrapping the vector according to periodic boundary condition.
 
Snapshot * getCurrentSnapshot()
Returns the pointer of current snapshot.
 
"Don't move, or you're dead! Stand up! Captain, we've got them!"
 
Vector3d getPos()
Returns the current position of this stuntDouble.
 
void setPos(const Vector3d &pos)
Sets the current position of this stuntDouble.
 
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
 
std::string getPrefix(const std::string &str)