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

Comparing:
branches/mmeineke/OOPSE/libmdtools/LJ_FF.cpp (file contents), Revision 377 by mmeineke, Fri Mar 21 17:42:12 2003 UTC vs.
trunk/OOPSE/libmdtools/LJ_FF.cpp (file contents), Revision 463 by gezelter, Sat Apr 5 03:39:25 2003 UTC

# Line 7 | Line 7 | using namespace std;
7  
8   #ifdef IS_MPI
9   #include <mpi.h>
10 #include <mpi++.h>
10   #endif //is_mpi
11  
12   #include "ForceFields.hpp"
# Line 43 | Line 42 | namespace LJ_NS{
42    MPI_Datatype mpiAtomStructType;
43    
44   #endif
45 +
46 +  class LinkedAtomType {
47 +  public:
48 +    LinkedAtomType(){
49 +      next = NULL;
50 +      name[0] = '\0';
51 +    }
52 +    ~LinkedAtomType(){ if( next != NULL ) delete next; }
53 +
54 +    LinkedAtomType* find(char* key){
55 +      if( !strcmp(name, key) ) return this;
56 +      if( next != NULL ) return next->find(key);
57 +      return NULL;
58 +    }
59 +    
60 +
61 +    void add( atomStruct &info ){
62 +    
63 +      // check for duplicates
64 +      
65 +      if( !strcmp( info.name, name ) ){
66 +        sprintf( painCave.errMsg,
67 +                 "Duplicate LJ atom type \"%s\" found in "
68 +                 "the LJ_FF param file./n",
69 +                 name );
70 +        painCave.isFatal = 1;
71 +        simError();
72 +      }
73 +      
74 +      if( next != NULL ) next->add(info);
75 +      else{
76 +        next = new LinkedAtomType();
77 +        strcpy(next->name, info.name);
78 +        next->mass     = info.mass;
79 +        next->epslon   = info.epslon;
80 +        next->sigma    = info.sigma;
81 +        next->ident    = info.ident;
82 +      }
83 +    }
84 +    
85 +
86 + #ifdef IS_MPI
87 +    
88 +    void duplicate( atomStruct &info ){
89 +      strcpy(info.name, name);
90 +      info.mass     = mass;
91 +      info.epslon   = epslon;
92 +      info.sigma    = sigma;
93 +      info.ident    = ident;
94 +      info.last     = 0;
95 +    }
96 +
97 +
98 + #endif
99 +
100 +    char name[15];
101 +    double mass;
102 +    double epslon;
103 +    double sigma;
104 +    int ident;
105 +    LinkedAtomType* next;
106 +  };
107 +
108 +  LinkedAtomType* headAtomType;
109 +  LinkedAtomType* currentAtomType;
110 +
111   }
112  
113   using namespace LJ_NS;
# Line 60 | Line 125 | LJ_FF::LJ_FF(){
125    char temp[200];
126    char errMsg[1000];
127  
128 +  headAtomType = NULL;
129 +  currentAtomType = NULL;
130 +
131    // do the funtion wrapping
132    wrapMeFF( this );
133  
# Line 142 | Line 210 | LJ_FF::~LJ_FF(){
210  
211   LJ_FF::~LJ_FF(){
212  
213 +  if( headAtomType != NULL ) delete headAtomType;
214 +
215   #ifdef IS_MPI
216    if( worldRank == 0 ){
217   #endif // is_mpi
# Line 158 | Line 228 | void LJ_FF::initForceField( int ljMixRule ){
228    initFortran( ljMixRule, 0 );
229   }
230  
231 + void LJ_FF::cleanMe( void ){
232  
233 < void LJ_FF::initializeAtoms( void ){
233 > #ifdef IS_MPI
234    
235 <  class LinkedType {
165 <  public:
166 <    LinkedType(){
167 <      next = NULL;
168 <      name[0] = '\0';
169 <    }
170 <    ~LinkedType(){ if( next != NULL ) delete next; }
235 >  // keep the linked list in the mpi version
236  
237 <    LinkedType* find(char* key){
173 <      if( !strcmp(name, key) ) return this;
174 <      if( next != NULL ) return next->find(key);
175 <      return NULL;
176 <    }
177 <    
237 > #else // is_mpi
238  
239 <    void add( atomStruct &info ){
180 <    
181 <      // check for duplicates
182 <      
183 <      if( !strcmp( info.name, name ) ){
184 <        sprintf( painCave.errMsg,
185 <                 "Duplicate LJ atom type \"%s\" found in "
186 <                 "the LJ_FF param file./n",
187 <                 name );
188 <        painCave.isFatal = 1;
189 <        simError();
190 <      }
191 <      
192 <      if( next != NULL ) next->add(info);
193 <      else{
194 <        next = new LinkedType();
195 <        strcpy(next->name, info.name);
196 <        next->mass     = info.mass;
197 <        next->epslon   = info.epslon;
198 <        next->sigma    = info.sigma;
199 <        next->ident    = info.ident;
200 <      }
201 <    }
202 <    
239 >  // delete the linked list in the single processor version
240  
241 < #ifdef IS_MPI
205 <    
206 <    void duplicate( atomStruct &info ){
207 <      strcpy(info.name, name);
208 <      info.mass     = mass;
209 <      info.epslon   = epslon;
210 <      info.sigma    = sigma;
211 <      info.ident    = ident;
212 <      info.last     = 0;
213 <    }
241 >  if( headAtomType != NULL ) delete headAtomType;
242  
243 + #endif // is_mpi
244 + }
245  
246 < #endif
246 > void LJ_FF::readParams( void ){
247  
218    char name[15];
219    double mass;
220    double epslon;
221    double sigma;
222    int ident;
223    LinkedType* next;
224  };
225  
226  LinkedType* headAtomType;
227  LinkedType* currentAtomType;
248    atomStruct info;
249    info.last = 1; // initialize last to have the last set.
250                   // if things go well, last will be set to 0
# Line 232 | Line 252 | void LJ_FF::initializeAtoms( void ){
252    int i;
253    int identNum;
254    
255 <  Atom** the_atoms;
256 <  int nAtoms;
237 <  the_atoms = entry_plug->atoms;
238 <  nAtoms = entry_plug->n_atoms;
239 <  
240 <  
255 >
256 >  bigSigma = 0.0;
257   #ifdef IS_MPI
258    if( worldRank == 0 ){
259   #endif
260      
261      // read in the atom types.
262  
263 <    headAtomType = new LinkedType;
263 >    headAtomType = new LinkedAtomType;
264      
265      fastForward( "AtomTypes", "initializeAtoms" );
266  
# Line 316 | Line 332 | void LJ_FF::initializeAtoms( void ){
332      
333      MPIcheckPoint();
334  
335 <    headAtomType = new LinkedType;
335 >    headAtomType = new LinkedAtomType;
336      recieveFrcStruct( &info, mpiAtomStructType );
337      
338      while( !info.last ){
# Line 341 | Line 357 | void LJ_FF::initializeAtoms( void ){
357    int isDipole = 0;
358    int isSSD = 0;
359    int isGB = 0;
344  double w0 = 0.0;
345  double v0 = 0.0;
360    double dipole = 0.0;
347  double GB_dummy = 0.0;
361    
349  
362    currentAtomType = headAtomType;
363    while( currentAtomType != NULL ){
364      
# Line 360 | Line 372 | void LJ_FF::initializeAtoms( void ){
372                   &(currentAtomType->epslon),
373                   &(currentAtomType->sigma),
374                   &dipole,
363                 &w0,
364                 &v0,
365                 &GB_dummy,
366                 &GB_dummy,
367                 &GB_dummy,
368                 &GB_dummy,
369                 &GB_dummy,
370                 &GB_dummy,
375                   &isError );
376        if( isError ){
377          sprintf( painCave.errMsg,
# Line 380 | Line 384 | void LJ_FF::initializeAtoms( void ){
384      currentAtomType = currentAtomType->next;
385    }
386        
387 +  entry_plug->useLJ = 1;
388 +
389   #ifdef IS_MPI
390    sprintf( checkPointMsg,
391             "LJ_FF atom structures successfully sent to fortran\n" );
392    MPIcheckPoint();
393   #endif // is_mpi
394  
395 + }
396 +
397 +
398 + void LJ_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){
399    
400 +  int i;
401  
402    // initialize the atoms
403    
404 <  double bigSigma = 0.0;
404 >
405    Atom* thisAtom;
406  
407    for( i=0; i<nAtoms; i++ ){
# Line 412 | Line 423 | void LJ_FF::initializeAtoms( void ){
423  
424      if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma;
425    }
426 + }
427  
428 + void LJ_FF::initializeBonds( int nBonds, Bond** BondArray,
429 +                             bond_pair* the_bonds ){
430    
431 < #ifdef IS_MPI
418 <  double tempBig = bigSigma;
419 <  MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX );
420 < #endif  //is_mpi
421 <
422 <  //calc rCut and rList
423 <
424 <  entry_plug->rCut = 2.5 * bigSigma;
425 <  if(entry_plug->rCut > (entry_plug->box_x / 2.0))
426 <    entry_plug->rCut = entry_plug->box_x / 2.0;
427 <  if(entry_plug->rCut > (entry_plug->box_y / 2.0))
428 <    entry_plug->rCut = entry_plug->box_y / 2.0;
429 <  if(entry_plug->rCut > (entry_plug->box_z / 2.0))
430 <    entry_plug->rCut = entry_plug->box_z / 2.0;
431 <
432 <  entry_plug->rList = entry_plug->rCut + 1.0;
433 <
434 <  entry_plug->useLJ = 1;
435 <
436 <  // clean up the memory
437 <  
438 <  delete headAtomType;
439 <
440 < #ifdef IS_MPI
441 <  sprintf( checkPointMsg, "LJ_FF atoms initialized succesfully" );
442 <  MPIcheckPoint();
443 < #endif // is_mpi
444 <
445 < }
446 <
447 < void LJ_FF::initializeBonds( bond_pair* the_bonds ){
448 <  
449 <    if( entry_plug->n_bonds ){
431 >    if( nBonds ){
432        sprintf( painCave.errMsg,
433                 "LJ_FF does not support bonds.\n" );
434        painCave.isFatal = 1;
435        simError();
436      }
455 #ifdef IS_MPI
456  MPIcheckPoint();
457 #endif // is_mpi
458
437   }
438  
439 < void LJ_FF::initializeBends( bend_set* the_bends ){
439 > void LJ_FF::initializeBends( int nBends, Bend** bendArray,
440 >                             bend_set* the_bends ){
441  
442 <    if( entry_plug->n_bends ){
442 >    if( nBends ){
443        sprintf( painCave.errMsg,
444                 "LJ_FF does not support bends.\n" );
445        painCave.isFatal = 1;
446        simError();
447      }
469 #ifdef IS_MPI
470  MPIcheckPoint();
471 #endif // is_mpi
472
448   }
449  
450 < void LJ_FF::initializeTorsions( torsion_set* the_torsions ){
450 > void LJ_FF::initializeTorsions( int nTorsions, Torsion** torsionArray,
451 >                                torsion_set* the_torsions ){
452  
453 <    if( entry_plug->n_torsions ){
453 >    if( nTorsions ){
454        sprintf( painCave.errMsg,
455                 "LJ_FF does not support torsions.\n" );
456        painCave.isFatal = 1;
457        simError();
458      }
483 #ifdef IS_MPI
484  MPIcheckPoint();
485 #endif // is_mpi
486
459   }
460  
461   void LJ_FF::fastForward( char* stopText, char* searchOwner ){

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines