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