--- trunk/mdtools/headers/Atom.hpp 2002/10/17 21:58:55 143 +++ trunk/mdtools/headers/Atom.hpp 2002/12/16 21:42:11 213 @@ -12,6 +12,10 @@ class Atom{ (public) is_VDW = 0; is_LJ = 0; index = theIndex; + offset = 3 * index; + offsetX = offset; + offsetY = offset+1; + offsetZ = offset+2; } virtual ~Atom() {} @@ -28,26 +32,26 @@ class Atom{ (public) delete[] trq; } - double getX() const {return pos[3*index];} - double getY() const {return pos[3*index+1];} - double getZ() const {return pos[3*index+2];} - void setX(double x) {pos[3*index] = x;} - void setY(double y) {pos[3*index+1] = y;} - void setZ(double z) {pos[3*index+2] = z;} + double getX() const {return pos[offsetX];} + double getY() const {return pos[offsetY];} + double getZ() const {return pos[offsetZ];} + void setX(double x) {pos[offsetX] = x;} + void setY(double y) {pos[offsetY] = y;} + void setZ(double z) {pos[offsetZ] = z;} - double get_vx() const {return vel[3*index];} - double get_vy() const {return vel[3*index+1];} - double get_vz() const {return vel[3*index+2];} - void set_vx(double vx) {vel[3*index] = vx;} - void set_vy(double vy) {vel[3*index+1] = vy;} - void set_vz(double vz) {vel[3*index+2] = vz;} + double get_vx() const {return vel[offsetX];} + double get_vy() const {return vel[offsetY];} + double get_vz() const {return vel[offsetZ];} + void set_vx(double vx) {vel[offsetX] = vx;} + void set_vy(double vy) {vel[offsetY] = vy;} + void set_vz(double vz) {vel[offsetZ] = vz;} - double getFx() const {return frc[3*index];} - double getFy() const {return frc[3*index+1];} - double getFz() const {return frc[3*index+2];} - void addFx(double add) {frc[3*index] += add;} - void addFy(double add) {frc[3*index+1] += add;} - void addFz(double add) {frc[3*index+2] += add;} + double getFx() const {return frc[offsetX];} + double getFy() const {return frc[offsetY];} + double getFz() const {return frc[offsetZ];} + void addFx(double add) {frc[offsetX] += add;} + void addFy(double add) {frc[offsetY] += add;} + void addFz(double add) {frc[offsetZ] += add;} virtual void zeroForces() = 0; double getMass() const {return c_mass;} @@ -63,8 +67,14 @@ class Atom{ (public) void setCovalent(double covalent) {c_covalent = covalent;} int getIndex() const {return index;} - void setIndex(int theIndex) {index = theIndex;} - + void setIndex(int theIndex) { + index = theIndex; + offset = index*3; + offsetX = offset; + offsetY = offset+1; + offsetZ = offset+2; + } + char *getType() {return c_name;} void setType(char * name) {strcpy(c_name,name);} @@ -82,19 +92,21 @@ class Atom{ (public) virtual int isDirectional( void ) = 0; -protected: - static double* pos; // the position array static double* vel; // the velocity array static double* frc; // the forc array static double* trq; // the torque vector ( space fixed ) +protected: + double c_mass; /* the mass of the atom in amu */ double c_sigma; /* the sigma parameter for van der walls interactions */ double c_epslon; /* the esplon parameter for VDW interactions */ double c_covalent; // The covalent radius of the atom. int index; /* set the atom's index */ + int offset; // the atom's offset in the storage array + int offsetX, offsetY, offsetZ; char c_name[100]; /* it's name */ @@ -106,6 +118,8 @@ class Atom{ (public) }; + + class GeneralAtom : public Atom{ public: @@ -114,9 +128,9 @@ class GeneralAtom : public Atom{ (public) int isDirectional( void ){ return 0; } void zeroForces() { - frc[3*index] = 0.0; - frc[3*index+1] = 0.0; - frc[3*index+2] = 0.0; + frc[offsetX] = 0.0; + frc[offsetY] = 0.0; + frc[offsetZ] = 0.0; } }; @@ -157,20 +171,20 @@ class DirectionalAtom : public Atom { (public) void setJy( double the_jy ) { jy = the_jy; } void setJz( double the_jz ) { jz = the_jz; } - void addTx( double the_tx ) { trq[3*index] += the_tx;} - void addTy( double the_ty ) { trq[3*index+1] += the_ty;} - void addTz( double the_tz ) { trq[3*index+2] += the_tz;} + void addTx( double the_tx ) { trq[offsetX] += the_tx;} + void addTy( double the_ty ) { trq[offsetY] += the_ty;} + void addTz( double the_tz ) { trq[offsetZ] += the_tz;} void setMu( double the_mu ) { mu = the_mu; } void zeroForces() { - frc[3*index] = 0.0; - frc[3*index+1] = 0.0; - frc[3*index+2] = 0.0; + frc[offsetX] = 0.0; + frc[offsetY] = 0.0; + frc[offsetZ] = 0.0; - trq[3*index] = 0.0; - trq[3*index+1] = 0.0; - trq[3*index+2] = 0.0; + trq[offsetX] = 0.0; + trq[offsetY] = 0.0; + trq[offsetZ] = 0.0; } double getAxx( void ) { return Axx; } @@ -198,9 +212,9 @@ class DirectionalAtom : public Atom { (public) double getJy( void ) { return jy; } double getJz( void ) { return jz; } - double getTx( void ) { return trq[3*index];} - double getTy( void ) { return trq[3*index+1]; } - double getTz( void ) { return trq[3*index+2]; } + double getTx( void ) { return trq[offsetX];} + double getTy( void ) { return trq[offsetY]; } + double getTz( void ) { return trq[offsetZ]; } double getIxx( void ) { return Ixx; } double getIxy( void ) { return Ixy; }