48#include "applications/staticProps/DipoleOrientation.hpp"
53#include "applications/staticProps/SpatialStatistics.hpp"
58#include "utils/Accumulator.hpp"
59#include "utils/AccumulatorView.hpp"
60#include "utils/BaseAccumulator.hpp"
63using namespace OpenMD::Utils;
67 DipoleOrientation::DipoleOrientation(
68 SimInfo* info,
const std::string& filename,
const std::string& sele,
69 const RealType dipoleX,
const RealType dipoleY,
const RealType dipoleZ,
70 int nzbins,
int axis) :
76 refAxis_ = Vector3d(1, 0, 0);
80 refAxis_ = Vector3d(0, 1, 0);
85 refAxis_ = Vector3d(0, 0, 1);
88 setOutputName(
getPrefix(filename) +
".Sz");
90 dipoleVector_ = Vector3d(dipoleX, dipoleY, dipoleZ);
91 dipoleVector_.normalize();
94 data_.resize(DipoleOrientation::ENDINDEX);
97 z.units =
"Angstroms";
99 z.dataHandling = DataHandling::Average;
100 for (
unsigned int i = 0; i < nBins_; i++)
101 z.accumulator.push_back(
103 data_[Z] = std::move(z);
107 orderS.title =
"Orientational Order parameter";
108 orderS.dataHandling = DataHandling::Average;
109 for (
unsigned int i = 0; i < nBins_; i++)
110 orderS.accumulator.push_back(
112 data_[ORDERS] = std::move(orderS);
114 OutputData orderSCos;
115 orderSCos.units =
"";
116 orderSCos.title =
"Orientational Order parameter cosine Theta";
117 orderSCos.dataHandling = DataHandling::Average;
118 for (
unsigned int i = 0; i < nBins_; i++)
119 orderSCos.accumulator.push_back(
121 data_[ORDERSCOS] = std::move(orderSCos);
124 void DipoleOrientation::processFrame(
int) {
127 hmat_ = currentSnapshot_->getHmat();
129 for (
unsigned int i = 0; i < nBins_; i++) {
130 z = (((RealType)i + 0.5) / (RealType)nBins_) * hmat_(axis_, axis_);
131 data_[Z].accumulator[i]->add(z);
134 volume_ = currentSnapshot_->getVolume();
139 std::vector<RealType> binS(nBins_, 0.0);
140 std::vector<RealType> binSCos(nBins_, 0.0);
142 std::vector<int> count(nBins_, 0.0);
144 if (evaluator_.isDynamic()) {
145 seleMan_.setSelectionSet(evaluator_.evaluate());
150 Vector3d rotatedDipoleVector;
152 RealType orderParameter;
154 for (sd = seleMan_.beginSelected(i); sd != NULL;
155 sd = seleMan_.nextSelected(i)) {
157 Vector3d pos = sd->
getPos();
159 int bin = getBin(pos);
163 rotatedDipoleVector = rotMat * dipoleVector_;
165 ctheta =
dot(rotatedDipoleVector, refAxis_);
167 orderParameter = (3 * (ctheta * ctheta) - 1) / 2;
169 binS[bin] += orderParameter;
170 binSCos[bin] += ctheta;
176 for (
unsigned int i = 0; i < nBins_; i++) {
177 count[i] != 0 ? data_[ORDERS].accumulator[i]->add(binS[i] / count[i]) :
178 data_[ORDERS].accumulator[i]->add(binS[i]);
180 data_[ORDERSCOS].accumulator[i]->add(binSCos[i] / count[i]) :
181 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)