| 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]; |
| 30 |
> |
double r[3], ji[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(); |
| 65 |
< |
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. |
| 54 |
|
|
| 55 |
< |
uSqr = (ux * ux) + (uy * uy) + (uz * uz); |
| 56 |
< |
|
| 57 |
< |
u = sqrt( uSqr ); |
| 58 |
< |
ux = ux / u; |
| 59 |
< |
uy = uy / u; |
| 72 |
< |
uz = uz / u; |
| 73 |
< |
|
| 74 |
< |
dAtom->setSUx( ux ); |
| 75 |
< |
dAtom->setSUy( uy ); |
| 76 |
< |
dAtom->setSUz( uz ); |
| 77 |
< |
|
| 55 |
> |
phi = currAtom->getEulerPhi() * M_PI / 180.0; |
| 56 |
> |
theta = currAtom->getEulerTheta() * M_PI / 180.0; |
| 57 |
> |
psi = currAtom->getEulerPsi()* M_PI / 180.0; |
| 58 |
> |
|
| 59 |
> |
dAtom->setUnitFrameFromEuler(phi, theta, psi); |
| 60 |
|
dAtom->setA( A ); |
| 61 |
+ |
|
| 62 |
+ |
ji[0] = 0.0; |
| 63 |
+ |
ji[1] = 0.0; |
| 64 |
+ |
ji[2] = 0.0; |
| 65 |
+ |
dAtom->setJ( ji ); |
| 66 |
|
|
| 80 |
– |
dAtom->setJx( 0.0 ); |
| 81 |
– |
dAtom->setJy( 0.0 ); |
| 82 |
– |
dAtom->setJz( 0.0 ); |
| 83 |
– |
|
| 67 |
|
} |
| 68 |
|
else{ |
| 69 |
< |
atomArray[j] = new GeneralAtom( j, myConfig); |
| 70 |
< |
atomArray[j]->setCoords(void); |
| 69 |
> |
atomArray[j] = new Atom( j, myConfig); |
| 70 |
> |
atomArray[j]->setCoords(); |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
atomArray[j]->setType( currAtom->getType() ); |
| 78 |
|
|
| 79 |
|
for(k=0; k<3; k++) r[k] += pos[k]; |
| 80 |
|
|
| 81 |
< |
atomArray[j]->setX( r[0] ); |
| 82 |
< |
atomArray[j]->setY( r[1] ); |
| 83 |
< |
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 ); |
| 81 |
> |
atomArray[j]->setPos( r ); |
| 82 |
> |
|
| 83 |
> |
atomArray[j]->setVel( vel );; |
| 84 |
|
} |
| 85 |
|
} |
| 86 |
|
|
| 180 |
|
} |
| 181 |
|
} |
| 182 |
|
} |
| 183 |
+ |
|
| 184 |
+ |
void getRandomRot( double rot[3][3] ){ |
| 185 |
+ |
|
| 186 |
+ |
double theta, phi, psi; |
| 187 |
+ |
double cosTheta; |
| 188 |
+ |
|
| 189 |
+ |
// select random phi, psi, and cosTheta |
| 190 |
+ |
|
| 191 |
+ |
phi = 2.0 * M_PI * drand48(); |
| 192 |
+ |
psi = 2.0 * M_PI * drand48(); |
| 193 |
+ |
cosTheta = (2.0 * drand48()) - 1.0; // sample cos -1 to 1 |
| 194 |
+ |
|
| 195 |
+ |
theta = acos( cosTheta ); |
| 196 |
+ |
|
| 197 |
+ |
getEulerRot( theta, phi, psi, rot ); |
| 198 |
+ |
} |
| 199 |
+ |
|
| 200 |
+ |
|
| 201 |
+ |
void getEulerRot( double theta, double phi, double psi, double rot[3][3] ){ |
| 202 |
+ |
|
| 203 |
+ |
rot[0][0] = (cos(phi) * cos(psi)) - (sin(phi) * cos(theta) * sin(psi)); |
| 204 |
+ |
rot[0][1] = (sin(phi) * cos(psi)) + (cos(phi) * cos(theta) * sin(psi)); |
| 205 |
+ |
rot[0][2] = sin(theta) * sin(psi); |
| 206 |
+ |
|
| 207 |
+ |
rot[1][0] = -(cos(phi) * sin(psi)) - (sin(phi) * cos(theta) * cos(psi)); |
| 208 |
+ |
rot[1][1] = -(sin(phi) * sin(psi)) + (cos(phi) * cos(theta) * cos(psi)); |
| 209 |
+ |
rot[1][2] = sin(theta) * cos(psi); |
| 210 |
+ |
|
| 211 |
+ |
rot[2][0] = sin(phi) * sin(theta); |
| 212 |
+ |
rot[2][1] = -cos(phi) * sin(theta); |
| 213 |
+ |
rot[2][2] = cos(theta); |
| 214 |
+ |
} |
| 215 |
+ |
|