ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/headers/Atom.hpp
(Generate patch)

Comparing:
branches/mmeineke/mdtools/headers/Atom.hpp (file contents), Revision 10 by mmeineke, Tue Jul 9 18:40:59 2002 UTC vs.
trunk/mdtools/headers/Atom.hpp (file contents), Revision 184 by mmeineke, Thu Nov 21 20:33:06 2002 UTC

# Line 6 | Line 6 | class Atom{ (public)
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    }
16 <  ~Atom() {}
16 >  virtual ~Atom() {}
17 >
18 >  static void createArrays (int nElements) {
19 >    pos = new double[nElements*3];
20 >    vel = new double[nElements*3];
21 >    frc = new double[nElements*3];
22 >    trq = new double[nElements*3];
23 >  }
24 >  static void destroyArrays(void) {
25 >    delete[] pos;
26 >    delete[] vel;
27 >    delete[] frc;
28 >    delete[] trq;
29 >  }
30    
31 <  double getX() const {return c_x;}
32 <  double getY() const {return c_y;}
33 <  double getZ() const {return c_z;}
34 <  void setX(double x) {c_x = x;}
35 <  void setY(double y) {c_y = y;}
36 <  void setZ(double z) {c_z = z;}
31 >  double getX() const {return pos[3*index];}
32 >  double getY() const {return pos[3*index+1];}
33 >  double getZ() const {return pos[3*index+2];}
34 >  void setX(double x) {pos[3*index]   = x;}
35 >  void setY(double y) {pos[3*index+1] = y;}
36 >  void setZ(double z) {pos[3*index+2] = z;}
37    
38 <  double get_vx() const {return c_vx;}
39 <  double get_vy() const {return c_vy;}
40 <  double get_vz() const {return c_vz;}
41 <  void set_vx(double vx) {c_vx = vx;}
42 <  void set_vy(double vy) {c_vy = vy;}
43 <  void set_vz(double vz) {c_vz = vz;}
38 >  double get_vx() const  {return vel[3*index];}
39 >  double get_vy() const  {return vel[3*index+1];}
40 >  double get_vz() const  {return vel[3*index+2];}
41 >  void set_vx(double vx) {vel[3*index]   = vx;}
42 >  void set_vy(double vy) {vel[3*index+1] = vy;}
43 >  void set_vz(double vz) {vel[3*index+2] = vz;}
44    
45 <  double getFx() const {return c_Fx;}
46 <  double getFy() const {return c_Fy;}
47 <  double getFz() const {return c_Fz;}
48 <  void addFx(double add) {c_Fx += add;}
49 <  void addFy(double add) {c_Fy += add;}
50 <  void addFz(double add) {c_Fz += add;}
45 >  double getFx() const   {return frc[3*index];}
46 >  double getFy() const   {return frc[3*index+1];}
47 >  double getFz() const   {return frc[3*index+2];}
48 >  void addFx(double add) {frc[3*index]   += add;}
49 >  void addFy(double add) {frc[3*index+1] += add;}
50 >  void addFz(double add) {frc[3*index+2] += add;}
51    virtual void zeroForces() = 0;
52  
53    double getMass() const {return c_mass;}
# Line 48 | Line 62 | class Atom{ (public)
62    double getCovalent() const {return c_covalent;}
63    void setCovalent(double covalent) {c_covalent = covalent;}
64    
65 <  int getIndex() const {return c_index;}
66 <  void setIndex(int index) {c_index = index;}
65 >  int getIndex() const {return index;}
66 >  void setIndex(int theIndex) {index = theIndex;}
67    
68    char *getType() {return c_name;}
69    void setType(char * name) {strcpy(c_name,name);}
# Line 58 | Line 72 | class Atom{ (public)
72    int get_n_hydrogens() const {return c_n_hyd;}
73  
74    void setHasDipole( int value ) { has_dipole = value; }
75 <  short int hasDipole( void ) { return has_dipole; }
75 >  int hasDipole( void ) { return has_dipole; }
76  
77    void setLJ( void )        { is_LJ = 1; is_VDW = 0; }
78 <  short int isLJ( void )    { return is_LJ; }
78 >  int isLJ( void )    { return is_LJ; }
79  
80    void seVDW( void )        { is_VDW = 1; is_LJ = 0; }
81 <  short int isVDW( void )    { return is_VDW; }
81 >  int isVDW( void )    { return is_VDW; }
82  
83    virtual int isDirectional( void ) = 0;
84  
85 +  static double* pos; // the position array
86 +  static double* vel; // the velocity array
87 +  static double* frc; // the forc array
88 +  static double* trq; // the torque vector  ( space fixed )
89 +
90   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;
91    
92    double c_mass; /* the mass of the atom in amu */
93    double c_sigma; /* the sigma parameter for van der walls interactions */
94    double c_epslon; /* the esplon parameter for VDW interactions */
95    double c_covalent; // The covalent radius of the atom.
96  
97 <  int c_index; /* set the atom's index */
97 >  int index; /* set the atom's index */
98  
99    char c_name[100]; /* it's name */
100  
101    int c_n_hyd; // the number of hydrogens bonded to the atom
102    
103 <  short int has_dipole; // dipole boolean
104 <  short int is_VDW;    // VDW boolean
105 <  short int is_LJ;    // LJ boolean
103 >  int has_dipole; // dipole boolean
104 >  int is_VDW;    // VDW boolean
105 >  int is_LJ;    // LJ boolean
106    
107   };
108  
109 +
110 +
111   class GeneralAtom : public Atom{
112  
113   public:
114 <  GeneralAtom(){}
115 <  ~GeneralAtom(){}
114 >  GeneralAtom(int theIndex): Atom(theIndex){}
115 >  virtual ~GeneralAtom(){}
116  
117    int isDirectional( void ){ return 0; }
118    void zeroForces() {
119 <    c_Fx = 0.0; c_Fy = 0.0; c_Fz = 0.0;
119 >    frc[3*index]   = 0.0;
120 >    frc[3*index+1] = 0.0;
121 >    frc[3*index+2] = 0.0;
122    }
123   };
124  
125   class DirectionalAtom : public Atom {
126    
127   public:
128 <  DirectionalAtom() { ssdIdentity = 0; }
129 <  ~DirectionalAtom() {}
128 >  DirectionalAtom(int theIndex) : Atom(theIndex)
129 >  {
130 >    ssdIdentity = 0;
131 >  }
132 >  virtual ~DirectionalAtom() {}
133  
134 +  static void createDArrays(int nElements){
135 +    trq = new double[nElements*3];
136 +  }
137 +  static void destroyDArrays(void){
138 +    delete[] trq;
139 +  }
140 +
141    int isDirectional(void) { return 1; }
142    
143    void setSSD( int value) { ssdIdentity = value; }
# Line 137 | Line 159 | class DirectionalAtom : public Atom { (public)
159    void setJy( double the_jy ) { jy = the_jy; }
160    void setJz( double the_jz ) { jz = the_jz; }
161      
162 <  void addTx( double the_tx ) { tx += the_tx;}
163 <  void addTy( double the_ty ) { ty += the_ty;}
164 <  void addTz( double the_tz ) { tz += the_tz;}
162 >  void addTx( double the_tx ) { trq[3*index]   += the_tx;}
163 >  void addTy( double the_ty ) { trq[3*index+1] += the_ty;}
164 >  void addTz( double the_tz ) { trq[3*index+2] += the_tz;}
165  
166    void setMu( double the_mu ) { mu = the_mu; }
167  
168    void zeroForces() {
169 <    c_Fx = 0.0; c_Fy = 0.0; c_Fz = 0.0;
170 <    tx = 0.0; ty = 0.0; tz = 0.0;
169 >    frc[3*index]   = 0.0;
170 >    frc[3*index+1] = 0.0;
171 >    frc[3*index+2] = 0.0;
172 >
173 >    trq[3*index]   = 0.0;
174 >    trq[3*index+1] = 0.0;
175 >    trq[3*index+2] = 0.0;
176    }
177  
178    double getAxx( void ) { return Axx; }
# Line 160 | Line 187 | class DirectionalAtom : public Atom { (public)
187    double getAzy( void ) { return Azy; }
188    double getAzz( void ) { return Azz; }
189  
190 +  void getA( double the_A[3][3] ); // get the full rotation matrix
191 +
192    double getSUx( void ) { return sux; }
193    double getSUy( void ) { return suy; }
194    double getSUz( void ) { return suz; }
# Line 171 | Line 200 | class DirectionalAtom : public Atom { (public)
200    double getJy( void ) { return jy; }
201    double getJz( void ) { return jz; }
202  
203 <  double getTx( void ) { return tx; }
204 <  double getTy( void ) { return ty; }
205 <  double getTz( void ) { return tz; }
203 >  double getTx( void ) { return trq[3*index];}
204 >  double getTy( void ) { return trq[3*index+1]; }
205 >  double getTz( void ) { return trq[3*index+2]; }
206  
207    double getIxx( void ) { return Ixx; }
208    double getIxy( void ) { return Ixy; }
# Line 193 | Line 222 | class DirectionalAtom : public Atom { (public)
222    void body2Lab( double r[3] );
223  
224   private:
225 +  int dIndex;
226  
227 <  double Axx, Axy, Axz;; // the rotational matrix
227 >  double Axx, Axy, Axz; // the rotational matrix
228    double Ayx, Ayy, Ayz;
229    double Azx, Azy, Azz;
230  
231 <  double sux, suy, suz; // the standard unit vector ( body fixed )
232 <  double jx, jy, jz; // the angular momentum vector ( body fixed )
203 <  double tx, ty, tz; // the torque vector           ( space fixed )
231 >  double sux, suy, suz; // the standard unit vector    ( body fixed )
232 >  double jx, jy, jz;    // the angular momentum vector ( body fixed )
233    
234 <  double Ixx, Ixy, Ixz; // the inertial tensor matrix ( body fixed )
234 >  double Ixx, Ixy, Ixz; // the inertial tensor matrix  ( body fixed )
235    double Iyx, Iyy, Iyz;
236    double Izx, Izy, Izz;
237  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines