ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/headers/Atom.hpp
Revision: 253
Committed: Thu Jan 30 15:20:21 2003 UTC (21 years, 5 months ago) by chuckv
File size: 7446 byte(s)
Log Message:
Added a generic util code directory and moved Linux_ifc_machdep to it.
MPI changes to compile MPI modules.

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