ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/UseTheForce/ForceFields.hpp
Revision: 1772
Committed: Tue Nov 23 22:48:31 2004 UTC (19 years, 7 months ago) by chrisfen
File size: 5970 byte(s)
Log Message:
Improvements to restraints

File Contents

# User Rev Content
1 gezelter 1490 #ifndef __FORCEFIELDS_H__
2     #define __FORCEFIELDS_H__
3    
4     #define MK_STR(s) # s
5     #define STR_DEFINE(t, s) t = MK_STR(s)
6    
7     #include <stdio.h>
8     #include <stdlib.h>
9     #include <math.h>
10 gezelter 1650 #include <string>
11     #include <map>
12 gezelter 1490
13 tim 1492 #include "primitives/Atom.hpp"
14     #include "brains/SimInfo.hpp"
15     #include "primitives/StuntDouble.hpp"
16 gezelter 1650 #include "types/ShapeAtomType.hpp"
17     #include "io/basic_ifstrstream.hpp"
18 gezelter 1490
19     #ifdef IS_MPI
20 tim 1492 #include "UseTheForce/mpiForceField.h"
21 gezelter 1490 #endif
22    
23 gezelter 1650 using namespace std;
24     using namespace oopse;
25    
26 gezelter 1490 class bond_pair{
27     public:
28     bond_pair(){}
29     ~bond_pair(){}
30    
31     int a;
32     int b;
33     };
34    
35     class bend_set{
36     public:
37     bend_set(){ isGhost = 0; }
38     ~bend_set(){}
39    
40     int ghost;
41     int isGhost;
42    
43     int a;
44     int b;
45     int c;
46     };
47    
48     class torsion_set{
49     public:
50     torsion_set(){}
51     ~torsion_set(){}
52    
53     int a;
54     int b;
55     int c;
56     int d;
57     };
58    
59    
60    
61     class ForceFields{
62    
63     public:
64 gezelter 1650 ForceFields(){
65 gezelter 1670
66     char* force_param_path;
67 gezelter 1650 frcFile = NULL;
68     entry_plug = NULL;
69     has_variant=0;
70 gezelter 1670
71     force_param_path = getenv("FORCE_PARAM_PATH");
72     if (force_param_path != NULL) {
73     ffPath = force_param_path;
74     } else {
75     ffPath = "";
76     }
77    
78 gezelter 1653 if( ffPath.empty() ) {
79 gezelter 1650 STR_DEFINE(ffPath, FRC_PATH );
80     }
81     }
82 gezelter 1670 ForceFields(const string &theVariant){
83     char* force_param_path;
84 gezelter 1650 frcFile = NULL;
85     entry_plug = NULL;
86     has_variant=1;
87 gezelter 1653 variant = theVariant;
88 gezelter 1670
89     force_param_path = getenv("FORCE_PARAM_PATH");
90     if (force_param_path != NULL) {
91     ffPath = force_param_path;
92     } else {
93     ffPath = "";
94     }
95    
96 gezelter 1653 if( ffPath.empty() ) {
97 gezelter 1650 STR_DEFINE(ffPath, FRC_PATH );
98     }
99     }
100 gezelter 1490 virtual ~ForceFields(){}
101    
102     void setSimInfo( SimInfo* the_entry_plug ) { entry_plug = the_entry_plug; }
103    
104     virtual void readParams( void ) = 0;
105    
106     virtual void cleanMe( void ) = 0;
107    
108    
109     virtual void initializeAtoms( int nAtoms, Atom** atomArray ) = 0;
110     virtual void initializeBonds( int nBonds, Bond** bondArray,
111     bond_pair* the_bonds ) = 0;
112     virtual void initializeBends( int nBends, Bend** bendArray,
113     bend_set* the_bends ) = 0;
114     virtual void initializeTorsions( int nTorsions, Torsion** torsionArray,
115     torsion_set* the_torsions ) = 0;
116 gezelter 1628 virtual void initForceField() = 0;
117 gezelter 1490
118     virtual void calcRcut( void );
119     virtual void setRcut( double LJrcut );
120     virtual void doForces( int calcPot, int calcStress );
121    
122     protected:
123    
124 gezelter 1628 void initFortran( int useReactionField );
125 chuckv 1617
126 gezelter 1490 FILE *frcFile;
127     SimInfo* entry_plug;
128    
129     int lineNum;
130     char readLine[500];
131     char* eof_test;
132     short int has_variant;
133     double bigSigma;
134    
135 gezelter 1653 string ffPath;
136 gezelter 1650 ifstrstream forceFile;
137 gezelter 1653 bool hasVariant;
138     string variant;
139 gezelter 1650 map<string, AtomType*> atomTypeMap;
140 gezelter 1653 // map<pair<string,string>, BondType*> bondTypeMap;
141     // map<tuple3<string,string,string>, BendType*> bendTypeMap;
142     // map<tuple4<string,string,string,string>, TorsionType*> torsionTypeMap;
143 gezelter 1650
144 gezelter 1490 };
145    
146    
147     class DUFF : public ForceFields{
148    
149     public:
150 gezelter 1656 DUFF();
151 gezelter 1490 virtual ~DUFF();
152    
153     void readParams();
154     void cleanMe( void );
155    
156     void initializeAtoms( int nAtoms, Atom** atomArray );
157     void initializeBonds( int nBonds, Bond** bondArray,
158     bond_pair* the_bonds );
159     void initializeBends( int nBends, Bend** bendArray,
160     bend_set* the_bends );
161     void initializeTorsions( int nTorsions, Torsion** torsionArray,
162     torsion_set* the_torsions );
163    
164 gezelter 1628 void initForceField();
165 gezelter 1490
166     private:
167    
168     void fastForward( char* stopText, char* searchOwner );
169     };
170    
171     class LJFF : public ForceFields{
172    
173     public:
174 gezelter 1656 LJFF();
175 gezelter 1490 virtual ~LJFF();
176    
177    
178     void readParams();
179     void cleanMe( void );
180    
181     void initializeAtoms( int nAtoms, Atom** atomArray );
182     void initializeBonds( int nBonds, Bond** bondArray,
183     bond_pair* the_bonds );
184     void initializeBends( int nBends, Bend** bendArray,
185     bend_set* the_bends );
186     void initializeTorsions( int nTorsions, Torsion** torsionArray,
187     torsion_set* the_torsions );
188    
189 gezelter 1628 void initForceField( );
190 gezelter 1490
191 gezelter 1650
192 gezelter 1490 private:
193    
194     void fastForward( char* stopText, char* searchOwner );
195    
196     };
197    
198     class EAM_FF : public ForceFields{
199    
200     public:
201 gezelter 1656
202     EAM_FF();
203 gezelter 1670 EAM_FF(const string &theVariant);
204 gezelter 1656
205 gezelter 1490 virtual ~EAM_FF();
206    
207     void readParams();
208     void cleanMe( void );
209    
210     void initializeAtoms( int nAtoms, Atom** atomArray );
211     void initializeBonds( int nBonds, Bond** bondArray,
212     bond_pair* the_bonds );
213     void initializeBends( int nBends, Bend** bendArray,
214     bend_set* the_bends );
215     void initializeTorsions( int nTorsions, Torsion** torsionArray,
216     torsion_set* the_torsions );
217    
218 gezelter 1628 void initForceField();
219 gezelter 1490
220     void calcRcut( void );
221 gezelter 1650
222 gezelter 1490 private:
223    
224     void fastForward( char* stopText, char* searchOwner );
225    
226     double eamRcut;
227     };
228    
229     class WATER : public ForceFields{
230    
231     public:
232 gezelter 1656 WATER();
233 gezelter 1490 virtual ~WATER();
234    
235     void readParams();
236     void cleanMe( void );
237     void initializeAtoms( int nAtoms, Atom** atomArray );
238     void initializeBonds( int nBonds, Bond** bondArray,
239     bond_pair* the_bonds );
240     void initializeBends( int nBends, Bend** bendArray,
241     bend_set* the_bends );
242     void initializeTorsions( int nTorsions, Torsion** torsionArray,
243     torsion_set* the_torsions );
244 gezelter 1628 void initForceField();
245 gezelter 1490
246 gezelter 1650
247 gezelter 1490 private:
248    
249     void fastForward( char* stopText, char* searchOwner );
250     void sectionSearch( char* secHead, char* stopText, char* searchOwner );
251    
252     };
253    
254 gezelter 1520 class Shapes_FF : public ForceFields{
255    
256     public:
257 gezelter 1650 Shapes_FF() : ForceFields() {};
258 gezelter 1670 Shapes_FF(const string &the_variant) : ForceFields(the_variant) {};
259 gezelter 1520 virtual ~Shapes_FF();
260    
261 gezelter 1650 void readParams();
262 gezelter 1520 void cleanMe( void );
263    
264     void initializeAtoms( int nAtoms, Atom** atomArray );
265     void initializeBonds( int nBonds, Bond** bondArray,
266     bond_pair* the_bonds );
267     void initializeBends( int nBends, Bend** bendArray,
268     bend_set* the_bends );
269     void initializeTorsions( int nTorsions, Torsion** torsionArray,
270     torsion_set* the_torsions );
271    
272 gezelter 1628 void initForceField();
273 gezelter 1520
274 chrisfen 1688 void calcRcut( void );
275    
276 gezelter 1650 void parseShapeFile(string shapeFileName, ShapeAtomType* st);
277    
278 gezelter 1520 private:
279 gezelter 1650
280     double findLargestContactDistance(ShapeAtomType* st);
281 chrisfen 1688 double findCutoffDistance(ShapeAtomType* st);
282 chrisfen 1646 double shapesRcut;
283 chrisfen 1688 double bigContact;
284 gezelter 1520
285     };
286    
287    
288 gezelter 1490 #endif
289