ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/RigidBody.hpp
Revision: 1187
Committed: Sat May 22 18:16:18 2004 UTC (20 years, 1 month ago) by chrisfen
File size: 3030 byte(s)
Log Message:
Fixed Thermodynamic integration code.

File Contents

# User Rev Content
1 gezelter 1100 #ifndef __RIGIDBODY_HPP__
2     #define __RIGIDBODY_HPP__
3    
4     #include <vector>
5     //#include "Atom.hpp"
6     //#include "AtomStamp.hpp"
7     #include "RigidBodyStamp.hpp"
8     #include "StuntDouble.hpp"
9     using namespace std;
10    
11     class Atom;
12     class AtomStamp;
13    
14     typedef struct {
15     double vec[3];
16     double& operator[](int index) {return vec[index];}
17     } vec3;
18    
19     typedef struct {
20     double mat[3][3];
21     double* operator[](int index) {return mat[index];}
22     } mat3x3;
23    
24     class RigidBody : public StuntDouble {
25    
26     public:
27    
28     RigidBody();
29     virtual ~RigidBody();
30    
31     void addAtom(Atom* at, AtomStamp* ats);
32    
33     void getPos( double theP[3] );
34     void setPos( double theP[3] );
35    
36     void getVel( double theV[3] );
37     void setVel( double theV[3] );
38    
39     void getFrc( double theF[3] );
40     void addFrc( double theF[3] );
41     void zeroForces();
42 tim 1118
43     virtual bool isLinear() {return is_linear;}
44     virtual int linearAxis() {return linear_axis;}
45 gezelter 1100
46     double getMass( void ) { return mass; }
47    
48     void printAmatIndex( void );
49 tim 1113 void setEuler( double phi, double theta, double psi );
50 gezelter 1100 void getQ( double the_q[4] ); // get the quanternions
51     void setQ( double the_q[4] );
52    
53     void getA( double the_A[3][3] ); // get the full rotation matrix
54     void setA( double the_A[3][3] );
55    
56     void getJ( double theJ[3] );
57     void setJ( double theJ[3] );
58    
59 tim 1108 virtual void setType(char* type) {strcpy(rbName, type);}
60     virtual char* getType() { return rbName;}
61    
62 gezelter 1100 void getTrq( double theT[3] );
63     void addTrq( double theT[3] );
64    
65     void getI( double the_I[3][3] );
66     void lab2Body( double r[3] );
67     void body2Lab( double r[3] );
68    
69 chrisfen 1187 double getZangle( );
70     void setZangle( double zAng );
71     void addZangle( double zAng );
72    
73 gezelter 1100 void calcRefCoords( void );
74     void doEulerToRotMat(vec3 &euler, mat3x3 &myA );
75     void calcForcesAndTorques( void );
76     void updateAtoms( void );
77    
78     //void yourAtomsHaveMoved( void );
79    
80     // Four functions added for derivatives with respect to Euler Angles:
81     // (Needed for minimization routines):
82    
83     void getGrad(double gradient[6] );
84     void getEulerAngles( double myEuler[3] );
85    
86     double max(double x, double y);
87     double min(double x, double y);
88    
89    
90     // utility routines
91    
92     void findCOM( void );
93 tim 1118
94     virtual void accept(BaseVisitor* v);
95    
96     vector<Atom*> getAtoms() { return myAtoms;}
97 gezelter 1100
98     protected:
99    
100     double mass; // the total mass
101     double pos[3]; // the position array (center of mass)
102     double vel[3]; // the velocity array (center of mass)
103     double frc[3]; // the force array (center of mass)
104     double trq[3]; // the torque vector ( space fixed )
105     double ji[3]; // the angular momentum vector (body fixed)
106     double A[3][3]; // the rotation matrix
107     double I[3][3]; // the inertial tensor (body fixed)
108     double sU[3][3]; // the standard unit vectors (body fixed)
109 chrisfen 1187 double zAngle; // the rotation about the z-axis (body fixed)
110 gezelter 1100
111 tim 1118 bool is_linear;
112     int linear_axis;
113 gezelter 1174 double momIntTol;
114 tim 1118
115 gezelter 1100 vector<Atom*> myAtoms; // the vector of atoms
116     vector<vec3> refCoords;
117     vector<mat3x3> refOrients;
118    
119 tim 1108 char rbName[100]; //it will eventually be converted into string
120 gezelter 1100 };
121    
122     #endif