| 13 |
|
myStamp = theStamp; |
| 14 |
|
nAtoms = myStamp->getNAtoms(); |
| 15 |
|
|
| 16 |
– |
myConfig=NULL; |
| 17 |
– |
|
| 16 |
|
myCoords = NULL; |
| 17 |
|
|
| 18 |
|
calcRefCoords(); |
| 23 |
|
if( myCoords != NULL ) delete[] myCoords; |
| 24 |
|
} |
| 25 |
|
|
| 28 |
– |
void MoLocator::setConfig(SimState * theConfig){ |
| 29 |
– |
|
| 30 |
– |
myConfig = theConfig; |
| 31 |
– |
haveConfig = true; |
| 32 |
– |
} |
| 33 |
– |
|
| 26 |
|
void MoLocator::placeMol( double pos[3], double A[3][3], Atom** atomArray, |
| 27 |
< |
int atomIndex ){ |
| 27 |
> |
int atomIndex, SimState* myConfig ){ |
| 28 |
|
|
| 29 |
|
int i,j,k; |
| 30 |
|
double r[3]; |
| 31 |
+ |
double phi, theta, psi; |
| 32 |
+ |
double sux, suy, suz; |
| 33 |
+ |
double Axx, Axy, Axz, Ayx, Ayy, Ayz, Azx, Azy, Azz; |
| 34 |
|
double ux, uy, uz, u, uSqr; |
| 35 |
|
|
| 36 |
|
AtomStamp* currAtom; |
| 37 |
|
DirectionalAtom* dAtom; |
| 38 |
+ |
double vel[3]; |
| 39 |
+ |
for(i=0;i<3;i++)vel[i]=0.0; |
| 40 |
|
|
| 44 |
– |
|
| 45 |
– |
if( !haveConfig ){ |
| 46 |
– |
sprintf(painCave.errMsg, |
| 47 |
– |
"attempt to placeMol without setting the SimState in the MoLocator.\n",); |
| 48 |
– |
painCave.isFatal = 1; |
| 49 |
– |
simError(void); |
| 50 |
– |
} |
| 51 |
– |
|
| 41 |
|
for(i=0; i<nAtoms; i++){ |
| 42 |
|
|
| 43 |
|
currAtom = myStamp->getAtom( i ); |
| 47 |
|
|
| 48 |
|
dAtom = new DirectionalAtom( j, myConfig); |
| 49 |
|
atomArray[j] = dAtom; |
| 50 |
< |
atomArray[j]->setCoords(void); |
| 51 |
< |
|
| 52 |
< |
ux = currAtom->getOrntX(); |
| 53 |
< |
uy = currAtom->getOrntY(); |
| 54 |
< |
uz = currAtom->getOrntZ(); |
| 50 |
> |
atomArray[j]->setCoords(); |
| 51 |
> |
|
| 52 |
> |
// Directional Atoms have standard unit vectors which are oriented |
| 53 |
> |
// in space using the three Euler angles. We assume the standard |
| 54 |
> |
// unit vector was originally along the z axis below. |
| 55 |
|
|
| 56 |
+ |
phi = currAtom->getEulerPhi() * M_PI / 180.0; |
| 57 |
+ |
theta = currAtom->getEulerTheta() * M_PI / 180.0; |
| 58 |
+ |
psi = currAtom->getEulerPsi()* M_PI / 180.0; |
| 59 |
+ |
|
| 60 |
+ |
Axx = (cos(phi) * cos(psi)) - (sin(phi) * cos(theta) * sin(psi)); |
| 61 |
+ |
Axy = (sin(phi) * cos(psi)) + (cos(phi) * cos(theta) * sin(psi)); |
| 62 |
+ |
Axz = sin(theta) * sin(psi); |
| 63 |
+ |
|
| 64 |
+ |
Ayx = -(cos(phi) * sin(psi)) - (sin(phi) * cos(theta) * cos(psi)); |
| 65 |
+ |
Ayy = -(sin(phi) * sin(psi)) + (cos(phi) * cos(theta) * cos(psi)); |
| 66 |
+ |
Ayz = sin(theta) * cos(psi); |
| 67 |
+ |
|
| 68 |
+ |
Azx = sin(phi) * sin(theta); |
| 69 |
+ |
Azy = -cos(phi) * sin(theta); |
| 70 |
+ |
Azz = cos(theta); |
| 71 |
+ |
|
| 72 |
+ |
sux = 0.0; |
| 73 |
+ |
suy = 0.0; |
| 74 |
+ |
suz = 1.0; |
| 75 |
+ |
|
| 76 |
+ |
ux = (Axx * sux) + (Ayx * suy) + (Azx * suz); |
| 77 |
+ |
uy = (Axy * sux) + (Ayy * suy) + (Azy * suz); |
| 78 |
+ |
uz = (Axz * sux) + (Ayz * suy) + (Azz * suz); |
| 79 |
+ |
|
| 80 |
|
uSqr = (ux * ux) + (uy * uy) + (uz * uz); |
| 81 |
|
|
| 82 |
|
u = sqrt( uSqr ); |
| 97 |
|
} |
| 98 |
|
else{ |
| 99 |
|
atomArray[j] = new GeneralAtom( j, myConfig); |
| 100 |
< |
atomArray[j]->setCoords(void); |
| 100 |
> |
atomArray[j]->setCoords(); |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
atomArray[j]->setType( currAtom->getType() ); |
| 108 |
|
|
| 109 |
|
for(k=0; k<3; k++) r[k] += pos[k]; |
| 110 |
|
|
| 111 |
< |
atomArray[j]->setX( r[0] ); |
| 112 |
< |
atomArray[j]->setY( r[1] ); |
| 113 |
< |
atomArray[j]->setZ( r[2] ); |
| 101 |
< |
|
| 102 |
< |
atomArray[j]->set_vx( 0.0 ); |
| 103 |
< |
atomArray[j]->set_vy( 0.0 ); |
| 104 |
< |
atomArray[j]->set_vz( 0.0 ); |
| 111 |
> |
atomArray[j]->setPos( r ); |
| 112 |
> |
|
| 113 |
> |
atomArray[j]->setVel( vel );; |
| 114 |
|
} |
| 115 |
|
} |
| 116 |
|
|
| 210 |
|
} |
| 211 |
|
} |
| 212 |
|
} |
| 213 |
+ |
|
| 214 |
+ |
void getRandomRot( double rot[3][3] ){ |
| 215 |
+ |
|
| 216 |
+ |
double theta, phi, psi; |
| 217 |
+ |
double cosTheta; |
| 218 |
+ |
|
| 219 |
+ |
// select random phi, psi, and cosTheta |
| 220 |
+ |
|
| 221 |
+ |
phi = 2.0 * M_PI * drand48(); |
| 222 |
+ |
psi = 2.0 * M_PI * drand48(); |
| 223 |
+ |
cosTheta = (2.0 * drand48()) - 1.0; // sample cos -1 to 1 |
| 224 |
+ |
|
| 225 |
+ |
theta = acos( cosTheta ); |
| 226 |
+ |
|
| 227 |
+ |
getEulerRot( theta, phi, psi, rot ); |
| 228 |
+ |
} |
| 229 |
+ |
|
| 230 |
+ |
|
| 231 |
+ |
void getEulerRot( double theta, double phi, double psi, double rot[3][3] ){ |
| 232 |
+ |
|
| 233 |
+ |
rot[0][0] = (cos(phi) * cos(psi)) - (sin(phi) * cos(theta) * sin(psi)); |
| 234 |
+ |
rot[0][1] = (sin(phi) * cos(psi)) + (cos(phi) * cos(theta) * sin(psi)); |
| 235 |
+ |
rot[0][2] = sin(theta) * sin(psi); |
| 236 |
+ |
|
| 237 |
+ |
rot[1][0] = -(cos(phi) * sin(psi)) - (sin(phi) * cos(theta) * cos(psi)); |
| 238 |
+ |
rot[1][1] = -(sin(phi) * sin(psi)) + (cos(phi) * cos(theta) * cos(psi)); |
| 239 |
+ |
rot[1][2] = sin(theta) * cos(psi); |
| 240 |
+ |
|
| 241 |
+ |
rot[2][0] = sin(phi) * sin(theta); |
| 242 |
+ |
rot[2][1] = -cos(phi) * sin(theta); |
| 243 |
+ |
rot[2][2] = cos(theta); |
| 244 |
+ |
} |
| 245 |
+ |
|