ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/headers/Atom.hpp
Revision: 189
Committed: Tue Nov 26 21:04:43 2002 UTC (21 years, 8 months ago) by mmeineke
File size: 6732 byte(s)
Log Message:
*** empty log message ***

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