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

Comparing trunk/OOPSE/libmdtools/LJ_FF.cpp (file contents):
Revision 378 by mmeineke, Fri Mar 21 17:42:12 2003 UTC vs.
Revision 420 by mmeineke, Thu Mar 27 17:32:03 2003 UTC

# Line 43 | Line 43 | namespace LJ_NS{
43    MPI_Datatype mpiAtomStructType;
44    
45   #endif
46 +
47 +  class LinkedAtomType {
48 +  public:
49 +    LinkedAtomType(){
50 +      next = NULL;
51 +      name[0] = '\0';
52 +    }
53 +    ~LinkedAtomType(){ if( next != NULL ) delete next; }
54 +
55 +    LinkedAtomType* find(char* key){
56 +      if( !strcmp(name, key) ) return this;
57 +      if( next != NULL ) return next->find(key);
58 +      return NULL;
59 +    }
60 +    
61 +
62 +    void add( atomStruct &info ){
63 +    
64 +      // check for duplicates
65 +      
66 +      if( !strcmp( info.name, name ) ){
67 +        sprintf( painCave.errMsg,
68 +                 "Duplicate LJ atom type \"%s\" found in "
69 +                 "the LJ_FF param file./n",
70 +                 name );
71 +        painCave.isFatal = 1;
72 +        simError();
73 +      }
74 +      
75 +      if( next != NULL ) next->add(info);
76 +      else{
77 +        next = new LinkedType();
78 +        strcpy(next->name, info.name);
79 +        next->mass     = info.mass;
80 +        next->epslon   = info.epslon;
81 +        next->sigma    = info.sigma;
82 +        next->ident    = info.ident;
83 +      }
84 +    }
85 +    
86 +
87 + #ifdef IS_MPI
88 +    
89 +    void duplicate( atomStruct &info ){
90 +      strcpy(info.name, name);
91 +      info.mass     = mass;
92 +      info.epslon   = epslon;
93 +      info.sigma    = sigma;
94 +      info.ident    = ident;
95 +      info.last     = 0;
96 +    }
97 +
98 +
99 + #endif
100 +
101 +    char name[15];
102 +    double mass;
103 +    double epslon;
104 +    double sigma;
105 +    int ident;
106 +    LinkedAtomType* next;
107 +  };
108 +
109 +  LinkedAtomType* headAtomType;
110 +  LinkedAtomType* currentAtomType;
111 +
112   }
113  
114   using namespace LJ_NS;
# Line 60 | Line 126 | LJ_FF::LJ_FF(){
126    char temp[200];
127    char errMsg[1000];
128  
129 +  headAtomType = NULL;
130 +  currentAtomType = NULL;
131 +
132    // do the funtion wrapping
133    wrapMeFF( this );
134  
# Line 142 | Line 211 | LJ_FF::~LJ_FF(){
211  
212   LJ_FF::~LJ_FF(){
213  
214 +  if( headAtomType != NULL ) delete headAtomType;
215 +
216   #ifdef IS_MPI
217    if( worldRank == 0 ){
218   #endif // is_mpi
# Line 158 | Line 229 | void LJ_FF::initForceField( int ljMixRule ){
229    initFortran( ljMixRule, 0 );
230   }
231  
232 + void LJ_FF::cleanMe( void ){
233  
234 < void LJ_FF::initializeAtoms( void ){
234 > #ifdef IS_MPI
235    
236 <  class LinkedType {
165 <  public:
166 <    LinkedType(){
167 <      next = NULL;
168 <      name[0] = '\0';
169 <    }
170 <    ~LinkedType(){ if( next != NULL ) delete next; }
236 >  // keep the linked list in the mpi version
237  
238 <    LinkedType* find(char* key){
173 <      if( !strcmp(name, key) ) return this;
174 <      if( next != NULL ) return next->find(key);
175 <      return NULL;
176 <    }
177 <    
238 > #else // is_mpi
239  
240 <    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 <    
240 >  // delete the linked list in the single processor version
241  
242 < #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 <    }
242 >  if( headAtomType != NULL ) delete headAtomType;
243  
244 + #endif // is_mpi
245 + }
246  
247 < #endif
247 > void LJ_FF::readParams( void ){
248  
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;
249    atomStruct info;
250    info.last = 1; // initialize last to have the last set.
251                   // if things go well, last will be set to 0
# Line 232 | Line 253 | void LJ_FF::initializeAtoms( void ){
253    int i;
254    int identNum;
255    
256 <  Atom** the_atoms;
257 <  int nAtoms;
237 <  the_atoms = entry_plug->atoms;
238 <  nAtoms = entry_plug->n_atoms;
239 <  
240 <  
256 >
257 >  bigSigma = 0.0;
258   #ifdef IS_MPI
259    if( worldRank == 0 ){
260   #endif
261      
262      // read in the atom types.
263  
264 <    headAtomType = new LinkedType;
264 >    headAtomType = new LinkedAtomType;
265      
266      fastForward( "AtomTypes", "initializeAtoms" );
267  
# Line 385 | Line 402 | void LJ_FF::initializeAtoms( void ){
402             "LJ_FF atom structures successfully sent to fortran\n" );
403    MPIcheckPoint();
404   #endif // is_mpi
405 +
406 + }
407 +
408  
409 + void LJ_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){
410    
411 +  int i;
412  
413    // initialize the atoms
414    
415 <  double bigSigma = 0.0;
415 >
416    Atom* thisAtom;
417  
418    for( i=0; i<nAtoms; i++ ){
# Line 412 | Line 434 | void LJ_FF::initializeAtoms( void ){
434  
435      if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma;
436    }
415
437    
417 #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
438    entry_plug->useLJ = 1;
439  
436  // clean up the memory
437  
438  delete headAtomType;
439
440   #ifdef IS_MPI
441    sprintf( checkPointMsg, "LJ_FF atoms initialized succesfully" );
442    MPIcheckPoint();
# Line 444 | Line 444 | void LJ_FF::initializeBonds( bond_pair* the_bonds ){
444  
445   }
446  
447 < void LJ_FF::initializeBonds( bond_pair* the_bonds ){
447 > void LJ_FF::initializeBonds( int nBonds, Bond** BondArray,
448 >                             bond_pair* the_bonds ){
449    
450 <    if( entry_plug->n_bonds ){
450 >    if( nBonds ){
451        sprintf( painCave.errMsg,
452                 "LJ_FF does not support bonds.\n" );
453        painCave.isFatal = 1;
# Line 458 | Line 459 | void LJ_FF::initializeBends( bend_set* the_bends ){
459  
460   }
461  
462 < void LJ_FF::initializeBends( bend_set* the_bends ){
462 > void LJ_FF::initializeBends( int nBends, Bend** bendArray,
463 >                             bend_set* the_bends ){
464  
465 <    if( entry_plug->n_bends ){
465 >    if( nBends ){
466        sprintf( painCave.errMsg,
467                 "LJ_FF does not support bends.\n" );
468        painCave.isFatal = 1;
# Line 472 | Line 474 | void LJ_FF::initializeTorsions( torsion_set* the_torsi
474  
475   }
476  
477 < void LJ_FF::initializeTorsions( torsion_set* the_torsions ){
477 > void LJ_FF::initializeTorsions( int nTorsions, Torsion** torsionArray,
478 >                                torsion_set* the_torsions ){
479  
480 <    if( entry_plug->n_torsions ){
480 >    if( nTorsions ){
481        sprintf( painCave.errMsg,
482                 "LJ_FF does not support torsions.\n" );
483        painCave.isFatal = 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines