ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/headers/Atom.hpp
Revision: 143
Committed: Thu Oct 17 21:58:55 2002 UTC (21 years, 8 months ago) by mmeineke
File size: 6665 byte(s)
Log Message:

Changing internal storage of positions, torqes, forces, velocities, etc.

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 protected:
86
87 static double* pos; // the position array
88 static double* vel; // the velocity array
89 static double* frc; // the forc array
90 static double* trq; // the torque vector ( space fixed )
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 class GeneralAtom : public Atom{
110
111 public:
112 GeneralAtom(int theIndex): Atom(theIndex){}
113 virtual ~GeneralAtom(){}
114
115 int isDirectional( void ){ return 0; }
116 void zeroForces() {
117 frc[3*index] = 0.0;
118 frc[3*index+1] = 0.0;
119 frc[3*index+2] = 0.0;
120 }
121 };
122
123 class DirectionalAtom : public Atom {
124
125 public:
126 DirectionalAtom(int theIndex) : Atom(theIndex)
127 {
128 ssdIdentity = 0;
129 }
130 virtual ~DirectionalAtom() {}
131
132 static void createDArrays(int nElements){
133 trq = new double[nElements*3];
134 }
135 static void destroyDArrays(void){
136 delete[] trq;
137 }
138
139 int isDirectional(void) { return 1; }
140
141 void setSSD( int value) { ssdIdentity = value; }
142 int isSSD(void) {return ssdIdentity; }
143
144 void setA( double the_A[3][3] );
145
146 void setI( double the_I[3][3] );
147
148 void setQ( double the_q[4] );
149
150 void setEuler( double phi, double theta, double psi );
151
152 void setSUx( double the_sux ) { sux = the_sux; }
153 void setSUy( double the_suy ) { suy = the_suy; }
154 void setSUz( double the_suz ) { suz = the_suz; }
155
156 void setJx( double the_jx ) { jx = the_jx; }
157 void setJy( double the_jy ) { jy = the_jy; }
158 void setJz( double the_jz ) { jz = the_jz; }
159
160 void addTx( double the_tx ) { trq[3*index] += the_tx;}
161 void addTy( double the_ty ) { trq[3*index+1] += the_ty;}
162 void addTz( double the_tz ) { trq[3*index+2] += the_tz;}
163
164 void setMu( double the_mu ) { mu = the_mu; }
165
166 void zeroForces() {
167 frc[3*index] = 0.0;
168 frc[3*index+1] = 0.0;
169 frc[3*index+2] = 0.0;
170
171 trq[3*index] = 0.0;
172 trq[3*index+1] = 0.0;
173 trq[3*index+2] = 0.0;
174 }
175
176 double getAxx( void ) { return Axx; }
177 double getAxy( void ) { return Axy; }
178 double getAxz( void ) { return Axz; }
179
180 double getAyx( void ) { return Ayx; }
181 double getAyy( void ) { return Ayy; }
182 double getAyz( void ) { return Ayz; }
183
184 double getAzx( void ) { return Azx; }
185 double getAzy( void ) { return Azy; }
186 double getAzz( void ) { return Azz; }
187
188 void getA( double the_A[3][3] ); // get the full rotation matrix
189
190 double getSUx( void ) { return sux; }
191 double getSUy( void ) { return suy; }
192 double getSUz( void ) { return suz; }
193
194 void getU( double the_u[3] ); // get the unit vector
195 void getQ( double the_q[4] ); // get the quanternions
196
197 double getJx( void ) { return jx; }
198 double getJy( void ) { return jy; }
199 double getJz( void ) { return jz; }
200
201 double getTx( void ) { return trq[3*index];}
202 double getTy( void ) { return trq[3*index+1]; }
203 double getTz( void ) { return trq[3*index+2]; }
204
205 double getIxx( void ) { return Ixx; }
206 double getIxy( void ) { return Ixy; }
207 double getIxz( void ) { return Ixz; }
208
209 double getIyx( void ) { return Iyx; }
210 double getIyy( void ) { return Iyy; }
211 double getIyz( void ) { return Iyz; }
212
213 double getIzx( void ) { return Izx; }
214 double getIzy( void ) { return Izy; }
215 double getIzz( void ) { return Izz; }
216
217 double getMu( void ) { return mu; }
218
219 void lab2Body( double r[3] );
220 void body2Lab( double r[3] );
221
222 private:
223 int dIndex;
224
225 double Axx, Axy, Axz; // the rotational matrix
226 double Ayx, Ayy, Ayz;
227 double Azx, Azy, Azz;
228
229 double sux, suy, suz; // the standard unit vector ( body fixed )
230 double jx, jy, jz; // the angular momentum vector ( body fixed )
231
232 double Ixx, Ixy, Ixz; // the inertial tensor matrix ( body fixed )
233 double Iyx, Iyy, Iyz;
234 double Izx, Izy, Izz;
235
236 double mu; // the magnitude of the dipole moment
237
238 int ssdIdentity; // boolean of whether atom is ssd
239
240 };
241
242 #endif