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 420 by mmeineke, Thu Mar 27 17:32:03 2003 UTC

# Line 82 | Line 82 | namespace TPE {  // restrict the access of the folowin
82    MPI_Datatype mpiBondStructType;
83    MPI_Datatype mpiBendStructType;
84    MPI_Datatype mpiTorsionStructType;
85 +
86 + #endif
87 +
88 +  class LinkedAtomType {
89 +  public:
90 +    LinkedAtomType(){
91 +      next = NULL;
92 +      name[0] = '\0';
93 +    }
94 +    ~LinkedAtomType(){ if( next != NULL ) delete next; }
95 +
96 +    LinkedAtomType* find(char* key){
97 +      if( !strcmp(name, key) ) return this;
98 +      if( next != NULL ) return next->find(key);
99 +      return NULL;
100 +    }
101 +    
102 +    void add( atomStruct &info ){
103 +
104 +      // check for duplicates
105 +      
106 +      if( !strcmp( info.name, name ) ){
107 +        sprintf( painCave.errMsg,
108 +                 "Duplicate TraPPE_Ex atom type \"%s\" found in "
109 +                 "the TraPPE_ExFF param file./n",
110 +                 name );
111 +        painCave.isFatal = 1;
112 +        simError();
113 +      }
114 +
115 +      if( next != NULL ) next->add(info);
116 +      else{
117 +        next = new LinkedType();
118 +        strcpy(next->name, info.name);
119 +        next->isDipole = info.isDipole;
120 +        next->isSSD    = info.isSSD;
121 +        next->mass     = info.mass;
122 +        next->epslon   = info.epslon;
123 +        next->sigma    = info.sigma;
124 +        next->dipole   = info.dipole;
125 +        next->w0       = info.w0;
126 +        next->v0       = info.v0;
127 +        next->ident    = info.ident;
128 +      }
129 +    }
130 +
131 + #ifdef IS_MPI
132 +    
133 +    void duplicate( atomStruct &info ){
134 +      strcpy(info.name, name);
135 +      info.isDipole = isDipole;
136 +      info.isSSD    = isSSD;
137 +      info.mass     = mass;
138 +      info.epslon   = epslon;
139 +      info.sigma    = sigma;
140 +      info.dipole   = dipole;
141 +      info.w0       = w0;
142 +      info.v0       = v0;
143 +      info.last     = 0;
144 +    }
145 +
146 +
147 + #endif
148 +
149 +    char name[15];
150 +    int isDipole;
151 +    int isSSD;
152 +    double mass;
153 +    double epslon;
154 +    double sigma;
155 +    double dipole;
156 +    double w0;
157 +    double v0;
158 +    int ident;
159 +    LinkedAtomType* next;
160 +  };
161 +
162 +  class LinkedBondType {
163 +  public:
164 +    LinkedBondType(){
165 +      next = NULL;
166 +      nameA[0] = '\0';
167 +      nameB[0] = '\0';
168 +      type[0] = '\0';
169 +    }
170 +    ~LinkedBondType(){ if( next != NULL ) delete next; }
171 +
172 +    LinkedBondType* find(char* key1, char* key2){
173 +      if( !strcmp(nameA, key1 ) && !strcmp( nameB, key2 ) ) return this;
174 +      if( !strcmp(nameA, key2 ) && !strcmp( nameB, key1 ) ) return this;
175 +      if( next != NULL ) return next->find(key1, key2);
176 +      return NULL;
177 +    }
178 +    
179 +
180 +    void add( bondStruct &info ){
181 +      
182 +      // check for duplicates
183 +      int dup = 0;
184 +
185 +      if( !strcmp(nameA, info.nameA ) && !strcmp( nameB, info.nameB ) ) dup = 1;
186 +      if( !strcmp(nameA, info.nameB ) && !strcmp( nameB, info.nameA ) ) dup = 1;
187 +      
188 +      if(dup){
189 +        sprintf( painCave.errMsg,
190 +                 "Duplicate TraPPE_Ex bond type \"%s - %s\" found in "
191 +                 "the TraPPE_ExFF param file./n",
192 +                 nameA, nameB );
193 +        painCave.isFatal = 1;
194 +        simError();
195 +      }
196 +
197 +        
198 +      if( next != NULL ) next->add(info);
199 +      else{
200 +        next = new LinkedType();
201 +        strcpy(next->nameA, info.nameA);
202 +        strcpy(next->nameB, info.nameB);
203 +        strcpy(next->type,  info.type);
204 +        next->d0 = info.d0;
205 +      }
206 +    }
207 +    
208 + #ifdef IS_MPI
209 +    void duplicate( bondStruct &info ){
210 +      strcpy(info.nameA, nameA);
211 +      strcpy(info.nameB, nameB);
212 +      strcpy(info.type,  type);
213 +      info.d0   = d0;
214 +      info.last = 0;
215 +    }
216 +
217 +
218 + #endif
219 +
220 +    char nameA[15];
221 +    char nameB[15];
222 +    char type[30];
223 +    double d0;
224 +
225 +    LinkedBondType* next;
226 +  };
227 +
228 +  class LinkedBendType {
229 +  public:
230 +    LinkedBendType(){
231 +      next = NULL;
232 +      nameA[0] = '\0';
233 +      nameB[0] = '\0';
234 +      nameC[0] = '\0';
235 +      type[0] = '\0';
236 +    }
237 +    ~LinkedBendType(){ if( next != NULL ) delete next; }
238 +
239 +    LinkedBendType* find( char* key1, char* key2, char* key3 ){
240 +      if( !strcmp( nameA, key1 ) && !strcmp( nameB, key2 )
241 +          && !strcmp( nameC, key3 ) ) return this;
242 +      if( !strcmp( nameA, key3 ) && !strcmp( nameB, key2 )
243 +          && !strcmp( nameC, key1 ) ) return this;
244 +      if( next != NULL ) return next->find(key1, key2, key3);
245 +      return NULL;
246 +    }
247 +    
248 +    void add( bendStruct &info ){
249 +
250 +      // check for duplicates
251 +      int dup = 0;
252 +      
253 +      if( !strcmp( nameA, info.nameA ) && !strcmp( nameB, info.nameB )
254 +          && !strcmp( nameC, info.nameC ) ) dup = 1;
255 +      if( !strcmp( nameA, info.nameC ) && !strcmp( nameB, info.nameB )
256 +          && !strcmp( nameC, info.nameA ) ) dup = 1;
257 +
258 +      if(dup){
259 +        sprintf( painCave.errMsg,
260 +                 "Duplicate TraPPE_Ex bend type \"%s - %s - %s\" found in "
261 +                 "the TraPPE_ExFF param file./n",
262 +                 nameA, nameB, nameC );
263 +        painCave.isFatal = 1;
264 +        simError();
265 +      }
266 +
267 +      if( next != NULL ) next->add(info);
268 +      else{
269 +        next = new LinkedType();
270 +        strcpy(next->nameA, info.nameA);
271 +        strcpy(next->nameB, info.nameB);
272 +        strcpy(next->nameC, info.nameC);
273 +        strcpy(next->type,  info.type);
274 +        next->k1 = info.k1;
275 +        next->k2 = info.k2;
276 +        next->k3 = info.k3;
277 +        next->t0 = info.t0;
278 +      }
279 +    }
280 +
281 + #ifdef IS_MPI    
282 +
283 +    void duplicate( bendStruct &info ){
284 +      strcpy(info.nameA, nameA);
285 +      strcpy(info.nameB, nameB);
286 +      strcpy(info.nameC, nameC);
287 +      strcpy(info.type,  type);
288 +      info.k1   = k1;
289 +      info.k2   = k2;
290 +      info.k3   = k3;
291 +      info.t0   = t0;
292 +      info.last = 0;
293 +    }
294  
295 + #endif // is_mpi
296 +
297 +    char nameA[15];
298 +    char nameB[15];
299 +    char nameC[15];
300 +    char type[30];
301 +    double k1, k2, k3, t0;
302 +
303 +    LinkedBendType* next;
304 +  };
305 +
306 +  class LinkedTorsionType {
307 +  public:
308 +    LinkedTorsionType(){
309 +      next = NULL;
310 +      nameA[0] = '\0';
311 +      nameB[0] = '\0';
312 +      nameC[0] = '\0';
313 +      type[0] = '\0';
314 +    }
315 +    ~LinkedTorsionType(){ if( next != NULL ) delete next; }
316 +
317 +    LinkedTorsionType* find( char* key1, char* key2, char* key3, char* key4 ){
318 +      
319 +
320 +
321 +
322 +      if( !strcmp( nameA, key1 ) && !strcmp( nameB, key2 ) &&
323 +          !strcmp( nameC, key3 ) && !strcmp( nameD, key4 ) ) return this;
324 +
325 +      if( !strcmp( nameA, key4 ) && !strcmp( nameB, key3 ) &&
326 +          !strcmp( nameC, key2 ) && !strcmp( nameD, key1 ) ) return this;
327 +
328 +      if( next != NULL ) return next->find(key1, key2, key3, key4);
329 +      return NULL;
330 +    }
331 +
332 +    void add( torsionStruct &info ){
333 +
334 +      // check for duplicates
335 +      int dup = 0;
336 +
337 +      if( !strcmp( nameA, info.nameA ) && !strcmp( nameB, info.nameB ) &&
338 +          !strcmp( nameC, info.nameC ) && !strcmp( nameD, info.nameD ) ) dup = 1;
339 +      
340 +      if( !strcmp( nameA, info.nameD ) && !strcmp( nameB, info.nameC ) &&
341 +          !strcmp( nameC, info.nameB ) && !strcmp( nameD, info.nameA ) ) dup = 1;
342 +      
343 +      if(dup){
344 +        sprintf( painCave.errMsg,
345 +                 "Duplicate TraPPE_Ex torsion type \"%s - %s - %s - %s\" found in "
346 +                 "the TraPPE_ExFF param file./n", nameA, nameB, nameC, nameD );
347 +        painCave.isFatal = 1;
348 +        simError();
349 +      }
350 +
351 +      if( next != NULL ) next->add(info);
352 +      else{
353 +        next = new LinkedType();
354 +        strcpy(next->nameA, info.nameA);
355 +        strcpy(next->nameB, info.nameB);
356 +        strcpy(next->nameC, info.nameC);
357 +        strcpy(next->nameD, info.nameD);
358 +        strcpy(next->type,  info.type);
359 +        next->k1 = info.k1;
360 +        next->k2 = info.k2;
361 +        next->k3 = info.k3;
362 +        next->k4 = info.k4;
363 +
364 +      }
365 +    }
366 +
367 + #ifdef IS_MPI
368 +    
369 +    void duplicate( torsionStruct &info ){
370 +      strcpy(info.nameA, nameA);
371 +      strcpy(info.nameB, nameB);
372 +      strcpy(info.nameC, nameC);
373 +      strcpy(info.nameD, nameD);
374 +      strcpy(info.type,  type);
375 +      info.k1   = k1;
376 +      info.k2   = k2;
377 +      info.k3   = k3;
378 +      info.k4   = k4;
379 +      info.last = 0;
380 +    }
381 +
382   #endif
383  
384 +    char nameA[15];
385 +    char nameB[15];
386 +    char nameC[15];
387 +    char nameD[15];
388 +    char type[30];
389 +    double k1, k2, k3, k4;
390 +
391 +    LinkedTorsionType* next;
392 +  };
393 +
394 +
395 +  LinkedAtomType* headAtomType;
396 +  LinkedAtomType* currentAtomType;
397 +  LinkedBondType* headBondType;
398 +  LinkedBondType* currentBondType;
399 +  LinkedBendType* headBendType;
400 +  LinkedBendType* currentBendType;
401 +  LinkedTorsionType* headTorsionType;
402 +  LinkedTorsionType* currentTorsionType;
403 +
404   } // namespace
405  
406   using namespace TPE;
# Line 103 | Line 419 | TraPPE_ExFF::TraPPE_ExFF(){
419    char temp[200];
420    char errMsg[1000];
421  
422 +  headAtomType       = NULL;
423 +  currentAtomType    = NULL;
424 +  headBondType       = NULL;
425 +  currentBondType    = NULL;
426 +  headBendType       = NULL;
427 +  currentBendType    = NULL;
428 +  headTorsionType    = NULL;
429 +  currentTorsionType = NULL;
430 +
431    // do the funtion wrapping
432    wrapMeFF( this );
433  
# Line 253 | Line 578 | TraPPE_ExFF::~TraPPE_ExFF(){
578  
579   TraPPE_ExFF::~TraPPE_ExFF(){
580  
581 +  if( headAtomType != NULL ) delete headAtomType;
582 +  if( headBondType != NULL ) delete headBondType;
583 +  if( headBendType != NULL ) delete headBendType;
584 +  if( headTorsionType != NULL ) delete headTorsionType;
585 +
586   #ifdef IS_MPI
587    if( worldRank == 0 ){
588   #endif // is_mpi
# Line 264 | Line 594 | void TraPPE_ExFF::initForceField( int ljMixRule ){
594   #endif // is_mpi
595   }
596  
597 < void TraPPE_ExFF::initForceField( int ljMixRule ){
268 <  
269 <  initFortran( ljMixRule, entry_plug->useReactionField );
270 < }
597 > void TraPPE_ExFF::cleanMe( void ){
598  
599 <
273 < void TraPPE_ExFF::initializeAtoms( void ){
599 > #ifdef IS_MPI
600    
601 <  class LinkedType {
276 <  public:
277 <    LinkedType(){
278 <      next = NULL;
279 <      name[0] = '\0';
280 <    }
281 <    ~LinkedType(){ if( next != NULL ) delete next; }
601 >  // keep the linked lists in the mpi version
602  
603 <    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 ){
603 > #else // is_mpi
604  
605 <      // 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 <      }
605 >  // delete the linked lists in the single processor version
606  
607 <      if( next != NULL ) next->add(info);
608 <      else{
609 <        next = new LinkedType();
610 <        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 <    }
607 >  if( headAtomType != NULL ) delete headAtomType;
608 >  if( headBondType != NULL ) delete headBondType;
609 >  if( headBendType != NULL ) delete headBendType;
610 >  if( headTorsionType != NULL ) delete headTorsionType;
611  
612 < #ifdef IS_MPI
613 <    
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 <    }
612 > #endif // is_mpi
613 > }
614  
615  
616 < #endif
616 > void TraPPE_ExFF::initForceField( int ljMixRule ){
617 >  
618 >  initFortran( ljMixRule, entry_plug->useReactionField );
619 > }
620  
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
621  
622 <  
622 > void TraPPE_ExFF::readParams( void ){
623  
624    int i;
625    int identNum;
626    
627 <  Atom** the_atoms;
628 <  int nAtoms;
629 <  the_atoms = entry_plug->atoms;
630 <  nAtoms = entry_plug->n_atoms;
627 >  atomStruct atomInfo;
628 >  bondStruct bondInfo;
629 >  bendStruct bendInfo;
630 >  torsionStruct torsionInfo;
631    
365  //////////////////////////////////////////////////
366  // a quick water fix
367
368  double waterI[3][3];
369  waterI[0][0] = 1.76958347772500;
370  waterI[0][1] = 0.0;
371  waterI[0][2] = 0.0;
372
373  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
632    
633 +  atomInfo.last = 1;
634 +  bondInfo.last = 1;
635 +  bendInfo.last = 1;
636 +  torsionInfo.last = 1;
637  
638 <  //////////////////////////////////////////////////
639 <
399 <
638 >  // read in the atom info
639 >  
640   #ifdef IS_MPI
641    if( worldRank == 0 ){
642   #endif
643      
644      // read in the atom types.
405
406    headAtomType = new LinkedType;
645      
646 +    headAtomType = new LinkedAtomType;
647 +    
648      fastForward( "AtomTypes", "initializeAtoms" );
649  
650      // we are now at the AtomTypes section.
# Line 431 | Line 671 | void TraPPE_ExFF::initializeAtoms( void ){
671        if( readLine[0] != '!' ){
672          
673          // the parser returns 0 if the line was blank
674 <        if( parseAtom( readLine, lineNum, info ) ){
675 <          info.ident = identNum;
676 <          headAtomType->add( info );;
674 >        if( parseAtom( readLine, lineNum, atomInfo ) ){
675 >          atomInfo.ident = identNum;
676 >          headAtomType->add( atomInfo );;
677            identNum++;
678          }
679        }
# Line 451 | Line 691 | void TraPPE_ExFF::initializeAtoms( void ){
691  
692      currentAtomType = headAtomType->next; //skip the first element who is a place holder.
693      while( currentAtomType != NULL ){
694 <      currentAtomType->duplicate( info );
694 >      currentAtomType->duplicate( atomInfo );
695  
696  
697  
698 <      sendFrcStruct( &info, mpiAtomStructType );
698 >      sendFrcStruct( &atomInfo, mpiAtomStructType );
699  
700        sprintf( checkPointMsg,
701                 "successfully sent TraPPE_Ex force type: \"%s\"\n",
702 <               info.name );
702 >               atomInfo.name );
703        MPIcheckPoint();
704  
705        currentAtomType = currentAtomType->next;
706      }
707 <    info.last = 1;
708 <    sendFrcStruct( &info, mpiAtomStructType );
707 >    atomInfo.last = 1;
708 >    sendFrcStruct( &atomInfo, mpiAtomStructType );
709      
710    }
711  
# Line 476 | Line 716 | void TraPPE_ExFF::initializeAtoms( void ){
716      MPIcheckPoint();
717  
718      headAtomType = new LinkedType;
719 <    recieveFrcStruct( &info, mpiAtomStructType );
719 >    recieveFrcStruct( &atomInfo, mpiAtomStructType );
720      
721 <    while( !info.last ){
721 >    while( !atomInfo.last ){
722  
723  
724  
725 <      headAtomType->add( info );
725 >      headAtomType->add( atomInfo );
726        
727        MPIcheckPoint();
728  
729 <      recieveFrcStruct( &info, mpiAtomStructType );
729 >      recieveFrcStruct( &atomInfo, mpiAtomStructType );
730      }
731    }
732   #endif // is_mpi
# Line 543 | Line 783 | void TraPPE_ExFF::initializeAtoms( void ){
783             "TraPPE_ExFF atom structures successfully sent to fortran\n" );
784    MPIcheckPoint();
785   #endif // is_mpi
786 +
787 +  
788  
789 +  // read in the bonds
790 +
791    
792 +  
793 +  
794 + }
795 +
796 +
797 +
798 + void TraPPE_ExFF::initializeAtoms( void ){
799 +  
800 +
801 +  
802 +
803 +
804 +  
805 +  Atom** the_atoms;
806 +  int nAtoms;
807 +  the_atoms = entry_plug->atoms;
808 +  nAtoms = entry_plug->n_atoms;
809 +  
810 +  //////////////////////////////////////////////////
811 +  // a quick water fix
812 +
813 +  double waterI[3][3];
814 +  waterI[0][0] = 1.76958347772500;
815 +  waterI[0][1] = 0.0;
816 +  waterI[0][2] = 0.0;
817 +
818 +  waterI[1][0] = 0.0;
819 +  waterI[1][1] = 0.614537057924513;
820 +  waterI[1][2] = 0.0;
821 +
822 +  waterI[2][0] = 0.0;
823 +  waterI[2][1] = 0.0;
824 +  waterI[2][2] = 1.15504641980049;
825 +
826 +
827 +  double headI[3][3];
828 +  headI[0][0] = 1125;
829 +  headI[0][1] = 0.0;
830 +  headI[0][2] = 0.0;
831 +
832 +  headI[1][0] = 0.0;
833 +  headI[1][1] = 1125;
834 +  headI[1][2] = 0.0;
835 +
836 +  headI[2][0] = 0.0;
837 +  headI[2][1] = 0.0;
838 +  headI[2][2] = 250;
839 +
840 +  
841 +
842 +  //////////////////////////////////////////////////
843 +
844 +
845 +
846 +  
847    // initialize the atoms
848    
849    double bigSigma = 0.0;
# Line 654 | Line 953 | void TraPPE_ExFF::initializeBonds( bond_pair* the_bond
953  
954   void TraPPE_ExFF::initializeBonds( bond_pair* the_bonds ){
955    
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; }
956  
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    }
673    
957  
675    void add( bondStruct &info ){
676      
677      // check for duplicates
678      int dup = 0;
958  
959 <      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 <
692 <        
693 <      if( next != NULL ) next->add(info);
694 <      else{
695 <        next = new LinkedType();
696 <        strcpy(next->nameA, info.nameA);
697 <        strcpy(next->nameB, info.nameB);
698 <        strcpy(next->type,  info.type);
699 <        next->d0 = info.d0;
700 <      }
701 <    }
702 <    
703 < #ifdef IS_MPI
704 <    void duplicate( bondStruct &info ){
705 <      strcpy(info.nameA, nameA);
706 <      strcpy(info.nameB, nameB);
707 <      strcpy(info.type,  type);
708 <      info.d0   = d0;
709 <      info.last = 0;
710 <    }
959 >  
960  
961  
713 #endif
714
715    char nameA[15];
716    char nameB[15];
717    char type[30];
718    double d0;
719
720    LinkedType* next;
721  };
722
723
724  
725  LinkedType* headBondType;
726  LinkedType* currentBondType;
727  bondStruct info;
962    info.last = 1; // initialize last to have the last set.
963                   // if things go well, last will be set to 0
964  
# Line 858 | Line 1092 | void TraPPE_ExFF::initializeBends( bend_set* the_bends
1092  
1093   void TraPPE_ExFF::initializeBends( bend_set* the_bends ){
1094    
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; }
1095  
1096 <    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;
1096 >  
1097  
936    LinkedType* next;
937  };
938  
939  LinkedType* headBendType;
940  LinkedType* currentBendType;
1098    bendStruct info;
1099    info.last = 1; // initialize last to have the last set.
1100                   // if things go well, last will be set to 0
# Line 1117 | Line 1274 | void TraPPE_ExFF::initializeTorsions( torsion_set* the
1274  
1275   void TraPPE_ExFF::initializeTorsions( torsion_set* the_torsions ){
1276  
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; }
1277  
1278 <    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 <      }
1278 >  
1279  
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;
1280    torsionStruct info;
1281    info.last = 1; // initialize last to have the last set.
1282                   // if things go well, last will be set to 0

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines