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 |
+ |
#include "SimState.hpp" |
9 |
+ |
|
10 |
|
class Atom{ |
11 |
|
public: |
12 |
|
|
13 |
< |
Atom(int theIndex); |
13 |
> |
Atom(int theIndex, SimState* theConfig ); |
14 |
|
virtual ~Atom() {} |
15 |
|
|
16 |
< |
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; |
16 |
> |
virtual void setCoords(void); |
17 |
|
|
18 |
< |
static void createArrays (int the_nElements); |
19 |
< |
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); |
18 |
> |
void getPos( double theP[3] ); |
19 |
> |
void setPos( double theP[3] ); |
20 |
|
|
21 |
< |
static double* getPosArray( void ) { return pos; } |
22 |
< |
static double* getVelArray( void ) { return vel; } |
23 |
< |
static double* getFrcArray( void ) { return frc; } |
24 |
< |
static double* getTrqArray( void ) { return trq; } |
25 |
< |
static double* getAmatArray( void ) { return Amat; } |
26 |
< |
static double* getMuArray( void ) { return mu; } |
37 |
< |
static double* getUlArray( void ) { return ul; } |
38 |
< |
|
39 |
< |
double getX() const {return pos[offsetX];} |
40 |
< |
double getY() const {return pos[offsetY];} |
41 |
< |
double getZ() const {return pos[offsetZ];} |
42 |
< |
void setX(double x) {pos[offsetX] = x;} |
43 |
< |
void setY(double y) {pos[offsetY] = y;} |
44 |
< |
void setZ(double z) {pos[offsetZ] = z;} |
45 |
< |
|
46 |
< |
double get_vx() const {return vel[offsetX];} |
47 |
< |
double get_vy() const {return vel[offsetY];} |
48 |
< |
double get_vz() const {return vel[offsetZ];} |
49 |
< |
void set_vx(double vx) {vel[offsetX] = vx;} |
50 |
< |
void set_vy(double vy) {vel[offsetY] = vy;} |
51 |
< |
void set_vz(double vz) {vel[offsetZ] = vz;} |
52 |
< |
|
53 |
< |
double getFx() const {return frc[offsetX];} |
54 |
< |
double getFy() const {return frc[offsetY];} |
55 |
< |
double getFz() const {return frc[offsetZ];} |
56 |
< |
void addFx(double add) {frc[offsetX] += add;} |
57 |
< |
void addFy(double add) {frc[offsetY] += add;} |
58 |
< |
void addFz(double add) {frc[offsetZ] += add;} |
21 |
> |
void getVel( double theV[3] ); |
22 |
> |
void setVel( double theV[3] ); |
23 |
> |
|
24 |
> |
void getFrc( double theF[3] ); |
25 |
> |
void addFrc( double theF[3] ); |
26 |
> |
|
27 |
|
virtual void zeroForces() = 0; |
28 |
|
|
29 |
|
double getMass() const {return c_mass;} |
30 |
|
void setMass(double mass) {c_mass = mass;} |
31 |
+ |
|
32 |
+ |
double getEamRcut() const {return myEamRcut;} |
33 |
+ |
void setEamRcut(double eamRcut) {myEamRcut = eamRcut;} |
34 |
|
|
35 |
|
double getSigma() const {return c_sigma;} |
36 |
|
void setSigma(double sigma) {c_sigma = sigma;} |
66 |
|
void seVDW( void ) { is_VDW = 1; is_LJ = 0; } |
67 |
|
int isVDW( void ) { return is_VDW; } |
68 |
|
|
69 |
+ |
void setEAM( void ) { is_EAM = 1; } |
70 |
+ |
int isEAM( void ) { return is_EAM; } |
71 |
+ |
|
72 |
|
virtual int isDirectional( void ) = 0; |
73 |
|
|
74 |
|
|
75 |
|
protected: |
76 |
|
|
77 |
+ |
SimState* myConfig; |
78 |
+ |
|
79 |
+ |
double* pos; // the position array |
80 |
+ |
double* vel; // the velocity array |
81 |
+ |
double* frc; // the forc array |
82 |
+ |
double* trq; // the torque vector ( space fixed ) |
83 |
+ |
double* Amat; // the rotation matrix |
84 |
+ |
double* mu; // the array of dipole moments |
85 |
+ |
double* ul; // the lab frame unit directional vector |
86 |
+ |
|
87 |
|
double c_mass; /* the mass of the atom in amu */ |
88 |
|
double c_sigma; /* the sigma parameter for van der walls interactions */ |
89 |
|
double c_epslon; /* the esplon parameter for VDW interactions */ |
90 |
|
double c_covalent; // The covalent radius of the atom. |
91 |
|
|
92 |
+ |
double myEamRcut; // Atom rcut for eam defined by the forcefield. |
93 |
+ |
|
94 |
|
int index; /* set the atom's index */ |
95 |
|
int offset; // the atom's offset in the storage array |
96 |
|
int offsetX, offsetY, offsetZ; |
107 |
|
int has_dipole; // dipole boolean |
108 |
|
int is_VDW; // VDW boolean |
109 |
|
int is_LJ; // LJ boolean |
110 |
+ |
int is_EAM; //EAM boolean |
111 |
|
|
112 |
+ |
bool hasCoords; |
113 |
+ |
|
114 |
|
#ifdef IS_MPI |
115 |
|
int myGlobalIndex; |
116 |
|
#endif |
120 |
|
class GeneralAtom : public Atom{ |
121 |
|
|
122 |
|
public: |
123 |
< |
GeneralAtom(int theIndex): Atom(theIndex){} |
123 |
> |
GeneralAtom(int theIndex, SimState* theConfig): Atom(theIndex, theConfig){} |
124 |
|
virtual ~GeneralAtom(){} |
125 |
|
|
126 |
|
int isDirectional( void ){ return 0; } |
127 |
< |
void zeroForces() { |
139 |
< |
frc[offsetX] = 0.0; |
140 |
< |
frc[offsetY] = 0.0; |
141 |
< |
frc[offsetZ] = 0.0; |
142 |
< |
} |
127 |
> |
void zeroForces( void ); |
128 |
|
}; |
129 |
|
|
130 |
|
class DirectionalAtom : public Atom { |
131 |
|
|
132 |
|
public: |
133 |
< |
DirectionalAtom(int theIndex) : Atom(theIndex) |
133 |
> |
DirectionalAtom(int theIndex, SimState* theConfig) : Atom(theIndex, |
134 |
> |
theConfig) |
135 |
|
{ |
136 |
|
ssdIdentity = 0; |
137 |
|
sux = 0.0; |
138 |
|
suy = 0.0; |
139 |
|
suz = 0.0; |
140 |
+ |
myMu = 0.0; |
141 |
|
} |
142 |
|
virtual ~DirectionalAtom() {} |
143 |
|
|
144 |
+ |
virtual void setCoords(void); |
145 |
+ |
|
146 |
+ |
void printAmatIndex( void ); |
147 |
+ |
|
148 |
|
int isDirectional(void) { return 1; } |
149 |
|
|
150 |
|
void setSSD( int value) { ssdIdentity = value; } |
151 |
|
int isSSD(void) {return ssdIdentity; } |
152 |
|
|
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] ); |
153 |
|
|
154 |
|
void setEuler( double phi, double theta, double psi ); |
155 |
+ |
|
156 |
+ |
double getSUx( void ) { return sux; } |
157 |
+ |
double getSUy( void ) { return suy; } |
158 |
+ |
double getSUz( void ) { return suz; } |
159 |
|
|
160 |
|
void setSUx( double the_sux ) { sux = the_sux; } |
161 |
|
void setSUy( double the_suy ) { suy = the_suy; } |
162 |
|
void setSUz( double the_suz ) { suz = the_suz; } |
163 |
|
|
164 |
< |
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;} |
164 |
> |
void zeroForces(); |
165 |
|
|
182 |
– |
void zeroForces() { |
183 |
– |
frc[offsetX] = 0.0; |
184 |
– |
frc[offsetY] = 0.0; |
185 |
– |
frc[offsetZ] = 0.0; |
186 |
– |
|
187 |
– |
trq[offsetX] = 0.0; |
188 |
– |
trq[offsetY] = 0.0; |
189 |
– |
trq[offsetZ] = 0.0; |
190 |
– |
} |
191 |
– |
|
192 |
– |
double getAxx( void ) { return Amat[Axx]; } |
193 |
– |
double getAxy( void ) { return Amat[Axy]; } |
194 |
– |
double getAxz( void ) { return Amat[Axz]; } |
195 |
– |
|
196 |
– |
double getAyx( void ) { return Amat[Ayx]; } |
197 |
– |
double getAyy( void ) { return Amat[Ayy]; } |
198 |
– |
double getAyz( void ) { return Amat[Ayz]; } |
199 |
– |
|
200 |
– |
double getAzx( void ) { return Amat[Azx]; } |
201 |
– |
double getAzy( void ) { return Amat[Azy]; } |
202 |
– |
double getAzz( void ) { return Amat[Azz]; } |
203 |
– |
|
166 |
|
void getA( double the_A[3][3] ); // get the full rotation matrix |
167 |
+ |
void setA( double the_A[3][3] ); |
168 |
|
|
206 |
– |
double getSUx( void ) { return sux; } |
207 |
– |
double getSUy( void ) { return suy; } |
208 |
– |
double getSUz( void ) { return suz; } |
209 |
– |
|
169 |
|
void getU( double the_u[3] ); // get the unit vetor |
170 |
+ |
void updateU( void ); |
171 |
+ |
|
172 |
|
void getQ( double the_q[4] ); // get the quanternions |
173 |
+ |
void setQ( double the_q[4] ); |
174 |
|
|
175 |
+ |
void getJ( double theJ[3] ); |
176 |
+ |
void setJ( double theJ[3] ); |
177 |
+ |
|
178 |
|
double getJx( void ) { return jx; } |
179 |
|
double getJy( void ) { return jy; } |
180 |
|
double getJz( void ) { return jz; } |
181 |
|
|
182 |
< |
double getTx( void ) { return trq[offsetX];} |
183 |
< |
double getTy( void ) { return trq[offsetY]; } |
184 |
< |
double getTz( void ) { return trq[offsetZ]; } |
182 |
> |
void setJx( double the_jx ) { jx = the_jx; } |
183 |
> |
void setJy( double the_jy ) { jy = the_jy; } |
184 |
> |
void setJz( double the_jz ) { jz = the_jz; } |
185 |
|
|
186 |
+ |
void getTrq( double theT[3] ); |
187 |
+ |
void addTrq( double theT[3] ); |
188 |
+ |
|
189 |
+ |
// double getTx( void ) { return trq[offsetX];} |
190 |
+ |
// double getTy( void ) { return trq[offsetY]; } |
191 |
+ |
// double getTz( void ) { return trq[offsetZ]; } |
192 |
+ |
|
193 |
+ |
void setI( double the_I[3][3] ); |
194 |
+ |
void getI( double the_I[3][3] ); |
195 |
+ |
|
196 |
|
double getIxx( void ) { return Ixx; } |
197 |
|
double getIxy( void ) { return Ixy; } |
198 |
|
double getIxz( void ) { return Ixz; } |
205 |
|
double getIzy( void ) { return Izy; } |
206 |
|
double getIzz( void ) { return Izz; } |
207 |
|
|
208 |
< |
double getMu( void ) { return mu[index]; } |
209 |
< |
void setMu( double the_mu ) { mu[index] = the_mu; } |
208 |
> |
double getMu( void ); |
209 |
> |
void setMu( double the_mu ); |
210 |
|
|
211 |
|
void lab2Body( double r[3] ); |
212 |
|
void body2Lab( double r[3] ); |
238 |
– |
void updateU( void ); |
213 |
|
|
214 |
+ |
|
215 |
|
private: |
216 |
|
int dIndex; |
217 |
|
|
218 |
+ |
double myMu; |
219 |
+ |
|
220 |
|
double sux, suy, suz; // the standard unit vector ( body fixed ) |
221 |
|
double jx, jy, jz; // the angular momentum vector ( body fixed ) |
222 |
|
|