| 2 |
|
#define _ATOM_H_ |
| 3 |
|
|
| 4 |
|
#include <cstring> |
| 5 |
+ |
#include <cstdlib> |
| 6 |
|
#include <iostream> |
| 7 |
|
|
| 8 |
|
class Atom{ |
| 12 |
|
has_dipole = 0; |
| 13 |
|
is_VDW = 0; |
| 14 |
|
is_LJ = 0; |
| 15 |
+ |
pos = NULL; |
| 16 |
+ |
|
| 17 |
|
index = theIndex; |
| 18 |
|
offset = 3 * index; |
| 19 |
|
offsetX = offset; |
| 20 |
|
offsetY = offset+1; |
| 21 |
|
offsetZ = offset+2; |
| 22 |
+ |
|
| 23 |
+ |
Axx = index*9; |
| 24 |
+ |
Axy = Axx+1; |
| 25 |
+ |
Axz = Axx+2; |
| 26 |
+ |
|
| 27 |
+ |
Ayx = Axx+3; |
| 28 |
+ |
Ayy = Axx+4; |
| 29 |
+ |
Ayz = Axx+5; |
| 30 |
+ |
|
| 31 |
+ |
Azx = Axx+6; |
| 32 |
+ |
Azy = Axx+7; |
| 33 |
+ |
Azz = Axx+8; |
| 34 |
|
} |
| 35 |
|
virtual ~Atom() {} |
| 36 |
|
|
| 37 |
|
static void createArrays (int nElements) { |
| 38 |
+ |
|
| 39 |
+ |
if( pos != NULL ) destroyArrays(); |
| 40 |
+ |
|
| 41 |
|
pos = new double[nElements*3]; |
| 42 |
|
vel = new double[nElements*3]; |
| 43 |
|
frc = new double[nElements*3]; |
| 44 |
|
trq = new double[nElements*3]; |
| 45 |
+ |
Amat = new double[nElements*9]; |
| 46 |
+ |
mu = new double[nElements]; |
| 47 |
+ |
ul = new double[nElements]; |
| 48 |
+ |
|
| 49 |
+ |
// init directional values to zero |
| 50 |
+ |
|
| 51 |
+ |
trq[offsetX] = 0.0; |
| 52 |
+ |
trq[offsetY] = 0.0; |
| 53 |
+ |
trq[offsetZ] = 0.0; |
| 54 |
+ |
|
| 55 |
+ |
Amat[Axx] = 1.0; |
| 56 |
+ |
Amat[Axy] = 0.0; |
| 57 |
+ |
Amat[Axz] = 0.0; |
| 58 |
+ |
|
| 59 |
+ |
Amat[Ayx] = 0.0; |
| 60 |
+ |
Amat[Ayy] = 1.0; |
| 61 |
+ |
Amat[Ayz] = 0.0; |
| 62 |
+ |
|
| 63 |
+ |
Amat[Azx] = 0.0; |
| 64 |
+ |
Amat[Azy] = 0.0; |
| 65 |
+ |
Amat[Azz] = 1.0; |
| 66 |
+ |
|
| 67 |
+ |
mu[index] = 0.0; |
| 68 |
+ |
|
| 69 |
+ |
ul[offsetX] = 0.0; |
| 70 |
+ |
ul[offsetY] = 0.0; |
| 71 |
+ |
ul[offsetZ] = 0.0; |
| 72 |
|
} |
| 73 |
|
static void destroyArrays(void) { |
| 74 |
|
delete[] pos; |
| 75 |
|
delete[] vel; |
| 76 |
|
delete[] frc; |
| 77 |
|
delete[] trq; |
| 78 |
+ |
delete[] Amat; |
| 79 |
+ |
delete[] mu; |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
static double* getPosArray( void ) { return pos; } |
| 83 |
|
static double* getVelArray( void ) { return vel; } |
| 84 |
|
static double* getFrcArray( void ) { return frc; } |
| 85 |
|
static double* getTrqArray( void ) { return trq; } |
| 86 |
+ |
static double* getAmatArray( void ) { return Amat; } |
| 87 |
+ |
static double* getMuArray( void ) { return mu; } |
| 88 |
+ |
static double* getUlArray( void ) { return ul; } |
| 89 |
|
|
| 40 |
– |
|
| 90 |
|
double getX() const {return pos[offsetX];} |
| 91 |
|
double getY() const {return pos[offsetY];} |
| 92 |
|
double getZ() const {return pos[offsetZ];} |
| 128 |
|
offsetX = offset; |
| 129 |
|
offsetY = offset+1; |
| 130 |
|
offsetZ = offset+2; |
| 131 |
+ |
|
| 132 |
+ |
Axx = index*9; |
| 133 |
+ |
Axy = Axx+1; |
| 134 |
+ |
Axz = Axx+2; |
| 135 |
+ |
|
| 136 |
+ |
Ayx = Axx+3; |
| 137 |
+ |
Ayy = Axx+4; |
| 138 |
+ |
Ayz = Axx+5; |
| 139 |
+ |
|
| 140 |
+ |
Azx = Axx+6; |
| 141 |
+ |
Azy = Axx+7; |
| 142 |
+ |
Azz = Axx+8; |
| 143 |
|
} |
| 144 |
|
|
| 145 |
|
char *getType() {return c_name;} |
| 171 |
|
static double* vel; // the velocity array |
| 172 |
|
static double* frc; // the forc array |
| 173 |
|
static double* trq; // the torque vector ( space fixed ) |
| 174 |
+ |
static double* Amat; // the rotation matrix |
| 175 |
+ |
static double* mu; // the dipole moment array |
| 176 |
+ |
static double* ul; // the lab frame unit directional vector |
| 177 |
|
|
| 178 |
|
protected: |
| 179 |
|
|
| 186 |
|
int offset; // the atom's offset in the storage array |
| 187 |
|
int offsetX, offsetY, offsetZ; |
| 188 |
|
|
| 189 |
+ |
int Axx, Axy, Axz; // the rotational matrix indices |
| 190 |
+ |
int Ayx, Ayy, Ayz; |
| 191 |
+ |
int Azx, Azy, Azz; |
| 192 |
+ |
|
| 193 |
|
char c_name[100]; /* it's name */ |
| 194 |
|
int ident; // it's unique numeric identity. |
| 195 |
|
|
| 215 |
|
|
| 216 |
|
int isDirectional( void ){ return 0; } |
| 217 |
|
void zeroForces() { |
| 218 |
< |
frc[offsetX] = 0.0; |
| 218 |
> |
frc[offsetX] = 0.0; |
| 219 |
|
frc[offsetY] = 0.0; |
| 220 |
|
frc[offsetZ] = 0.0; |
| 221 |
|
} |
| 227 |
|
DirectionalAtom(int theIndex) : Atom(theIndex) |
| 228 |
|
{ |
| 229 |
|
ssdIdentity = 0; |
| 230 |
+ |
sux = 0.0; |
| 231 |
+ |
suy = 0.0; |
| 232 |
+ |
suz = 0.0; |
| 233 |
|
} |
| 234 |
|
virtual ~DirectionalAtom() {} |
| 235 |
|
|
| 165 |
– |
static void createDArrays(int nElements){ |
| 166 |
– |
trq = new double[nElements*3]; |
| 167 |
– |
} |
| 168 |
– |
static void destroyDArrays(void){ |
| 169 |
– |
delete[] trq; |
| 170 |
– |
} |
| 171 |
– |
|
| 236 |
|
int isDirectional(void) { return 1; } |
| 237 |
|
|
| 238 |
|
void setSSD( int value) { ssdIdentity = value; } |
| 254 |
|
void setJy( double the_jy ) { jy = the_jy; } |
| 255 |
|
void setJz( double the_jz ) { jz = the_jz; } |
| 256 |
|
|
| 257 |
< |
void addTx( double the_tx ) { trq[offsetX] += the_tx;} |
| 257 |
> |
void addTx( double the_tx ) { trq[offsetX] += the_tx;} |
| 258 |
|
void addTy( double the_ty ) { trq[offsetY] += the_ty;} |
| 259 |
|
void addTz( double the_tz ) { trq[offsetZ] += the_tz;} |
| 260 |
|
|
| 197 |
– |
void setMu( double the_mu ) { mu = the_mu; } |
| 198 |
– |
|
| 261 |
|
void zeroForces() { |
| 262 |
< |
frc[offsetX] = 0.0; |
| 262 |
> |
frc[offsetX] = 0.0; |
| 263 |
|
frc[offsetY] = 0.0; |
| 264 |
|
frc[offsetZ] = 0.0; |
| 265 |
|
|
| 266 |
< |
trq[offsetX] = 0.0; |
| 266 |
> |
trq[offsetX] = 0.0; |
| 267 |
|
trq[offsetY] = 0.0; |
| 268 |
|
trq[offsetZ] = 0.0; |
| 269 |
|
} |
| 270 |
|
|
| 271 |
< |
double getAxx( void ) { return Axx; } |
| 272 |
< |
double getAxy( void ) { return Axy; } |
| 273 |
< |
double getAxz( void ) { return Axz; } |
| 271 |
> |
double getAxx( void ) { return Amat[Axx]; } |
| 272 |
> |
double getAxy( void ) { return Amat[Axy]; } |
| 273 |
> |
double getAxz( void ) { return Amat[Axz]; } |
| 274 |
|
|
| 275 |
< |
double getAyx( void ) { return Ayx; } |
| 276 |
< |
double getAyy( void ) { return Ayy; } |
| 277 |
< |
double getAyz( void ) { return Ayz; } |
| 275 |
> |
double getAyx( void ) { return Amat[Ayx]; } |
| 276 |
> |
double getAyy( void ) { return Amat[Ayy]; } |
| 277 |
> |
double getAyz( void ) { return Amat[Ayz]; } |
| 278 |
|
|
| 279 |
< |
double getAzx( void ) { return Azx; } |
| 280 |
< |
double getAzy( void ) { return Azy; } |
| 281 |
< |
double getAzz( void ) { return Azz; } |
| 279 |
> |
double getAzx( void ) { return Amat[Azx]; } |
| 280 |
> |
double getAzy( void ) { return Amat[Azy]; } |
| 281 |
> |
double getAzz( void ) { return Amat[Azz]; } |
| 282 |
|
|
| 283 |
|
void getA( double the_A[3][3] ); // get the full rotation matrix |
| 284 |
|
|
| 286 |
|
double getSUy( void ) { return suy; } |
| 287 |
|
double getSUz( void ) { return suz; } |
| 288 |
|
|
| 289 |
< |
void getU( double the_u[3] ); // get the unit vector |
| 289 |
> |
void getU( double the_u[3] ); // get the unit vetor |
| 290 |
|
void getQ( double the_q[4] ); // get the quanternions |
| 291 |
|
|
| 292 |
|
double getJx( void ) { return jx; } |
| 309 |
|
double getIzy( void ) { return Izy; } |
| 310 |
|
double getIzz( void ) { return Izz; } |
| 311 |
|
|
| 312 |
< |
double getMu( void ) { return mu; } |
| 312 |
> |
double getMu( void ) { return mu[index]; } |
| 313 |
> |
void setMu( double the_mu ) { mu[index] = the_mu; } |
| 314 |
|
|
| 315 |
|
void lab2Body( double r[3] ); |
| 316 |
|
void body2Lab( double r[3] ); |
| 317 |
+ |
void updateU( void ); |
| 318 |
|
|
| 319 |
|
private: |
| 320 |
|
int dIndex; |
| 321 |
|
|
| 258 |
– |
double Axx, Axy, Axz; // the rotational matrix |
| 259 |
– |
double Ayx, Ayy, Ayz; |
| 260 |
– |
double Azx, Azy, Azz; |
| 261 |
– |
|
| 322 |
|
double sux, suy, suz; // the standard unit vector ( body fixed ) |
| 323 |
|
double jx, jy, jz; // the angular momentum vector ( body fixed ) |
| 324 |
|
|
| 326 |
|
double Iyx, Iyy, Iyz; |
| 327 |
|
double Izx, Izy, Izz; |
| 328 |
|
|
| 269 |
– |
double mu; // the magnitude of the dipole moment |
| 270 |
– |
|
| 329 |
|
int ssdIdentity; // boolean of whether atom is ssd |
| 330 |
|
|
| 331 |
|
}; |