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

Comparing trunk/OOPSE/libmdtools/TraPPE_ExFF.cpp (file contents):
Revision 394 by gezelter, Mon Mar 24 21:55:34 2003 UTC vs.
Revision 463 by gezelter, Sat Apr 5 03:39:25 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::initForceField( int ljMixRule ){
604 > void TraPPE_ExFF::cleanMe( void ){
605 >
606 > #ifdef IS_MPI
607    
608 <  initFortran( ljMixRule, entry_plug->useReactionField );
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::initializeAtoms( void ){
623 > void TraPPE_ExFF::initForceField( int ljMixRule ){
624    
625 <  class LinkedType {
626 <  public:
277 <    LinkedType(){
278 <      next = NULL;
279 <      name[0] = '\0';
280 <    }
281 <    ~LinkedType(){ if( next != NULL ) delete next; }
625 >  initFortran( ljMixRule, entry_plug->useReactionField );
626 > }
627  
628 <    LinkedType* find(char* key){
629 <      if( !strcmp(name, key) ) return this;
285 <      if( next != NULL ) return next->find(key);
286 <      return NULL;
287 <    }
288 <    
289 <    void add( atomStruct &info ){
628 >
629 > void TraPPE_ExFF::readParams( void ){
630  
631 <      // 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      
763      if(currentAtomType->isDipole) entry_plug->useDipole = 1;
764 <    if(currentAtomType->isSSD)    entry_plug->useSticky = 1;
764 >    if(currentAtomType->isSSD) {
765 >      entry_plug->useSticky = 1;
766 >      set_sticky_params( &(currentAtomType->w0), &(currentAtomType->v0));
767 >    }
768  
769      if( currentAtomType->name[0] != '\0' ){
770        isError = 0;
# Line 518 | Line 776 | void TraPPE_ExFF::initializeAtoms( void ){
776                   &(currentAtomType->epslon),
777                   &(currentAtomType->sigma),
778                   &(currentAtomType->dipole),
521                 &(currentAtomType->w0),
522                 &(currentAtomType->v0),
523                 &GB_dummy,
524                 &GB_dummy,
525                 &GB_dummy,
526                 &GB_dummy,
527                 &GB_dummy,
528                 &GB_dummy,
779                   &isError );
780        if( isError ){
781          sprintf( painCave.errMsg,
# Line 545 | Line 795 | void TraPPE_ExFF::initializeAtoms( void ){
795   #endif // is_mpi
796  
797    
548  // initialize the atoms
549  
550  double bigSigma = 0.0;
551  DirectionalAtom* dAtom;
798  
799 <  for( i=0; i<nAtoms; i++ ){
799 >  // read in the bonds
800 >  
801 > #ifdef IS_MPI
802 >  if( worldRank == 0 ){
803 > #endif
804 >    
805 >    // read in the bond types.
806 >    
807 >    headBondType = new LinkedBondType;
808 >    
809 >    fastForward( "BondTypes", "initializeBonds" );
810  
811 +    // we are now at the bondTypes section
812 +
813 +    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
814 +    lineNum++;
815      
816 <    currentAtomType = headAtomType->find( the_atoms[i]->getType() );
817 <    if( currentAtomType == NULL ){
816 >    
817 >    // read a line, and start parseing out the atom types
818 >
819 >    if( eof_test == NULL ){
820        sprintf( painCave.errMsg,
821 <               "AtomType error, %s not found in force file.\n",
822 <               the_atoms[i]->getType() );
821 >               "Error in reading bonds from force file at line %d.\n",
822 >               lineNum );
823        painCave.isFatal = 1;
824        simError();
825      }
826      
827 <    the_atoms[i]->setMass( currentAtomType->mass );
828 <    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();
827 >    // stop reading at end of file, or at next section
828 >    while( readLine[0] != '#' && eof_test != NULL ){
829  
830 <    if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma;
831 <
573 <    if( currentAtomType->isDipole ){
574 <      if( the_atoms[i]->isDirectional() ){
830 >      // toss comment lines
831 >      if( readLine[0] != '!' ){
832          
833 <        dAtom = (DirectionalAtom *) the_atoms[i];
834 <        dAtom->setMu( currentAtomType->dipole );
835 <        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 );
833 >        // the parser returns 0 if the line was blank
834 >        if( parseBond( readLine, lineNum, bondInfo ) ){
835 >          headBondType->add( bondInfo );
836          }
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++;
837        }
838 <      else{
839 <        
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 <      }
838 >      eof_test = fgets( readLine, sizeof(readLine), frcFile );
839 >      lineNum++;
840      }
841 <    else{
842 <      if( the_atoms[i]->isDirectional() ){
843 <        sprintf( painCave.errMsg,
844 <                 "TraPPE_ExFF error: Atom \"%s\" was given a standard"
845 <                 "orientation in the BASS file, yet it is not a dipole.\n",
846 <                 currentAtomType->name);
847 <        painCave.isFatal = 1;
848 <        simError();
849 <      }
841 >        
842 > #ifdef IS_MPI
843 >    
844 >    // send out the linked list to all the other processes
845 >    
846 >    sprintf( checkPointMsg,
847 >             "TraPPE_Ex bond structures read successfully." );
848 >    MPIcheckPoint();
849 >    
850 >    currentBondType = headBondType->next;
851 >    while( currentBondType != NULL ){
852 >      currentBondType->duplicate( bondInfo );
853 >      sendFrcStruct( &bondInfo, mpiBondStructType );
854 >      currentBondType = currentBondType->next;
855      }
856 +    bondInfo.last = 1;
857 +    sendFrcStruct( &bondInfo, mpiBondStructType );
858 +    
859    }
860  
861 < #ifdef IS_MPI
862 <  double tempBig = bigSigma;
863 <  MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX );
864 < #endif  //is_mpi
861 >  else{
862 >    
863 >    // listen for node 0 to send out the force params
864 >    
865 >    MPIcheckPoint();
866  
867 <  //calc rCut and rList
867 >    headBondType = new LinkedBondType;
868 >    recieveFrcStruct( &bondInfo, mpiBondStructType );
869 >    while( !bondInfo.last ){
870  
871 <  entry_plug->rCut = 2.5 * bigSigma;
871 >      headBondType->add( bondInfo );
872 >      recieveFrcStruct( &bondInfo, mpiBondStructType );
873 >    }
874 >  }
875 > #endif // is_mpi
876    
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;
877  
878 <  entry_plug->rList = entry_plug->rCut + 1.0;
878 >  // read in the bends
879  
880 <  entry_plug->useLJ = 1; // use Lennard Jones is on by default
880 > #ifdef IS_MPI
881 >  if( worldRank == 0 ){
882 > #endif
883  
884 <  // clean up the memory
645 <  
646 <  delete headAtomType;
884 >    // read in the bend types.
885  
886 < #ifdef IS_MPI
887 <  sprintf( checkPointMsg, "TraPPE_Ex atoms initialized succesfully" );
888 <  MPIcheckPoint();
651 < #endif // is_mpi
886 >    headBendType = new LinkedBendType;
887 >    
888 >    fastForward( "BendTypes", "initializeBends" );
889  
890 < }
890 >    // we are now at the bendTypes section
891  
892 < void TraPPE_ExFF::initializeBonds( bond_pair* the_bonds ){
893 <  
894 <  class LinkedType {
895 <  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; }
892 >    eof_test =  fgets( readLine, sizeof(readLine), frcFile );
893 >    lineNum++;
894 >        
895 >    // read a line, and start parseing out the bend types
896  
897 <    LinkedType* find(char* key1, char* key2){
898 <      if( !strcmp(nameA, key1 ) && !strcmp( nameB, key2 ) ) return this;
899 <      if( !strcmp(nameA, key2 ) && !strcmp( nameB, key1 ) ) return this;
900 <      if( next != NULL ) return next->find(key1, key2);
901 <      return NULL;
897 >    if( eof_test == NULL ){
898 >      sprintf( painCave.errMsg,
899 >               "Error in reading bends from force file at line %d.\n",
900 >               lineNum );
901 >      painCave.isFatal = 1;
902 >      simError();
903      }
904      
905 <
906 <    void add( bondStruct &info ){
905 >    // stop reading at end of file, or at next section
906 >    while( readLine[0] != '#' && eof_test != NULL ){
907        
908 <      // check for duplicates
909 <      int dup = 0;
679 <
680 <      if( !strcmp(nameA, info.nameA ) && !strcmp( nameB, info.nameB ) ) dup = 1;
681 <      if( !strcmp(nameA, info.nameB ) && !strcmp( nameB, info.nameA ) ) dup = 1;
682 <      
683 <      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 <      }
691 <
908 >      // toss comment lines
909 >      if( readLine[0] != '!' ){
910          
911 <      if( next != NULL ) next->add(info);
912 <      else{
913 <        next = new LinkedType();
914 <        strcpy(next->nameA, info.nameA);
697 <        strcpy(next->nameB, info.nameB);
698 <        strcpy(next->type,  info.type);
699 <        next->d0 = info.d0;
911 >        // the parser returns 0 if the line was blank
912 >        if( parseBend( readLine, lineNum, bendInfo ) ){
913 >          headBendType->add( bendInfo );
914 >        }
915        }
916 +      eof_test = fgets( readLine, sizeof(readLine), frcFile );
917 +      lineNum++;
918      }
919      
920   #ifdef IS_MPI
921 <    void duplicate( bondStruct &info ){
922 <      strcpy(info.nameA, nameA);
706 <      strcpy(info.nameB, nameB);
707 <      strcpy(info.type,  type);
708 <      info.d0   = d0;
709 <      info.last = 0;
710 <    }
921 >    
922 >    // send out the linked list to all the other processes
923  
924 +    sprintf( checkPointMsg,
925 +             "TraPPE_Ex bend structures read successfully." );
926 +    MPIcheckPoint();
927  
928 < #endif
928 >    currentBendType = headBendType->next;
929 >    while( currentBendType != NULL ){
930 >      currentBendType->duplicate( bendInfo );
931 >      sendFrcStruct( &bendInfo, mpiBendStructType );
932 >      currentBendType = currentBendType->next;
933 >    }
934 >    bendInfo.last = 1;
935 >    sendFrcStruct( &bendInfo, mpiBendStructType );
936 >    
937 >  }
938  
939 <    char nameA[15];
940 <    char nameB[15];
941 <    char type[30];
942 <    double d0;
939 >  else{
940 >    
941 >    // listen for node 0 to send out the force params
942 >    
943 >    MPIcheckPoint();
944  
945 <    LinkedType* next;
946 <  };
945 >    headBendType = new LinkedBendType;
946 >    recieveFrcStruct( &bendInfo, mpiBendStructType );
947 >    while( !bendInfo.last ){
948  
949 +      headBendType->add( bendInfo );
950 +      recieveFrcStruct( &bendInfo, mpiBendStructType );
951 +    }
952 +  }
953 + #endif // is_mpi
954  
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
955  
956 <  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;
956 >  // read in the torsions
957  
738  int i, a, b;
739  char* atomA;
740  char* atomB;
741  
958   #ifdef IS_MPI
959    if( worldRank == 0 ){
960   #endif
961 +
962 +    // read in the torsion types.
963 +
964 +    headTorsionType = new LinkedTorsionType;
965      
966 <    // read in the bond types.
747 <    
748 <    headBondType = new LinkedType;
749 <    
750 <    fastForward( "BondTypes", "initializeBonds" );
966 >    fastForward( "TorsionTypes", "initializeTorsions" );
967  
968 <    // we are now at the bondTypes section
968 >    // we are now at the torsionTypes section
969  
970      eof_test =  fgets( readLine, sizeof(readLine), frcFile );
971      lineNum++;
# Line 759 | Line 975 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
975  
976      if( eof_test == NULL ){
977        sprintf( painCave.errMsg,
978 <               "Error in reading bonds from force file at line %d.\n",
978 >               "Error in reading torsions from force file at line %d.\n",
979                 lineNum );
980        painCave.isFatal = 1;
981        simError();
# Line 772 | Line 988 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
988        if( readLine[0] != '!' ){
989          
990          // the parser returns 0 if the line was blank
991 <        if( parseBond( readLine, lineNum, info ) ){
992 <          headBondType->add( info );
991 >        if( parseTorsion( readLine, lineNum, torsionInfo ) ){
992 >          headTorsionType->add( torsionInfo );
993 >
994          }
995        }
996        eof_test = fgets( readLine, sizeof(readLine), frcFile );
997        lineNum++;
998      }
999 <        
999 >
1000   #ifdef IS_MPI
1001      
1002      // send out the linked list to all the other processes
1003      
1004      sprintf( checkPointMsg,
1005 <             "TraPPE_Ex bond structures read successfully." );
1005 >             "TraPPE_Ex torsion structures read successfully." );
1006      MPIcheckPoint();
1007      
1008 <    currentBondType = headBondType;
1009 <    while( currentBondType != NULL ){
1010 <      currentBondType->duplicate( info );
1011 <      sendFrcStruct( &info, mpiBondStructType );
1012 <      currentBondType = currentBondType->next;
1008 >    currentTorsionType = headTorsionType->next;
1009 >    while( currentTorsionType != NULL ){
1010 >      currentTorsionType->duplicate( torsionInfo );
1011 >      sendFrcStruct( &torsionInfo, mpiTorsionStructType );
1012 >      currentTorsionType = currentTorsionType->next;
1013      }
1014 <    info.last = 1;
1015 <    sendFrcStruct( &info, mpiBondStructType );
1014 >    torsionInfo.last = 1;
1015 >    sendFrcStruct( &torsionInfo, mpiTorsionStructType );
1016      
1017    }
1018  
# Line 805 | Line 1022 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
1022      
1023      MPIcheckPoint();
1024  
1025 <    headBondType = new LinkedType;
1026 <    recieveFrcStruct( &info, mpiBondStructType );
1027 <    while( !info.last ){
1025 >    headTorsionType = new LinkedTorsionType;
1026 >    recieveFrcStruct( &torsionInfo, mpiTorsionStructType );
1027 >    while( !torsionInfo.last ){
1028  
1029 <      headBondType->add( info );
1030 <      recieveFrcStruct( &info, mpiBondStructType );
1029 >      headTorsionType->add( torsionInfo );
1030 >      recieveFrcStruct( &torsionInfo, mpiTorsionStructType );
1031      }
1032    }
1033   #endif // is_mpi
1034 +
1035 +  entry_plug->useLJ = 1;
1036 + }
1037 +
1038 +
1039 +
1040 + void TraPPE_ExFF::initializeAtoms( int nAtoms, Atom** the_atoms ){
1041    
1042    
1043 <  // initialize the Bonds
1043 >  //////////////////////////////////////////////////
1044 >  // a quick water fix
1045 >
1046 >  double waterI[3][3];
1047 >  waterI[0][0] = 1.76958347772500;
1048 >  waterI[0][1] = 0.0;
1049 >  waterI[0][2] = 0.0;
1050 >
1051 >  waterI[1][0] = 0.0;
1052 >  waterI[1][1] = 0.614537057924513;
1053 >  waterI[1][2] = 0.0;
1054 >
1055 >  waterI[2][0] = 0.0;
1056 >  waterI[2][1] = 0.0;
1057 >  waterI[2][2] = 1.15504641980049;
1058 >
1059 >
1060 >  double headI[3][3];
1061 >  headI[0][0] = 1125;
1062 >  headI[0][1] = 0.0;
1063 >  headI[0][2] = 0.0;
1064 >
1065 >  headI[1][0] = 0.0;
1066 >  headI[1][1] = 1125;
1067 >  headI[1][2] = 0.0;
1068 >
1069 >  headI[2][0] = 0.0;
1070 >  headI[2][1] = 0.0;
1071 >  headI[2][2] = 250;
1072 >
1073 >  //////////////////////////////////////////////////
1074 >
1075    
1076 +  // initialize the atoms
1077 +  
1078 +  DirectionalAtom* dAtom;
1079  
1080 +  for(int i=0; i<nAtoms; i++ ){
1081 +
1082 +    currentAtomType = headAtomType->find( the_atoms[i]->getType() );
1083 +    if( currentAtomType == NULL ){
1084 +      sprintf( painCave.errMsg,
1085 +               "AtomType error, %s not found in force file.\n",
1086 +               the_atoms[i]->getType() );
1087 +      painCave.isFatal = 1;
1088 +      simError();
1089 +    }
1090 +    
1091 +    the_atoms[i]->setMass( currentAtomType->mass );
1092 +    the_atoms[i]->setEpslon( currentAtomType->epslon );
1093 +    the_atoms[i]->setSigma( currentAtomType->sigma );
1094 +    the_atoms[i]->setIdent( currentAtomType->ident );
1095 +    the_atoms[i]->setLJ();
1096 +
1097 +    if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma;
1098 +
1099 +    if( currentAtomType->isDipole ){
1100 +      if( the_atoms[i]->isDirectional() ){
1101 +        
1102 +        dAtom = (DirectionalAtom *) the_atoms[i];
1103 +        dAtom->setMu( currentAtomType->dipole );
1104 +        dAtom->setHasDipole( 1 );
1105 +        dAtom->setJx( 0.0 );
1106 +        dAtom->setJy( 0.0 );
1107 +        dAtom->setJz( 0.0 );
1108 +        
1109 +        if(!strcmp("SSD",the_atoms[i]->getType())){
1110 +          dAtom->setI( waterI );
1111 +          dAtom->setSSD( 1 );
1112 +        }
1113 +        else if(!strcmp("HEAD",the_atoms[i]->getType())){
1114 +          dAtom->setI( headI );
1115 +          dAtom->setSSD( 0 );
1116 +        }
1117 +        else{
1118 +          sprintf(painCave.errMsg,
1119 +                  "AtmType error, %s does not have a moment of inertia set.\n",
1120 +                  the_atoms[i]->getType() );
1121 +          painCave.isFatal = 1;
1122 +          simError();
1123 +        }
1124 +        entry_plug->n_dipoles++;
1125 +      }
1126 +      else{
1127 +        
1128 +        sprintf( painCave.errMsg,
1129 +                "TraPPE_ExFF error: Atom \"%s\" is a dipole, yet no standard"
1130 +                 " orientation was specifed in the BASS file.\n",
1131 +                 currentAtomType->name );
1132 +        painCave.isFatal = 1;
1133 +        simError();
1134 +      }
1135 +    }
1136 +    else{
1137 +      if( the_atoms[i]->isDirectional() ){
1138 +        sprintf( painCave.errMsg,
1139 +                 "TraPPE_ExFF error: Atom \"%s\" was given a standard"
1140 +                 "orientation in the BASS file, yet it is not a dipole.\n",
1141 +                 currentAtomType->name);
1142 +        painCave.isFatal = 1;
1143 +        simError();
1144 +      }
1145 +    }
1146 +  }
1147 + }
1148 +
1149 + void TraPPE_ExFF::initializeBonds( int nBonds, Bond** bondArray,
1150 +                                   bond_pair* the_bonds ){
1151 +  int i,a,b;
1152 +  char* atomA;
1153 +  char* atomB;
1154 +  
1155 +  Atom** the_atoms;
1156 +  the_atoms = entry_plug->atoms;
1157 +  
1158 +
1159 +  // initialize the Bonds
1160 +  
1161    for( i=0; i<nBonds; i++ ){
1162      
1163      a = the_bonds[i].a;
# Line 837 | Line 1176 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
1176      
1177      if( !strcmp( currentBondType->type, "fixed" ) ){
1178        
1179 <      the_sris[i] = new ConstrainedBond( *the_atoms[a],
1180 <                                         *the_atoms[b],
1181 <                                         currentBondType->d0 );
1179 >      bondArray[i] = new ConstrainedBond( *the_atoms[a],
1180 >                                          *the_atoms[b],
1181 >                                          currentBondType->d0 );
1182        entry_plug->n_constraints++;
1183      }
1184    }
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
1185   }
1186  
1187 < void TraPPE_ExFF::initializeBends( bend_set* the_bends ){
1188 <  
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 <  };
1187 > void TraPPE_ExFF::initializeBends( int nBends, Bend** bendArray,
1188 >                                   bend_set* the_bends ){
1189    
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
1190    QuadraticBend* qBend;
1191    GhostBend* gBend;
947  SRI **the_sris;
1192    Atom** the_atoms;
949  int nBends;
950  the_sris = entry_plug->sr_interactions;
1193    the_atoms = entry_plug->atoms;
1194 <  nBends = entry_plug->n_bends;
953 <
1194 >  
1195    int i, a, b, c;
1196    char* atomA;
1197    char* atomB;
1198    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
1199    
1200    // initialize the Bends
1036  
1037  int index;
1201  
1202    for( i=0; i<nBends; i++ ){
1203      
# Line 1059 | Line 1222 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
1222      
1223      if( !strcmp( currentBendType->type, "quadratic" ) ){
1224        
1062      index = i + entry_plug->n_bonds;
1063      
1225        if( the_bends[i].isGhost){
1226          
1227          if( the_bends[i].ghost == b ){
# Line 1088 | Line 1249 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
1249                               currentBendType->k2,
1250                               currentBendType->k3,
1251                               currentBendType->t0 );
1252 <        the_sris[index] = gBend;
1252 >        bendArray[i] = gBend;
1253        }
1254        else{
1255          qBend = new QuadraticBend( *the_atoms[a],
# Line 1098 | Line 1259 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
1259                               currentBendType->k2,
1260                               currentBendType->k3,
1261                               currentBendType->t0 );
1262 <        the_sris[index] = qBend;
1262 >        bendArray[i] = qBend;
1263        }
1264      }
1265    }
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
1266   }
1267  
1268 < void TraPPE_ExFF::initializeTorsions( torsion_set* the_torsions ){
1269 <
1120 <  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 ){
1268 > void TraPPE_ExFF::initializeTorsions( int nTorsions, Torsion** torsionArray,
1269 >                                      torsion_set* the_torsions ){
1270  
1271 <      // 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;
1271 >  int i, a, b, c, d;
1272    char* atomA;
1273    char* atomB;
1274    char* atomC;
1275    char* atomD;
1219  CubicTorsion* cTors;
1276  
1277 <  SRI **the_sris;
1277 >  CubicTorsion* cTors;
1278    Atom** the_atoms;
1223  int nTorsions;
1224  the_sris = entry_plug->sr_interactions;
1279    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  }
1288
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 ){
1280  
1299      headTorsionType->add( info );
1300      recieveFrcStruct( &info, mpiTorsionStructType );
1301    }
1302  }
1303 #endif // is_mpi
1304  
1281    // initialize the Torsions
1282  
1283    for( i=0; i<nTorsions; i++ ){
# Line 1326 | Line 1302 | void TraPPE_ExFF::initializeTorsions( torsion_set* the
1302      }
1303      
1304      if( !strcmp( currentTorsionType->type, "cubic" ) ){
1329      index = i + entry_plug->n_bonds + entry_plug->n_bends;
1305        
1306        cTors = new CubicTorsion( *the_atoms[a], *the_atoms[b],
1307                                  *the_atoms[c], *the_atoms[d] );
1308        cTors->setConstants( currentTorsionType->k1, currentTorsionType->k2,
1309                             currentTorsionType->k3, currentTorsionType->k4 );
1310 <      the_sris[index] = cTors;
1310 >      torsionArray[i] = cTors;
1311      }
1312    }
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
1313   }
1314  
1315   void TraPPE_ExFF::fastForward( char* stopText, char* searchOwner ){

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines