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

Comparing:
branches/mmeineke/OOPSE/libmdtools/TraPPE_ExFF.cpp (file contents), Revision 377 by mmeineke, Fri Mar 21 17:42:12 2003 UTC vs.
trunk/OOPSE/libmdtools/TraPPE_ExFF.cpp (file contents), Revision 451 by mmeineke, Thu Apr 3 22:01:29 2003 UTC

# Line 12 | Line 12 | using namespace std;
12   #include "fortranWrappers.hpp"
13  
14   #ifdef IS_MPI
15 #include <mpi++.h>
15   #include "mpiForceField.h"
16   #endif // is_mpi
17  
# Line 82 | Line 81 | namespace TPE {  // restrict the access of the folowin
81    MPI_Datatype mpiBondStructType;
82    MPI_Datatype mpiBendStructType;
83    MPI_Datatype mpiTorsionStructType;
84 +
85 + #endif
86 +
87 +  class LinkedAtomType {
88 +  public:
89 +    LinkedAtomType(){
90 +      next = NULL;
91 +      name[0] = '\0';
92 +    }
93 +    ~LinkedAtomType(){ if( next != NULL ) delete next; }
94 +
95 +    LinkedAtomType* find(char* key){
96 +      if( !strcmp(name, key) ) return this;
97 +      if( next != NULL ) return next->find(key);
98 +      return NULL;
99 +    }
100 +    
101 +    void printMe( void ){
102 +      
103 +      std::cerr << "LinkedAtype " << name << ": ident = " << ident << "\n";
104 +      if( next != NULL ) next->printMe();
105 +
106 +    }
107 +
108 +    void add( atomStruct &info ){
109 +
110 +      // check for duplicates
111 +      
112 +      if( !strcmp( info.name, name ) ){
113 +        sprintf( painCave.errMsg,
114 +                 "Duplicate TraPPE_Ex atom type \"%s\" found in "
115 +                 "the TraPPE_ExFF param file./n",
116 +                 name );
117 +        painCave.isFatal = 1;
118 +        simError();
119 +      }
120 +
121 +      if( next != NULL ) next->add(info);
122 +      else{
123 +        next = new LinkedAtomType();
124 +        strcpy(next->name, info.name);
125 +        next->isDipole = info.isDipole;
126 +        next->isSSD    = info.isSSD;
127 +        next->mass     = info.mass;
128 +        next->epslon   = info.epslon;
129 +        next->sigma    = info.sigma;
130 +        next->dipole   = info.dipole;
131 +        next->w0       = info.w0;
132 +        next->v0       = info.v0;
133 +        next->ident    = info.ident;
134 +      }
135 +    }
136 +
137 + #ifdef IS_MPI
138 +    
139 +    void duplicate( atomStruct &info ){
140 +      strcpy(info.name, name);
141 +      info.isDipole = isDipole;
142 +      info.isSSD    = isSSD;
143 +      info.mass     = mass;
144 +      info.epslon   = epslon;
145 +      info.sigma    = sigma;
146 +      info.dipole   = dipole;
147 +      info.w0       = w0;
148 +      info.v0       = v0;
149 +      info.ident    = ident;
150 +      info.last     = 0;
151 +    }
152 +
153 +
154 + #endif
155 +
156 +    char name[15];
157 +    int isDipole;
158 +    int isSSD;
159 +    double mass;
160 +    double epslon;
161 +    double sigma;
162 +    double dipole;
163 +    double w0;
164 +    double v0;
165 +    int ident;
166 +    LinkedAtomType* next;
167 +  };
168 +
169 +  class LinkedBondType {
170 +  public:
171 +    LinkedBondType(){
172 +      next = NULL;
173 +      nameA[0] = '\0';
174 +      nameB[0] = '\0';
175 +      type[0] = '\0';
176 +    }
177 +    ~LinkedBondType(){ if( next != NULL ) delete next; }
178 +
179 +    LinkedBondType* find(char* key1, char* key2){
180 +      if( !strcmp(nameA, key1 ) && !strcmp( nameB, key2 ) ) return this;
181 +      if( !strcmp(nameA, key2 ) && !strcmp( nameB, key1 ) ) return this;
182 +      if( next != NULL ) return next->find(key1, key2);
183 +      return NULL;
184 +    }
185 +    
186 +
187 +    void add( bondStruct &info ){
188 +      
189 +      // check for duplicates
190 +      int dup = 0;
191 +
192 +      if( !strcmp(nameA, info.nameA ) && !strcmp( nameB, info.nameB ) ) dup = 1;
193 +      if( !strcmp(nameA, info.nameB ) && !strcmp( nameB, info.nameA ) ) dup = 1;
194 +      
195 +      if(dup){
196 +        sprintf( painCave.errMsg,
197 +                 "Duplicate TraPPE_Ex bond type \"%s - %s\" found in "
198 +                 "the TraPPE_ExFF param file./n",
199 +                 nameA, nameB );
200 +        painCave.isFatal = 1;
201 +        simError();
202 +      }
203 +
204 +        
205 +      if( next != NULL ) next->add(info);
206 +      else{
207 +        next = new LinkedBondType();
208 +        strcpy(next->nameA, info.nameA);
209 +        strcpy(next->nameB, info.nameB);
210 +        strcpy(next->type,  info.type);
211 +        next->d0 = info.d0;
212 +      }
213 +    }
214 +    
215 + #ifdef IS_MPI
216 +    void duplicate( bondStruct &info ){
217 +      strcpy(info.nameA, nameA);
218 +      strcpy(info.nameB, nameB);
219 +      strcpy(info.type,  type);
220 +      info.d0   = d0;
221 +      info.last = 0;
222 +    }
223 +
224 +
225 + #endif
226 +
227 +    char nameA[15];
228 +    char nameB[15];
229 +    char type[30];
230 +    double d0;
231 +
232 +    LinkedBondType* next;
233 +  };
234 +
235 +  class LinkedBendType {
236 +  public:
237 +    LinkedBendType(){
238 +      next = NULL;
239 +      nameA[0] = '\0';
240 +      nameB[0] = '\0';
241 +      nameC[0] = '\0';
242 +      type[0] = '\0';
243 +    }
244 +    ~LinkedBendType(){ if( next != NULL ) delete next; }
245 +
246 +    LinkedBendType* find( char* key1, char* key2, char* key3 ){
247 +      if( !strcmp( nameA, key1 ) && !strcmp( nameB, key2 )
248 +          && !strcmp( nameC, key3 ) ) return this;
249 +      if( !strcmp( nameA, key3 ) && !strcmp( nameB, key2 )
250 +          && !strcmp( nameC, key1 ) ) return this;
251 +      if( next != NULL ) return next->find(key1, key2, key3);
252 +      return NULL;
253 +    }
254 +    
255 +    void add( bendStruct &info ){
256 +
257 +      // check for duplicates
258 +      int dup = 0;
259 +      
260 +      if( !strcmp( nameA, info.nameA ) && !strcmp( nameB, info.nameB )
261 +          && !strcmp( nameC, info.nameC ) ) dup = 1;
262 +      if( !strcmp( nameA, info.nameC ) && !strcmp( nameB, info.nameB )
263 +          && !strcmp( nameC, info.nameA ) ) dup = 1;
264 +
265 +      if(dup){
266 +        sprintf( painCave.errMsg,
267 +                 "Duplicate TraPPE_Ex bend type \"%s - %s - %s\" found in "
268 +                 "the TraPPE_ExFF param file./n",
269 +                 nameA, nameB, nameC );
270 +        painCave.isFatal = 1;
271 +        simError();
272 +      }
273  
274 +      if( next != NULL ) next->add(info);
275 +      else{
276 +        next = new LinkedBendType();
277 +        strcpy(next->nameA, info.nameA);
278 +        strcpy(next->nameB, info.nameB);
279 +        strcpy(next->nameC, info.nameC);
280 +        strcpy(next->type,  info.type);
281 +        next->k1 = info.k1;
282 +        next->k2 = info.k2;
283 +        next->k3 = info.k3;
284 +        next->t0 = info.t0;
285 +      }
286 +    }
287 +
288 + #ifdef IS_MPI    
289 +
290 +    void duplicate( bendStruct &info ){
291 +      strcpy(info.nameA, nameA);
292 +      strcpy(info.nameB, nameB);
293 +      strcpy(info.nameC, nameC);
294 +      strcpy(info.type,  type);
295 +      info.k1   = k1;
296 +      info.k2   = k2;
297 +      info.k3   = k3;
298 +      info.t0   = t0;
299 +      info.last = 0;
300 +    }
301 +
302 + #endif // is_mpi
303 +
304 +    char nameA[15];
305 +    char nameB[15];
306 +    char nameC[15];
307 +    char type[30];
308 +    double k1, k2, k3, t0;
309 +
310 +    LinkedBendType* next;
311 +  };
312 +
313 +  class LinkedTorsionType {
314 +  public:
315 +    LinkedTorsionType(){
316 +      next = NULL;
317 +      nameA[0] = '\0';
318 +      nameB[0] = '\0';
319 +      nameC[0] = '\0';
320 +      type[0] = '\0';
321 +    }
322 +    ~LinkedTorsionType(){ if( next != NULL ) delete next; }
323 +
324 +    LinkedTorsionType* find( char* key1, char* key2, char* key3, char* key4 ){
325 +      
326 +
327 +
328 +
329 +      if( !strcmp( nameA, key1 ) && !strcmp( nameB, key2 ) &&
330 +          !strcmp( nameC, key3 ) && !strcmp( nameD, key4 ) ) return this;
331 +
332 +      if( !strcmp( nameA, key4 ) && !strcmp( nameB, key3 ) &&
333 +          !strcmp( nameC, key2 ) && !strcmp( nameD, key1 ) ) return this;
334 +
335 +      if( next != NULL ) return next->find(key1, key2, key3, key4);
336 +      return NULL;
337 +    }
338 +
339 +    void add( torsionStruct &info ){
340 +
341 +      // check for duplicates
342 +      int dup = 0;
343 +
344 +      if( !strcmp( nameA, info.nameA ) && !strcmp( nameB, info.nameB ) &&
345 +          !strcmp( nameC, info.nameC ) && !strcmp( nameD, info.nameD ) ) dup = 1;
346 +      
347 +      if( !strcmp( nameA, info.nameD ) && !strcmp( nameB, info.nameC ) &&
348 +          !strcmp( nameC, info.nameB ) && !strcmp( nameD, info.nameA ) ) dup = 1;
349 +      
350 +      if(dup){
351 +        sprintf( painCave.errMsg,
352 +                 "Duplicate TraPPE_Ex torsion type \"%s - %s - %s - %s\" found in "
353 +                 "the TraPPE_ExFF param file./n", nameA, nameB, nameC, nameD );
354 +        painCave.isFatal = 1;
355 +        simError();
356 +      }
357 +
358 +      if( next != NULL ) next->add(info);
359 +      else{
360 +        next = new LinkedTorsionType();
361 +        strcpy(next->nameA, info.nameA);
362 +        strcpy(next->nameB, info.nameB);
363 +        strcpy(next->nameC, info.nameC);
364 +        strcpy(next->nameD, info.nameD);
365 +        strcpy(next->type,  info.type);
366 +        next->k1 = info.k1;
367 +        next->k2 = info.k2;
368 +        next->k3 = info.k3;
369 +        next->k4 = info.k4;
370 +
371 +      }
372 +    }
373 +
374 + #ifdef IS_MPI
375 +    
376 +    void duplicate( torsionStruct &info ){
377 +      strcpy(info.nameA, nameA);
378 +      strcpy(info.nameB, nameB);
379 +      strcpy(info.nameC, nameC);
380 +      strcpy(info.nameD, nameD);
381 +      strcpy(info.type,  type);
382 +      info.k1   = k1;
383 +      info.k2   = k2;
384 +      info.k3   = k3;
385 +      info.k4   = k4;
386 +      info.last = 0;
387 +    }
388 +
389   #endif
390  
391 +    char nameA[15];
392 +    char nameB[15];
393 +    char nameC[15];
394 +    char nameD[15];
395 +    char type[30];
396 +    double k1, k2, k3, k4;
397 +
398 +    LinkedTorsionType* next;
399 +  };
400 +
401 +
402 +  LinkedAtomType* headAtomType;
403 +  LinkedAtomType* currentAtomType;
404 +  LinkedBondType* headBondType;
405 +  LinkedBondType* currentBondType;
406 +  LinkedBendType* headBendType;
407 +  LinkedBendType* currentBendType;
408 +  LinkedTorsionType* headTorsionType;
409 +  LinkedTorsionType* currentTorsionType;
410 +
411   } // namespace
412  
413   using namespace TPE;
# Line 103 | Line 426 | TraPPE_ExFF::TraPPE_ExFF(){
426    char temp[200];
427    char errMsg[1000];
428  
429 +  headAtomType       = NULL;
430 +  currentAtomType    = NULL;
431 +  headBondType       = NULL;
432 +  currentBondType    = NULL;
433 +  headBendType       = NULL;
434 +  currentBendType    = NULL;
435 +  headTorsionType    = NULL;
436 +  currentTorsionType = NULL;
437 +
438    // do the funtion wrapping
439    wrapMeFF( this );
440  
# Line 253 | Line 585 | TraPPE_ExFF::~TraPPE_ExFF(){
585  
586   TraPPE_ExFF::~TraPPE_ExFF(){
587  
588 +  if( headAtomType != NULL ) delete headAtomType;
589 +  if( headBondType != NULL ) delete headBondType;
590 +  if( headBendType != NULL ) delete headBendType;
591 +  if( headTorsionType != NULL ) delete headTorsionType;
592 +
593   #ifdef IS_MPI
594    if( worldRank == 0 ){
595   #endif // is_mpi
# Line 264 | Line 601 | void TraPPE_ExFF::initForceField( int ljMixRule ){
601   #endif // is_mpi
602   }
603  
604 + void TraPPE_ExFF::cleanMe( void ){
605 +
606 + #ifdef IS_MPI
607 +  
608 +  // keep the linked lists in the mpi version
609 +
610 + #else // is_mpi
611 +
612 +  // delete the linked lists in the single processor version
613 +
614 +  if( headAtomType != NULL ) delete headAtomType;
615 +  if( headBondType != NULL ) delete headBondType;
616 +  if( headBendType != NULL ) delete headBendType;
617 +  if( headTorsionType != NULL ) delete headTorsionType;
618 +
619 + #endif // is_mpi
620 + }
621 +
622 +
623   void TraPPE_ExFF::initForceField( int ljMixRule ){
624    
625    initFortran( ljMixRule, entry_plug->useReactionField );
626   }
627  
628  
629 < void TraPPE_ExFF::initializeAtoms( void ){
274 <  
275 <  class LinkedType {
276 <  public:
277 <    LinkedType(){
278 <      next = NULL;
279 <      name[0] = '\0';
280 <    }
281 <    ~LinkedType(){ if( next != NULL ) delete next; }
629 > void TraPPE_ExFF::readParams( void ){
630  
631 <    LinkedType* find(char* key){
284 <      if( !strcmp(name, key) ) return this;
285 <      if( next != NULL ) return next->find(key);
286 <      return NULL;
287 <    }
288 <    
289 <    void add( atomStruct &info ){
290 <
291 <      // check for duplicates
292 <      
293 <      if( !strcmp( info.name, name ) ){
294 <        sprintf( painCave.errMsg,
295 <                 "Duplicate TraPPE_Ex atom type \"%s\" found in "
296 <                 "the TraPPE_ExFF param file./n",
297 <                 name );
298 <        painCave.isFatal = 1;
299 <        simError();
300 <      }
301 <
302 <      if( next != NULL ) next->add(info);
303 <      else{
304 <        next = new LinkedType();
305 <        strcpy(next->name, info.name);
306 <        next->isDipole = info.isDipole;
307 <        next->isSSD    = info.isSSD;
308 <        next->mass     = info.mass;
309 <        next->epslon   = info.epslon;
310 <        next->sigma    = info.sigma;
311 <        next->dipole   = info.dipole;
312 <        next->w0       = info.w0;
313 <        next->v0       = info.v0;
314 <        next->ident    = info.ident;
315 <      }
316 <    }
317 <
318 < #ifdef IS_MPI
319 <    
320 <    void duplicate( atomStruct &info ){
321 <      strcpy(info.name, name);
322 <      info.isDipole = isDipole;
323 <      info.isSSD    = isSSD;
324 <      info.mass     = mass;
325 <      info.epslon   = epslon;
326 <      info.sigma    = sigma;
327 <      info.dipole   = dipole;
328 <      info.w0       = w0;
329 <      info.v0       = v0;
330 <      info.last     = 0;
331 <    }
332 <
333 <
334 < #endif
335 <
336 <    char name[15];
337 <    int isDipole;
338 <    int isSSD;
339 <    double mass;
340 <    double epslon;
341 <    double sigma;
342 <    double dipole;
343 <    double w0;
344 <    double v0;
345 <    int ident;
346 <    LinkedType* next;
347 <  };
348 <  
349 <  LinkedType* headAtomType;
350 <  LinkedType* currentAtomType;
351 <  atomStruct info;
352 <  info.last = 1; // initialize last to have the last set.
353 <                 // if things go well, last will be set to 0
354 <
355 <  
356 <
357 <  int i;
631 >  int i, a, b, c, d;
632    int identNum;
633 +  char* atomA;
634 +  char* atomB;
635 +  char* atomC;
636 +  char* atomD;
637    
638 <  Atom** the_atoms;
639 <  int nAtoms;
640 <  the_atoms = entry_plug->atoms;
641 <  nAtoms = entry_plug->n_atoms;
638 >  atomStruct atomInfo;
639 >  bondStruct bondInfo;
640 >  bendStruct bendInfo;
641 >  torsionStruct torsionInfo;
642    
643 <  //////////////////////////////////////////////////
366 <  // a quick water fix
643 >  bigSigma = 0.0;
644  
645 <  double waterI[3][3];
646 <  waterI[0][0] = 1.76958347772500;
647 <  waterI[0][1] = 0.0;
648 <  waterI[0][2] = 0.0;
645 >  atomInfo.last = 1;
646 >  bondInfo.last = 1;
647 >  bendInfo.last = 1;
648 >  torsionInfo.last = 1;
649  
650 <  waterI[1][0] = 0.0;
374 <  waterI[1][1] = 0.614537057924513;
375 <  waterI[1][2] = 0.0;
376 <
377 <  waterI[2][0] = 0.0;
378 <  waterI[2][1] = 0.0;
379 <  waterI[2][2] = 1.15504641980049;
380 <
381 <
382 <  double headI[3][3];
383 <  headI[0][0] = 1125;
384 <  headI[0][1] = 0.0;
385 <  headI[0][2] = 0.0;
386 <
387 <  headI[1][0] = 0.0;
388 <  headI[1][1] = 1125;
389 <  headI[1][2] = 0.0;
390 <
391 <  headI[2][0] = 0.0;
392 <  headI[2][1] = 0.0;
393 <  headI[2][2] = 250;
394 <
650 >  // read in the atom info
651    
396
397  //////////////////////////////////////////////////
398
399
652   #ifdef IS_MPI
653    if( worldRank == 0 ){
654   #endif
655      
656      // read in the atom types.
405
406    headAtomType = new LinkedType;
657      
658 +    headAtomType = new LinkedAtomType;
659 +    
660      fastForward( "AtomTypes", "initializeAtoms" );
661  
662      // we are now at the AtomTypes section.
# Line 431 | Line 683 | void TraPPE_ExFF::initializeAtoms( void ){
683        if( readLine[0] != '!' ){
684          
685          // the parser returns 0 if the line was blank
686 <        if( parseAtom( readLine, lineNum, info ) ){
687 <          info.ident = identNum;
688 <          headAtomType->add( info );;
686 >        if( parseAtom( readLine, lineNum, atomInfo ) ){
687 >          atomInfo.ident = identNum;
688 >          headAtomType->add( atomInfo );;
689            identNum++;
690          }
691        }
# Line 451 | Line 703 | void TraPPE_ExFF::initializeAtoms( void ){
703  
704      currentAtomType = headAtomType->next; //skip the first element who is a place holder.
705      while( currentAtomType != NULL ){
706 <      currentAtomType->duplicate( info );
706 >      currentAtomType->duplicate( atomInfo );
707  
708  
709  
710 <      sendFrcStruct( &info, mpiAtomStructType );
710 >      sendFrcStruct( &atomInfo, mpiAtomStructType );
711  
712        sprintf( checkPointMsg,
713                 "successfully sent TraPPE_Ex force type: \"%s\"\n",
714 <               info.name );
714 >               atomInfo.name );
715        MPIcheckPoint();
716  
717        currentAtomType = currentAtomType->next;
718      }
719 <    info.last = 1;
720 <    sendFrcStruct( &info, mpiAtomStructType );
719 >    atomInfo.last = 1;
720 >    sendFrcStruct( &atomInfo, mpiAtomStructType );
721      
722    }
723  
# Line 475 | Line 727 | void TraPPE_ExFF::initializeAtoms( void ){
727      
728      MPIcheckPoint();
729  
730 <    headAtomType = new LinkedType;
731 <    recieveFrcStruct( &info, mpiAtomStructType );
730 >    headAtomType = new LinkedAtomType;
731 >    recieveFrcStruct( &atomInfo, mpiAtomStructType );
732      
733 <    while( !info.last ){
733 >    while( !atomInfo.last ){
734  
735  
736  
737 <      headAtomType->add( info );
737 >      headAtomType->add( atomInfo );
738        
739        MPIcheckPoint();
740  
741 <      recieveFrcStruct( &info, mpiAtomStructType );
741 >      recieveFrcStruct( &atomInfo, mpiAtomStructType );
742      }
743    }
744 +
745   #endif // is_mpi
746  
747 +
748 +
749    // call new A_types in fortran
750    
751    int isError;
# Line 502 | Line 757 | void TraPPE_ExFF::initializeAtoms( void ){
757    double GB_dummy = 0.0;
758    
759    
760 <  currentAtomType = headAtomType;
760 >  currentAtomType = headAtomType->next;;
761    while( currentAtomType != NULL ){
762      
508    if(currentAtomType->isDipole) entry_plug->useReactionField = 1;
763      if(currentAtomType->isDipole) entry_plug->useDipole = 1;
764      if(currentAtomType->isSSD)    entry_plug->useSticky = 1;
765  
# Line 546 | Line 800 | void TraPPE_ExFF::initializeAtoms( void ){
800   #endif // is_mpi
801  
802    
549  // initialize the atoms
550  
551  double bigSigma = 0.0;
552  DirectionalAtom* dAtom;
803  
804 <  for( i=0; i<nAtoms; i++ ){
804 >  // read in the bonds
805 >  
806 > #ifdef IS_MPI
807 >  if( worldRank == 0 ){
808 > #endif
809      
810 <    currentAtomType = headAtomType->find( the_atoms[i]->getType() );
811 <    if( currentAtomType == NULL ){
810 >    // read in the bond types.
811 >    
812 >    headBondType = new LinkedBondType;
813 >    
814 >    fastForward( "BondTypes", "initializeBonds" );
815 >
816 >    // we are now at the bondTypes section
817 >
818 >    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
819 >    lineNum++;
820 >    
821 >    
822 >    // read a line, and start parseing out the atom types
823 >
824 >    if( eof_test == NULL ){
825        sprintf( painCave.errMsg,
826 <               "AtomType error, %s not found in force file.\n",
827 <               the_atoms[i]->getType() );
826 >               "Error in reading bonds from force file at line %d.\n",
827 >               lineNum );
828        painCave.isFatal = 1;
829        simError();
830      }
831      
832 <    the_atoms[i]->setMass( currentAtomType->mass );
833 <    the_atoms[i]->setEpslon( currentAtomType->epslon );
567 <    the_atoms[i]->setSigma( currentAtomType->sigma );
568 <    the_atoms[i]->setIdent( currentAtomType->ident );
569 <    the_atoms[i]->setLJ();
832 >    // stop reading at end of file, or at next section
833 >    while( readLine[0] != '#' && eof_test != NULL ){
834  
835 <    if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma;
836 <
573 <    if( currentAtomType->isDipole ){
574 <      if( the_atoms[i]->isDirectional() ){
835 >      // toss comment lines
836 >      if( readLine[0] != '!' ){
837          
838 <        dAtom = (DirectionalAtom *) the_atoms[i];
839 <        dAtom->setMu( currentAtomType->dipole );
840 <        dAtom->setHasDipole( 1 );
579 <        dAtom->setJx( 0.0 );
580 <        dAtom->setJy( 0.0 );
581 <        dAtom->setJz( 0.0 );
582 <        
583 <        if(!strcmp("SSD",the_atoms[i]->getType())){
584 <          dAtom->setI( waterI );
585 <          dAtom->setSSD( 1 );
838 >        // the parser returns 0 if the line was blank
839 >        if( parseBond( readLine, lineNum, bondInfo ) ){
840 >          headBondType->add( bondInfo );
841          }
587        else if(!strcmp("HEAD",the_atoms[i]->getType())){
588          dAtom->setI( headI );
589          dAtom->setSSD( 0 );
590        }
591        else{
592          sprintf(painCave.errMsg,
593                  "AtmType error, %s does not have a moment of inertia set.\n",
594                  the_atoms[i]->getType() );
595          painCave.isFatal = 1;
596          simError();
597        }
598        entry_plug->n_dipoles++;
842        }
843 <      else{
844 <        
602 <        sprintf( painCave.errMsg,
603 <                "TraPPE_ExFF error: Atom \"%s\" is a dipole, yet no standard"
604 <                 " orientation was specifed in the BASS file.\n",
605 <                 currentAtomType->name );
606 <        painCave.isFatal = 1;
607 <        simError();
608 <      }
843 >      eof_test = fgets( readLine, sizeof(readLine), frcFile );
844 >      lineNum++;
845      }
846 <    else{
847 <      if( the_atoms[i]->isDirectional() ){
848 <        sprintf( painCave.errMsg,
849 <                 "TraPPE_ExFF error: Atom \"%s\" was given a standard"
850 <                 "orientation in the BASS file, yet it is not a dipole.\n",
851 <                 currentAtomType->name);
852 <        painCave.isFatal = 1;
853 <        simError();
854 <      }
846 >        
847 > #ifdef IS_MPI
848 >    
849 >    // send out the linked list to all the other processes
850 >    
851 >    sprintf( checkPointMsg,
852 >             "TraPPE_Ex bond structures read successfully." );
853 >    MPIcheckPoint();
854 >    
855 >    currentBondType = headBondType->next;
856 >    while( currentBondType != NULL ){
857 >      currentBondType->duplicate( bondInfo );
858 >      sendFrcStruct( &bondInfo, mpiBondStructType );
859 >      currentBondType = currentBondType->next;
860      }
861 +    bondInfo.last = 1;
862 +    sendFrcStruct( &bondInfo, mpiBondStructType );
863 +    
864    }
865  
866 < #ifdef IS_MPI
867 <  double tempBig = bigSigma;
868 <  MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX );
869 < #endif  //is_mpi
866 >  else{
867 >    
868 >    // listen for node 0 to send out the force params
869 >    
870 >    MPIcheckPoint();
871  
872 <  //calc rCut and rList
872 >    headBondType = new LinkedBondType;
873 >    recieveFrcStruct( &bondInfo, mpiBondStructType );
874 >    while( !bondInfo.last ){
875  
876 <  entry_plug->rCut = 2.5 * bigSigma;
876 >      headBondType->add( bondInfo );
877 >      recieveFrcStruct( &bondInfo, mpiBondStructType );
878 >    }
879 >  }
880 > #endif // is_mpi
881    
631  if(entry_plug->rCut > (entry_plug->box_x / 2.0))
632    entry_plug->rCut = entry_plug->box_x / 2.0;
633  
634  if(entry_plug->rCut > (entry_plug->box_y / 2.0))
635    entry_plug->rCut = entry_plug->box_y / 2.0;
636  
637  if(entry_plug->rCut > (entry_plug->box_z / 2.0))
638    entry_plug->rCut = entry_plug->box_z / 2.0;
882  
883 <  entry_plug->rList = entry_plug->rCut + 1.0;
883 >  // read in the bends
884  
642  entry_plug->useLJ = 1; // use Lennard Jones is on by default
643
644  // clean up the memory
645  
646  delete headAtomType;
647
885   #ifdef IS_MPI
886 <  sprintf( checkPointMsg, "TraPPE_Ex atoms initialized succesfully" );
887 <  MPIcheckPoint();
651 < #endif // is_mpi
886 >  if( worldRank == 0 ){
887 > #endif
888  
889 < }
889 >    // read in the bend types.
890  
891 < void TraPPE_ExFF::initializeBonds( bond_pair* the_bonds ){
656 <  
657 <  class LinkedType {
658 <  public:
659 <    LinkedType(){
660 <      next = NULL;
661 <      nameA[0] = '\0';
662 <      nameB[0] = '\0';
663 <      type[0] = '\0';
664 <    }
665 <    ~LinkedType(){ if( next != NULL ) delete next; }
666 <
667 <    LinkedType* find(char* key1, char* key2){
668 <      if( !strcmp(nameA, key1 ) && !strcmp( nameB, key2 ) ) return this;
669 <      if( !strcmp(nameA, key2 ) && !strcmp( nameB, key1 ) ) return this;
670 <      if( next != NULL ) return next->find(key1, key2);
671 <      return NULL;
672 <    }
891 >    headBendType = new LinkedBendType;
892      
893 +    fastForward( "BendTypes", "initializeBends" );
894  
895 <    void add( bondStruct &info ){
676 <      
677 <      // check for duplicates
678 <      int dup = 0;
895 >    // we are now at the bendTypes section
896  
897 <      if( !strcmp(nameA, info.nameA ) && !strcmp( nameB, info.nameB ) ) dup = 1;
898 <      if( !strcmp(nameA, info.nameB ) && !strcmp( nameB, info.nameA ) ) dup = 1;
899 <      
900 <      if(dup){
684 <        sprintf( painCave.errMsg,
685 <                 "Duplicate TraPPE_Ex bond type \"%s - %s\" found in "
686 <                 "the TraPPE_ExFF param file./n",
687 <                 nameA, nameB );
688 <        painCave.isFatal = 1;
689 <        simError();
690 <      }
897 >    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
898 >    lineNum++;
899 >        
900 >    // read a line, and start parseing out the bend types
901  
902 +    if( eof_test == NULL ){
903 +      sprintf( painCave.errMsg,
904 +               "Error in reading bends from force file at line %d.\n",
905 +               lineNum );
906 +      painCave.isFatal = 1;
907 +      simError();
908 +    }
909 +    
910 +    // stop reading at end of file, or at next section
911 +    while( readLine[0] != '#' && eof_test != NULL ){
912 +      
913 +      // toss comment lines
914 +      if( readLine[0] != '!' ){
915          
916 <      if( next != NULL ) next->add(info);
917 <      else{
918 <        next = new LinkedType();
919 <        strcpy(next->nameA, info.nameA);
697 <        strcpy(next->nameB, info.nameB);
698 <        strcpy(next->type,  info.type);
699 <        next->d0 = info.d0;
916 >        // the parser returns 0 if the line was blank
917 >        if( parseBend( readLine, lineNum, bendInfo ) ){
918 >          headBendType->add( bendInfo );
919 >        }
920        }
921 +      eof_test = fgets( readLine, sizeof(readLine), frcFile );
922 +      lineNum++;
923      }
924      
925   #ifdef IS_MPI
926 <    void duplicate( bondStruct &info ){
927 <      strcpy(info.nameA, nameA);
706 <      strcpy(info.nameB, nameB);
707 <      strcpy(info.type,  type);
708 <      info.d0   = d0;
709 <      info.last = 0;
710 <    }
926 >    
927 >    // send out the linked list to all the other processes
928  
929 +    sprintf( checkPointMsg,
930 +             "TraPPE_Ex bend structures read successfully." );
931 +    MPIcheckPoint();
932  
933 < #endif
933 >    currentBendType = headBendType->next;
934 >    while( currentBendType != NULL ){
935 >      currentBendType->duplicate( bendInfo );
936 >      sendFrcStruct( &bendInfo, mpiBendStructType );
937 >      currentBendType = currentBendType->next;
938 >    }
939 >    bendInfo.last = 1;
940 >    sendFrcStruct( &bendInfo, mpiBendStructType );
941 >    
942 >  }
943  
944 <    char nameA[15];
945 <    char nameB[15];
946 <    char type[30];
947 <    double d0;
944 >  else{
945 >    
946 >    // listen for node 0 to send out the force params
947 >    
948 >    MPIcheckPoint();
949  
950 <    LinkedType* next;
951 <  };
950 >    headBendType = new LinkedBendType;
951 >    recieveFrcStruct( &bendInfo, mpiBendStructType );
952 >    while( !bendInfo.last ){
953  
954 +      headBendType->add( bendInfo );
955 +      recieveFrcStruct( &bendInfo, mpiBendStructType );
956 +    }
957 +  }
958 + #endif // is_mpi
959  
724  
725  LinkedType* headBondType;
726  LinkedType* currentBondType;
727  bondStruct info;
728  info.last = 1; // initialize last to have the last set.
729                 // if things go well, last will be set to 0
960  
961 <  SRI **the_sris;
732 <  Atom** the_atoms;
733 <  int nBonds;
734 <  the_sris = entry_plug->sr_interactions;
735 <  the_atoms = entry_plug->atoms;
736 <  nBonds = entry_plug->n_bonds;
961 >  // read in the torsions
962  
738  int i, a, b;
739  char* atomA;
740  char* atomB;
741  
963   #ifdef IS_MPI
964    if( worldRank == 0 ){
965   #endif
966 +
967 +    // read in the torsion types.
968 +
969 +    headTorsionType = new LinkedTorsionType;
970      
971 <    // read in the bond types.
747 <    
748 <    headBondType = new LinkedType;
749 <    
750 <    fastForward( "BondTypes", "initializeBonds" );
971 >    fastForward( "TorsionTypes", "initializeTorsions" );
972  
973 <    // we are now at the bondTypes section
973 >    // we are now at the torsionTypes section
974  
975      eof_test =  fgets( readLine, sizeof(readLine), frcFile );
976      lineNum++;
# Line 759 | Line 980 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
980  
981      if( eof_test == NULL ){
982        sprintf( painCave.errMsg,
983 <               "Error in reading bonds from force file at line %d.\n",
983 >               "Error in reading torsions from force file at line %d.\n",
984                 lineNum );
985        painCave.isFatal = 1;
986        simError();
# Line 772 | Line 993 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
993        if( readLine[0] != '!' ){
994          
995          // the parser returns 0 if the line was blank
996 <        if( parseBond( readLine, lineNum, info ) ){
997 <          headBondType->add( info );
996 >        if( parseTorsion( readLine, lineNum, torsionInfo ) ){
997 >          headTorsionType->add( torsionInfo );
998 >
999          }
1000        }
1001        eof_test = fgets( readLine, sizeof(readLine), frcFile );
1002        lineNum++;
1003      }
1004 <        
1004 >
1005   #ifdef IS_MPI
1006      
1007      // send out the linked list to all the other processes
1008      
1009      sprintf( checkPointMsg,
1010 <             "TraPPE_Ex bond structures read successfully." );
1010 >             "TraPPE_Ex torsion structures read successfully." );
1011      MPIcheckPoint();
1012      
1013 <    currentBondType = headBondType;
1014 <    while( currentBondType != NULL ){
1015 <      currentBondType->duplicate( info );
1016 <      sendFrcStruct( &info, mpiBondStructType );
1017 <      currentBondType = currentBondType->next;
1013 >    currentTorsionType = headTorsionType->next;
1014 >    while( currentTorsionType != NULL ){
1015 >      currentTorsionType->duplicate( torsionInfo );
1016 >      sendFrcStruct( &torsionInfo, mpiTorsionStructType );
1017 >      currentTorsionType = currentTorsionType->next;
1018      }
1019 <    info.last = 1;
1020 <    sendFrcStruct( &info, mpiBondStructType );
1019 >    torsionInfo.last = 1;
1020 >    sendFrcStruct( &torsionInfo, mpiTorsionStructType );
1021      
1022    }
1023  
# Line 805 | Line 1027 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
1027      
1028      MPIcheckPoint();
1029  
1030 <    headBondType = new LinkedType;
1031 <    recieveFrcStruct( &info, mpiBondStructType );
1032 <    while( !info.last ){
1030 >    headTorsionType = new LinkedTorsionType;
1031 >    recieveFrcStruct( &torsionInfo, mpiTorsionStructType );
1032 >    while( !torsionInfo.last ){
1033  
1034 <      headBondType->add( info );
1035 <      recieveFrcStruct( &info, mpiBondStructType );
1034 >      headTorsionType->add( torsionInfo );
1035 >      recieveFrcStruct( &torsionInfo, mpiTorsionStructType );
1036      }
1037    }
1038   #endif // is_mpi
1039 +
1040 +  entry_plug->useLJ = 1;
1041 + }
1042 +
1043 +
1044 +
1045 + void TraPPE_ExFF::initializeAtoms( int nAtoms, Atom** the_atoms ){
1046    
1047    
1048 <  // initialize the Bonds
1048 >  //////////////////////////////////////////////////
1049 >  // a quick water fix
1050 >
1051 >  double waterI[3][3];
1052 >  waterI[0][0] = 1.76958347772500;
1053 >  waterI[0][1] = 0.0;
1054 >  waterI[0][2] = 0.0;
1055 >
1056 >  waterI[1][0] = 0.0;
1057 >  waterI[1][1] = 0.614537057924513;
1058 >  waterI[1][2] = 0.0;
1059 >
1060 >  waterI[2][0] = 0.0;
1061 >  waterI[2][1] = 0.0;
1062 >  waterI[2][2] = 1.15504641980049;
1063 >
1064 >
1065 >  double headI[3][3];
1066 >  headI[0][0] = 1125;
1067 >  headI[0][1] = 0.0;
1068 >  headI[0][2] = 0.0;
1069 >
1070 >  headI[1][0] = 0.0;
1071 >  headI[1][1] = 1125;
1072 >  headI[1][2] = 0.0;
1073 >
1074 >  headI[2][0] = 0.0;
1075 >  headI[2][1] = 0.0;
1076 >  headI[2][2] = 250;
1077 >
1078 >  //////////////////////////////////////////////////
1079 >
1080    
1081 +  // initialize the atoms
1082 +  
1083 +  DirectionalAtom* dAtom;
1084  
1085 +  for(int i=0; i<nAtoms; i++ ){
1086 +
1087 +    currentAtomType = headAtomType->find( the_atoms[i]->getType() );
1088 +    if( currentAtomType == NULL ){
1089 +      sprintf( painCave.errMsg,
1090 +               "AtomType error, %s not found in force file.\n",
1091 +               the_atoms[i]->getType() );
1092 +      painCave.isFatal = 1;
1093 +      simError();
1094 +    }
1095 +    
1096 +    the_atoms[i]->setMass( currentAtomType->mass );
1097 +    the_atoms[i]->setEpslon( currentAtomType->epslon );
1098 +    the_atoms[i]->setSigma( currentAtomType->sigma );
1099 +    the_atoms[i]->setIdent( currentAtomType->ident );
1100 +    the_atoms[i]->setLJ();
1101 +
1102 +    if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma;
1103 +
1104 +    if( currentAtomType->isDipole ){
1105 +      if( the_atoms[i]->isDirectional() ){
1106 +        
1107 +        dAtom = (DirectionalAtom *) the_atoms[i];
1108 +        dAtom->setMu( currentAtomType->dipole );
1109 +        dAtom->setHasDipole( 1 );
1110 +        dAtom->setJx( 0.0 );
1111 +        dAtom->setJy( 0.0 );
1112 +        dAtom->setJz( 0.0 );
1113 +        
1114 +        if(!strcmp("SSD",the_atoms[i]->getType())){
1115 +          dAtom->setI( waterI );
1116 +          dAtom->setSSD( 1 );
1117 +        }
1118 +        else if(!strcmp("HEAD",the_atoms[i]->getType())){
1119 +          dAtom->setI( headI );
1120 +          dAtom->setSSD( 0 );
1121 +        }
1122 +        else{
1123 +          sprintf(painCave.errMsg,
1124 +                  "AtmType error, %s does not have a moment of inertia set.\n",
1125 +                  the_atoms[i]->getType() );
1126 +          painCave.isFatal = 1;
1127 +          simError();
1128 +        }
1129 +        entry_plug->n_dipoles++;
1130 +      }
1131 +      else{
1132 +        
1133 +        sprintf( painCave.errMsg,
1134 +                "TraPPE_ExFF error: Atom \"%s\" is a dipole, yet no standard"
1135 +                 " orientation was specifed in the BASS file.\n",
1136 +                 currentAtomType->name );
1137 +        painCave.isFatal = 1;
1138 +        simError();
1139 +      }
1140 +    }
1141 +    else{
1142 +      if( the_atoms[i]->isDirectional() ){
1143 +        sprintf( painCave.errMsg,
1144 +                 "TraPPE_ExFF error: Atom \"%s\" was given a standard"
1145 +                 "orientation in the BASS file, yet it is not a dipole.\n",
1146 +                 currentAtomType->name);
1147 +        painCave.isFatal = 1;
1148 +        simError();
1149 +      }
1150 +    }
1151 +  }
1152 + }
1153 +
1154 + void TraPPE_ExFF::initializeBonds( int nBonds, Bond** bondArray,
1155 +                                   bond_pair* the_bonds ){
1156 +  int i,a,b;
1157 +  char* atomA;
1158 +  char* atomB;
1159 +  
1160 +  Atom** the_atoms;
1161 +  the_atoms = entry_plug->atoms;
1162 +  
1163 +
1164 +  // initialize the Bonds
1165 +  
1166    for( i=0; i<nBonds; i++ ){
1167      
1168      a = the_bonds[i].a;
# Line 837 | Line 1181 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
1181      
1182      if( !strcmp( currentBondType->type, "fixed" ) ){
1183        
1184 <      the_sris[i] = new ConstrainedBond( *the_atoms[a],
1185 <                                         *the_atoms[b],
1186 <                                         currentBondType->d0 );
1184 >      bondArray[i] = new ConstrainedBond( *the_atoms[a],
1185 >                                          *the_atoms[b],
1186 >                                          currentBondType->d0 );
1187        entry_plug->n_constraints++;
1188      }
1189    }
846
847
848  // clean up the memory
849  
850  delete headBondType;
851
852 #ifdef IS_MPI
853  sprintf( checkPointMsg, "TraPPE_Ex bonds initialized succesfully" );
854  MPIcheckPoint();
855 #endif // is_mpi
856
1190   }
1191  
1192 < void TraPPE_ExFF::initializeBends( bend_set* the_bends ){
1193 <  
861 <  class LinkedType {
862 <  public:
863 <    LinkedType(){
864 <      next = NULL;
865 <      nameA[0] = '\0';
866 <      nameB[0] = '\0';
867 <      nameC[0] = '\0';
868 <      type[0] = '\0';
869 <    }
870 <    ~LinkedType(){ if( next != NULL ) delete next; }
871 <
872 <    LinkedType* find( char* key1, char* key2, char* key3 ){
873 <      if( !strcmp( nameA, key1 ) && !strcmp( nameB, key2 )
874 <          && !strcmp( nameC, key3 ) ) return this;
875 <      if( !strcmp( nameA, key3 ) && !strcmp( nameB, key2 )
876 <          && !strcmp( nameC, key1 ) ) return this;
877 <      if( next != NULL ) return next->find(key1, key2, key3);
878 <      return NULL;
879 <    }
880 <    
881 <    void add( bendStruct &info ){
882 <
883 <      // check for duplicates
884 <      int dup = 0;
885 <      
886 <      if( !strcmp( nameA, info.nameA ) && !strcmp( nameB, info.nameB )
887 <          && !strcmp( nameC, info.nameC ) ) dup = 1;
888 <      if( !strcmp( nameA, info.nameC ) && !strcmp( nameB, info.nameB )
889 <          && !strcmp( nameC, info.nameA ) ) dup = 1;
890 <
891 <      if(dup){
892 <        sprintf( painCave.errMsg,
893 <                 "Duplicate TraPPE_Ex bend type \"%s - %s - %s\" found in "
894 <                 "the TraPPE_ExFF param file./n",
895 <                 nameA, nameB, nameC );
896 <        painCave.isFatal = 1;
897 <        simError();
898 <      }
899 <
900 <      if( next != NULL ) next->add(info);
901 <      else{
902 <        next = new LinkedType();
903 <        strcpy(next->nameA, info.nameA);
904 <        strcpy(next->nameB, info.nameB);
905 <        strcpy(next->nameC, info.nameC);
906 <        strcpy(next->type,  info.type);
907 <        next->k1 = info.k1;
908 <        next->k2 = info.k2;
909 <        next->k3 = info.k3;
910 <        next->t0 = info.t0;
911 <      }
912 <    }
913 <
914 < #ifdef IS_MPI    
915 <
916 <    void duplicate( bendStruct &info ){
917 <      strcpy(info.nameA, nameA);
918 <      strcpy(info.nameB, nameB);
919 <      strcpy(info.nameC, nameC);
920 <      strcpy(info.type,  type);
921 <      info.k1   = k1;
922 <      info.k2   = k2;
923 <      info.k3   = k3;
924 <      info.t0   = t0;
925 <      info.last = 0;
926 <    }
927 <
928 < #endif // is_mpi
929 <
930 <    char nameA[15];
931 <    char nameB[15];
932 <    char nameC[15];
933 <    char type[30];
934 <    double k1, k2, k3, t0;
935 <
936 <    LinkedType* next;
937 <  };
1192 > void TraPPE_ExFF::initializeBends( int nBends, Bend** bendArray,
1193 >                                   bend_set* the_bends ){
1194    
939  LinkedType* headBendType;
940  LinkedType* currentBendType;
941  bendStruct info;
942  info.last = 1; // initialize last to have the last set.
943                 // if things go well, last will be set to 0
944
1195    QuadraticBend* qBend;
1196    GhostBend* gBend;
947  SRI **the_sris;
1197    Atom** the_atoms;
949  int nBends;
950  the_sris = entry_plug->sr_interactions;
1198    the_atoms = entry_plug->atoms;
1199 <  nBends = entry_plug->n_bends;
953 <
1199 >  
1200    int i, a, b, c;
1201    char* atomA;
1202    char* atomB;
1203    char* atomC;
958
959
960 #ifdef IS_MPI
961  if( worldRank == 0 ){
962 #endif
963
964    // read in the bend types.
965
966    headBendType = new LinkedType;
967    
968    fastForward( "BendTypes", "initializeBends" );
969
970    // we are now at the bendTypes section
971
972    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
973    lineNum++;
974        
975    // read a line, and start parseing out the bend types
976
977    if( eof_test == NULL ){
978      sprintf( painCave.errMsg,
979               "Error in reading bends from force file at line %d.\n",
980               lineNum );
981      painCave.isFatal = 1;
982      simError();
983    }
984    
985    // stop reading at end of file, or at next section
986    while( readLine[0] != '#' && eof_test != NULL ){
987      
988      // toss comment lines
989      if( readLine[0] != '!' ){
990        
991        // the parser returns 0 if the line was blank
992        if( parseBend( readLine, lineNum, info ) ){
993          headBendType->add( info );
994        }
995      }
996      eof_test = fgets( readLine, sizeof(readLine), frcFile );
997      lineNum++;
998    }
999    
1000 #ifdef IS_MPI
1001    
1002    // send out the linked list to all the other processes
1003
1004    sprintf( checkPointMsg,
1005             "TraPPE_Ex bend structures read successfully." );
1006    MPIcheckPoint();
1007
1008    currentBendType = headBendType;
1009    while( currentBendType != NULL ){
1010      currentBendType->duplicate( info );
1011      sendFrcStruct( &info, mpiBendStructType );
1012      currentBendType = currentBendType->next;
1013    }
1014    info.last = 1;
1015    sendFrcStruct( &info, mpiBendStructType );
1016    
1017  }
1018
1019  else{
1020    
1021    // listen for node 0 to send out the force params
1022    
1023    MPIcheckPoint();
1024
1025    headBendType = new LinkedType;
1026    recieveFrcStruct( &info, mpiBendStructType );
1027    while( !info.last ){
1028
1029      headBendType->add( info );
1030      recieveFrcStruct( &info, mpiBendStructType );
1031    }
1032  }
1033 #endif // is_mpi
1204    
1205    // initialize the Bends
1036  
1037  int index;
1206  
1207    for( i=0; i<nBends; i++ ){
1208      
# Line 1059 | Line 1227 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
1227      
1228      if( !strcmp( currentBendType->type, "quadratic" ) ){
1229        
1062      index = i + entry_plug->n_bonds;
1063      
1230        if( the_bends[i].isGhost){
1231          
1232          if( the_bends[i].ghost == b ){
# Line 1088 | Line 1254 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
1254                               currentBendType->k2,
1255                               currentBendType->k3,
1256                               currentBendType->t0 );
1257 <        the_sris[index] = gBend;
1257 >        bendArray[i] = gBend;
1258        }
1259        else{
1260          qBend = new QuadraticBend( *the_atoms[a],
# Line 1098 | Line 1264 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
1264                               currentBendType->k2,
1265                               currentBendType->k3,
1266                               currentBendType->t0 );
1267 <        the_sris[index] = qBend;
1267 >        bendArray[i] = qBend;
1268        }
1269      }
1270    }
1105
1106
1107  // clean up the memory
1108  
1109  delete headBendType;
1110
1111 #ifdef IS_MPI
1112  sprintf( checkPointMsg, "TraPPE_Ex bends initialized succesfully" );
1113  MPIcheckPoint();
1114 #endif // is_mpi
1115
1271   }
1272  
1273 < void TraPPE_ExFF::initializeTorsions( torsion_set* the_torsions ){
1273 > void TraPPE_ExFF::initializeTorsions( int nTorsions, Torsion** torsionArray,
1274 >                                      torsion_set* the_torsions ){
1275  
1276 <  class LinkedType {
1121 <  public:
1122 <    LinkedType(){
1123 <      next = NULL;
1124 <      nameA[0] = '\0';
1125 <      nameB[0] = '\0';
1126 <      nameC[0] = '\0';
1127 <      type[0] = '\0';
1128 <    }
1129 <    ~LinkedType(){ if( next != NULL ) delete next; }
1130 <
1131 <    LinkedType* find( char* key1, char* key2, char* key3, char* key4 ){
1132 <      
1133 <
1134 <
1135 <
1136 <      if( !strcmp( nameA, key1 ) && !strcmp( nameB, key2 ) &&
1137 <          !strcmp( nameC, key3 ) && !strcmp( nameD, key4 ) ) return this;
1138 <
1139 <      if( !strcmp( nameA, key4 ) && !strcmp( nameB, key3 ) &&
1140 <          !strcmp( nameC, key2 ) && !strcmp( nameD, key1 ) ) return this;
1141 <
1142 <      if( next != NULL ) return next->find(key1, key2, key3, key4);
1143 <      return NULL;
1144 <    }
1145 <
1146 <    void add( torsionStruct &info ){
1147 <
1148 <      // check for duplicates
1149 <      int dup = 0;
1150 <
1151 <      if( !strcmp( nameA, info.nameA ) && !strcmp( nameB, info.nameB ) &&
1152 <          !strcmp( nameC, info.nameC ) && !strcmp( nameD, info.nameD ) ) dup = 1;
1153 <      
1154 <      if( !strcmp( nameA, info.nameD ) && !strcmp( nameB, info.nameC ) &&
1155 <          !strcmp( nameC, info.nameB ) && !strcmp( nameD, info.nameA ) ) dup = 1;
1156 <      
1157 <      if(dup){
1158 <        sprintf( painCave.errMsg,
1159 <                 "Duplicate TraPPE_Ex torsion type \"%s - %s - %s - %s\" found in "
1160 <                 "the TraPPE_ExFF param file./n", nameA, nameB, nameC, nameD );
1161 <        painCave.isFatal = 1;
1162 <        simError();
1163 <      }
1164 <
1165 <      if( next != NULL ) next->add(info);
1166 <      else{
1167 <        next = new LinkedType();
1168 <        strcpy(next->nameA, info.nameA);
1169 <        strcpy(next->nameB, info.nameB);
1170 <        strcpy(next->nameC, info.nameC);
1171 <        strcpy(next->nameD, info.nameD);
1172 <        strcpy(next->type,  info.type);
1173 <        next->k1 = info.k1;
1174 <        next->k2 = info.k2;
1175 <        next->k3 = info.k3;
1176 <        next->k4 = info.k4;
1177 <
1178 <      }
1179 <    }
1180 <
1181 < #ifdef IS_MPI
1182 <    
1183 <    void duplicate( torsionStruct &info ){
1184 <      strcpy(info.nameA, nameA);
1185 <      strcpy(info.nameB, nameB);
1186 <      strcpy(info.nameC, nameC);
1187 <      strcpy(info.nameD, nameD);
1188 <      strcpy(info.type,  type);
1189 <      info.k1   = k1;
1190 <      info.k2   = k2;
1191 <      info.k3   = k3;
1192 <      info.k4   = k4;
1193 <      info.last = 0;
1194 <    }
1195 <
1196 < #endif
1197 <
1198 <    char nameA[15];
1199 <    char nameB[15];
1200 <    char nameC[15];
1201 <    char nameD[15];
1202 <    char type[30];
1203 <    double k1, k2, k3, k4;
1204 <
1205 <    LinkedType* next;
1206 <  };
1207 <  
1208 <  LinkedType* headTorsionType;
1209 <  LinkedType* currentTorsionType;
1210 <  torsionStruct info;
1211 <  info.last = 1; // initialize last to have the last set.
1212 <                 // if things go well, last will be set to 0
1213 <
1214 <  int i, a, b, c, d, index;
1276 >  int i, a, b, c, d;
1277    char* atomA;
1278    char* atomB;
1279    char* atomC;
1280    char* atomD;
1219  CubicTorsion* cTors;
1281  
1282 <  SRI **the_sris;
1282 >  CubicTorsion* cTors;
1283    Atom** the_atoms;
1223  int nTorsions;
1224  the_sris = entry_plug->sr_interactions;
1284    the_atoms = entry_plug->atoms;
1226  nTorsions = entry_plug->n_torsions;
1227
1228 #ifdef IS_MPI
1229  if( worldRank == 0 ){
1230 #endif
1231
1232    // read in the torsion types.
1233
1234    headTorsionType = new LinkedType;
1235    
1236    fastForward( "TorsionTypes", "initializeTorsions" );
1237
1238    // we are now at the torsionTypes section
1239
1240    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
1241    lineNum++;
1242    
1243    
1244    // read a line, and start parseing out the atom types
1245
1246    if( eof_test == NULL ){
1247      sprintf( painCave.errMsg,
1248               "Error in reading torsions from force file at line %d.\n",
1249               lineNum );
1250      painCave.isFatal = 1;
1251      simError();
1252    }
1253    
1254    // stop reading at end of file, or at next section
1255    while( readLine[0] != '#' && eof_test != NULL ){
1256
1257      // toss comment lines
1258      if( readLine[0] != '!' ){
1259        
1260        // the parser returns 0 if the line was blank
1261        if( parseTorsion( readLine, lineNum, info ) ){
1262          headTorsionType->add( info );
1263
1264        }
1265      }
1266      eof_test = fgets( readLine, sizeof(readLine), frcFile );
1267      lineNum++;
1268    }
1269
1270 #ifdef IS_MPI
1271    
1272    // send out the linked list to all the other processes
1273    
1274    sprintf( checkPointMsg,
1275             "TraPPE_Ex torsion structures read successfully." );
1276    MPIcheckPoint();
1277    
1278    currentTorsionType = headTorsionType;
1279    while( currentTorsionType != NULL ){
1280      currentTorsionType->duplicate( info );
1281      sendFrcStruct( &info, mpiTorsionStructType );
1282      currentTorsionType = currentTorsionType->next;
1283    }
1284    info.last = 1;
1285    sendFrcStruct( &info, mpiTorsionStructType );
1286    
1287  }
1285  
1289  else{
1290    
1291    // listen for node 0 to send out the force params
1292    
1293    MPIcheckPoint();
1294
1295    headTorsionType = new LinkedType;
1296    recieveFrcStruct( &info, mpiTorsionStructType );
1297    while( !info.last ){
1298
1299      headTorsionType->add( info );
1300      recieveFrcStruct( &info, mpiTorsionStructType );
1301    }
1302  }
1303 #endif // is_mpi
1304  
1286    // initialize the Torsions
1287  
1288    for( i=0; i<nTorsions; i++ ){
# Line 1326 | Line 1307 | void TraPPE_ExFF::initializeTorsions( torsion_set* the
1307      }
1308      
1309      if( !strcmp( currentTorsionType->type, "cubic" ) ){
1329      index = i + entry_plug->n_bonds + entry_plug->n_bends;
1310        
1311        cTors = new CubicTorsion( *the_atoms[a], *the_atoms[b],
1312                                  *the_atoms[c], *the_atoms[d] );
1313        cTors->setConstants( currentTorsionType->k1, currentTorsionType->k2,
1314                             currentTorsionType->k3, currentTorsionType->k4 );
1315 <      the_sris[index] = cTors;
1315 >      torsionArray[i] = cTors;
1316      }
1317    }
1338
1339
1340  // clean up the memory
1341  
1342  delete headTorsionType;
1343
1344 #ifdef IS_MPI
1345  sprintf( checkPointMsg, "TraPPE_Ex torsions initialized succesfully" );
1346  MPIcheckPoint();
1347 #endif // is_mpi
1348
1318   }
1319  
1320   void TraPPE_ExFF::fastForward( char* stopText, char* searchOwner ){
# Line 1560 | Line 1529 | int TPE::parseBend( char *lineBuffer, int lineNum, ben
1529  
1530      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1531        sprintf( painCave.errMsg,
1532 <               "Error parseing BondTypes: line %d\n", lineNum );
1532 >               "Error parseing BendTypes: line %d\n", lineNum );
1533        painCave.isFatal = 1;
1534        simError();
1535      }
# Line 1569 | Line 1538 | int TPE::parseBend( char *lineBuffer, int lineNum, ben
1538  
1539      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1540        sprintf( painCave.errMsg,
1541 <               "Error parseing BondTypes: line %d\n", lineNum );
1541 >               "Error parseing BendTypes: line %d\n", lineNum );
1542        painCave.isFatal = 1;
1543        simError();
1544      }
# Line 1578 | Line 1547 | int TPE::parseBend( char *lineBuffer, int lineNum, ben
1547  
1548      if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){
1549        sprintf( painCave.errMsg,
1550 <               "Error parseing BondTypes: line %d\n", lineNum );
1550 >               "Error parseing BendTypes: line %d\n", lineNum );
1551        painCave.isFatal = 1;
1552        simError();
1553      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines