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 |
|
} |
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 c_x;} |
33 |
< |
double getY() const {return c_y;} |
34 |
< |
double getZ() const {return c_z;} |
35 |
< |
void setX(double x) {c_x = x;} |
36 |
< |
void setY(double y) {c_y = y;} |
37 |
< |
void setZ(double z) {c_z = z;} |
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 c_vx;} |
40 |
< |
double get_vy() const {return c_vy;} |
41 |
< |
double get_vz() const {return c_vz;} |
42 |
< |
void set_vx(double vx) {c_vx = vx;} |
43 |
< |
void set_vy(double vy) {c_vy = vy;} |
44 |
< |
void set_vz(double vz) {c_vz = vz;} |
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 c_Fx;} |
47 |
< |
double getFy() const {return c_Fy;} |
48 |
< |
double getFz() const {return c_Fz;} |
49 |
< |
void addFx(double add) {c_Fx += add;} |
50 |
< |
void addFy(double add) {c_Fy += add;} |
51 |
< |
void addFz(double add) {c_Fz += add;} |
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;} |
63 |
|
double getCovalent() const {return c_covalent;} |
64 |
|
void setCovalent(double covalent) {c_covalent = covalent;} |
65 |
|
|
66 |
< |
int getIndex() const {return c_index;} |
67 |
< |
void setIndex(int index) {c_index = index;} |
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);} |
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: |
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; |
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 c_index; /* set the atom's index */ |
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 |
|
|
108 |
|
|
109 |
|
}; |
110 |
|
|
111 |
+ |
|
112 |
+ |
|
113 |
|
class GeneralAtom : public Atom{ |
114 |
|
|
115 |
|
public: |
116 |
< |
GeneralAtom(){} |
116 |
> |
GeneralAtom(int theIndex): Atom(theIndex){} |
117 |
|
virtual ~GeneralAtom(){} |
118 |
|
|
119 |
|
int isDirectional( void ){ return 0; } |
120 |
|
void zeroForces() { |
121 |
< |
c_Fx = 0.0; c_Fy = 0.0; c_Fz = 0.0; |
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() { ssdIdentity = 0; } |
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; } |
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 ) { tx += the_tx;} |
165 |
< |
void addTy( double the_ty ) { ty += the_ty;} |
166 |
< |
void addTz( double the_tz ) { tz += the_tz;} |
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 |
< |
c_Fx = 0.0; c_Fy = 0.0; c_Fz = 0.0; |
172 |
< |
tx = 0.0; ty = 0.0; tz = 0.0; |
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; } |
202 |
|
double getJy( void ) { return jy; } |
203 |
|
double getJz( void ) { return jz; } |
204 |
|
|
205 |
< |
double getTx( void ) { return tx; } |
206 |
< |
double getTy( void ) { return ty; } |
207 |
< |
double getTz( void ) { return tz; } |
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; } |
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 ) |
205 |
< |
double tx, ty, tz; // the torque vector ( space fixed ) |
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 ) |
236 |
> |
double Ixx, Ixy, Ixz; // the inertial tensor matrix ( body fixed ) |
237 |
|
double Iyx, Iyy, Iyz; |
238 |
|
double Izx, Izy, Izz; |
239 |
|
|