--- trunk/mdtools/headers/Atom.hpp 2002/07/09 18:40:59 11 +++ trunk/mdtools/headers/Atom.hpp 2002/10/17 21:58:55 143 @@ -6,34 +6,48 @@ class Atom{ (public) class Atom{ public: - Atom() { + Atom(int theIndex) { c_n_hyd = 0; has_dipole = 0; is_VDW = 0; is_LJ = 0; + index = theIndex; } - ~Atom() {} + virtual ~Atom() {} + + static void createArrays (int nElements) { + pos = new double[nElements*3]; + vel = new double[nElements*3]; + frc = new double[nElements*3]; + trq = new double[nElements*3]; + } + static void destroyArrays(void) { + delete[] pos; + delete[] vel; + delete[] frc; + delete[] trq; + } - double getX() const {return c_x;} - double getY() const {return c_y;} - double getZ() const {return c_z;} - void setX(double x) {c_x = x;} - void setY(double y) {c_y = y;} - void setZ(double z) {c_z = z;} + 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 get_vx() const {return c_vx;} - double get_vy() const {return c_vy;} - double get_vz() const {return c_vz;} - void set_vx(double vx) {c_vx = vx;} - void set_vy(double vy) {c_vy = vy;} - void set_vz(double vz) {c_vz = vz;} + 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 getFx() const {return c_Fx;} - double getFy() const {return c_Fy;} - double getFz() const {return c_Fz;} - void addFx(double add) {c_Fx += add;} - void addFy(double add) {c_Fy += add;} - void addFz(double add) {c_Fz += add;} + 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;} virtual void zeroForces() = 0; double getMass() const {return c_mass;} @@ -48,8 +62,8 @@ class Atom{ (public) double getCovalent() const {return c_covalent;} void setCovalent(double covalent) {c_covalent = covalent;} - int getIndex() const {return c_index;} - void setIndex(int index) {c_index = index;} + int getIndex() const {return index;} + void setIndex(int theIndex) {index = theIndex;} char *getType() {return c_name;} void setType(char * name) {strcpy(c_name,name);} @@ -58,64 +72,70 @@ class Atom{ (public) int get_n_hydrogens() const {return c_n_hyd;} void setHasDipole( int value ) { has_dipole = value; } - short int hasDipole( void ) { return has_dipole; } + int hasDipole( void ) { return has_dipole; } void setLJ( void ) { is_LJ = 1; is_VDW = 0; } - short int isLJ( void ) { return is_LJ; } + int isLJ( void ) { return is_LJ; } void seVDW( void ) { is_VDW = 1; is_LJ = 0; } - short int isVDW( void ) { return is_VDW; } + int isVDW( void ) { return is_VDW; } virtual int isDirectional( void ) = 0; protected: - double c_x; /*the atom's position */ - double c_y; - double c_z; - - double c_vx; /*the atom's velocity */ - double c_vy; - double c_vz; - - double c_Fx; /* the atom's forces */ - double c_Fy; - double c_Fz; + 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 ) + 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 c_index; /* set the atom's index */ + int index; /* set the atom's index */ char c_name[100]; /* it's name */ int c_n_hyd; // the number of hydrogens bonded to the atom - short int has_dipole; // dipole boolean - short int is_VDW; // VDW boolean - short int is_LJ; // LJ boolean + int has_dipole; // dipole boolean + int is_VDW; // VDW boolean + int is_LJ; // LJ boolean }; class GeneralAtom : public Atom{ public: - GeneralAtom(){} - ~GeneralAtom(){} + GeneralAtom(int theIndex): Atom(theIndex){} + virtual ~GeneralAtom(){} int isDirectional( void ){ return 0; } void zeroForces() { - c_Fx = 0.0; c_Fy = 0.0; c_Fz = 0.0; + frc[3*index] = 0.0; + frc[3*index+1] = 0.0; + frc[3*index+2] = 0.0; } }; class DirectionalAtom : public Atom { public: - DirectionalAtom() { ssdIdentity = 0; } - ~DirectionalAtom() {} + DirectionalAtom(int theIndex) : Atom(theIndex) + { + ssdIdentity = 0; + } + virtual ~DirectionalAtom() {} + static void createDArrays(int nElements){ + trq = new double[nElements*3]; + } + static void destroyDArrays(void){ + delete[] trq; + } + int isDirectional(void) { return 1; } void setSSD( int value) { ssdIdentity = value; } @@ -137,15 +157,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 ) { tx += the_tx;} - void addTy( double the_ty ) { ty += the_ty;} - void addTz( double the_tz ) { tz += the_tz;} + 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 setMu( double the_mu ) { mu = the_mu; } void zeroForces() { - c_Fx = 0.0; c_Fy = 0.0; c_Fz = 0.0; - tx = 0.0; ty = 0.0; tz = 0.0; + frc[3*index] = 0.0; + frc[3*index+1] = 0.0; + frc[3*index+2] = 0.0; + + trq[3*index] = 0.0; + trq[3*index+1] = 0.0; + trq[3*index+2] = 0.0; } double getAxx( void ) { return Axx; } @@ -160,6 +185,8 @@ class DirectionalAtom : public Atom { (public) double getAzy( void ) { return Azy; } double getAzz( void ) { return Azz; } + void getA( double the_A[3][3] ); // get the full rotation matrix + double getSUx( void ) { return sux; } double getSUy( void ) { return suy; } double getSUz( void ) { return suz; } @@ -171,9 +198,9 @@ class DirectionalAtom : public Atom { (public) double getJy( void ) { return jy; } double getJz( void ) { return jz; } - double getTx( void ) { return tx; } - double getTy( void ) { return ty; } - double getTz( void ) { return tz; } + double getTx( void ) { return trq[3*index];} + double getTy( void ) { return trq[3*index+1]; } + double getTz( void ) { return trq[3*index+2]; } double getIxx( void ) { return Ixx; } double getIxy( void ) { return Ixy; } @@ -193,16 +220,16 @@ class DirectionalAtom : public Atom { (public) void body2Lab( double r[3] ); private: + int dIndex; - double Axx, Axy, Axz;; // the rotational matrix + double Axx, Axy, Axz; // the rotational matrix double Ayx, Ayy, Ayz; double Azx, Azy, Azz; - double sux, suy, suz; // the standard unit vector ( body fixed ) - double jx, jy, jz; // the angular momentum vector ( body fixed ) - double tx, ty, tz; // the torque vector ( space fixed ) + double sux, suy, suz; // the standard unit vector ( body fixed ) + double jx, jy, jz; // the angular momentum vector ( body fixed ) - double Ixx, Ixy, Ixz; // the inertial tensor matrix ( body fixed ) + double Ixx, Ixy, Ixz; // the inertial tensor matrix ( body fixed ) double Iyx, Iyy, Iyz; double Izx, Izy, Izz;