ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/Atom.hpp
Revision: 409
Committed: Wed Mar 26 21:04:38 2003 UTC (21 years, 3 months ago) by gezelter
File size: 7436 byte(s)
Log Message:
Make Atom.cpp able to add and delete ranges of atoms

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