1 |
|
#include <stdlib.h> |
2 |
+ |
#include <math.h> |
3 |
|
#include <vector> |
4 |
|
|
5 |
+ |
#include "simError.h" |
6 |
|
#include "AllCorr.hpp" |
7 |
|
|
8 |
|
|
30 |
|
haveLength = true; |
31 |
|
} |
32 |
|
|
33 |
< |
void AllCorr::setNbins( double theNbins ){ |
33 |
> |
void AllCorr::setNbins( int theNbins ){ |
34 |
|
nBins = theNbins; |
35 |
|
haveNbins = true; |
36 |
|
} |
90 |
|
} |
91 |
|
|
92 |
|
|
91 |
– |
theList.sort(); |
92 |
– |
|
93 |
|
nPairs = (int)theList.size(); |
94 |
|
pairCorrs = new PairCorrType*[nPairs]; |
95 |
|
|
123 |
|
bool theHavePairCorrs, |
124 |
|
bool theHaveStaticCorrs ){ |
125 |
|
int i; |
126 |
< |
atomName* theNames = new atomNames[nAtoms]; |
126 |
> |
atomName* theNames = new atomName[nAtoms]; |
127 |
|
|
128 |
|
havePairCorrs = theHavePairCorrs; |
129 |
|
haveStaticCorrs = theHaveStaticCorrs; |
144 |
|
} |
145 |
|
|
146 |
|
for(i=0;i<nPairs;i++){ |
147 |
< |
pairCorrs[i]->initCoor(maxLength, theNames ); |
147 |
> |
pairCorrs[i]->initCorr(maxLength, theNames ); |
148 |
|
} |
149 |
|
} |
150 |
|
|
160 |
|
|
161 |
|
void AllCorr::calcCorrelations(){ |
162 |
|
|
163 |
< |
SimInfor* currInfo; |
163 |
> |
SimInfo* currInfo; |
164 |
|
int i,j,k,l; |
165 |
|
double rij[3], rDist, uHatI[3], uHatJ[3]; |
166 |
|
double* grndOut = NULL; |
205 |
|
// calc rdist and rij; |
206 |
|
|
207 |
|
currInfo->atoms[i]->getPos( ri ); |
208 |
< |
currInfo->wrapVector( ri ); |
208 |
> |
|
209 |
> |
currInfo->atoms[j]->getPos( rj ); |
210 |
|
|
210 |
– |
currInfo->atoms[i]->getPos( rj ); |
211 |
– |
currInfo->wrapVector( rj ); |
212 |
– |
|
211 |
|
for(l=0;l<3;l++) |
212 |
|
rij[l] = rj[l] - ri[l]; |
213 |
< |
|
213 |
> |
|
214 |
> |
currInfo->wrapVector( rij ); |
215 |
> |
|
216 |
|
dSqr=0; |
217 |
|
for(l=0;l<3;l++) |
218 |
< |
dSqr += rj[l] * rj[l]; |
218 |
> |
dSqr += rij[l] * rij[l]; |
219 |
|
|
220 |
|
rDist = sqrt( dSqr ); |
221 |
|
|
222 |
|
if( currInfo->atoms[i]->isDirectional() ){ |
223 |
|
|
224 |
< |
dAtom = (directionalAtom*)currInfo->atoms[i]; |
224 |
> |
dAtom = (DirectionalAtom*)currInfo->atoms[i]; |
225 |
|
dAtom->getU( uHatI ); |
226 |
|
|
227 |
|
if( currInfo->atoms[j]->isDirectional() ){ |
228 |
|
|
229 |
< |
dAtom = (directionalAtom*)currInfo->atoms[j]; |
229 |
> |
dAtom = (DirectionalAtom*)currInfo->atoms[j]; |
230 |
|
dAtom->getU( uHatJ ); |
231 |
|
|
232 |
|
this->pairCorrelate( rij, rDist, uHatI, uHatJ ); |
238 |
|
} |
239 |
|
else if( currInfo->atoms[j]->isDirectional() ){ |
240 |
|
|
241 |
< |
dAtom = (directionalAtom*)currInfo->atoms[j]; |
241 |
> |
dAtom = (DirectionalAtom*)currInfo->atoms[j]; |
242 |
|
dAtom->getU( uHatJ ); |
243 |
|
|
244 |
|
this->pairCorrelate( rij, rDist, grndOut, uHatJ ); |
296 |
|
return result; |
297 |
|
} |
298 |
|
|
299 |
< |
void AllCorr::pairCorrelate( double[3] Rij, double dist, |
300 |
< |
double[3] uHatI, double[3] uHatJ ){ |
299 |
> |
void AllCorr::pairCorrelate( double Rij[3], double dist, |
300 |
> |
double uHatI[3], double uHatJ[3] ){ |
301 |
|
|
302 |
|
int i; |
303 |
|
|
304 |
|
for(i=0;i<nPairs;i++) |
305 |
< |
pairCorrs[i]->correlate( Rij, dist, uHatI, uHatj ); |
305 |
> |
pairCorrs[i]->correlate( Rij, dist, uHatI, uHatJ ); |
306 |
|
} |
307 |
|
|
308 |
|
void AllCorr::setFrameVolume( double theVolume ){ |
327 |
|
|
328 |
|
if( havePairCorrs ){ |
329 |
|
|
330 |
< |
for(i=0;i<nPair;i++) |
330 |
> |
for(i=0;i<nPairs;i++) |
331 |
|
pairCorrs[i]->accumulateFrame(); |
332 |
|
} |
333 |
|
|
345 |
|
if( havePairCorrs ){ |
346 |
|
|
347 |
|
for(i=0;i<nPairs;i++) |
348 |
< |
pairCorrs[i]->writeCorrs( outPrefix ); |
348 |
> |
pairCorrs[i]->writeCorr( outPrefix ); |
349 |
|
} |
350 |
|
|
351 |
|
if( haveStaticCorrs ){ |