ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE_old/src/mdtools/libmdCode/Atom.hpp
Revision: 348
Committed: Fri Mar 14 21:33:10 2003 UTC (21 years, 4 months ago) by mmeineke
File size: 8710 byte(s)
Log Message:
mostly compiles. interface twixt c and fortran is broken. (c needs to be brought up to date with fortran.)

File Contents

# Content
1 #ifndef _ATOM_H_
2 #define _ATOM_H_
3
4 #include <cstring>
5 #include <cstdlib>
6 #include <iostream>
7
8 class Atom{
9 public:
10 Atom(int theIndex) {
11 c_n_hyd = 0;
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
92 double getX() const {return pos[offsetX];}
93 double getY() const {return pos[offsetY];}
94 double getZ() const {return pos[offsetZ];}
95 void setX(double x) {pos[offsetX] = x;}
96 void setY(double y) {pos[offsetY] = y;}
97 void setZ(double z) {pos[offsetZ] = z;}
98
99 double get_vx() const {return vel[offsetX];}
100 double get_vy() const {return vel[offsetY];}
101 double get_vz() const {return vel[offsetZ];}
102 void set_vx(double vx) {vel[offsetX] = vx;}
103 void set_vy(double vy) {vel[offsetY] = vy;}
104 void set_vz(double vz) {vel[offsetZ] = vz;}
105
106 double getFx() const {return frc[offsetX];}
107 double getFy() const {return frc[offsetY];}
108 double getFz() const {return frc[offsetZ];}
109 void addFx(double add) {frc[offsetX] += add;}
110 void addFy(double add) {frc[offsetY] += add;}
111 void addFz(double add) {frc[offsetZ] += add;}
112 virtual void zeroForces() = 0;
113
114 double getMass() const {return c_mass;}
115 void setMass(double mass) {c_mass = mass;}
116
117 double getSigma() const {return c_sigma;}
118 void setSigma(double sigma) {c_sigma = sigma;}
119
120 double getEpslon() const {return c_epslon;}
121 void setEpslon(double epslon) {c_epslon = epslon;}
122
123 double getCovalent() const {return c_covalent;}
124 void setCovalent(double covalent) {c_covalent = covalent;}
125
126 int getIndex() const {return index;}
127 void setIndex(int theIndex) {
128 index = theIndex;
129 offset = index*3;
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;}
148 void setType(char * name) {strcpy(c_name,name);}
149
150 int getIdent( void ) { return ident; }
151 void setIdent( int info ) { ident = info; }
152
153 #ifdef IS_MPI
154 int getGlobalIndex( void ) { return myGlobalIndex; }
155 void setGlobalIndex( int info ) { myGlobalIndex = info; }
156 #endif // is_mpi
157
158 void set_n_hydrogens( int n_h ) {c_n_hyd = n_h;}
159 int get_n_hydrogens() const {return c_n_hyd;}
160
161 void setHasDipole( int value ) { has_dipole = value; }
162 int hasDipole( void ) { return has_dipole; }
163
164 void setLJ( void ) { is_LJ = 1; is_VDW = 0; }
165 int isLJ( void ) { return is_LJ; }
166
167 void seVDW( void ) { is_VDW = 1; is_LJ = 0; }
168 int isVDW( void ) { return is_VDW; }
169
170 virtual int isDirectional( void ) = 0;
171
172 static double* pos; // the position array
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
182 double c_mass; /* the mass of the atom in amu */
183 double c_sigma; /* the sigma parameter for van der walls interactions */
184 double c_epslon; /* the esplon parameter for VDW interactions */
185 double c_covalent; // The covalent radius of the atom.
186
187 int index; /* set the atom's index */
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
198 int c_n_hyd; // the number of hydrogens bonded to the atom
199
200 int has_dipole; // dipole boolean
201 int is_VDW; // VDW boolean
202 int is_LJ; // LJ boolean
203
204 #ifdef IS_MPI
205 int myGlobalIndex;
206 #endif
207
208 };
209
210
211
212 class GeneralAtom : public Atom{
213
214 public:
215 GeneralAtom(int theIndex): Atom(theIndex){}
216 virtual ~GeneralAtom(){}
217
218 int isDirectional( void ){ return 0; }
219 void zeroForces() {
220 frc[offsetX] = 0.0;
221 frc[offsetY] = 0.0;
222 frc[offsetZ] = 0.0;
223 }
224 };
225
226 class DirectionalAtom : public Atom {
227
228 public:
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
238 int isDirectional(void) { return 1; }
239
240 void setSSD( int value) { ssdIdentity = value; }
241 int isSSD(void) {return ssdIdentity; }
242
243 void setA( double the_A[3][3] );
244
245 void setI( double the_I[3][3] );
246
247 void setQ( double the_q[4] );
248
249 void setEuler( double phi, double theta, double psi );
250
251 void setSUx( double the_sux ) { sux = the_sux; }
252 void setSUy( double the_suy ) { suy = the_suy; }
253 void setSUz( double the_suz ) { suz = the_suz; }
254
255 void setJx( double the_jx ) { jx = the_jx; }
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;}
260 void addTy( double the_ty ) { trq[offsetY] += the_ty;}
261 void addTz( double the_tz ) { trq[offsetZ] += the_tz;}
262
263 void zeroForces() {
264 frc[offsetX] = 0.0;
265 frc[offsetY] = 0.0;
266 frc[offsetZ] = 0.0;
267
268 trq[offsetX] = 0.0;
269 trq[offsetY] = 0.0;
270 trq[offsetZ] = 0.0;
271 }
272
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 Amat[Ayx]; }
278 double getAyy( void ) { return Amat[Ayy]; }
279 double getAyz( void ) { return Amat[Ayz]; }
280
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
287 double getSUx( void ) { return sux; }
288 double getSUy( void ) { return suy; }
289 double getSUz( void ) { return suz; }
290
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; }
295 double getJy( void ) { return jy; }
296 double getJz( void ) { return jz; }
297
298 double getTx( void ) { return trq[offsetX];}
299 double getTy( void ) { return trq[offsetY]; }
300 double getTz( void ) { return trq[offsetZ]; }
301
302 double getIxx( void ) { return Ixx; }
303 double getIxy( void ) { return Ixy; }
304 double getIxz( void ) { return Ixz; }
305
306 double getIyx( void ) { return Iyx; }
307 double getIyy( void ) { return Iyy; }
308 double getIyz( void ) { return Iyz; }
309
310 double getIzx( void ) { return Izx; }
311 double getIzy( void ) { return Izy; }
312 double getIzz( void ) { return Izz; }
313
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
324 double sux, suy, suz; // the standard unit vector ( body fixed )
325 double jx, jy, jz; // the angular momentum vector ( body fixed )
326
327 double Ixx, Ixy, Ixz; // the inertial tensor matrix ( body fixed )
328 double Iyx, Iyy, Iyz;
329 double Izx, Izy, Izz;
330
331 int ssdIdentity; // boolean of whether atom is ssd
332
333 };
334
335 #endif