50#include "applications/staticProps/OrderParameterProbZ.hpp"
55#include "brains/Thermo.hpp"
60#include "types/FixedChargeAdapter.hpp"
61#include "types/FluctuatingChargeAdapter.hpp"
62#include "utils/simError.h"
66 OrderParameterProbZ::OrderParameterProbZ(
67 SimInfo* info,
const std::string& filename,
const std::string& sele,
68 const RealType dipoleX,
const RealType dipoleY,
const RealType dipoleZ,
69 int nbins,
int axis) :
71 selectionScript_(sele), evaluator_(info), seleMan_(info), thermo_(info),
72 nbins_(nbins), axis_(axis) {
73 evaluator_.loadScriptString(sele);
74 if (!evaluator_.isDynamic()) {
75 seleMan_.setSelectionSet(evaluator_.evaluate());
80 std::fill(Count_.begin(), Count_.end(), 0);
98 dipoleVector_ =
Vector3d(dipoleX, dipoleY, dipoleZ);
99 dipoleVector_.normalize();
101 setOutputName(
getPrefix(filename) +
".OrderProb");
104 void OrderParameterProbZ::process() {
107 RealType orderMin = -1.0;
108 RealType orderMax = 1.0;
109 RealType deltaOrder = (orderMax - orderMin) / nbins_;
111 bool usePeriodicBoundaryConditions_ =
112 info_->getSimParams()->getUsePeriodicBoundaryConditions();
115 int nFrames = reader.getNFrames();
117 for (
int istep = 0; istep < nFrames; istep += step_) {
118 reader.readFrame(istep);
122 seleMan_.setSelectionSet(evaluator_.evaluate());
130 if (usePeriodicBoundaryConditions_) currentSnapshot_->
wrapVector(pos);
140 rotatedDipoleVector = rotMat * dipoleVector_;
142 ctheta =
dot(rotatedDipoleVector, refAxis_);
143 int index = int((ctheta - orderMin) / deltaOrder);
153 void OrderParameterProbZ::writeOrderCount() {
154 std::ofstream rdfStream(outputFilename_.c_str());
155 if (rdfStream.is_open()) {
156 rdfStream <<
"#Order count probablity "
158 rdfStream <<
"#selection: (" << selectionScript_ <<
")\n";
159 rdfStream <<
"# Prefered Axis:" << axisLabel_
160 <<
"\n##Order\tProbOrderCount\n";
161 for (
unsigned int i = 0; i < Count_.size(); ++i) {
162 RealType order = i * (2.0 / Count_.size());
164 if (totalCount_ == 0)
167 prop = Count_[i] / totalCount_;
168 rdfStream << order <<
"\t" << prop <<
"\n";
172 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
173 "OrderProb: unable to open %s\n", outputFilename_.c_str());
174 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.
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!"
RotMat3x3d getA()
Returns the current rotation matrix of this stuntDouble.
Vector3d getPos()
Returns the current position of this stuntDouble.
void setPos(const Vector3d &pos)
Sets the current position of this stuntDouble.
bool isRigidBody()
Tests if this stuntDouble is a rigid body.
bool isDirectional()
Tests if this stuntDouble is a directional one.
void normalize()
Normalizes this vector in place.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
Real dot(const DynamicVector< Real > &v1, const DynamicVector< Real > &v2)
Returns the dot product of two DynamicVectors.
std::string getPrefix(const std::string &str)