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