54#include "types/FixedChargeAdapter.hpp"
55#include "types/FluctuatingChargeAdapter.hpp"
56#include "utils/simError.h"
61 const std::string& sele) :
63 selectionScript_(sele), seleMan_(info), evaluator_(info) {
67 setOutputName(
getPrefix(filename) +
".potDiff");
74 int rigidBodyStorageLayout = info->getRigidBodyStorageLayout();
75 int cutoffGroupStorageLayout = info->getCutoffGroupStorageLayout();
77 atomStorageLayout |= DataStorage::dslFlucQPosition;
78 atomStorageLayout |= DataStorage::dslFlucQVelocity;
79 atomStorageLayout |= DataStorage::dslFlucQForce;
83 rigidBodyStorageLayout,
84 cutoffGroupStorageLayout));
88 evaluator_.loadScriptString(sele);
89 seleMan_.setSelectionSet(evaluator_.evaluate());
94 if (fqa.isFluctuatingCharge()) {
95 selectionWasFlucQ_.push_back(
true);
97 selectionWasFlucQ_.push_back(
false);
102 fqa.makeFluctuatingCharge(1.0e9, 0.0, 0.0, 1);
123 for (
int i = 0; i < nFrames; i += step_) {
129 if (!selectionWasFlucQ_[j]) { sd->
setFlucQPos(0.0); }
132 forceMan->calcForces();
133 RealType pot1 = thermo->getPotential();
136 seleMan_.setSelectionSet(evaluator_.evaluate());
146 RealType charge = 0.0;
148 if (fca.isFixedCharge()) charge += fca.getCharge();
149 if (fqa.isFluctuatingCharge()) charge += sd->
getFlucQPos();
155 forceMan->calcForces();
156 RealType pot2 = thermo->getPotential();
157 RealType diff = pot2 - pot1;
160 diff_.push_back(diff);
161 times_.push_back(currentSnapshot_->getTime());
169 void PotDiff::writeDiff() {
170 std::ofstream ofs(outputFilename_.c_str(), std::ios::binary);
177 ofs <<
"#selection: (" << selectionScript_ <<
")\n";
178 ofs <<
"# <diff> = " << mu <<
"\n";
179 ofs <<
"# StdDev = " << sigma <<
"\n";
180 ofs <<
"# 95% confidence interval = " << m95 <<
"\n";
181 ofs <<
"# t\tdiff[t]\n";
182 for (
unsigned int i = 0; i < diff_.size(); ++i) {
183 ofs << times_[i] <<
"\t" << diff_[i] <<
"\n";
187 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
188 "PotDiff: unable to open %s\n", outputFilename_.c_str());
189 painCave.isFatal = 1;
StaticAnalyser for Potential Energy changes with charges turned off.
void getAverage(ResultType &ret)
compute the Mean
void get95percentConfidenceInterval(ResultType &ret)
return the 95% confidence interval:
virtual void add(ElementType const &val)
Accumulate another value.
void getStdDev(ResultType &ret)
compute error of average value
AtomType is what OpenMD looks to for unchanging data about an atom.
int getNFrames()
Returns the number of frames in the dump file.
ForceManager is responsible for calculating both the short range (bonded) interactions and long range...
virtual void process()
Process the data.
PotDiff(SimInfo *info, const std::string &filename, const std::string &sele)
Default constructor.
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...
void setAtomStorageLayout(int asl)
Sets the storage layouts (computed by SimCreator)
int getAtomStorageLayout()
Returns the storage layouts (computed by SimCreator)
void setSnapshotManager(SnapshotManager *sman)
Sets the snapshot manager.
SnapshotManager * getSnapshotManager()
Returns the snapshot manager.
"brains/SimSnapshotManager.hpp"
void clearDerivedProperties()
sets the state of the computed properties to false
Snapshot * getCurrentSnapshot()
Returns the pointer of current snapshot.
"Don't move, or you're dead! Stand up! Captain, we've got them!"
void setFlucQPos(RealType charge)
Sets the current fluctuating charge of this stuntDouble.
RealType getFlucQPos()
Returns the current fluctuating charge 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)