45#include "applications/staticProps/DipoleOrientation.hpp"
50#include "applications/staticProps/SpatialStatistics.hpp"
55#include "utils/Accumulator.hpp"
56#include "utils/AccumulatorView.hpp"
57#include "utils/BaseAccumulator.hpp"
60using namespace OpenMD::Utils;
64 DipoleOrientation::DipoleOrientation(
65 SimInfo* info,
const std::string& filename,
const std::string& sele,
66 const RealType dipoleX,
const RealType dipoleY,
const RealType dipoleZ,
67 int nzbins,
int axis) :
85 setOutputName(
getPrefix(filename) +
".Sz");
87 dipoleVector_ =
Vector3d(dipoleX, dipoleY, dipoleZ);
88 dipoleVector_.normalize();
91 data_.resize(DipoleOrientation::ENDINDEX);
94 z.units =
"Angstroms";
96 z.dataHandling = DataHandling::Average;
97 for (
unsigned int i = 0; i < nBins_; i++)
98 z.accumulator.push_back(
100 data_[Z] = std::move(z);
104 orderS.title =
"Orientational Order parameter";
105 orderS.dataHandling = DataHandling::Average;
106 for (
unsigned int i = 0; i < nBins_; i++)
107 orderS.accumulator.push_back(
109 data_[ORDERS] = std::move(orderS);
111 OutputData orderSCos;
112 orderSCos.units =
"";
113 orderSCos.title =
"Orientational Order parameter cosine Theta";
114 orderSCos.dataHandling = DataHandling::Average;
115 for (
unsigned int i = 0; i < nBins_; i++)
116 orderSCos.accumulator.push_back(
118 data_[ORDERSCOS] = std::move(orderSCos);
121 void DipoleOrientation::processFrame(
int) {
124 hmat_ = currentSnapshot_->getHmat();
126 for (
unsigned int i = 0; i < nBins_; i++) {
127 z = (((RealType)i + 0.5) / (RealType)nBins_) * hmat_(axis_, axis_);
128 data_[Z].accumulator[i]->add(z);
131 volume_ = currentSnapshot_->getVolume();
136 std::vector<RealType> binS(nBins_, 0.0);
137 std::vector<RealType> binSCos(nBins_, 0.0);
139 std::vector<int> count(nBins_, 0.0);
141 if (evaluator_.isDynamic()) {
142 seleMan_.setSelectionSet(evaluator_.evaluate());
149 RealType orderParameter;
151 for (sd = seleMan_.beginSelected(i); sd != NULL;
152 sd = seleMan_.nextSelected(i)) {
156 int bin = getBin(pos);
160 rotatedDipoleVector = rotMat * dipoleVector_;
162 ctheta =
dot(rotatedDipoleVector, refAxis_);
164 orderParameter = (3 * (ctheta * ctheta) - 1) / 2;
166 binS[bin] += orderParameter;
167 binSCos[bin] += ctheta;
173 for (
unsigned int i = 0; i < nBins_; i++) {
174 count[i] != 0 ? data_[ORDERS].accumulator[i]->add(binS[i] / count[i]) :
175 data_[ORDERS].accumulator[i]->add(binS[i]);
177 data_[ORDERSCOS].accumulator[i]->add(binSCos[i] / count[i]) :
178 data_[ORDERSCOS].accumulator[i]->add(binSCos[i]);
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
"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.
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)