| 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]; |
| 32 |
|
|
| 33 |
|
AtomStamp* currAtom; |
| 34 |
|
DirectionalAtom* dAtom; |
| 35 |
+ |
double vel[3]; |
| 36 |
+ |
for(i=0;i<3;i++)vel[i]=0.0; |
| 37 |
|
|
| 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 |
– |
|
| 38 |
|
for(i=0; i<nAtoms; i++){ |
| 39 |
|
|
| 40 |
|
currAtom = myStamp->getAtom( i ); |
| 44 |
|
|
| 45 |
|
dAtom = new DirectionalAtom( j, myConfig); |
| 46 |
|
atomArray[j] = dAtom; |
| 47 |
< |
atomArray[j]->setCoords(void); |
| 47 |
> |
atomArray[j]->setCoords(); |
| 48 |
|
|
| 49 |
|
ux = currAtom->getOrntX(); |
| 50 |
|
uy = currAtom->getOrntY(); |
| 70 |
|
} |
| 71 |
|
else{ |
| 72 |
|
atomArray[j] = new GeneralAtom( j, myConfig); |
| 73 |
< |
atomArray[j]->setCoords(void); |
| 73 |
> |
atomArray[j]->setCoords(); |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
atomArray[j]->setType( currAtom->getType() ); |
| 81 |
|
|
| 82 |
|
for(k=0; k<3; k++) r[k] += pos[k]; |
| 83 |
|
|
| 84 |
< |
atomArray[j]->setX( r[0] ); |
| 85 |
< |
atomArray[j]->setY( r[1] ); |
| 86 |
< |
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 ); |
| 84 |
> |
atomArray[j]->setPos( r ); |
| 85 |
> |
|
| 86 |
> |
atomArray[j]->setVel( vel );; |
| 87 |
|
} |
| 88 |
|
} |
| 89 |
|
|
| 183 |
|
} |
| 184 |
|
} |
| 185 |
|
} |
| 186 |
+ |
|
| 187 |
+ |
void getRandomRot( double rot[3][3] ){ |
| 188 |
+ |
|
| 189 |
+ |
double theta, phi, psi; |
| 190 |
+ |
double cosTheta; |
| 191 |
+ |
|
| 192 |
+ |
// select random phi, psi, and cosTheta |
| 193 |
+ |
|
| 194 |
+ |
phi = 2.0 * M_PI * drand48(); |
| 195 |
+ |
psi = 2.0 * M_PI * drand48(); |
| 196 |
+ |
cosTheta = (2.0 * drand48()) - 1.0; // sample cos -1 to 1 |
| 197 |
+ |
|
| 198 |
+ |
theta = acos( cosTheta ); |
| 199 |
+ |
|
| 200 |
+ |
getEulerRot( theta, phi, psi, rot ); |
| 201 |
+ |
} |
| 202 |
+ |
|
| 203 |
+ |
|
| 204 |
+ |
void getEulerRot( double theta, double phi, double psi, double rot[3][3] ){ |
| 205 |
+ |
|
| 206 |
+ |
rot[0][0] = (cos(phi) * cos(psi)) - (sin(phi) * cos(theta) * sin(psi)); |
| 207 |
+ |
rot[0][1] = (sin(phi) * cos(psi)) + (cos(phi) * cos(theta) * sin(psi)); |
| 208 |
+ |
rot[0][2] = sin(theta) * sin(psi); |
| 209 |
+ |
|
| 210 |
+ |
rot[1][0] = -(cos(phi) * sin(psi)) - (sin(phi) * cos(theta) * cos(psi)); |
| 211 |
+ |
rot[1][1] = -(sin(phi) * sin(psi)) + (cos(phi) * cos(theta) * cos(psi)); |
| 212 |
+ |
rot[1][2] = sin(theta) * cos(psi); |
| 213 |
+ |
|
| 214 |
+ |
rot[2][0] = sin(phi) * sin(theta); |
| 215 |
+ |
rot[2][1] = -cos(phi) * sin(theta); |
| 216 |
+ |
rot[2][2] = cos(theta); |
| 217 |
+ |
} |
| 218 |
+ |
|