ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/SHAPES/forcer.cpp
(Generate patch)

Comparing trunk/SHAPES/forcer.cpp (file contents):
Revision 1244 by gezelter, Fri Jun 4 16:21:23 2004 UTC vs.
Revision 1287 by chrisfen, Wed Jun 23 20:18:48 2004 UTC

# Line 4 | Line 4
4   #include <vector>
5   #include "forcerCmd.h"
6   #include "PDBReader.hpp"
7 + #include "RigidBody.hpp"
8 + #include "GridBuilder.hpp"
9  
10   #define MK_STR(s) # s
11   #define STR_DEFINE(t, s) t = MK_STR(s)
# Line 47 | Line 49 | int main(int argc, char* argv[]){
49    vector<Atype*>   vdwAtypes;
50    vector<Atype*>::iterator i;
51    Atype* at;
52 +  RigidBody* rb;
53    vector<VDWAtom*> theAtoms;
54    vector<VDWAtom*>::iterator j;
55    VDWAtom* atom;
56 <
56 >  GridBuilder* gb;
57 >  vector<double> sigmaGrid;
58 >  vector<double> epsGrid;
59 >  vector<double> sGrid;
60 >  
61    double mass, rpar, eps;
62 +  double xyz3[3];
63    string fileName;  
64    char vdwFileName[2002];
65    char structureFileName[2002];
66    char temp[200];
67    char readLine[500];
68 +  char xyzFile[200];
69 +  char shapeFile[200];
70    FILE *vdwFile, *structureFile;
71    char* ffPath_env = "VDW_PATH";
72    char* ffPath;
# Line 64 | Line 74 | int main(int argc, char* argv[]){
74    char* foo;
75    char* myType;
76    char* vType;
77 +  char *token;
78 +  const char *file;
79 +  const char *period = ".";
80 +  int k;
81    int lineNum;
82    int nTokens;
83    int FF;
84 +  int bandwidth;
85 +  int gridwidth;
86    short int gotMatch;
87  
88    //parse the command line options
# Line 81 | Line 97 | int main(int argc, char* argv[]){
97      exit(1);
98    }
99  
100 +  file = fileName.c_str();
101 +  strcpy(xyzFile, file);
102 +  token = strtok(xyzFile, period);
103 +  strcpy(xyzFile, token);
104 +  strcpy(shapeFile, token);
105 +  strcat(xyzFile, "Ref.xyz");
106 +  strcat(shapeFile, ".shape");
107 +  ofstream xfiles(xyzFile);
108 +  
109 +  //the bandwidth has a default value (default=16), so it is always given
110 +  bandwidth = args_info.bandwidth_arg;
111 +  gridwidth = bandwidth*2;
112 +  
113    if (args_info.charmm_given) {
114      FF=CHARMM;
115      strcpy(vdwFileName, "charmm27.vdw");
# Line 106 | Line 135 | int main(int argc, char* argv[]){
135      strcpy(vdwFileName, "oplsaal.vdw");
136    }
137  
138 +
139 +  printf ("opening %s\n", vdwFileName);
140    vdwFile = fopen( vdwFileName, "r" );
141    
142    if( vdwFile == NULL ){
# Line 122 | Line 153 | int main(int argc, char* argv[]){
153      strcat( temp, vdwFileName );
154      strcpy( vdwFileName, temp );
155      
156 +    printf ("opening %s\n", vdwFileName);
157      vdwFile = fopen( vdwFileName, "r" );
158      
159      if( vdwFile == NULL ){
# Line 132 | Line 164 | int main(int argc, char* argv[]){
164                 vdwFileName );
165        exit(-1);
166      }
167 <    printf( "VDW file %s opened sucessfully.\n", vdwFileName );
168 <    lineNum = 0;
169 <    
167 >  }
168 >  printf( "VDW file %s opened sucessfully.\n", vdwFileName );
169 >  lineNum = 0;
170 >  
171 >  eof_test = fgets( readLine, sizeof(readLine), vdwFile );
172 >  lineNum++;
173 >  
174 >  if( eof_test == NULL ){
175 >    printf("Error in reading Atoms from force file at line %d.\n",
176 >           lineNum );
177 >    exit(-1);
178 >  }
179 >  
180 >  while( eof_test != NULL ){
181 >    // toss comment lines
182 >    if( readLine[0] != '!' && readLine[0] != '#' ){
183 >      
184 >      nTokens = count_tokens(readLine, " ,;\t");
185 >      if (nTokens < 4) {
186 >        printf("Not enough tokens on line %d.\n", lineNum);
187 >        exit(-1);
188 >      }
189 >      
190 >      at = new Atype();
191 >      foo = strtok(readLine, " ,;\t");
192 >      at->setType(foo);
193 >      foo = strtok(NULL, " ,;\t");      
194 >      mass = atof(foo);
195 >      at->setMass(mass);
196 >      foo = strtok(NULL, " ,;\t");
197 >      rpar = atof(foo);
198 >      at->setRpar(rpar);
199 >      foo = strtok(NULL, " ,;\t");
200 >      eps = atof(foo);  
201 >      at->setEps(eps);
202 >      vdwAtypes.push_back(at);        
203 >    }
204      eof_test = fgets( readLine, sizeof(readLine), vdwFile );
205      lineNum++;
206 <    
207 <    if( eof_test == NULL ){
208 <      printf("Error in reading Atoms from force file at line %d.\n",
209 <             lineNum );
144 <      exit(-1);
145 <    }
146 <    
147 <    while( eof_test != NULL ){
148 <      // toss comment lines
149 <      if( readLine[0] != '!' && readLine[0] != '#' ){
150 <      
151 <        nTokens = count_tokens(readLine, " ,;\t");
152 <        if (nTokens < 4) {
153 <          printf("Not enough tokens on line %d.\n", lineNum);
154 <          exit(-1);
155 <        }
156 <              
157 <        at = new Atype();
158 <        foo = strtok(readLine, " ,;\t");
159 <        at->setType(foo);
160 <        foo = strtok(NULL, " ,;\t");      
161 <        mass = atof(foo);
162 <        at->setMass(mass);
163 <        foo = strtok(NULL, " ,;\t");
164 <        rpar = atof(foo);
165 <        at->setRpar(rpar);
166 <        foo = strtok(NULL, " ,;\t");
167 <        eps = atof(foo);  
168 <        at->setEps(eps);
169 <        vdwAtypes.push_back(at);        
170 <      }
171 <      eof_test = fgets( readLine, sizeof(readLine), vdwFile );
172 <      lineNum++;
173 <    }          
174 <    
175 <    fclose( vdwFile );
176 <  }
206 >  }          
207 >  
208 >  fclose( vdwFile );
209 >  
210    printf("%d Atom Types read from VDW file\n", vdwAtypes.size());
211  
212    // Now, open and parse the input file!
# Line 222 | Line 255 | int main(int argc, char* argv[]){
255      }
256    }
257  
258 <  //GridBuilder gb = new GridBuilder();
259 <  //gb->findAxesAndOrigin(theAtoms);
260 <  //gb->launchProbe(FF, sigmaGrid, sGrid, epsGrid);
261 <
258 >  rb = new RigidBody();
259 >  for( j = theAtoms.begin(); j !=  theAtoms.end(); ++j){
260 >    rb->addAtom(*j);
261 >  }
262  
263 +  rb->calcRefCoords();
264 +  
265 +  //print a reference coordinate xyz file
266 +  xfiles << rb->getNumAtoms() << "\n\n";
267 +  for (k=0; k<rb->getNumAtoms(); k++){
268 +    rb->getAtomRefCoor(xyz3, k);
269 +    xfiles << rb->getAtomBase(k) << "\t" <<
270 +              xyz3[0] << "\t" << xyz3[1] << "\t" <<
271 +              xyz3[2] << "\n";
272 +  }
273 +  
274 +  gb = new GridBuilder(rb, gridwidth);
275 +
276 +  cout << "Doing GridBuilder calculations...\n";
277 +  gb->launchProbe(FF, sigmaGrid, sGrid, epsGrid);
278 +  
279 +  gb->printGridFiles();
280 +  
281 +  //load the grid element values to the main grid vectors
282 +  for (k=0; k<gridwidth*gridwidth; k++){
283 +    sigmaGrid.push_back(gb->passSig(k));
284 +    sGrid.push_back(gb->passS(k));
285 +    epsGrid.push_back(gb->passEps(k));
286 +  }
287 +
288 +  
289 +  
290   }
291  
292   int count_tokens(char *line, char *delimiters) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines