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 LinkedAtomType(); |
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; |
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 |
|
|
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 |
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 |
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 |
|
|
333 |
|
|
334 |
|
MPIcheckPoint(); |
335 |
|
|
336 |
< |
headAtomType = new LinkedType; |
336 |
> |
headAtomType = new LinkedAtomType; |
337 |
|
recieveFrcStruct( &info, mpiAtomStructType ); |
338 |
|
|
339 |
|
while( !info.last ){ |
397 |
|
currentAtomType = currentAtomType->next; |
398 |
|
} |
399 |
|
|
400 |
+ |
entry_plug->useLJ = 1; |
401 |
+ |
|
402 |
|
#ifdef IS_MPI |
403 |
|
sprintf( checkPointMsg, |
404 |
|
"LJ_FF atom structures successfully sent to fortran\n" ); |
405 |
|
MPIcheckPoint(); |
406 |
|
#endif // is_mpi |
407 |
+ |
|
408 |
+ |
} |
409 |
|
|
410 |
+ |
|
411 |
+ |
void LJ_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){ |
412 |
|
|
413 |
+ |
int i; |
414 |
|
|
415 |
|
// initialize the atoms |
416 |
|
|
417 |
< |
double bigSigma = 0.0; |
417 |
> |
|
418 |
|
Atom* thisAtom; |
419 |
|
|
420 |
|
for( i=0; i<nAtoms; i++ ){ |
436 |
|
|
437 |
|
if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma; |
438 |
|
} |
415 |
– |
|
439 |
|
|
417 |
– |
#ifdef IS_MPI |
418 |
– |
double tempBig = bigSigma; |
419 |
– |
MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX ); |
420 |
– |
#endif //is_mpi |
440 |
|
|
422 |
– |
//calc rCut and rList |
441 |
|
|
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 |
– |
|
442 |
|
#ifdef IS_MPI |
443 |
|
sprintf( checkPointMsg, "LJ_FF atoms initialized succesfully" ); |
444 |
|
MPIcheckPoint(); |
446 |
|
|
447 |
|
} |
448 |
|
|
449 |
< |
void LJ_FF::initializeBonds( bond_pair* the_bonds ){ |
449 |
> |
void LJ_FF::initializeBonds( int nBonds, Bond** BondArray, |
450 |
> |
bond_pair* the_bonds ){ |
451 |
|
|
452 |
< |
if( entry_plug->n_bonds ){ |
452 |
> |
if( nBonds ){ |
453 |
|
sprintf( painCave.errMsg, |
454 |
|
"LJ_FF does not support bonds.\n" ); |
455 |
|
painCave.isFatal = 1; |
461 |
|
|
462 |
|
} |
463 |
|
|
464 |
< |
void LJ_FF::initializeBends( bend_set* the_bends ){ |
464 |
> |
void LJ_FF::initializeBends( int nBends, Bend** bendArray, |
465 |
> |
bend_set* the_bends ){ |
466 |
|
|
467 |
< |
if( entry_plug->n_bends ){ |
467 |
> |
if( nBends ){ |
468 |
|
sprintf( painCave.errMsg, |
469 |
|
"LJ_FF does not support bends.\n" ); |
470 |
|
painCave.isFatal = 1; |
476 |
|
|
477 |
|
} |
478 |
|
|
479 |
< |
void LJ_FF::initializeTorsions( torsion_set* the_torsions ){ |
479 |
> |
void LJ_FF::initializeTorsions( int nTorsions, Torsion** torsionArray, |
480 |
> |
torsion_set* the_torsions ){ |
481 |
|
|
482 |
< |
if( entry_plug->n_torsions ){ |
482 |
> |
if( nTorsions ){ |
483 |
|
sprintf( painCave.errMsg, |
484 |
|
"LJ_FF does not support torsions.\n" ); |
485 |
|
painCave.isFatal = 1; |