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 |
+ |
int i; |
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*3]; |
48 |
+ |
|
49 |
+ |
// init directional values to zero |
50 |
+ |
|
51 |
+ |
for( i=0; i<nElements; i++){ |
52 |
+ |
trq[i] = 0.0; |
53 |
+ |
trq[i+1] = 0.0; |
54 |
+ |
trq[i+2] = 0.0; |
55 |
+ |
|
56 |
+ |
Amat[i] = 1.0; |
57 |
+ |
Amat[i+1] = 0.0; |
58 |
+ |
Amat[i+2] = 0.0; |
59 |
+ |
|
60 |
+ |
Amat[i+3] = 0.0; |
61 |
+ |
Amat[i+4] = 1.0; |
62 |
+ |
Amat[i+5] = 0.0; |
63 |
+ |
|
64 |
+ |
Amat[i+6] = 0.0; |
65 |
+ |
Amat[i+7] = 0.0; |
66 |
+ |
Amat[i+8] = 1.0; |
67 |
+ |
|
68 |
+ |
mu[i] = 0.0; |
69 |
+ |
|
70 |
+ |
ul[i] = 0.0; |
71 |
+ |
ul[i+1] = 0.0; |
72 |
+ |
ul[i+2] = 0.0; |
73 |
+ |
} |
74 |
|
} |
75 |
|
static void destroyArrays(void) { |
76 |
|
delete[] pos; |
77 |
|
delete[] vel; |
78 |
|
delete[] frc; |
79 |
|
delete[] trq; |
80 |
+ |
delete[] Amat; |
81 |
+ |
delete[] mu; |
82 |
|
} |
83 |
|
|
84 |
|
static double* getPosArray( void ) { return pos; } |
85 |
|
static double* getVelArray( void ) { return vel; } |
86 |
|
static double* getFrcArray( void ) { return frc; } |
87 |
|
static double* getTrqArray( void ) { return trq; } |
88 |
+ |
static double* getAmatArray( void ) { return Amat; } |
89 |
+ |
static double* getMuArray( void ) { return mu; } |
90 |
+ |
static double* getUlArray( void ) { return ul; } |
91 |
|
|
40 |
– |
|
92 |
|
double getX() const {return pos[offsetX];} |
93 |
|
double getY() const {return pos[offsetY];} |
94 |
|
double getZ() const {return pos[offsetZ];} |
130 |
|
offsetX = offset; |
131 |
|
offsetY = offset+1; |
132 |
|
offsetZ = offset+2; |
133 |
+ |
|
134 |
+ |
Axx = index*9; |
135 |
+ |
Axy = Axx+1; |
136 |
+ |
Axz = Axx+2; |
137 |
+ |
|
138 |
+ |
Ayx = Axx+3; |
139 |
+ |
Ayy = Axx+4; |
140 |
+ |
Ayz = Axx+5; |
141 |
+ |
|
142 |
+ |
Azx = Axx+6; |
143 |
+ |
Azy = Axx+7; |
144 |
+ |
Azz = Axx+8; |
145 |
|
} |
146 |
|
|
147 |
|
char *getType() {return c_name;} |
173 |
|
static double* vel; // the velocity array |
174 |
|
static double* frc; // the forc array |
175 |
|
static double* trq; // the torque vector ( space fixed ) |
176 |
+ |
static double* Amat; // the rotation matrix |
177 |
+ |
static double* mu; // the dipole moment array |
178 |
+ |
static double* ul; // the lab frame unit directional vector |
179 |
|
|
180 |
|
protected: |
181 |
|
|
188 |
|
int offset; // the atom's offset in the storage array |
189 |
|
int offsetX, offsetY, offsetZ; |
190 |
|
|
191 |
+ |
int Axx, Axy, Axz; // the rotational matrix indices |
192 |
+ |
int Ayx, Ayy, Ayz; |
193 |
+ |
int Azx, Azy, Azz; |
194 |
+ |
|
195 |
|
char c_name[100]; /* it's name */ |
196 |
|
int ident; // it's unique numeric identity. |
197 |
|
|
217 |
|
|
218 |
|
int isDirectional( void ){ return 0; } |
219 |
|
void zeroForces() { |
220 |
< |
frc[offsetX] = 0.0; |
220 |
> |
frc[offsetX] = 0.0; |
221 |
|
frc[offsetY] = 0.0; |
222 |
|
frc[offsetZ] = 0.0; |
223 |
|
} |
229 |
|
DirectionalAtom(int theIndex) : Atom(theIndex) |
230 |
|
{ |
231 |
|
ssdIdentity = 0; |
232 |
+ |
sux = 0.0; |
233 |
+ |
suy = 0.0; |
234 |
+ |
suz = 0.0; |
235 |
|
} |
236 |
|
virtual ~DirectionalAtom() {} |
237 |
|
|
165 |
– |
static void createDArrays(int nElements){ |
166 |
– |
trq = new double[nElements*3]; |
167 |
– |
} |
168 |
– |
static void destroyDArrays(void){ |
169 |
– |
delete[] trq; |
170 |
– |
} |
171 |
– |
|
238 |
|
int isDirectional(void) { return 1; } |
239 |
|
|
240 |
|
void setSSD( int value) { ssdIdentity = value; } |
256 |
|
void setJy( double the_jy ) { jy = the_jy; } |
257 |
|
void setJz( double the_jz ) { jz = the_jz; } |
258 |
|
|
259 |
< |
void addTx( double the_tx ) { trq[offsetX] += the_tx;} |
259 |
> |
void addTx( double the_tx ) { trq[offsetX] += the_tx;} |
260 |
|
void addTy( double the_ty ) { trq[offsetY] += the_ty;} |
261 |
|
void addTz( double the_tz ) { trq[offsetZ] += the_tz;} |
262 |
|
|
197 |
– |
void setMu( double the_mu ) { mu = the_mu; } |
198 |
– |
|
263 |
|
void zeroForces() { |
264 |
< |
frc[offsetX] = 0.0; |
264 |
> |
frc[offsetX] = 0.0; |
265 |
|
frc[offsetY] = 0.0; |
266 |
|
frc[offsetZ] = 0.0; |
267 |
|
|
268 |
< |
trq[offsetX] = 0.0; |
268 |
> |
trq[offsetX] = 0.0; |
269 |
|
trq[offsetY] = 0.0; |
270 |
|
trq[offsetZ] = 0.0; |
271 |
|
} |
272 |
|
|
273 |
< |
double getAxx( void ) { return Axx; } |
274 |
< |
double getAxy( void ) { return Axy; } |
275 |
< |
double getAxz( void ) { return Axz; } |
273 |
> |
double getAxx( void ) { return Amat[Axx]; } |
274 |
> |
double getAxy( void ) { return Amat[Axy]; } |
275 |
> |
double getAxz( void ) { return Amat[Axz]; } |
276 |
|
|
277 |
< |
double getAyx( void ) { return Ayx; } |
278 |
< |
double getAyy( void ) { return Ayy; } |
279 |
< |
double getAyz( void ) { return Ayz; } |
277 |
> |
double getAyx( void ) { return Amat[Ayx]; } |
278 |
> |
double getAyy( void ) { return Amat[Ayy]; } |
279 |
> |
double getAyz( void ) { return Amat[Ayz]; } |
280 |
|
|
281 |
< |
double getAzx( void ) { return Azx; } |
282 |
< |
double getAzy( void ) { return Azy; } |
283 |
< |
double getAzz( void ) { return Azz; } |
281 |
> |
double getAzx( void ) { return Amat[Azx]; } |
282 |
> |
double getAzy( void ) { return Amat[Azy]; } |
283 |
> |
double getAzz( void ) { return Amat[Azz]; } |
284 |
|
|
285 |
|
void getA( double the_A[3][3] ); // get the full rotation matrix |
286 |
|
|
288 |
|
double getSUy( void ) { return suy; } |
289 |
|
double getSUz( void ) { return suz; } |
290 |
|
|
291 |
< |
void getU( double the_u[3] ); // get the unit vector |
291 |
> |
void getU( double the_u[3] ); // get the unit vetor |
292 |
|
void getQ( double the_q[4] ); // get the quanternions |
293 |
|
|
294 |
|
double getJx( void ) { return jx; } |
311 |
|
double getIzy( void ) { return Izy; } |
312 |
|
double getIzz( void ) { return Izz; } |
313 |
|
|
314 |
< |
double getMu( void ) { return mu; } |
314 |
> |
double getMu( void ) { return mu[index]; } |
315 |
> |
void setMu( double the_mu ) { mu[index] = the_mu; } |
316 |
|
|
317 |
|
void lab2Body( double r[3] ); |
318 |
|
void body2Lab( double r[3] ); |
319 |
+ |
void updateU( void ); |
320 |
|
|
321 |
|
private: |
322 |
|
int dIndex; |
323 |
|
|
258 |
– |
double Axx, Axy, Axz; // the rotational matrix |
259 |
– |
double Ayx, Ayy, Ayz; |
260 |
– |
double Azx, Azy, Azz; |
261 |
– |
|
324 |
|
double sux, suy, suz; // the standard unit vector ( body fixed ) |
325 |
|
double jx, jy, jz; // the angular momentum vector ( body fixed ) |
326 |
|
|
328 |
|
double Iyx, Iyy, Iyz; |
329 |
|
double Izx, Izy, Izz; |
330 |
|
|
269 |
– |
double mu; // the magnitude of the dipole moment |
270 |
– |
|
331 |
|
int ssdIdentity; // boolean of whether atom is ssd |
332 |
|
|
333 |
|
}; |