6 |
|
|
7 |
|
class Atom{ |
8 |
|
public: |
9 |
< |
Atom() { |
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 |
< |
~Atom() {} |
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 c_x;} |
36 |
< |
double getY() const {return c_y;} |
37 |
< |
double getZ() const {return c_z;} |
38 |
< |
void setX(double x) {c_x = x;} |
39 |
< |
void setY(double y) {c_y = y;} |
40 |
< |
void setZ(double z) {c_z = z;} |
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 c_vx;} |
43 |
< |
double get_vy() const {return c_vy;} |
44 |
< |
double get_vz() const {return c_vz;} |
45 |
< |
void set_vx(double vx) {c_vx = vx;} |
46 |
< |
void set_vy(double vy) {c_vy = vy;} |
47 |
< |
void set_vz(double vz) {c_vz = vz;} |
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 c_Fx;} |
50 |
< |
double getFy() const {return c_Fy;} |
51 |
< |
double getFz() const {return c_Fz;} |
52 |
< |
void addFx(double add) {c_Fx += add;} |
53 |
< |
void addFy(double add) {c_Fy += add;} |
54 |
< |
void addFz(double add) {c_Fz += add;} |
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;} |
66 |
|
double getCovalent() const {return c_covalent;} |
67 |
|
void setCovalent(double covalent) {c_covalent = covalent;} |
68 |
|
|
69 |
< |
int getIndex() const {return c_index;} |
70 |
< |
void setIndex(int index) {c_index = index;} |
71 |
< |
|
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 |
|
|
82 |
|
int get_n_hydrogens() const {return c_n_hyd;} |
83 |
|
|
84 |
|
void setHasDipole( int value ) { has_dipole = value; } |
85 |
< |
short int hasDipole( void ) { return has_dipole; } |
85 |
> |
int hasDipole( void ) { return has_dipole; } |
86 |
|
|
87 |
|
void setLJ( void ) { is_LJ = 1; is_VDW = 0; } |
88 |
< |
short int isLJ( void ) { return is_LJ; } |
88 |
> |
int isLJ( void ) { return is_LJ; } |
89 |
|
|
90 |
|
void seVDW( void ) { is_VDW = 1; is_LJ = 0; } |
91 |
< |
short int isVDW( void ) { return is_VDW; } |
91 |
> |
int isVDW( void ) { return is_VDW; } |
92 |
|
|
93 |
|
virtual int isDirectional( void ) = 0; |
94 |
|
|
95 |
+ |
static double* pos; // the position array |
96 |
+ |
static double* vel; // the velocity array |
97 |
+ |
static double* frc; // the forc array |
98 |
+ |
static double* trq; // the torque vector ( space fixed ) |
99 |
+ |
|
100 |
|
protected: |
72 |
– |
double c_x; /*the atom's position */ |
73 |
– |
double c_y; |
74 |
– |
double c_z; |
75 |
– |
|
76 |
– |
double c_vx; /*the atom's velocity */ |
77 |
– |
double c_vy; |
78 |
– |
double c_vz; |
79 |
– |
|
80 |
– |
double c_Fx; /* the atom's forces */ |
81 |
– |
double c_Fy; |
82 |
– |
double c_Fz; |
101 |
|
|
102 |
|
double c_mass; /* the mass of the atom in amu */ |
103 |
|
double c_sigma; /* the sigma parameter for van der walls interactions */ |
104 |
|
double c_epslon; /* the esplon parameter for VDW interactions */ |
105 |
|
double c_covalent; // The covalent radius of the atom. |
106 |
|
|
107 |
< |
int c_index; /* set the atom's index */ |
107 |
> |
int index; /* set the atom's index */ |
108 |
> |
int offset; // the atom's offset in the storage array |
109 |
|
|
110 |
|
char c_name[100]; /* it's name */ |
111 |
|
|
112 |
|
int c_n_hyd; // the number of hydrogens bonded to the atom |
113 |
|
|
114 |
< |
short int has_dipole; // dipole boolean |
115 |
< |
short int is_VDW; // VDW boolean |
116 |
< |
short int is_LJ; // LJ boolean |
114 |
> |
int has_dipole; // dipole boolean |
115 |
> |
int is_VDW; // VDW boolean |
116 |
> |
int is_LJ; // LJ boolean |
117 |
|
|
118 |
|
}; |
119 |
|
|
120 |
+ |
|
121 |
+ |
|
122 |
|
class GeneralAtom : public Atom{ |
123 |
|
|
124 |
|
public: |
125 |
< |
GeneralAtom(){} |
126 |
< |
~GeneralAtom(){} |
125 |
> |
GeneralAtom(int theIndex): Atom(theIndex){} |
126 |
> |
virtual ~GeneralAtom(){} |
127 |
|
|
128 |
|
int isDirectional( void ){ return 0; } |
129 |
|
void zeroForces() { |
130 |
< |
c_Fx = 0.0; c_Fy = 0.0; c_Fz = 0.0; |
130 |
> |
frc[offsetX] = 0.0; |
131 |
> |
frc[offsetY] = 0.0; |
132 |
> |
frc[offsetZ] = 0.0; |
133 |
|
} |
134 |
|
}; |
135 |
|
|
136 |
|
class DirectionalAtom : public Atom { |
137 |
|
|
138 |
|
public: |
139 |
< |
DirectionalAtom() { ssdIdentity = 0; } |
140 |
< |
~DirectionalAtom() {} |
139 |
> |
DirectionalAtom(int theIndex) : Atom(theIndex) |
140 |
> |
{ |
141 |
> |
ssdIdentity = 0; |
142 |
> |
} |
143 |
> |
virtual ~DirectionalAtom() {} |
144 |
|
|
145 |
+ |
static void createDArrays(int nElements){ |
146 |
+ |
trq = new double[nElements*3]; |
147 |
+ |
} |
148 |
+ |
static void destroyDArrays(void){ |
149 |
+ |
delete[] trq; |
150 |
+ |
} |
151 |
+ |
|
152 |
|
int isDirectional(void) { return 1; } |
153 |
|
|
154 |
|
void setSSD( int value) { ssdIdentity = value; } |
170 |
|
void setJy( double the_jy ) { jy = the_jy; } |
171 |
|
void setJz( double the_jz ) { jz = the_jz; } |
172 |
|
|
173 |
< |
void addTx( double the_tx ) { tx += the_tx;} |
174 |
< |
void addTy( double the_ty ) { ty += the_ty;} |
175 |
< |
void addTz( double the_tz ) { tz += the_tz;} |
173 |
> |
void addTx( double the_tx ) { trq[offsetX] += the_tx;} |
174 |
> |
void addTy( double the_ty ) { trq[offsetY] += the_ty;} |
175 |
> |
void addTz( double the_tz ) { trq[offsetZ] += the_tz;} |
176 |
|
|
177 |
|
void setMu( double the_mu ) { mu = the_mu; } |
178 |
|
|
179 |
|
void zeroForces() { |
180 |
< |
c_Fx = 0.0; c_Fy = 0.0; c_Fz = 0.0; |
181 |
< |
tx = 0.0; ty = 0.0; tz = 0.0; |
180 |
> |
frc[offsetX] = 0.0; |
181 |
> |
frc[offsetY] = 0.0; |
182 |
> |
frc[offsetZ] = 0.0; |
183 |
> |
|
184 |
> |
trq[offsetX] = 0.0; |
185 |
> |
trq[offsetY] = 0.0; |
186 |
> |
trq[offsetZ] = 0.0; |
187 |
|
} |
188 |
|
|
189 |
|
double getAxx( void ) { return Axx; } |
198 |
|
double getAzy( void ) { return Azy; } |
199 |
|
double getAzz( void ) { return Azz; } |
200 |
|
|
201 |
+ |
void getA( double the_A[3][3] ); // get the full rotation matrix |
202 |
+ |
|
203 |
|
double getSUx( void ) { return sux; } |
204 |
|
double getSUy( void ) { return suy; } |
205 |
|
double getSUz( void ) { return suz; } |
211 |
|
double getJy( void ) { return jy; } |
212 |
|
double getJz( void ) { return jz; } |
213 |
|
|
214 |
< |
double getTx( void ) { return tx; } |
215 |
< |
double getTy( void ) { return ty; } |
216 |
< |
double getTz( void ) { return tz; } |
214 |
> |
double getTx( void ) { return trq[offsetX];} |
215 |
> |
double getTy( void ) { return trq[offsetY]; } |
216 |
> |
double getTz( void ) { return trq[offsetZ]; } |
217 |
|
|
218 |
|
double getIxx( void ) { return Ixx; } |
219 |
|
double getIxy( void ) { return Ixy; } |
233 |
|
void body2Lab( double r[3] ); |
234 |
|
|
235 |
|
private: |
236 |
+ |
int dIndex; |
237 |
|
|
238 |
< |
double Axx, Axy, Axz;; // the rotational matrix |
238 |
> |
double Axx, Axy, Axz; // the rotational matrix |
239 |
|
double Ayx, Ayy, Ayz; |
240 |
|
double Azx, Azy, Azz; |
241 |
|
|
242 |
< |
double sux, suy, suz; // the standard unit vector ( body fixed ) |
243 |
< |
double jx, jy, jz; // the angular momentum vector ( body fixed ) |
203 |
< |
double tx, ty, tz; // the torque vector ( space fixed ) |
242 |
> |
double sux, suy, suz; // the standard unit vector ( body fixed ) |
243 |
> |
double jx, jy, jz; // the angular momentum vector ( body fixed ) |
244 |
|
|
245 |
< |
double Ixx, Ixy, Ixz; // the inertial tensor matrix ( body fixed ) |
245 |
> |
double Ixx, Ixy, Ixz; // the inertial tensor matrix ( body fixed ) |
246 |
|
double Iyx, Iyy, Iyz; |
247 |
|
double Izx, Izy, Izz; |
248 |
|
|