45 |
|
* Phys Rev B, 28,784,1983 |
46 |
|
* |
47 |
|
*/ |
48 |
< |
|
48 |
> |
|
49 |
|
#include "applications/staticProps/BondOrderParameter.hpp" |
50 |
|
#include "utils/simError.h" |
51 |
|
#include "io/DumpReader.hpp" |
52 |
|
#include "primitives/Molecule.hpp" |
53 |
|
#include "utils/NumericConstant.hpp" |
54 |
< |
#include "math/RealSphericalHarmonic.hpp" |
54 |
> |
|
55 |
|
namespace oopse { |
56 |
|
|
57 |
+ |
BondOrderParameter::BondOrderParameter(SimInfo* info, |
58 |
+ |
const std::string& filename, |
59 |
+ |
const std::string& sele, |
60 |
+ |
double rCut, int nbins) : StaticAnalyser(info, filename), selectionScript_(sele), evaluator_(info), seleMan_(info){ |
61 |
+ |
|
62 |
+ |
setOutputName(getPrefix(filename) + ".bo"); |
63 |
|
|
64 |
< |
BondOrderParameter::BondOrderParameter(SimInfo* info, const std::string& filename, const std::string& sele1, |
65 |
< |
const std::string& sele2, double rCut, int lNumber) |
66 |
< |
: StaticAnalyser(info, filename), |
67 |
< |
selectionScript1_(sele1), evaluator1_(info), |
62 |
< |
seleMan1_(info){ |
64 |
> |
evaluator_.loadScriptString(sele); |
65 |
> |
if (!evaluator_.isDynamic()) { |
66 |
> |
seleMan_.setSelectionSet(evaluator_.evaluate()); |
67 |
> |
} |
68 |
|
|
69 |
< |
setOutputName(getPrefix(filename) + ".obo"); |
69 |
> |
// Set up cutoff radius and order of the Legendre Polynomial: |
70 |
|
|
71 |
< |
evaluator1_.loadScriptString(sele1); |
72 |
< |
evaluator2_.loadScriptString(sele2); |
71 |
> |
rCut_ = rCut; |
72 |
> |
nBins_ = nbins; |
73 |
> |
Qcount_.resize(lMax_+1); |
74 |
> |
Wcount_.resize(lMax_+1); |
75 |
|
|
76 |
< |
if (!evaluator1_.isDynamic()) { |
70 |
< |
seleMan1_.setSelectionSet(evaluator1_.evaluate()); |
71 |
< |
}else { |
72 |
< |
sprintf( painCave.errMsg, |
73 |
< |
"--sele1 must be static selection\n"); |
74 |
< |
painCave.severity = OOPSE_ERROR; |
75 |
< |
painCave.isFatal = 1; |
76 |
< |
simError(); |
77 |
< |
} |
76 |
> |
// Q can take values from 0 to 1 |
77 |
|
|
78 |
< |
/* Set up cutoff radius and type of order parameter we are calcuating*/ |
79 |
< |
lNumber_ = lNumber; |
80 |
< |
rCut_ = rCut; |
82 |
< |
mSize_ = 2*lNumber_+1; |
78 |
> |
MinQ_ = 0.0; |
79 |
> |
MaxQ_ = 1.1; |
80 |
> |
deltaQ_ = (MaxQ_ - MinQ_) / nbins; |
81 |
|
|
82 |
< |
int i; |
83 |
< |
int j; |
86 |
< |
StuntDouble* sd1; |
87 |
< |
StuntDouble* sd2; |
88 |
< |
for (sd1 = seleMan1_.beginSelected(i), sd2 = seleMan1_.beginSelected(j); |
89 |
< |
sd1 != NULL && sd2 != NULL; |
90 |
< |
sd1 = seleMan1_.nextSelected(i), sd2 = seleMan2_.nextSelected(j)) { |
91 |
< |
for (sd2 = seleMan1_.beginSelected(j),sd2 |
92 |
< |
sdPairs_.push_back(std::make_pair(sd1, sd2)); |
93 |
< |
} |
82 |
> |
// W_6 for icosahedral clusters is 11 / sqrt(4199) = 0.169754, so we'll |
83 |
> |
// use values for MinW_ and MaxW_ that are slightly larger than this: |
84 |
|
|
85 |
+ |
MinW_ = -0.25; |
86 |
+ |
MaxW_ = 0.25; |
87 |
+ |
deltaW_ = (MaxW_ - MinW_) / nbins; |
88 |
|
|
89 |
+ |
// Make arrays for Wigner3jm |
90 |
+ |
double* THRCOF = new double[2*lMax_+1]; |
91 |
+ |
// Variables for Wigner routine |
92 |
+ |
double lPass, m1Pass, m2m, m2M; |
93 |
+ |
int error, mSize; |
94 |
+ |
mSize = 2*lMax_+1; |
95 |
+ |
|
96 |
+ |
for (int l = 0; l <= lMax_; l++) { |
97 |
+ |
lPass = (double)l; |
98 |
+ |
for (int m1 = -l; m1 <= l; m1++) { |
99 |
+ |
m1Pass = (double)m1; |
100 |
+ |
|
101 |
+ |
std::pair<int,int> lm = std::make_pair(l, m1); |
102 |
+ |
|
103 |
+ |
// Zero work array |
104 |
+ |
for (int ii = 0; ii < 2*l + 1; ii++){ |
105 |
+ |
THRCOF[ii] = 0.0; |
106 |
+ |
} |
107 |
+ |
|
108 |
+ |
// Get Wigner coefficients |
109 |
+ |
Wigner3jm(&lPass, &lPass, &lPass, |
110 |
+ |
&m1Pass, &m2m, &m2M, |
111 |
+ |
THRCOF, &mSize, &error); |
112 |
+ |
|
113 |
+ |
m2Min[lm] = (int)floor(m2m); |
114 |
+ |
m2Max[lm] = (int)floor(m2M); |
115 |
+ |
|
116 |
+ |
for (int mmm = 0; mmm < (int)(m2M - m2m); mmm++) { |
117 |
+ |
w3j[lm].push_back(THRCOF[mmm]); |
118 |
+ |
} |
119 |
+ |
} |
120 |
|
} |
121 |
+ |
} |
122 |
+ |
|
123 |
+ |
BondOrderParameter::~BondOrderParameter() { |
124 |
+ |
Q_histogram_.clear(); |
125 |
+ |
W_histogram_.clear(); |
126 |
+ |
} |
127 |
|
|
128 |
< |
void BondOrderParameter::process |
129 |
< |
() { |
130 |
< |
Molecule* mol; |
131 |
< |
RigidBody* rb; |
132 |
< |
SimInfo::MoleculeIterator mi; |
133 |
< |
Molecule::RigidBodyIterator rbIter; |
134 |
< |
RealType theta; |
135 |
< |
RealType phi; |
106 |
< |
RealType r; |
107 |
< |
RealType dist; |
108 |
< |
RealType* QBar_lm; |
109 |
< |
RealType QSq_l; |
110 |
< |
int nBonds; |
111 |
< |
int m, m_index; |
112 |
< |
RealSphericalHarmonic sphericalHarmonic; |
128 |
> |
void BondOrderParameter::initalizeHistogram() { |
129 |
> |
for (int bin = 0; bin < nBins_; bin++) { |
130 |
> |
for (int l = 0; l <= lMax_; l++) { |
131 |
> |
Q_histogram_[std::make_pair(bin,l)] = 0; |
132 |
> |
W_histogram_[std::make_pair(bin,l)] = 0; |
133 |
> |
} |
134 |
> |
} |
135 |
> |
} |
136 |
|
|
137 |
+ |
void BondOrderParameter::process() { |
138 |
+ |
Molecule* mol; |
139 |
+ |
Atom* atom; |
140 |
+ |
RigidBody* rb; |
141 |
+ |
int myIndex; |
142 |
+ |
SimInfo::MoleculeIterator mi; |
143 |
+ |
Molecule::RigidBodyIterator rbIter; |
144 |
+ |
Molecule::AtomIterator ai; |
145 |
+ |
StuntDouble* sd; |
146 |
+ |
Vector3d vec; |
147 |
+ |
RealType costheta; |
148 |
+ |
RealType phi; |
149 |
+ |
RealType r; |
150 |
+ |
RealType dist; |
151 |
+ |
std::map<std::pair<int,int>,ComplexType> q; |
152 |
+ |
std::vector<RealType> q_l; |
153 |
+ |
std::vector<RealType> q2; |
154 |
+ |
std::vector<ComplexType> w; |
155 |
+ |
std::vector<ComplexType> w_hat; |
156 |
+ |
std::map<std::pair<int,int>,ComplexType> QBar; |
157 |
+ |
std::vector<RealType> Q2; |
158 |
+ |
std::vector<RealType> Q; |
159 |
+ |
std::vector<ComplexType> W; |
160 |
+ |
std::vector<ComplexType> W_hat; |
161 |
+ |
int nBonds, Nbonds; |
162 |
+ |
SphericalHarmonic sphericalHarmonic; |
163 |
+ |
int i, j; |
164 |
|
|
165 |
< |
DumpReader reader(info_, dumpFilename_); |
166 |
< |
int nFrames = reader.getNFrames(); |
165 |
> |
DumpReader reader(info_, dumpFilename_); |
166 |
> |
int nFrames = reader.getNFrames(); |
167 |
> |
frameCounter_ = 0; |
168 |
|
|
169 |
< |
/*Set the l for the spherical harmonic, it doesn't change*/ |
170 |
< |
sphericalHarmonic.setL(lNumber_); |
169 |
> |
q_l.resize(lMax_+1); |
170 |
> |
q2.resize(lMax_+1); |
171 |
> |
w.resize(lMax_+1); |
172 |
> |
w_hat.resize(lMax_+1); |
173 |
|
|
174 |
< |
for (int i = 0; i < nFrames; i += step_) { |
175 |
< |
reader.readFrame(i); |
176 |
< |
currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); |
177 |
< |
nBonds = 0; |
174 |
> |
Q2.resize(lMax_+1); |
175 |
> |
Q.resize(lMax_+1); |
176 |
> |
W.resize(lMax_+1); |
177 |
> |
W_hat.resize(lMax_+1); |
178 |
|
|
179 |
< |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
180 |
< |
//change the positions of atoms which belong to the rigidbodies |
181 |
< |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
182 |
< |
rb->updateAtoms(); |
183 |
< |
} |
179 |
> |
for (int istep = 0; istep < nFrames; istep += step_) { |
180 |
> |
reader.readFrame(istep); |
181 |
> |
frameCounter_++; |
182 |
> |
currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); |
183 |
> |
|
184 |
> |
if (evaluator_.isDynamic()) { |
185 |
> |
seleMan_.setSelectionSet(evaluator_.evaluate()); |
186 |
> |
} |
187 |
|
|
188 |
< |
} |
188 |
> |
// update the positions of atoms which belong to the rigidbodies |
189 |
|
|
190 |
+ |
for (mol = info_->beginMolecule(mi); mol != NULL; |
191 |
+ |
mol = info_->nextMolecule(mi)) { |
192 |
+ |
for (rb = mol->beginRigidBody(rbIter); rb != NULL; |
193 |
+ |
rb = mol->nextRigidBody(rbIter)) { |
194 |
+ |
rb->updateAtoms(); |
195 |
+ |
} |
196 |
+ |
} |
197 |
+ |
|
198 |
+ |
// outer loop is over the selected StuntDoubles: |
199 |
|
|
200 |
< |
/* Setup QBar */ |
201 |
< |
QBar_lm = new double[mSize_]; |
200 |
> |
for (sd = seleMan_.beginSelected(i); sd != NULL; |
201 |
> |
sd = seleMan_.nextSelected(i)) { |
202 |
|
|
203 |
< |
/* Calculate "bonds" and build Q_lm(r) where Q_lm = Y_lm(theta(r),phi(r)) */ |
204 |
< |
for (std::vector<std::pair<StuntDouble*, StuntDouble*> >::iterator j = sdPairs_.begin(); j != sdPairs_.end(); ++j) { |
205 |
< |
Vector3d vec = j->first->getPos() - j->second->getPos(); |
206 |
< |
currentSnapshot_->wrapVector(vec); |
207 |
< |
/* The spherical harmonics are wrt any arbitray coordiate sysetm, |
208 |
< |
* we choose standard spherical coordinates */ |
209 |
< |
r = sqrt(pow(vec.x(),2)+pow(vec.y(),2)+pow(vec.z(),2)); |
203 |
> |
myIndex = sd->getGlobalIndex(); |
204 |
> |
nBonds = 0; |
205 |
> |
|
206 |
> |
for (int l = 0; l <= lMax_; l++) { |
207 |
> |
for (int m = -l; m <= l; m++) { |
208 |
> |
q[std::make_pair(l,m)] = 0.0; |
209 |
> |
} |
210 |
> |
} |
211 |
> |
|
212 |
> |
// inner loop is over all other atoms in the system: |
213 |
> |
|
214 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; |
215 |
> |
mol = info_->nextMolecule(mi)) { |
216 |
> |
for (atom = mol->beginAtom(ai); atom != NULL; |
217 |
> |
atom = mol->nextAtom(ai)) { |
218 |
|
|
219 |
< |
/* Check to see if neighbor is in bond cuttoff*/ |
147 |
< |
if (r<rCut_){ |
148 |
< |
theta = atan(vec.y()/vec.x()); |
149 |
< |
phi = acos(vec.z()/r); |
150 |
< |
for(int m_index = 0; m_index < mSize_; m_index++){ |
151 |
< |
sphericalHarmonic.setM(m_index-lNumber_); |
152 |
< |
QBar_lm(m_index) += sphericalHarmonic.getValueAt(theta,phi); |
153 |
< |
} |
154 |
< |
nBonds++; |
155 |
< |
} |
156 |
< |
} |
219 |
> |
if (atom->getGlobalIndex() != myIndex) { |
220 |
|
|
221 |
< |
/*Normalize Qbar by number of Bonds*/ |
222 |
< |
for ( int m_index = 0;m_index < mSize_; m_index++){ |
223 |
< |
QBar_lm(m_index) = QBar_lm(m_index)/nBonds; |
224 |
< |
} |
221 |
> |
vec = sd->getPos() - atom->getPos(); |
222 |
> |
currentSnapshot_->wrapVector(vec); |
223 |
> |
|
224 |
> |
// Calculate "bonds" and build Q_lm(r) where |
225 |
> |
// Q_lm = Y_lm(theta(r),phi(r)) |
226 |
> |
// The spherical harmonics are wrt any arbitrary coordinate |
227 |
> |
// system, we choose standard spherical coordinates |
228 |
> |
|
229 |
> |
r = vec.length(); |
230 |
> |
|
231 |
> |
// Check to see if neighbor is in bond cutoff |
232 |
> |
|
233 |
> |
if (r < rCut_) { |
234 |
> |
costheta = vec.z() / r; |
235 |
> |
phi = atan2(vec.y(), vec.x()); |
236 |
|
|
237 |
+ |
for (int l = 0; l <= lMax_; l++) { |
238 |
+ |
sphericalHarmonic.setL(l); |
239 |
+ |
for(int m = -l; m <= l; m++){ |
240 |
+ |
sphericalHarmonic.setM(m); |
241 |
+ |
q[std::make_pair(l,m)] += sphericalHarmonic.getValueAt(costheta, phi); |
242 |
+ |
} |
243 |
+ |
} |
244 |
+ |
nBonds++; |
245 |
+ |
} |
246 |
+ |
} |
247 |
+ |
} |
248 |
+ |
} |
249 |
+ |
|
250 |
+ |
|
251 |
+ |
for (int l = 0; l <= lMax_; l++) { |
252 |
+ |
q_l[l] = 0.0; |
253 |
+ |
for(int m = -l; m <= l; m++) { |
254 |
+ |
q_l[l] += norm(q[std::make_pair(l,m)]); |
255 |
+ |
} |
256 |
+ |
q_l[l] *= 4.0*NumericConstant::PI/(RealType)(2*l + 1); |
257 |
+ |
q_l[l] = sqrt(q_l[l])/(RealType)nBonds; |
258 |
+ |
} |
259 |
|
|
260 |
< |
} |
260 |
> |
// Find second order invariant Q_l |
261 |
> |
|
262 |
> |
for (int l = 0; l <= lMax_; l++) { |
263 |
> |
q2[l] = 0.0; |
264 |
> |
for (int m = -l; m <= l; m++){ |
265 |
> |
q2[l] += norm(q[std::make_pair(l,m)]); |
266 |
> |
} |
267 |
> |
q_l[l] = sqrt(q2[l] * 4.0 * NumericConstant::PI / |
268 |
> |
(RealType)(2*l + 1))/(RealType)nBonds; |
269 |
> |
} |
270 |
|
|
271 |
< |
/*Normalize by number of frames*/ |
272 |
< |
for ( int m_index = 0;m_index < mSize_; m_index++){ |
273 |
< |
QBar_lm(m_index) = QBar_lm(m_index)/nFrames; |
271 |
> |
// Find Third Order Invariant W_l |
272 |
> |
|
273 |
> |
for (int l = 0; l <= lMax_; l++) { |
274 |
> |
w[l] = 0.0; |
275 |
> |
for (int m1 = -l; m1 <= l; m1++) { |
276 |
> |
std::pair<int,int> lm = std::make_pair(l, m1); |
277 |
> |
for (int mmm = 0; mmm < (m2Max[lm] - m2Min[lm]); mmm++) { |
278 |
> |
int m2 = m2Min[lm] + mmm; |
279 |
> |
int m3 = -m1-m2; |
280 |
> |
w[l] += w3j[lm][mmm] * q[lm] * |
281 |
> |
q[std::make_pair(l,m2)] * q[std::make_pair(l,m3)]; |
282 |
> |
} |
283 |
> |
} |
284 |
> |
|
285 |
> |
w_hat[l] = w[l] / pow(q2[l], 1.5); |
286 |
> |
} |
287 |
> |
|
288 |
> |
collectHistogram(q_l, w_hat); |
289 |
> |
|
290 |
> |
Nbonds += nBonds; |
291 |
> |
for (int l = 0; l <= lMax_; l++) { |
292 |
> |
for (int m = -l; m <= l; m++) { |
293 |
> |
QBar[std::make_pair(l,m)] += q[std::make_pair(l,m)]; |
294 |
> |
} |
295 |
> |
} |
296 |
|
} |
297 |
+ |
} |
298 |
+ |
|
299 |
+ |
// Normalize Qbar2 |
300 |
+ |
for (int l = 0; l <= lMax_; l++) { |
301 |
+ |
for (int m = -l; m <= l; m++){ |
302 |
+ |
QBar[std::make_pair(l,m)] /= Nbonds; |
303 |
+ |
} |
304 |
+ |
} |
305 |
+ |
|
306 |
+ |
// Find second order invariant Q_l |
307 |
+ |
|
308 |
+ |
for (int l = 0; l <= lMax_; l++) { |
309 |
+ |
Q2[l] = 0.0; |
310 |
+ |
for (int m = -l; m <= l; m++){ |
311 |
+ |
Q2[l] += norm(QBar[std::make_pair(l,m)]); |
312 |
+ |
} |
313 |
+ |
Q[l] = sqrt(Q2[l] * 4.0 * NumericConstant::PI / (RealType)(2*l + 1)); |
314 |
+ |
} |
315 |
+ |
|
316 |
+ |
// Find Third Order Invariant W_l |
317 |
+ |
|
318 |
+ |
for (int l = 0; l <= lMax_; l++) { |
319 |
+ |
W[l] = 0.0; |
320 |
+ |
for (int m1 = -l; m1 <= l; m1++) { |
321 |
+ |
std::pair<int,int> lm = std::make_pair(l, m1); |
322 |
+ |
for (int mmm = 0; mmm < (m2Max[lm] - m2Min[lm]); mmm++) { |
323 |
+ |
int m2 = m2Min[lm] + mmm; |
324 |
+ |
int m3 = -m1-m2; |
325 |
+ |
W[l] += w3j[lm][mmm] * QBar[lm] * |
326 |
+ |
QBar[std::make_pair(l,m2)] * QBar[std::make_pair(l,m3)]; |
327 |
+ |
} |
328 |
+ |
} |
329 |
+ |
|
330 |
+ |
W_hat[l] = W[l] / pow(Q2[l], 1.5); |
331 |
+ |
} |
332 |
+ |
|
333 |
+ |
writeOrderParameter(Q, W_hat); |
334 |
+ |
} |
335 |
|
|
336 |
+ |
void BondOrderParameter::collectHistogram(std::vector<RealType> q, |
337 |
+ |
std::vector<ComplexType> what) { |
338 |
|
|
339 |
+ |
for (int l = 0; l <= lMax_; l++) { |
340 |
+ |
if (q[l] >= MinQ_ && q[l] < MaxQ_) { |
341 |
+ |
int qbin = (q[l] - MinQ_) / deltaQ_; |
342 |
+ |
Q_histogram_[std::make_pair(qbin,l)] += 1; |
343 |
+ |
Qcount_[l]++; |
344 |
+ |
} else { |
345 |
+ |
sprintf( painCave.errMsg, |
346 |
+ |
"q_l value outside reasonable range\n"); |
347 |
+ |
painCave.severity = OOPSE_ERROR; |
348 |
+ |
painCave.isFatal = 1; |
349 |
+ |
simError(); |
350 |
+ |
} |
351 |
+ |
} |
352 |
|
|
353 |
< |
/* Find second order invariant Q_l*/ |
354 |
< |
|
355 |
< |
for (int m_index = 0 ;m_index <= sizeM_; m++){ |
356 |
< |
QSq_l += pow(QBar_lm(m),2); |
353 |
> |
for (int l = 0; l <= lMax_; l++) { |
354 |
> |
if (real(what[l]) >= MinW_ && real(what[l]) < MaxW_) { |
355 |
> |
int wbin = (real(what[l]) - MinW_) / deltaW_; |
356 |
> |
W_histogram_[std::make_pair(wbin,l)] += 1; |
357 |
> |
Wcount_[l]++; |
358 |
> |
} else { |
359 |
> |
sprintf( painCave.errMsg, |
360 |
> |
"Re[w_hat] value outside reasonable range\n"); |
361 |
> |
painCave.severity = OOPSE_ERROR; |
362 |
> |
painCave.isFatal = 1; |
363 |
> |
simError(); |
364 |
|
} |
365 |
< |
Q_l_ = sqrt((4*NumericConstant::PI/lNumber_+1)*QSq_l); |
365 |
> |
} |
366 |
|
|
367 |
< |
/* Find Third Order Invariant W_l*/ |
367 |
> |
} |
368 |
|
|
182 |
– |
/* Make arrays for Wigner3jm */ |
183 |
– |
double* THRCOF = new double[mSize_]; |
184 |
– |
/* Variables for Wigner routine */ |
185 |
– |
double l_ = (double)lNumber_; |
186 |
– |
double m2Min; |
187 |
– |
double m2Max; |
188 |
– |
int error; |
189 |
– |
int m1; |
190 |
– |
int m2; |
191 |
– |
int m3; |
369 |
|
|
370 |
< |
for (int m1 = -lNumber_;m <= lNumber_;m1++){ |
371 |
< |
/* Zero work array */ |
372 |
< |
for (i=0; i<mSize_;i++){ |
373 |
< |
THRCOF[i] = 0.0; |
374 |
< |
} |
375 |
< |
/* Get wigner coefficients */ |
376 |
< |
Wigner3jm(&l_,&l_,&l_,&(double)m1,&m2Min,&m2Max&,THRCOF,&mSize_,&error); |
377 |
< |
for (m_index=1; i<(m2Max-M2Min-1.0);m_index++){ |
378 |
< |
m2 = floor(m2Min) + m_index - 1; |
379 |
< |
m3 = -m1-m2; |
380 |
< |
W_l_ += THRCOF(m_index)*QBar_lm(m1+lNumber_)*QBar_lm(m2+lNumber_)*QBar_lm(m3+lNumber_); |
381 |
< |
} |
370 |
> |
void BondOrderParameter::writeOrderParameter(std::vector<RealType> Q, |
371 |
> |
std::vector<ComplexType> What) { |
372 |
> |
|
373 |
> |
std::ofstream osq((getOutputFileName() + "q").c_str()); |
374 |
> |
|
375 |
> |
if (osq.is_open()) { |
376 |
> |
|
377 |
> |
osq << "# Bond Order Parameters\n"; |
378 |
> |
osq << "# selection: (" << selectionScript_ << ")\n"; |
379 |
> |
osq << "# \n"; |
380 |
> |
for (int l = 0; l <= lMax_; l++) { |
381 |
> |
osq << "# <Q_" << l << ">: " << Q[l] << "\n"; |
382 |
|
} |
383 |
+ |
// Normalize by number of frames and write it out: |
384 |
+ |
for (int i = 0; i < nBins_; ++i) { |
385 |
+ |
RealType Qval = MinQ_ + (i + 0.5) * deltaQ_; |
386 |
+ |
osq << Qval; |
387 |
+ |
for (int l = 0; l <= lMax_; l++) { |
388 |
+ |
osq << "\t" << (RealType)Q_histogram_[std::make_pair(i,l)] / (RealType)Qcount_[l]; |
389 |
+ |
} |
390 |
+ |
osq << "\n"; |
391 |
+ |
} |
392 |
|
|
393 |
+ |
osq.close(); |
394 |
|
|
395 |
< |
writeOrderParameter(); |
396 |
< |
|
395 |
> |
} else { |
396 |
> |
sprintf(painCave.errMsg, "BondOrderParameter: unable to open %s\n", |
397 |
> |
(getOutputFileName() + "q").c_str()); |
398 |
> |
painCave.isFatal = 1; |
399 |
> |
simError(); |
400 |
|
} |
401 |
|
|
402 |
+ |
std::ofstream osw((getOutputFileName() + "w").c_str()); |
403 |
|
|
404 |
< |
void BondOrderParameter::writeOrderParameter() { |
405 |
< |
|
406 |
< |
std::ofstream os(getOutputFileName().c_str()); |
407 |
< |
os << "#radial distribution function\n"; |
408 |
< |
os<< "#selection1: (" << selectionScript1_ << ")\t"; |
409 |
< |
os << "selection2: (" << selectionScript2_ << ")\n"; |
219 |
< |
os << "#p2\tdirector_x\tdirector_y\tdiretor_z\tangle(degree)\n"; |
220 |
< |
|
221 |
< |
for (std::size_t i = 0; i < orderParams_.size(); ++i) { |
222 |
< |
os << orderParams_[i].p2 << "\t" |
223 |
< |
<< orderParams_[i].director[0] << "\t" |
224 |
< |
<< orderParams_[i].director[1] << "\t" |
225 |
< |
<< orderParams_[i].director[2] << "\t" |
226 |
< |
<< orderParams_[i].angle << "\n"; |
227 |
< |
|
404 |
> |
if (osw.is_open()) { |
405 |
> |
osw << "# Bond Order Parameters\n"; |
406 |
> |
osw << "# selection: (" << selectionScript_ << ")\n"; |
407 |
> |
osw << "# \n"; |
408 |
> |
for (int l = 0; l <= lMax_; l++) { |
409 |
> |
osw << "# <W_" << l << ">: " << real(What[l]) << "\n"; |
410 |
|
} |
411 |
+ |
// Normalize by number of frames and write it out: |
412 |
+ |
for (int i = 0; i < nBins_; ++i) { |
413 |
+ |
RealType Wval = MinW_ + (i + 0.5) * deltaW_; |
414 |
+ |
osw << Wval; |
415 |
+ |
for (int l = 0; l <= lMax_; l++) { |
416 |
+ |
osw << "\t" << (RealType)W_histogram_[std::make_pair(i,l)] / (RealType)Wcount_[l]; |
417 |
+ |
} |
418 |
+ |
osw << "\n"; |
419 |
+ |
} |
420 |
|
|
421 |
+ |
osw.close(); |
422 |
+ |
} else { |
423 |
+ |
sprintf(painCave.errMsg, "BondOrderParameter: unable to open %s\n", |
424 |
+ |
(getOutputFileName() + "w").c_str()); |
425 |
+ |
painCave.isFatal = 1; |
426 |
+ |
simError(); |
427 |
|
} |
428 |
< |
|
428 |
> |
|
429 |
|
} |
430 |
< |
|
430 |
> |
} |