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 |
> |
static double* getPosArray( void ) { return pos; } |
36 |
> |
static double* getVelArray( void ) { return vel; } |
37 |
> |
static double* getFrcArray( void ) { return frc; } |
38 |
> |
static double* getTrqArray( void ) { return trq; } |
39 |
|
|
17 |
– |
double getX() const {return c_x;} |
18 |
– |
double getY() const {return c_y;} |
19 |
– |
double getZ() const {return c_z;} |
20 |
– |
void setX(double x) {c_x = x;} |
21 |
– |
void setY(double y) {c_y = y;} |
22 |
– |
void setZ(double z) {c_z = z;} |
40 |
|
|
41 |
< |
double get_vx() const {return c_vx;} |
42 |
< |
double get_vy() const {return c_vy;} |
43 |
< |
double get_vz() const {return c_vz;} |
44 |
< |
void set_vx(double vx) {c_vx = vx;} |
45 |
< |
void set_vy(double vy) {c_vy = vy;} |
46 |
< |
void set_vz(double vz) {c_vz = vz;} |
41 |
> |
double getX() const {return pos[offsetX];} |
42 |
> |
double getY() const {return pos[offsetY];} |
43 |
> |
double getZ() const {return pos[offsetZ];} |
44 |
> |
void setX(double x) {pos[offsetX] = x;} |
45 |
> |
void setY(double y) {pos[offsetY] = y;} |
46 |
> |
void setZ(double z) {pos[offsetZ] = z;} |
47 |
|
|
48 |
< |
double getFx() const {return c_Fx;} |
49 |
< |
double getFy() const {return c_Fy;} |
50 |
< |
double getFz() const {return c_Fz;} |
51 |
< |
void addFx(double add) {c_Fx += add;} |
52 |
< |
void addFy(double add) {c_Fy += add;} |
53 |
< |
void addFz(double add) {c_Fz += add;} |
48 |
> |
double get_vx() const {return vel[offsetX];} |
49 |
> |
double get_vy() const {return vel[offsetY];} |
50 |
> |
double get_vz() const {return vel[offsetZ];} |
51 |
> |
void set_vx(double vx) {vel[offsetX] = vx;} |
52 |
> |
void set_vy(double vy) {vel[offsetY] = vy;} |
53 |
> |
void set_vz(double vz) {vel[offsetZ] = vz;} |
54 |
> |
|
55 |
> |
double getFx() const {return frc[offsetX];} |
56 |
> |
double getFy() const {return frc[offsetY];} |
57 |
> |
double getFz() const {return frc[offsetZ];} |
58 |
> |
void addFx(double add) {frc[offsetX] += add;} |
59 |
> |
void addFy(double add) {frc[offsetY] += add;} |
60 |
> |
void addFz(double add) {frc[offsetZ] += add;} |
61 |
|
virtual void zeroForces() = 0; |
62 |
|
|
63 |
|
double getMass() const {return c_mass;} |
72 |
|
double getCovalent() const {return c_covalent;} |
73 |
|
void setCovalent(double covalent) {c_covalent = covalent;} |
74 |
|
|
75 |
< |
int getIndex() const {return c_index;} |
76 |
< |
void setIndex(int index) {c_index = index;} |
77 |
< |
|
75 |
> |
int getIndex() const {return index;} |
76 |
> |
void setIndex(int theIndex) { |
77 |
> |
index = theIndex; |
78 |
> |
offset = index*3; |
79 |
> |
offsetX = offset; |
80 |
> |
offsetY = offset+1; |
81 |
> |
offsetZ = offset+2; |
82 |
> |
} |
83 |
> |
|
84 |
|
char *getType() {return c_name;} |
85 |
|
void setType(char * name) {strcpy(c_name,name);} |
86 |
+ |
|
87 |
+ |
int getIdent( void ) { return ident; } |
88 |
+ |
void setIdent( int info ) { ident = info; } |
89 |
|
|
90 |
|
void set_n_hydrogens( int n_h ) {c_n_hyd = n_h;} |
91 |
|
int get_n_hydrogens() const {return c_n_hyd;} |
92 |
|
|
93 |
|
void setHasDipole( int value ) { has_dipole = value; } |
94 |
< |
short int hasDipole( void ) { return has_dipole; } |
94 |
> |
int hasDipole( void ) { return has_dipole; } |
95 |
|
|
96 |
|
void setLJ( void ) { is_LJ = 1; is_VDW = 0; } |
97 |
< |
short int isLJ( void ) { return is_LJ; } |
97 |
> |
int isLJ( void ) { return is_LJ; } |
98 |
|
|
99 |
|
void seVDW( void ) { is_VDW = 1; is_LJ = 0; } |
100 |
< |
short int isVDW( void ) { return is_VDW; } |
100 |
> |
int isVDW( void ) { return is_VDW; } |
101 |
|
|
102 |
|
virtual int isDirectional( void ) = 0; |
103 |
|
|
104 |
+ |
static double* pos; // the position array |
105 |
+ |
static double* vel; // the velocity array |
106 |
+ |
static double* frc; // the forc array |
107 |
+ |
static double* trq; // the torque vector ( space fixed ) |
108 |
+ |
|
109 |
|
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; |
110 |
|
|
111 |
|
double c_mass; /* the mass of the atom in amu */ |
112 |
|
double c_sigma; /* the sigma parameter for van der walls interactions */ |
113 |
|
double c_epslon; /* the esplon parameter for VDW interactions */ |
114 |
|
double c_covalent; // The covalent radius of the atom. |
115 |
|
|
116 |
< |
int c_index; /* set the atom's index */ |
116 |
> |
int index; /* set the atom's index */ |
117 |
> |
int offset; // the atom's offset in the storage array |
118 |
> |
int offsetX, offsetY, offsetZ; |
119 |
|
|
120 |
|
char c_name[100]; /* it's name */ |
121 |
+ |
int ident; // it's unique numeric identity. |
122 |
|
|
123 |
|
int c_n_hyd; // the number of hydrogens bonded to the atom |
124 |
|
|
125 |
< |
short int has_dipole; // dipole boolean |
126 |
< |
short int is_VDW; // VDW boolean |
127 |
< |
short int is_LJ; // LJ boolean |
125 |
> |
int has_dipole; // dipole boolean |
126 |
> |
int is_VDW; // VDW boolean |
127 |
> |
int is_LJ; // LJ boolean |
128 |
|
|
129 |
|
}; |
130 |
|
|
131 |
+ |
|
132 |
+ |
|
133 |
|
class GeneralAtom : public Atom{ |
134 |
|
|
135 |
|
public: |
136 |
< |
GeneralAtom(){} |
137 |
< |
~GeneralAtom(){} |
136 |
> |
GeneralAtom(int theIndex): Atom(theIndex){} |
137 |
> |
virtual ~GeneralAtom(){} |
138 |
|
|
139 |
|
int isDirectional( void ){ return 0; } |
140 |
|
void zeroForces() { |
141 |
< |
c_Fx = 0.0; c_Fy = 0.0; c_Fz = 0.0; |
141 |
> |
frc[offsetX] = 0.0; |
142 |
> |
frc[offsetY] = 0.0; |
143 |
> |
frc[offsetZ] = 0.0; |
144 |
|
} |
145 |
|
}; |
146 |
|
|
147 |
|
class DirectionalAtom : public Atom { |
148 |
|
|
149 |
|
public: |
150 |
< |
DirectionalAtom() { ssdIdentity = 0; } |
151 |
< |
~DirectionalAtom() {} |
150 |
> |
DirectionalAtom(int theIndex) : Atom(theIndex) |
151 |
> |
{ |
152 |
> |
ssdIdentity = 0; |
153 |
> |
} |
154 |
> |
virtual ~DirectionalAtom() {} |
155 |
|
|
156 |
+ |
static void createDArrays(int nElements){ |
157 |
+ |
trq = new double[nElements*3]; |
158 |
+ |
} |
159 |
+ |
static void destroyDArrays(void){ |
160 |
+ |
delete[] trq; |
161 |
+ |
} |
162 |
+ |
|
163 |
|
int isDirectional(void) { return 1; } |
164 |
|
|
165 |
|
void setSSD( int value) { ssdIdentity = value; } |
181 |
|
void setJy( double the_jy ) { jy = the_jy; } |
182 |
|
void setJz( double the_jz ) { jz = the_jz; } |
183 |
|
|
184 |
< |
void addTx( double the_tx ) { tx += the_tx;} |
185 |
< |
void addTy( double the_ty ) { ty += the_ty;} |
186 |
< |
void addTz( double the_tz ) { tz += the_tz;} |
184 |
> |
void addTx( double the_tx ) { trq[offsetX] += the_tx;} |
185 |
> |
void addTy( double the_ty ) { trq[offsetY] += the_ty;} |
186 |
> |
void addTz( double the_tz ) { trq[offsetZ] += the_tz;} |
187 |
|
|
188 |
|
void setMu( double the_mu ) { mu = the_mu; } |
189 |
|
|
190 |
|
void zeroForces() { |
191 |
< |
c_Fx = 0.0; c_Fy = 0.0; c_Fz = 0.0; |
192 |
< |
tx = 0.0; ty = 0.0; tz = 0.0; |
191 |
> |
frc[offsetX] = 0.0; |
192 |
> |
frc[offsetY] = 0.0; |
193 |
> |
frc[offsetZ] = 0.0; |
194 |
> |
|
195 |
> |
trq[offsetX] = 0.0; |
196 |
> |
trq[offsetY] = 0.0; |
197 |
> |
trq[offsetZ] = 0.0; |
198 |
|
} |
199 |
|
|
200 |
|
double getAxx( void ) { return Axx; } |
222 |
|
double getJy( void ) { return jy; } |
223 |
|
double getJz( void ) { return jz; } |
224 |
|
|
225 |
< |
double getTx( void ) { return tx; } |
226 |
< |
double getTy( void ) { return ty; } |
227 |
< |
double getTz( void ) { return tz; } |
225 |
> |
double getTx( void ) { return trq[offsetX];} |
226 |
> |
double getTy( void ) { return trq[offsetY]; } |
227 |
> |
double getTz( void ) { return trq[offsetZ]; } |
228 |
|
|
229 |
|
double getIxx( void ) { return Ixx; } |
230 |
|
double getIxy( void ) { return Ixy; } |
244 |
|
void body2Lab( double r[3] ); |
245 |
|
|
246 |
|
private: |
247 |
+ |
int dIndex; |
248 |
|
|
249 |
< |
double Axx, Axy, Axz;; // the rotational matrix |
249 |
> |
double Axx, Axy, Axz; // the rotational matrix |
250 |
|
double Ayx, Ayy, Ayz; |
251 |
|
double Azx, Azy, Azz; |
252 |
|
|
253 |
< |
double sux, suy, suz; // the standard unit vector ( body fixed ) |
254 |
< |
double jx, jy, jz; // the angular momentum vector ( body fixed ) |
205 |
< |
double tx, ty, tz; // the torque vector ( space fixed ) |
253 |
> |
double sux, suy, suz; // the standard unit vector ( body fixed ) |
254 |
> |
double jx, jy, jz; // the angular momentum vector ( body fixed ) |
255 |
|
|
256 |
< |
double Ixx, Ixy, Ixz; // the inertial tensor matrix ( body fixed ) |
256 |
> |
double Ixx, Ixy, Ixz; // the inertial tensor matrix ( body fixed ) |
257 |
|
double Iyx, Iyy, Iyz; |
258 |
|
double Izx, Izy, Izz; |
259 |
|
|