ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE_old/src/mdtools/libmdCode/Atom.hpp
Revision: 296
Committed: Thu Mar 6 20:05:39 2003 UTC (21 years, 6 months ago) by mmeineke
File size: 8496 byte(s)
Log Message:
dded more static arrays to the Atom class;

File Contents

# Content
1 #ifndef _ATOM_H_
2 #define _ATOM_H_
3
4 #include <cstring>
5 #include <iostream>
6
7 class Atom{
8 public:
9 Atom(int theIndex) {
10 c_n_hyd = 0;
11 has_dipole = 0;
12 is_VDW = 0;
13 is_LJ = 0;
14 index = theIndex;
15 offset = 3 * index;
16 offsetX = offset;
17 offsetY = offset+1;
18 offsetZ = offset+2;
19
20 Axx = index*9;
21 Axy = Axx+1;
22 Axz = Axx+2;
23
24 Ayx = Axx+3;
25 Ayy = Axx+4;
26 Ayz = Axx+5;
27
28 Azx = Axx+6;
29 Azy = Axx+7;
30 Azz = Axx+8;
31 }
32 virtual ~Atom() {}
33
34 static void createArrays (int nElements) {
35 pos = new double[nElements*3];
36 vel = new double[nElements*3];
37 frc = new double[nElements*3];
38 trq = new double[nElements*3];
39 Amat = new double[nElements*9];
40 mu = new double[nElements];
41 ul = new double[nElements];
42
43 // init directional values to zero
44
45 trq[offsetX] = 0.0;
46 trq[offsetY] = 0.0;
47 trq[offsetZ] = 0.0;
48
49 Amat[Axx] = 0.0;
50 Amat[Axy] = 0.0;
51 Amat[Axz] = 0.0;
52
53 Amat[Ayx] = 0.0;
54 Amat[Ayy] = 0.0;
55 Amat[Ayz] = 0.0;
56
57 Amat[Azx] = 0.0;
58 Amat[Azy] = 0.0;
59 Amat[Azz] = 0.0;
60
61 mu[index] = 0.0;
62
63 ul[offsetX] = 0.0;
64 ul[offsetY] = 0.0;
65 ul[offsetZ] = 0.0;
66 }
67 static void destroyArrays(void) {
68 delete[] pos;
69 delete[] vel;
70 delete[] frc;
71 delete[] trq;
72 delete[] Amat;
73 delete[] mu;
74 }
75
76 static double* getPosArray( void ) { return pos; }
77 static double* getVelArray( void ) { return vel; }
78 static double* getFrcArray( void ) { return frc; }
79 static double* getTrqArray( void ) { return trq; }
80 static double* getAmatArray( void ) { return Amat; }
81 static double* getMuArray( void ) { return mu; }
82 static double* getUlArray( void ) { return ul; }
83
84 double getX() const {return pos[offsetX];}
85 double getY() const {return pos[offsetY];}
86 double getZ() const {return pos[offsetZ];}
87 void setX(double x) {pos[offsetX] = x;}
88 void setY(double y) {pos[offsetY] = y;}
89 void setZ(double z) {pos[offsetZ] = z;}
90
91 double get_vx() const {return vel[offsetX];}
92 double get_vy() const {return vel[offsetY];}
93 double get_vz() const {return vel[offsetZ];}
94 void set_vx(double vx) {vel[offsetX] = vx;}
95 void set_vy(double vy) {vel[offsetY] = vy;}
96 void set_vz(double vz) {vel[offsetZ] = vz;}
97
98 double getFx() const {return frc[offsetX];}
99 double getFy() const {return frc[offsetY];}
100 double getFz() const {return frc[offsetZ];}
101 void addFx(double add) {frc[offsetX] += add;}
102 void addFy(double add) {frc[offsetY] += add;}
103 void addFz(double add) {frc[offsetZ] += add;}
104 virtual void zeroForces() = 0;
105
106 double getMass() const {return c_mass;}
107 void setMass(double mass) {c_mass = mass;}
108
109 double getSigma() const {return c_sigma;}
110 void setSigma(double sigma) {c_sigma = sigma;}
111
112 double getEpslon() const {return c_epslon;}
113 void setEpslon(double epslon) {c_epslon = epslon;}
114
115 double getCovalent() const {return c_covalent;}
116 void setCovalent(double covalent) {c_covalent = covalent;}
117
118 int getIndex() const {return index;}
119 void setIndex(int theIndex) {
120 index = theIndex;
121 offset = index*3;
122 offsetX = offset;
123 offsetY = offset+1;
124 offsetZ = offset+2;
125
126 Axx = index*9;
127 Axy = Axx+1;
128 Axz = Axx+2;
129
130 Ayx = Axx+3;
131 Ayy = Axx+4;
132 Ayz = Axx+5;
133
134 Azx = Axx+6;
135 Azy = Axx+7;
136 Azz = Axx+8;
137 }
138
139 char *getType() {return c_name;}
140 void setType(char * name) {strcpy(c_name,name);}
141
142 int getIdent( void ) { return ident; }
143 void setIdent( int info ) { ident = info; }
144
145 #ifdef IS_MPI
146 int getGlobalIndex( void ) { return myGlobalIndex; }
147 void setGlobalIndex( int info ) { myGlobalIndex = info; }
148 #endif // is_mpi
149
150 void set_n_hydrogens( int n_h ) {c_n_hyd = n_h;}
151 int get_n_hydrogens() const {return c_n_hyd;}
152
153 void setHasDipole( int value ) { has_dipole = value; }
154 int hasDipole( void ) { return has_dipole; }
155
156 void setLJ( void ) { is_LJ = 1; is_VDW = 0; }
157 int isLJ( void ) { return is_LJ; }
158
159 void seVDW( void ) { is_VDW = 1; is_LJ = 0; }
160 int isVDW( void ) { return is_VDW; }
161
162 virtual int isDirectional( void ) = 0;
163
164 static double* pos; // the position array
165 static double* vel; // the velocity array
166 static double* frc; // the forc array
167 static double* trq; // the torque vector ( space fixed )
168 static double* Amat; // the rotation matrix
169 static double* mu; // the dipole moment array
170 static double* ul; // the lab frame unit directional vector
171
172 protected:
173
174 double c_mass; /* the mass of the atom in amu */
175 double c_sigma; /* the sigma parameter for van der walls interactions */
176 double c_epslon; /* the esplon parameter for VDW interactions */
177 double c_covalent; // The covalent radius of the atom.
178
179 int index; /* set the atom's index */
180 int offset; // the atom's offset in the storage array
181 int offsetX, offsetY, offsetZ;
182
183 int Axx, Axy, Axz; // the rotational matrix indices
184 int Ayx, Ayy, Ayz;
185 int Azx, Azy, Azz;
186
187 char c_name[100]; /* it's name */
188 int ident; // it's unique numeric identity.
189
190 int c_n_hyd; // the number of hydrogens bonded to the atom
191
192 int has_dipole; // dipole boolean
193 int is_VDW; // VDW boolean
194 int is_LJ; // LJ boolean
195
196 #ifdef IS_MPI
197 int myGlobalIndex;
198 #endif
199
200 };
201
202
203
204 class GeneralAtom : public Atom{
205
206 public:
207 GeneralAtom(int theIndex): Atom(theIndex){}
208 virtual ~GeneralAtom(){}
209
210 int isDirectional( void ){ return 0; }
211 void zeroForces() {
212 frc[offsetX] = 0.0;
213 frc[offsetY] = 0.0;
214 frc[offsetZ] = 0.0;
215 }
216 };
217
218 class DirectionalAtom : public Atom {
219
220 public:
221 DirectionalAtom(int theIndex) : Atom(theIndex)
222 {
223 ssdIdentity = 0;
224
225 }
226 virtual ~DirectionalAtom() {}
227
228 int isDirectional(void) { return 1; }
229
230 void setSSD( int value) { ssdIdentity = value; }
231 int isSSD(void) {return ssdIdentity; }
232
233 void setA( double the_A[3][3] );
234
235 void setI( double the_I[3][3] );
236
237 void setQ( double the_q[4] );
238
239 void setEuler( double phi, double theta, double psi );
240
241 void setSUx( double the_sux ) { sux = the_sux; }
242 void setSUy( double the_suy ) { suy = the_suy; }
243 void setSUz( double the_suz ) { suz = the_suz; }
244
245 void setJx( double the_jx ) { jx = the_jx; }
246 void setJy( double the_jy ) { jy = the_jy; }
247 void setJz( double the_jz ) { jz = the_jz; }
248
249 void addTx( double the_tx ) { trq[offsetX] += the_tx;}
250 void addTy( double the_ty ) { trq[offsetY] += the_ty;}
251 void addTz( double the_tz ) { trq[offsetZ] += the_tz;}
252
253 void zeroForces() {
254 frc[offsetX] = 0.0;
255 frc[offsetY] = 0.0;
256 frc[offsetZ] = 0.0;
257
258 trq[offsetX] = 0.0;
259 trq[offsetY] = 0.0;
260 trq[offsetZ] = 0.0;
261 }
262
263 double getAxx( void ) { return Amat[Axx]; }
264 double getAxy( void ) { return Amat[Axy]; }
265 double getAxz( void ) { return Amat[Axz]; }
266
267 double getAyx( void ) { return Amat[Ayx]; }
268 double getAyy( void ) { return Amat[Ayy]; }
269 double getAyz( void ) { return Amat[Ayz]; }
270
271 double getAzx( void ) { return Amat[Azx]; }
272 double getAzy( void ) { return Amat[Azy]; }
273 double getAzz( void ) { return Amat[Azz]; }
274
275 void getA( double the_A[3][3] ); // get the full rotation matrix
276
277 double getSUx( void ) { return sux; }
278 double getSUy( void ) { return suy; }
279 double getSUz( void ) { return suz; }
280
281 void getU( double the_u[3] ); // get the unit vetor
282 void getQ( double the_q[4] ); // get the quanternions
283
284 double getJx( void ) { return jx; }
285 double getJy( void ) { return jy; }
286 double getJz( void ) { return jz; }
287
288 double getTx( void ) { return trq[offsetX];}
289 double getTy( void ) { return trq[offsetY]; }
290 double getTz( void ) { return trq[offsetZ]; }
291
292 double getIxx( void ) { return Ixx; }
293 double getIxy( void ) { return Ixy; }
294 double getIxz( void ) { return Ixz; }
295
296 double getIyx( void ) { return Iyx; }
297 double getIyy( void ) { return Iyy; }
298 double getIyz( void ) { return Iyz; }
299
300 double getIzx( void ) { return Izx; }
301 double getIzy( void ) { return Izy; }
302 double getIzz( void ) { return Izz; }
303
304 double getMu( void ) { return mu[index]; }
305 void setMu( double the_mu ) { mu[index] = the_mu; }
306
307 void lab2Body( double r[3] );
308 void body2Lab( double r[3] );
309
310 private:
311 int dIndex;
312
313 double sux, suy, suz; // the standard unit vector ( body fixed )
314 double jx, jy, jz; // the angular momentum vector ( body fixed )
315
316 double Ixx, Ixy, Ixz; // the inertial tensor matrix ( body fixed )
317 double Iyx, Iyy, Iyz;
318 double Izx, Izy, Izz;
319
320 int ssdIdentity; // boolean of whether atom is ssd
321
322 };
323
324 #endif