| 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 |
|
|
| 104 |
|
pairCorrs[i] = new GofR(pair1, pair2, nAtoms, nBins); |
| 105 |
|
break; |
| 106 |
|
|
| 107 |
+ |
case gofrTheta: |
| 108 |
+ |
pairCorrs[i] = new GofRtheta(pair1, pair2, nAtoms, nBins); |
| 109 |
+ |
break; |
| 110 |
+ |
|
| 111 |
+ |
case gofrOmega: |
| 112 |
+ |
pairCorrs[i] = new GofRomega(pair1, pair2, nAtoms, nBins); |
| 113 |
+ |
break; |
| 114 |
+ |
|
| 115 |
|
default: |
| 116 |
|
|
| 117 |
|
sprintf( painCave.errMsg, |
| 131 |
|
bool theHavePairCorrs, |
| 132 |
|
bool theHaveStaticCorrs ){ |
| 133 |
|
int i; |
| 134 |
< |
atomName* theNames = new atomNames[nAtoms]; |
| 134 |
> |
atomName* theNames = new atomName[nAtoms]; |
| 135 |
|
|
| 136 |
|
havePairCorrs = theHavePairCorrs; |
| 137 |
|
haveStaticCorrs = theHaveStaticCorrs; |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
for(i=0;i<nPairs;i++){ |
| 155 |
< |
pairCorrs[i]->initCoor(maxLength, theNames ); |
| 155 |
> |
pairCorrs[i]->initCorr(maxLength, theNames ); |
| 156 |
|
} |
| 157 |
|
} |
| 158 |
|
|
| 168 |
|
|
| 169 |
|
void AllCorr::calcCorrelations(){ |
| 170 |
|
|
| 171 |
< |
SimInfor* currInfo; |
| 171 |
> |
SimInfo* currInfo; |
| 172 |
|
int i,j,k,l; |
| 173 |
|
double rij[3], rDist, uHatI[3], uHatJ[3]; |
| 174 |
|
double* grndOut = NULL; |
| 213 |
|
// calc rdist and rij; |
| 214 |
|
|
| 215 |
|
currInfo->atoms[i]->getPos( ri ); |
| 216 |
< |
currInfo->wrapVector( ri ); |
| 217 |
< |
|
| 218 |
< |
currInfo->atoms[i]->getPos( rj ); |
| 211 |
< |
currInfo->wrapVector( rj ); |
| 212 |
< |
|
| 216 |
> |
|
| 217 |
> |
currInfo->atoms[j]->getPos( rj ); |
| 218 |
> |
|
| 219 |
|
for(l=0;l<3;l++) |
| 220 |
|
rij[l] = rj[l] - ri[l]; |
| 221 |
< |
|
| 221 |
> |
|
| 222 |
> |
currInfo->wrapVector( rij ); |
| 223 |
> |
|
| 224 |
|
dSqr=0; |
| 225 |
|
for(l=0;l<3;l++) |
| 226 |
< |
dSqr += rj[l] * rj[l]; |
| 226 |
> |
dSqr += rij[l] * rij[l]; |
| 227 |
|
|
| 228 |
|
rDist = sqrt( dSqr ); |
| 229 |
|
|
| 230 |
|
if( currInfo->atoms[i]->isDirectional() ){ |
| 231 |
|
|
| 232 |
< |
dAtom = (directionalAtom*)currInfo->atoms[i]; |
| 232 |
> |
dAtom = (DirectionalAtom*)currInfo->atoms[i]; |
| 233 |
|
dAtom->getU( uHatI ); |
| 234 |
|
|
| 235 |
|
if( currInfo->atoms[j]->isDirectional() ){ |
| 236 |
|
|
| 237 |
< |
dAtom = (directionalAtom*)currInfo->atoms[j]; |
| 237 |
> |
dAtom = (DirectionalAtom*)currInfo->atoms[j]; |
| 238 |
|
dAtom->getU( uHatJ ); |
| 239 |
|
|
| 240 |
|
this->pairCorrelate( rij, rDist, uHatI, uHatJ ); |
| 246 |
|
} |
| 247 |
|
else if( currInfo->atoms[j]->isDirectional() ){ |
| 248 |
|
|
| 249 |
< |
dAtom = (directionalAtom*)currInfo->atoms[j]; |
| 249 |
> |
dAtom = (DirectionalAtom*)currInfo->atoms[j]; |
| 250 |
|
dAtom->getU( uHatJ ); |
| 251 |
|
|
| 252 |
|
this->pairCorrelate( rij, rDist, grndOut, uHatJ ); |
| 304 |
|
return result; |
| 305 |
|
} |
| 306 |
|
|
| 307 |
< |
void AllCorr::pairCorrelate( double[3] Rij, double dist, |
| 308 |
< |
double[3] uHatI, double[3] uHatJ ){ |
| 307 |
> |
void AllCorr::pairCorrelate( double Rij[3], double dist, |
| 308 |
> |
double uHatI[3], double uHatJ[3] ){ |
| 309 |
|
|
| 310 |
|
int i; |
| 311 |
|
|
| 312 |
|
for(i=0;i<nPairs;i++) |
| 313 |
< |
pairCorrs[i]->correlate( Rij, dist, uHatI, uHatj ); |
| 313 |
> |
pairCorrs[i]->correlate( Rij, dist, uHatI, uHatJ ); |
| 314 |
|
} |
| 315 |
|
|
| 316 |
|
void AllCorr::setFrameVolume( double theVolume ){ |
| 335 |
|
|
| 336 |
|
if( havePairCorrs ){ |
| 337 |
|
|
| 338 |
< |
for(i=0;i<nPair;i++) |
| 338 |
> |
for(i=0;i<nPairs;i++) |
| 339 |
|
pairCorrs[i]->accumulateFrame(); |
| 340 |
|
} |
| 341 |
|
|
| 353 |
|
if( havePairCorrs ){ |
| 354 |
|
|
| 355 |
|
for(i=0;i<nPairs;i++) |
| 356 |
< |
pairCorrs[i]->writeCorrs( outPrefix ); |
| 356 |
> |
pairCorrs[i]->writeCorr( outPrefix ); |
| 357 |
|
} |
| 358 |
|
|
| 359 |
|
if( haveStaticCorrs ){ |