1 |
|
#ifndef _ATOM_H_ |
2 |
|
#define _ATOM_H_ |
3 |
|
|
4 |
< |
#include <cstring> |
5 |
< |
#include <cstdlib> |
4 |
> |
#include <string.h> |
5 |
> |
#include <stdlib.h> |
6 |
|
#include <iostream> |
7 |
|
|
8 |
< |
class Atom{ |
8 |
> |
#include "SimState.hpp" |
9 |
> |
#include "StuntDouble.hpp" |
10 |
> |
#include "BaseVisitor.hpp" |
11 |
> |
|
12 |
> |
class Atom : public StuntDouble { |
13 |
|
public: |
14 |
|
|
15 |
< |
Atom(int theIndex); |
15 |
> |
Atom(int theIndex, SimState* theConfig ); |
16 |
|
virtual ~Atom() {} |
17 |
|
|
18 |
< |
static double* pos; // the position array |
15 |
< |
static double* vel; // the velocity array |
16 |
< |
static double* frc; // the forc array |
17 |
< |
static double* trq; // the torque vector ( space fixed ) |
18 |
< |
static double* Amat; // the rotation matrix |
19 |
< |
static double* mu; // the dipole moment array |
20 |
< |
static double* ul; // the lab frame unit directional vector |
21 |
< |
static int nElements; |
18 |
> |
virtual void setCoords(void); |
19 |
|
|
23 |
– |
static void createArrays (int the_nElements); |
24 |
– |
static void destroyArrays(void); |
25 |
– |
void addAtoms(int nAdded, double* Apos, double* Avel, double* Afrc, |
26 |
– |
double* Atrq, double* AAmat, double* Amu, |
27 |
– |
double* Aul); |
28 |
– |
void deleteAtom(int theIndex); |
29 |
– |
void deleteRange(int startIndex, int stopIndex); |
30 |
– |
|
31 |
– |
static double* getPosArray( void ) { return pos; } |
32 |
– |
static double* getVelArray( void ) { return vel; } |
33 |
– |
static double* getFrcArray( void ) { return frc; } |
34 |
– |
static double* getTrqArray( void ) { return trq; } |
35 |
– |
static double* getAmatArray( void ) { return Amat; } |
36 |
– |
static double* getMuArray( void ) { return mu; } |
37 |
– |
static double* getUlArray( void ) { return ul; } |
38 |
– |
|
20 |
|
void getPos( double theP[3] ); |
21 |
|
void setPos( double theP[3] ); |
22 |
|
|
42 |
– |
double getX() const {return pos[offsetX];} |
43 |
– |
double getY() const {return pos[offsetY];} |
44 |
– |
double getZ() const {return pos[offsetZ];} |
45 |
– |
void setX(double x) {pos[offsetX] = x;} |
46 |
– |
void setY(double y) {pos[offsetY] = y;} |
47 |
– |
void setZ(double z) {pos[offsetZ] = z;} |
48 |
– |
|
23 |
|
void getVel( double theV[3] ); |
24 |
|
void setVel( double theV[3] ); |
25 |
|
|
52 |
– |
double get_vx() const {return vel[offsetX];} |
53 |
– |
double get_vy() const {return vel[offsetY];} |
54 |
– |
double get_vz() const {return vel[offsetZ];} |
55 |
– |
void set_vx(double vx) {vel[offsetX] = vx;} |
56 |
– |
void set_vy(double vy) {vel[offsetY] = vy;} |
57 |
– |
void set_vz(double vz) {vel[offsetZ] = vz;} |
58 |
– |
|
59 |
– |
|
26 |
|
void getFrc( double theF[3] ); |
27 |
|
void addFrc( double theF[3] ); |
28 |
|
|
29 |
< |
double getFx() const {return frc[offsetX];} |
64 |
< |
double getFy() const {return frc[offsetY];} |
65 |
< |
double getFz() const {return frc[offsetZ];} |
66 |
< |
void addFx(double add) {frc[offsetX] += add;} |
67 |
< |
void addFy(double add) {frc[offsetY] += add;} |
68 |
< |
void addFz(double add) {frc[offsetZ] += add;} |
69 |
< |
virtual void zeroForces() = 0; |
29 |
> |
virtual void zeroForces(); |
30 |
|
|
31 |
< |
double getMass() const {return c_mass;} |
31 |
> |
double getMass() {return c_mass;} |
32 |
|
void setMass(double mass) {c_mass = mass;} |
33 |
|
|
74 |
– |
double getSigma() const {return c_sigma;} |
75 |
– |
void setSigma(double sigma) {c_sigma = sigma;} |
76 |
– |
|
77 |
– |
double getEpslon() const {return c_epslon;} |
78 |
– |
void setEpslon(double epslon) {c_epslon = epslon;} |
79 |
– |
|
80 |
– |
double getCovalent() const {return c_covalent;} |
81 |
– |
void setCovalent(double covalent) {c_covalent = covalent;} |
82 |
– |
|
34 |
|
int getIndex() const {return index;} |
35 |
|
void setIndex(int theIndex); |
36 |
+ |
|
37 |
|
char *getType() {return c_name;} |
38 |
|
void setType(char * name) {strcpy(c_name,name);} |
39 |
|
|
45 |
|
void setGlobalIndex( int info ) { myGlobalIndex = info; } |
46 |
|
#endif // is_mpi |
47 |
|
|
96 |
– |
void set_n_hydrogens( int n_h ) {c_n_hyd = n_h;} |
97 |
– |
int get_n_hydrogens() const {return c_n_hyd;} |
98 |
– |
|
48 |
|
void setHasDipole( int value ) { has_dipole = value; } |
49 |
|
int hasDipole( void ) { return has_dipole; } |
50 |
|
|
51 |
< |
void setLJ( void ) { is_LJ = 1; is_VDW = 0; } |
52 |
< |
int isLJ( void ) { return is_LJ; } |
51 |
> |
void setHasCharge(int value) {has_charge = value;} |
52 |
> |
int hasCharge(void) {return has_charge;} |
53 |
|
|
105 |
– |
void seVDW( void ) { is_VDW = 1; is_LJ = 0; } |
106 |
– |
int isVDW( void ) { return is_VDW; } |
54 |
|
|
55 |
< |
void setEAM( void ) { is_EAM = 1; } |
56 |
< |
int isEAM( void ) { return is_EAM; } |
110 |
< |
|
111 |
< |
virtual int isDirectional( void ) = 0; |
112 |
< |
|
113 |
< |
|
55 |
> |
virtual void accept(BaseVisitor* v) {v->visit(this);} |
56 |
> |
|
57 |
|
protected: |
58 |
|
|
59 |
+ |
SimState* myConfig; |
60 |
+ |
|
61 |
+ |
double* pos; // the position array |
62 |
+ |
double* vel; // the velocity array |
63 |
+ |
double* frc; // the forc array |
64 |
+ |
double* trq; // the torque vector ( space fixed ) |
65 |
+ |
double* Amat; // the rotation matrix |
66 |
+ |
double* mu; // the array of dipole moments |
67 |
+ |
double* ul; // the lab frame unit directional vector |
68 |
+ |
|
69 |
|
double c_mass; /* the mass of the atom in amu */ |
117 |
– |
double c_sigma; /* the sigma parameter for van der walls interactions */ |
118 |
– |
double c_epslon; /* the esplon parameter for VDW interactions */ |
119 |
– |
double c_covalent; // The covalent radius of the atom. |
70 |
|
|
71 |
|
int index; /* set the atom's index */ |
72 |
|
int offset; // the atom's offset in the storage array |
78 |
|
|
79 |
|
char c_name[100]; /* it's name */ |
80 |
|
int ident; // it's unique numeric identity. |
131 |
– |
|
132 |
– |
int c_n_hyd; // the number of hydrogens bonded to the atom |
81 |
|
|
82 |
|
int has_dipole; // dipole boolean |
83 |
< |
int is_VDW; // VDW boolean |
136 |
< |
int is_LJ; // LJ boolean |
137 |
< |
int is_EAM; //EAM boolean |
83 |
> |
int has_charge; // charge boolean |
84 |
|
|
85 |
+ |
bool hasCoords; |
86 |
+ |
|
87 |
|
#ifdef IS_MPI |
88 |
|
int myGlobalIndex; |
89 |
|
#endif |
90 |
|
|
91 |
|
}; |
92 |
|
|
145 |
– |
class GeneralAtom : public Atom{ |
146 |
– |
|
147 |
– |
public: |
148 |
– |
GeneralAtom(int theIndex): Atom(theIndex){} |
149 |
– |
virtual ~GeneralAtom(){} |
150 |
– |
|
151 |
– |
int isDirectional( void ){ return 0; } |
152 |
– |
void zeroForces() { |
153 |
– |
frc[offsetX] = 0.0; |
154 |
– |
frc[offsetY] = 0.0; |
155 |
– |
frc[offsetZ] = 0.0; |
156 |
– |
} |
157 |
– |
}; |
158 |
– |
|
159 |
– |
class DirectionalAtom : public Atom { |
160 |
– |
|
161 |
– |
public: |
162 |
– |
DirectionalAtom(int theIndex) : Atom(theIndex) |
163 |
– |
{ |
164 |
– |
ssdIdentity = 0; |
165 |
– |
sux = 0.0; |
166 |
– |
suy = 0.0; |
167 |
– |
suz = 0.0; |
168 |
– |
} |
169 |
– |
virtual ~DirectionalAtom() {} |
170 |
– |
|
171 |
– |
void printAmatIndex( void ); |
172 |
– |
|
173 |
– |
int isDirectional(void) { return 1; } |
174 |
– |
|
175 |
– |
void setSSD( int value) { ssdIdentity = value; } |
176 |
– |
int isSSD(void) {return ssdIdentity; } |
177 |
– |
|
178 |
– |
|
179 |
– |
void setEuler( double phi, double theta, double psi ); |
180 |
– |
|
181 |
– |
double getSUx( void ) { return sux; } |
182 |
– |
double getSUy( void ) { return suy; } |
183 |
– |
double getSUz( void ) { return suz; } |
184 |
– |
|
185 |
– |
void setSUx( double the_sux ) { sux = the_sux; } |
186 |
– |
void setSUy( double the_suy ) { suy = the_suy; } |
187 |
– |
void setSUz( double the_suz ) { suz = the_suz; } |
188 |
– |
|
189 |
– |
void zeroForces() { |
190 |
– |
frc[offsetX] = 0.0; |
191 |
– |
frc[offsetY] = 0.0; |
192 |
– |
frc[offsetZ] = 0.0; |
193 |
– |
|
194 |
– |
trq[offsetX] = 0.0; |
195 |
– |
trq[offsetY] = 0.0; |
196 |
– |
trq[offsetZ] = 0.0; |
197 |
– |
} |
198 |
– |
|
199 |
– |
void getA( double the_A[3][3] ); // get the full rotation matrix |
200 |
– |
void setA( double the_A[3][3] ); |
201 |
– |
|
202 |
– |
void getU( double the_u[3] ); // get the unit vetor |
203 |
– |
void updateU( void ); |
204 |
– |
|
205 |
– |
void getQ( double the_q[4] ); // get the quanternions |
206 |
– |
void setQ( double the_q[4] ); |
207 |
– |
|
208 |
– |
void getJ( double theJ[3] ); |
209 |
– |
void setJ( double theJ[3] ); |
210 |
– |
|
211 |
– |
double getJx( void ) { return jx; } |
212 |
– |
double getJy( void ) { return jy; } |
213 |
– |
double getJz( void ) { return jz; } |
214 |
– |
|
215 |
– |
void setJx( double the_jx ) { jx = the_jx; } |
216 |
– |
void setJy( double the_jy ) { jy = the_jy; } |
217 |
– |
void setJz( double the_jz ) { jz = the_jz; } |
218 |
– |
|
219 |
– |
void getTrq( double theT[3] ); |
220 |
– |
void addTrq( double theT[3] ); |
221 |
– |
|
222 |
– |
// double getTx( void ) { return trq[offsetX];} |
223 |
– |
// double getTy( void ) { return trq[offsetY]; } |
224 |
– |
// double getTz( void ) { return trq[offsetZ]; } |
225 |
– |
|
226 |
– |
void addTx( double the_tx ) { trq[offsetX] += the_tx;} |
227 |
– |
void addTy( double the_ty ) { trq[offsetY] += the_ty;} |
228 |
– |
void addTz( double the_tz ) { trq[offsetZ] += the_tz;} |
229 |
– |
|
230 |
– |
void setI( double the_I[3][3] ); |
231 |
– |
void getI( double the_I[3][3] ); |
232 |
– |
|
233 |
– |
double getIxx( void ) { return Ixx; } |
234 |
– |
double getIxy( void ) { return Ixy; } |
235 |
– |
double getIxz( void ) { return Ixz; } |
236 |
– |
|
237 |
– |
double getIyx( void ) { return Iyx; } |
238 |
– |
double getIyy( void ) { return Iyy; } |
239 |
– |
double getIyz( void ) { return Iyz; } |
240 |
– |
|
241 |
– |
double getIzx( void ) { return Izx; } |
242 |
– |
double getIzy( void ) { return Izy; } |
243 |
– |
double getIzz( void ) { return Izz; } |
244 |
– |
|
245 |
– |
|
246 |
– |
double getMu( void ) { return mu[index]; } |
247 |
– |
void setMu( double the_mu ) { mu[index] = the_mu; } |
248 |
– |
|
249 |
– |
void lab2Body( double r[3] ); |
250 |
– |
void body2Lab( double r[3] ); |
251 |
– |
|
252 |
– |
|
253 |
– |
private: |
254 |
– |
int dIndex; |
255 |
– |
|
256 |
– |
double sux, suy, suz; // the standard unit vector ( body fixed ) |
257 |
– |
double jx, jy, jz; // the angular momentum vector ( body fixed ) |
258 |
– |
|
259 |
– |
double Ixx, Ixy, Ixz; // the inertial tensor matrix ( body fixed ) |
260 |
– |
double Iyx, Iyy, Iyz; |
261 |
– |
double Izx, Izy, Izz; |
262 |
– |
|
263 |
– |
int ssdIdentity; // boolean of whether atom is ssd |
264 |
– |
|
265 |
– |
}; |
266 |
– |
|
93 |
|
#endif |