1 |
+ |
#include <algorithm> |
2 |
|
#include <cstdlib> |
3 |
|
#include <iostream> |
4 |
|
#include <cmath> |
5 |
+ |
#include <string> |
6 |
|
|
7 |
|
#include "SimSetup.hpp" |
8 |
|
#include "parse_me.h" |
16 |
|
|
17 |
|
// some defines for ensemble and Forcefield cases |
18 |
|
|
19 |
< |
#define NVE_ENS 0 |
20 |
< |
#define NVT_ENS 1 |
21 |
< |
#define NPTi_ENS 2 |
22 |
< |
#define NPTf_ENS 3 |
23 |
< |
#define NPTim_ENS 4 |
24 |
< |
#define NPTfm_ENS 5 |
19 |
> |
#define NVE_ENS 0 |
20 |
> |
#define NVT_ENS 1 |
21 |
> |
#define NPTi_ENS 2 |
22 |
> |
#define NPTf_ENS 3 |
23 |
> |
#define NPTim_ENS 4 |
24 |
> |
#define NPTfm_ENS 5 |
25 |
> |
#define NVEZCONS_ENS 6 |
26 |
> |
#define NVTZCONS_ENS 7 |
27 |
> |
#define NPTiZCONS_ENS 8 |
28 |
> |
#define NPTfZCONS_ENS 9 |
29 |
> |
#define NPTimZCONS_ENS 10 |
30 |
> |
#define NPTfmZCONS_ENS 11 |
31 |
|
|
24 |
– |
|
32 |
|
#define FF_DUFF 0 |
33 |
|
#define FF_LJ 1 |
34 |
+ |
#define FF_EAM 2 |
35 |
|
|
36 |
+ |
using namespace std; |
37 |
|
|
38 |
|
SimSetup::SimSetup(){ |
39 |
+ |
|
40 |
+ |
isInfoArray = 0; |
41 |
+ |
nInfo = 1; |
42 |
+ |
|
43 |
|
stamps = new MakeStamps(); |
44 |
|
globals = new Globals(); |
45 |
|
|
46 |
+ |
|
47 |
|
#ifdef IS_MPI |
48 |
|
strcpy( checkPointMsg, "SimSetup creation successful" ); |
49 |
|
MPIcheckPoint(); |
55 |
|
delete globals; |
56 |
|
} |
57 |
|
|
58 |
+ |
void SimSetup::setSimInfo( SimInfo* the_info, int theNinfo ) { |
59 |
+ |
info = the_info; |
60 |
+ |
nInfo = theNinfo; |
61 |
+ |
isInfoArray = 1; |
62 |
+ |
} |
63 |
+ |
|
64 |
+ |
|
65 |
|
void SimSetup::parseFile( char* fileName ){ |
66 |
|
|
67 |
|
#ifdef IS_MPI |
97 |
|
|
98 |
|
#endif // is_mpi |
99 |
|
|
100 |
< |
void SimSetup::createSim( void ){ |
100 |
> |
void SimSetup::createSim(void){ |
101 |
|
|
81 |
– |
MakeStamps *the_stamps; |
82 |
– |
Globals* the_globals; |
102 |
|
int i, j, k, globalAtomIndex; |
103 |
|
|
104 |
< |
int ensembleCase; |
86 |
< |
int ffCase; |
104 |
> |
// gather all of the information from the Bass file |
105 |
|
|
106 |
< |
ensembleCase = -1; |
89 |
< |
ffCase = -1; |
106 |
> |
gatherInfo(); |
107 |
|
|
108 |
< |
// get the stamps and globals; |
92 |
< |
the_stamps = stamps; |
93 |
< |
the_globals = globals; |
108 |
> |
// creation of complex system objects |
109 |
|
|
110 |
< |
// set the easy ones first |
96 |
< |
simnfo->target_temp = the_globals->getTargetTemp(); |
97 |
< |
simnfo->dt = the_globals->getDt(); |
98 |
< |
simnfo->run_time = the_globals->getRunTime(); |
110 |
> |
sysObjectsCreation(); |
111 |
|
|
112 |
< |
// get the ones we know are there, yet still may need some work. |
113 |
< |
n_components = the_globals->getNComponents(); |
114 |
< |
strcpy( force_field, the_globals->getForceField() ); |
112 |
> |
// check on the post processing info |
113 |
> |
|
114 |
> |
finalInfoCheck(); |
115 |
|
|
116 |
+ |
// initialize the system coordinates |
117 |
+ |
|
118 |
+ |
if( !isInfoArray ) initSystemCoords(); |
119 |
+ |
|
120 |
+ |
// make the output filenames |
121 |
+ |
|
122 |
+ |
makeOutNames(); |
123 |
+ |
|
124 |
+ |
// make the integrator |
125 |
+ |
|
126 |
+ |
makeIntegrator(); |
127 |
+ |
|
128 |
+ |
#ifdef IS_MPI |
129 |
+ |
mpiSim->mpiRefresh(); |
130 |
+ |
#endif |
131 |
+ |
|
132 |
+ |
// initialize the Fortran |
133 |
+ |
|
134 |
+ |
initFortran(); |
135 |
+ |
|
136 |
+ |
|
137 |
+ |
|
138 |
+ |
} |
139 |
+ |
|
140 |
+ |
|
141 |
+ |
void SimSetup::makeMolecules( void ){ |
142 |
+ |
|
143 |
+ |
int k,l; |
144 |
+ |
int i, j, exI, exJ, tempEx, stampID, atomOffset, excludeOffset; |
145 |
+ |
molInit molInfo; |
146 |
+ |
DirectionalAtom* dAtom; |
147 |
+ |
LinkedAssign* extras; |
148 |
+ |
LinkedAssign* current_extra; |
149 |
+ |
AtomStamp* currentAtom; |
150 |
+ |
BondStamp* currentBond; |
151 |
+ |
BendStamp* currentBend; |
152 |
+ |
TorsionStamp* currentTorsion; |
153 |
+ |
|
154 |
+ |
bond_pair* theBonds; |
155 |
+ |
bend_set* theBends; |
156 |
+ |
torsion_set* theTorsions; |
157 |
+ |
|
158 |
+ |
|
159 |
+ |
//init the forceField paramters |
160 |
+ |
|
161 |
+ |
the_ff->readParams(); |
162 |
+ |
|
163 |
+ |
|
164 |
+ |
// init the atoms |
165 |
+ |
|
166 |
+ |
double ux, uy, uz, u, uSqr; |
167 |
+ |
|
168 |
+ |
for(k=0; k<nInfo; k++){ |
169 |
+ |
|
170 |
+ |
the_ff->setSimInfo( &(info[k]) ); |
171 |
+ |
|
172 |
+ |
atomOffset = 0; |
173 |
+ |
excludeOffset = 0; |
174 |
+ |
for(i=0; i<info[k].n_mol; i++){ |
175 |
+ |
|
176 |
+ |
stampID = info[k].molecules[i].getStampID(); |
177 |
+ |
|
178 |
+ |
molInfo.nAtoms = comp_stamps[stampID]->getNAtoms(); |
179 |
+ |
molInfo.nBonds = comp_stamps[stampID]->getNBonds(); |
180 |
+ |
molInfo.nBends = comp_stamps[stampID]->getNBends(); |
181 |
+ |
molInfo.nTorsions = comp_stamps[stampID]->getNTorsions(); |
182 |
+ |
molInfo.nExcludes = molInfo.nBonds + molInfo.nBends + molInfo.nTorsions; |
183 |
+ |
|
184 |
+ |
molInfo.myAtoms = &(info[k].atoms[atomOffset]); |
185 |
+ |
molInfo.myExcludes = &(info[k].excludes[excludeOffset]); |
186 |
+ |
molInfo.myBonds = new Bond*[molInfo.nBonds]; |
187 |
+ |
molInfo.myBends = new Bend*[molInfo.nBends]; |
188 |
+ |
molInfo.myTorsions = new Torsion*[molInfo.nTorsions]; |
189 |
+ |
|
190 |
+ |
theBonds = new bond_pair[molInfo.nBonds]; |
191 |
+ |
theBends = new bend_set[molInfo.nBends]; |
192 |
+ |
theTorsions = new torsion_set[molInfo.nTorsions]; |
193 |
+ |
|
194 |
+ |
// make the Atoms |
195 |
+ |
|
196 |
+ |
for(j=0; j<molInfo.nAtoms; j++){ |
197 |
+ |
|
198 |
+ |
currentAtom = comp_stamps[stampID]->getAtom( j ); |
199 |
+ |
if( currentAtom->haveOrientation() ){ |
200 |
+ |
|
201 |
+ |
dAtom = new DirectionalAtom( (j + atomOffset), |
202 |
+ |
info[k].getConfiguration() ); |
203 |
+ |
info[k].n_oriented++; |
204 |
+ |
molInfo.myAtoms[j] = dAtom; |
205 |
+ |
|
206 |
+ |
ux = currentAtom->getOrntX(); |
207 |
+ |
uy = currentAtom->getOrntY(); |
208 |
+ |
uz = currentAtom->getOrntZ(); |
209 |
+ |
|
210 |
+ |
uSqr = (ux * ux) + (uy * uy) + (uz * uz); |
211 |
+ |
|
212 |
+ |
u = sqrt( uSqr ); |
213 |
+ |
ux = ux / u; |
214 |
+ |
uy = uy / u; |
215 |
+ |
uz = uz / u; |
216 |
+ |
|
217 |
+ |
dAtom->setSUx( ux ); |
218 |
+ |
dAtom->setSUy( uy ); |
219 |
+ |
dAtom->setSUz( uz ); |
220 |
+ |
} |
221 |
+ |
else{ |
222 |
+ |
molInfo.myAtoms[j] = new GeneralAtom( (j + atomOffset), |
223 |
+ |
info[k].getConfiguration() ); |
224 |
+ |
} |
225 |
+ |
molInfo.myAtoms[j]->setType( currentAtom->getType() ); |
226 |
+ |
|
227 |
+ |
#ifdef IS_MPI |
228 |
+ |
|
229 |
+ |
molInfo.myAtoms[j]->setGlobalIndex( globalIndex[j+atomOffset] ); |
230 |
+ |
|
231 |
+ |
#endif // is_mpi |
232 |
+ |
} |
233 |
+ |
|
234 |
+ |
// make the bonds |
235 |
+ |
for(j=0; j<molInfo.nBonds; j++){ |
236 |
+ |
|
237 |
+ |
currentBond = comp_stamps[stampID]->getBond( j ); |
238 |
+ |
theBonds[j].a = currentBond->getA() + atomOffset; |
239 |
+ |
theBonds[j].b = currentBond->getB() + atomOffset; |
240 |
+ |
|
241 |
+ |
exI = theBonds[j].a; |
242 |
+ |
exJ = theBonds[j].b; |
243 |
+ |
|
244 |
+ |
// exclude_I must always be the smaller of the pair |
245 |
+ |
if( exI > exJ ){ |
246 |
+ |
tempEx = exI; |
247 |
+ |
exI = exJ; |
248 |
+ |
exJ = tempEx; |
249 |
+ |
} |
250 |
+ |
#ifdef IS_MPI |
251 |
+ |
tempEx = exI; |
252 |
+ |
exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
253 |
+ |
tempEx = exJ; |
254 |
+ |
exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
255 |
+ |
|
256 |
+ |
info[k].excludes[j+excludeOffset]->setPair( exI, exJ ); |
257 |
+ |
#else // isn't MPI |
258 |
+ |
|
259 |
+ |
info[k].excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); |
260 |
+ |
#endif //is_mpi |
261 |
+ |
} |
262 |
+ |
excludeOffset += molInfo.nBonds; |
263 |
+ |
|
264 |
+ |
//make the bends |
265 |
+ |
for(j=0; j<molInfo.nBends; j++){ |
266 |
+ |
|
267 |
+ |
currentBend = comp_stamps[stampID]->getBend( j ); |
268 |
+ |
theBends[j].a = currentBend->getA() + atomOffset; |
269 |
+ |
theBends[j].b = currentBend->getB() + atomOffset; |
270 |
+ |
theBends[j].c = currentBend->getC() + atomOffset; |
271 |
+ |
|
272 |
+ |
if( currentBend->haveExtras() ){ |
273 |
+ |
|
274 |
+ |
extras = currentBend->getExtras(); |
275 |
+ |
current_extra = extras; |
276 |
+ |
|
277 |
+ |
while( current_extra != NULL ){ |
278 |
+ |
if( !strcmp( current_extra->getlhs(), "ghostVectorSource" )){ |
279 |
+ |
|
280 |
+ |
switch( current_extra->getType() ){ |
281 |
+ |
|
282 |
+ |
case 0: |
283 |
+ |
theBends[j].ghost = |
284 |
+ |
current_extra->getInt() + atomOffset; |
285 |
+ |
theBends[j].isGhost = 1; |
286 |
+ |
break; |
287 |
+ |
|
288 |
+ |
case 1: |
289 |
+ |
theBends[j].ghost = |
290 |
+ |
(int)current_extra->getDouble() + atomOffset; |
291 |
+ |
theBends[j].isGhost = 1; |
292 |
+ |
break; |
293 |
+ |
|
294 |
+ |
default: |
295 |
+ |
sprintf( painCave.errMsg, |
296 |
+ |
"SimSetup Error: ghostVectorSource was neither a " |
297 |
+ |
"double nor an int.\n" |
298 |
+ |
"-->Bend[%d] in %s\n", |
299 |
+ |
j, comp_stamps[stampID]->getID() ); |
300 |
+ |
painCave.isFatal = 1; |
301 |
+ |
simError(); |
302 |
+ |
} |
303 |
+ |
} |
304 |
+ |
|
305 |
+ |
else{ |
306 |
+ |
|
307 |
+ |
sprintf( painCave.errMsg, |
308 |
+ |
"SimSetup Error: unhandled bend assignment:\n" |
309 |
+ |
" -->%s in Bend[%d] in %s\n", |
310 |
+ |
current_extra->getlhs(), |
311 |
+ |
j, comp_stamps[stampID]->getID() ); |
312 |
+ |
painCave.isFatal = 1; |
313 |
+ |
simError(); |
314 |
+ |
} |
315 |
+ |
|
316 |
+ |
current_extra = current_extra->getNext(); |
317 |
+ |
} |
318 |
+ |
} |
319 |
+ |
|
320 |
+ |
if( !theBends[j].isGhost ){ |
321 |
+ |
|
322 |
+ |
exI = theBends[j].a; |
323 |
+ |
exJ = theBends[j].c; |
324 |
+ |
} |
325 |
+ |
else{ |
326 |
+ |
|
327 |
+ |
exI = theBends[j].a; |
328 |
+ |
exJ = theBends[j].b; |
329 |
+ |
} |
330 |
+ |
|
331 |
+ |
// exclude_I must always be the smaller of the pair |
332 |
+ |
if( exI > exJ ){ |
333 |
+ |
tempEx = exI; |
334 |
+ |
exI = exJ; |
335 |
+ |
exJ = tempEx; |
336 |
+ |
} |
337 |
+ |
#ifdef IS_MPI |
338 |
+ |
tempEx = exI; |
339 |
+ |
exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
340 |
+ |
tempEx = exJ; |
341 |
+ |
exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
342 |
+ |
|
343 |
+ |
info[k].excludes[j+excludeOffset]->setPair( exI, exJ ); |
344 |
+ |
#else // isn't MPI |
345 |
+ |
info[k].excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); |
346 |
+ |
#endif //is_mpi |
347 |
+ |
} |
348 |
+ |
excludeOffset += molInfo.nBends; |
349 |
+ |
|
350 |
+ |
for(j=0; j<molInfo.nTorsions; j++){ |
351 |
+ |
|
352 |
+ |
currentTorsion = comp_stamps[stampID]->getTorsion( j ); |
353 |
+ |
theTorsions[j].a = currentTorsion->getA() + atomOffset; |
354 |
+ |
theTorsions[j].b = currentTorsion->getB() + atomOffset; |
355 |
+ |
theTorsions[j].c = currentTorsion->getC() + atomOffset; |
356 |
+ |
theTorsions[j].d = currentTorsion->getD() + atomOffset; |
357 |
+ |
|
358 |
+ |
exI = theTorsions[j].a; |
359 |
+ |
exJ = theTorsions[j].d; |
360 |
+ |
|
361 |
+ |
// exclude_I must always be the smaller of the pair |
362 |
+ |
if( exI > exJ ){ |
363 |
+ |
tempEx = exI; |
364 |
+ |
exI = exJ; |
365 |
+ |
exJ = tempEx; |
366 |
+ |
} |
367 |
+ |
#ifdef IS_MPI |
368 |
+ |
tempEx = exI; |
369 |
+ |
exI = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
370 |
+ |
tempEx = exJ; |
371 |
+ |
exJ = info[k].atoms[tempEx]->getGlobalIndex() + 1; |
372 |
+ |
|
373 |
+ |
info[k].excludes[j+excludeOffset]->setPair( exI, exJ ); |
374 |
+ |
#else // isn't MPI |
375 |
+ |
info[k].excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); |
376 |
+ |
#endif //is_mpi |
377 |
+ |
} |
378 |
+ |
excludeOffset += molInfo.nTorsions; |
379 |
+ |
|
380 |
+ |
|
381 |
+ |
// send the arrays off to the forceField for init. |
382 |
+ |
|
383 |
+ |
the_ff->initializeAtoms( molInfo.nAtoms, molInfo.myAtoms ); |
384 |
+ |
the_ff->initializeBonds( molInfo.nBonds, molInfo.myBonds, theBonds ); |
385 |
+ |
the_ff->initializeBends( molInfo.nBends, molInfo.myBends, theBends ); |
386 |
+ |
the_ff->initializeTorsions( molInfo.nTorsions, molInfo.myTorsions, theTorsions ); |
387 |
+ |
|
388 |
+ |
|
389 |
+ |
info[k].molecules[i].initialize( molInfo ); |
390 |
+ |
|
391 |
+ |
|
392 |
+ |
atomOffset += molInfo.nAtoms; |
393 |
+ |
delete[] theBonds; |
394 |
+ |
delete[] theBends; |
395 |
+ |
delete[] theTorsions; |
396 |
+ |
} |
397 |
+ |
} |
398 |
+ |
|
399 |
+ |
#ifdef IS_MPI |
400 |
+ |
sprintf( checkPointMsg, "all molecules initialized succesfully" ); |
401 |
+ |
MPIcheckPoint(); |
402 |
+ |
#endif // is_mpi |
403 |
+ |
|
404 |
+ |
// clean up the forcefield |
405 |
+ |
|
406 |
+ |
the_ff->calcRcut(); |
407 |
+ |
the_ff->cleanMe(); |
408 |
+ |
|
409 |
+ |
} |
410 |
+ |
|
411 |
+ |
void SimSetup::initFromBass( void ){ |
412 |
+ |
|
413 |
+ |
int i, j, k; |
414 |
+ |
int n_cells; |
415 |
+ |
double cellx, celly, cellz; |
416 |
+ |
double temp1, temp2, temp3; |
417 |
+ |
int n_per_extra; |
418 |
+ |
int n_extra; |
419 |
+ |
int have_extra, done; |
420 |
+ |
|
421 |
+ |
double vel[3]; |
422 |
+ |
vel[0] = 0.0; |
423 |
+ |
vel[1] = 0.0; |
424 |
+ |
vel[2] = 0.0; |
425 |
+ |
|
426 |
+ |
temp1 = (double)tot_nmol / 4.0; |
427 |
+ |
temp2 = pow( temp1, ( 1.0 / 3.0 ) ); |
428 |
+ |
temp3 = ceil( temp2 ); |
429 |
+ |
|
430 |
+ |
have_extra =0; |
431 |
+ |
if( temp2 < temp3 ){ // we have a non-complete lattice |
432 |
+ |
have_extra =1; |
433 |
+ |
|
434 |
+ |
n_cells = (int)temp3 - 1; |
435 |
+ |
cellx = info[0].boxL[0] / temp3; |
436 |
+ |
celly = info[0].boxL[1] / temp3; |
437 |
+ |
cellz = info[0].boxL[2] / temp3; |
438 |
+ |
n_extra = tot_nmol - ( 4 * n_cells * n_cells * n_cells ); |
439 |
+ |
temp1 = ((double)n_extra) / ( pow( temp3, 3.0 ) - pow( n_cells, 3.0 ) ); |
440 |
+ |
n_per_extra = (int)ceil( temp1 ); |
441 |
+ |
|
442 |
+ |
if( n_per_extra > 4){ |
443 |
+ |
sprintf( painCave.errMsg, |
444 |
+ |
"SimSetup error. There has been an error in constructing" |
445 |
+ |
" the non-complete lattice.\n" ); |
446 |
+ |
painCave.isFatal = 1; |
447 |
+ |
simError(); |
448 |
+ |
} |
449 |
+ |
} |
450 |
+ |
else{ |
451 |
+ |
n_cells = (int)temp3; |
452 |
+ |
cellx = info[0].boxL[0] / temp3; |
453 |
+ |
celly = info[0].boxL[1] / temp3; |
454 |
+ |
cellz = info[0].boxL[2] / temp3; |
455 |
+ |
} |
456 |
+ |
|
457 |
+ |
current_mol = 0; |
458 |
+ |
current_comp_mol = 0; |
459 |
+ |
current_comp = 0; |
460 |
+ |
current_atom_ndx = 0; |
461 |
+ |
|
462 |
+ |
for( i=0; i < n_cells ; i++ ){ |
463 |
+ |
for( j=0; j < n_cells; j++ ){ |
464 |
+ |
for( k=0; k < n_cells; k++ ){ |
465 |
+ |
|
466 |
+ |
makeElement( i * cellx, |
467 |
+ |
j * celly, |
468 |
+ |
k * cellz ); |
469 |
+ |
|
470 |
+ |
makeElement( i * cellx + 0.5 * cellx, |
471 |
+ |
j * celly + 0.5 * celly, |
472 |
+ |
k * cellz ); |
473 |
+ |
|
474 |
+ |
makeElement( i * cellx, |
475 |
+ |
j * celly + 0.5 * celly, |
476 |
+ |
k * cellz + 0.5 * cellz ); |
477 |
+ |
|
478 |
+ |
makeElement( i * cellx + 0.5 * cellx, |
479 |
+ |
j * celly, |
480 |
+ |
k * cellz + 0.5 * cellz ); |
481 |
+ |
} |
482 |
+ |
} |
483 |
+ |
} |
484 |
+ |
|
485 |
+ |
if( have_extra ){ |
486 |
+ |
done = 0; |
487 |
+ |
|
488 |
+ |
int start_ndx; |
489 |
+ |
for( i=0; i < (n_cells+1) && !done; i++ ){ |
490 |
+ |
for( j=0; j < (n_cells+1) && !done; j++ ){ |
491 |
+ |
|
492 |
+ |
if( i < n_cells ){ |
493 |
+ |
|
494 |
+ |
if( j < n_cells ){ |
495 |
+ |
start_ndx = n_cells; |
496 |
+ |
} |
497 |
+ |
else start_ndx = 0; |
498 |
+ |
} |
499 |
+ |
else start_ndx = 0; |
500 |
+ |
|
501 |
+ |
for( k=start_ndx; k < (n_cells+1) && !done; k++ ){ |
502 |
+ |
|
503 |
+ |
makeElement( i * cellx, |
504 |
+ |
j * celly, |
505 |
+ |
k * cellz ); |
506 |
+ |
done = ( current_mol >= tot_nmol ); |
507 |
+ |
|
508 |
+ |
if( !done && n_per_extra > 1 ){ |
509 |
+ |
makeElement( i * cellx + 0.5 * cellx, |
510 |
+ |
j * celly + 0.5 * celly, |
511 |
+ |
k * cellz ); |
512 |
+ |
done = ( current_mol >= tot_nmol ); |
513 |
+ |
} |
514 |
+ |
|
515 |
+ |
if( !done && n_per_extra > 2){ |
516 |
+ |
makeElement( i * cellx, |
517 |
+ |
j * celly + 0.5 * celly, |
518 |
+ |
k * cellz + 0.5 * cellz ); |
519 |
+ |
done = ( current_mol >= tot_nmol ); |
520 |
+ |
} |
521 |
+ |
|
522 |
+ |
if( !done && n_per_extra > 3){ |
523 |
+ |
makeElement( i * cellx + 0.5 * cellx, |
524 |
+ |
j * celly, |
525 |
+ |
k * cellz + 0.5 * cellz ); |
526 |
+ |
done = ( current_mol >= tot_nmol ); |
527 |
+ |
} |
528 |
+ |
} |
529 |
+ |
} |
530 |
+ |
} |
531 |
+ |
} |
532 |
+ |
|
533 |
+ |
for( i=0; i<info[0].n_atoms; i++ ){ |
534 |
+ |
info[0].atoms[i]->setVel( vel ); |
535 |
+ |
} |
536 |
+ |
} |
537 |
+ |
|
538 |
+ |
void SimSetup::makeElement( double x, double y, double z ){ |
539 |
+ |
|
540 |
+ |
int k; |
541 |
+ |
AtomStamp* current_atom; |
542 |
+ |
DirectionalAtom* dAtom; |
543 |
+ |
double rotMat[3][3]; |
544 |
+ |
double pos[3]; |
545 |
+ |
|
546 |
+ |
for( k=0; k<comp_stamps[current_comp]->getNAtoms(); k++ ){ |
547 |
+ |
|
548 |
+ |
current_atom = comp_stamps[current_comp]->getAtom( k ); |
549 |
+ |
if( !current_atom->havePosition() ){ |
550 |
+ |
sprintf( painCave.errMsg, |
551 |
+ |
"SimSetup:initFromBass error.\n" |
552 |
+ |
"\tComponent %s, atom %s does not have a position specified.\n" |
553 |
+ |
"\tThe initialization routine is unable to give a start" |
554 |
+ |
" position.\n", |
555 |
+ |
comp_stamps[current_comp]->getID(), |
556 |
+ |
current_atom->getType() ); |
557 |
+ |
painCave.isFatal = 1; |
558 |
+ |
simError(); |
559 |
+ |
} |
560 |
+ |
|
561 |
+ |
pos[0] = x + current_atom->getPosX(); |
562 |
+ |
pos[1] = y + current_atom->getPosY(); |
563 |
+ |
pos[2] = z + current_atom->getPosZ(); |
564 |
+ |
|
565 |
+ |
info[0].atoms[current_atom_ndx]->setPos( pos ); |
566 |
+ |
|
567 |
+ |
if( info[0].atoms[current_atom_ndx]->isDirectional() ){ |
568 |
+ |
|
569 |
+ |
dAtom = (DirectionalAtom *)info[0].atoms[current_atom_ndx]; |
570 |
+ |
|
571 |
+ |
rotMat[0][0] = 1.0; |
572 |
+ |
rotMat[0][1] = 0.0; |
573 |
+ |
rotMat[0][2] = 0.0; |
574 |
+ |
|
575 |
+ |
rotMat[1][0] = 0.0; |
576 |
+ |
rotMat[1][1] = 1.0; |
577 |
+ |
rotMat[1][2] = 0.0; |
578 |
+ |
|
579 |
+ |
rotMat[2][0] = 0.0; |
580 |
+ |
rotMat[2][1] = 0.0; |
581 |
+ |
rotMat[2][2] = 1.0; |
582 |
+ |
|
583 |
+ |
dAtom->setA( rotMat ); |
584 |
+ |
} |
585 |
+ |
|
586 |
+ |
current_atom_ndx++; |
587 |
+ |
} |
588 |
+ |
|
589 |
+ |
current_mol++; |
590 |
+ |
current_comp_mol++; |
591 |
+ |
|
592 |
+ |
if( current_comp_mol >= components_nmol[current_comp] ){ |
593 |
+ |
|
594 |
+ |
current_comp_mol = 0; |
595 |
+ |
current_comp++; |
596 |
+ |
} |
597 |
+ |
} |
598 |
+ |
|
599 |
+ |
|
600 |
+ |
void SimSetup::gatherInfo( void ){ |
601 |
+ |
int i,j,k; |
602 |
+ |
|
603 |
+ |
ensembleCase = -1; |
604 |
+ |
ffCase = -1; |
605 |
+ |
|
606 |
+ |
// set the easy ones first |
607 |
+ |
|
608 |
+ |
for( i=0; i<nInfo; i++){ |
609 |
+ |
info[i].target_temp = globals->getTargetTemp(); |
610 |
+ |
info[i].dt = globals->getDt(); |
611 |
+ |
info[i].run_time = globals->getRunTime(); |
612 |
+ |
} |
613 |
+ |
n_components = globals->getNComponents(); |
614 |
+ |
|
615 |
+ |
|
616 |
+ |
// get the forceField |
617 |
+ |
|
618 |
+ |
strcpy( force_field, globals->getForceField() ); |
619 |
+ |
|
620 |
|
if( !strcasecmp( force_field, "DUFF" )) ffCase = FF_DUFF; |
621 |
|
else if( !strcasecmp( force_field, "LJ" )) ffCase = FF_LJ; |
622 |
+ |
else if( !strcasecmp( force_field, "EAM" )) ffCase = FF_EAM; |
623 |
|
else{ |
624 |
|
sprintf( painCave.errMsg, |
625 |
|
"SimSetup Error. Unrecognized force field -> %s\n", |
628 |
|
simError(); |
629 |
|
} |
630 |
|
|
631 |
< |
// get the ensemble: |
115 |
< |
strcpy( ensemble, the_globals->getEnsemble() ); |
631 |
> |
// get the ensemble |
632 |
|
|
633 |
+ |
strcpy( ensemble, globals->getEnsemble() ); |
634 |
+ |
|
635 |
|
if( !strcasecmp( ensemble, "NVE" )) ensembleCase = NVE_ENS; |
636 |
|
else if( !strcasecmp( ensemble, "NVT" )) ensembleCase = NVT_ENS; |
637 |
|
else if( !strcasecmp( ensemble, "NPTi" ) || !strcasecmp( ensemble, "NPT") ) |
639 |
|
else if( !strcasecmp( ensemble, "NPTf" )) ensembleCase = NPTf_ENS; |
640 |
|
else if( !strcasecmp( ensemble, "NPTim" )) ensembleCase = NPTim_ENS; |
641 |
|
else if( !strcasecmp( ensemble, "NPTfm" )) ensembleCase = NPTfm_ENS; |
642 |
+ |
|
643 |
+ |
else if( !strcasecmp( ensemble, "NVEZCONS")) ensembleCase = NVEZCONS_ENS; |
644 |
+ |
else if( !strcasecmp( ensemble, "NVTZCONS")) ensembleCase = NVTZCONS_ENS; |
645 |
+ |
else if( !strcasecmp( ensemble, "NPTiZCONS") || !strcasecmp( ensemble, "NPTZCONS")) |
646 |
+ |
ensembleCase = NPTiZCONS_ENS; |
647 |
+ |
else if( !strcasecmp( ensemble, "NPTfZCONS")) ensembleCase = NPTfZCONS_ENS; |
648 |
+ |
else if( !strcasecmp( ensemble, "NPTimZCONS")) ensembleCase = NPTimZCONS_ENS; |
649 |
+ |
else if( !strcasecmp( ensemble, "NPTfmZCONS")) ensembleCase = NPTfmZCONS_ENS; |
650 |
+ |
|
651 |
|
else{ |
652 |
|
sprintf( painCave.errMsg, |
653 |
|
"SimSetup Warning. Unrecognized Ensemble -> %s, " |
658 |
|
strcpy( ensemble, "NVE" ); |
659 |
|
ensembleCase = NVE_ENS; |
660 |
|
} |
661 |
< |
strcpy( simnfo->ensemble, ensemble ); |
661 |
> |
|
662 |
> |
for(i=0; i<nInfo; i++){ |
663 |
> |
|
664 |
> |
strcpy( info[i].ensemble, ensemble ); |
665 |
|
|
666 |
+ |
// get the mixing rule |
667 |
|
|
668 |
< |
// if( !strcasecmp( ensemble, "NPT" ) ) { |
669 |
< |
// the_extendedsystem = new ExtendedSystem( simnfo ); |
139 |
< |
// the_extendedsystem->setTargetTemp(the_globals->getTargetTemp()); |
140 |
< |
// if (the_globals->haveTargetPressure()) |
141 |
< |
// the_extendedsystem->setTargetPressure(the_globals->getTargetPressure()); |
142 |
< |
// else { |
143 |
< |
// sprintf( painCave.errMsg, |
144 |
< |
// "SimSetup error: If you use the constant pressure\n" |
145 |
< |
// " ensemble, you must set targetPressure.\n" |
146 |
< |
// " This was found in the BASS file.\n"); |
147 |
< |
// painCave.isFatal = 1; |
148 |
< |
// simError(); |
149 |
< |
// } |
150 |
< |
|
151 |
< |
// if (the_globals->haveTauThermostat()) |
152 |
< |
// the_extendedsystem->setTauThermostat(the_globals->getTauThermostat()); |
153 |
< |
// else if (the_globals->haveQmass()) |
154 |
< |
// the_extendedsystem->setQmass(the_globals->getQmass()); |
155 |
< |
// else { |
156 |
< |
// sprintf( painCave.errMsg, |
157 |
< |
// "SimSetup error: If you use one of the constant temperature\n" |
158 |
< |
// " ensembles, you must set either tauThermostat or qMass.\n" |
159 |
< |
// " Neither of these was found in the BASS file.\n"); |
160 |
< |
// painCave.isFatal = 1; |
161 |
< |
// simError(); |
162 |
< |
// } |
163 |
< |
|
164 |
< |
// if (the_globals->haveTauBarostat()) |
165 |
< |
// the_extendedsystem->setTauBarostat(the_globals->getTauBarostat()); |
166 |
< |
// else { |
167 |
< |
// sprintf( painCave.errMsg, |
168 |
< |
// "SimSetup error: If you use the constant pressure\n" |
169 |
< |
// " ensemble, you must set tauBarostat.\n" |
170 |
< |
// " This was found in the BASS file.\n"); |
171 |
< |
// painCave.isFatal = 1; |
172 |
< |
// simError(); |
173 |
< |
// } |
174 |
< |
|
175 |
< |
// } else if ( !strcasecmp( ensemble, "NVT") ) { |
176 |
< |
// the_extendedsystem = new ExtendedSystem( simnfo ); |
177 |
< |
// the_extendedsystem->setTargetTemp(the_globals->getTargetTemp()); |
178 |
< |
|
179 |
< |
// if (the_globals->haveTauThermostat()) |
180 |
< |
// the_extendedsystem->setTauThermostat(the_globals->getTauThermostat()); |
181 |
< |
// else if (the_globals->haveQmass()) |
182 |
< |
// the_extendedsystem->setQmass(the_globals->getQmass()); |
183 |
< |
// else { |
184 |
< |
// sprintf( painCave.errMsg, |
185 |
< |
// "SimSetup error: If you use one of the constant temperature\n" |
186 |
< |
// " ensembles, you must set either tauThermostat or qMass.\n" |
187 |
< |
// " Neither of these was found in the BASS file.\n"); |
188 |
< |
// painCave.isFatal = 1; |
189 |
< |
// simError(); |
190 |
< |
// } |
191 |
< |
|
192 |
< |
strcpy( simnfo->mixingRule, the_globals->getMixingRule() ); |
193 |
< |
simnfo->usePBC = the_globals->getPBC(); |
194 |
< |
|
195 |
< |
int usesDipoles = 0; |
196 |
< |
switch( ffCase ){ |
197 |
< |
|
198 |
< |
case FF_DUFF: |
199 |
< |
the_ff = new DUFF(); |
200 |
< |
usesDipoles = 1; |
201 |
< |
break; |
202 |
< |
|
203 |
< |
case FF_LJ: |
204 |
< |
the_ff = new LJFF(); |
205 |
< |
break; |
206 |
< |
|
207 |
< |
default: |
208 |
< |
sprintf( painCave.errMsg, |
209 |
< |
"SimSetup Error. Unrecognized force field in case statement.\n"); |
210 |
< |
painCave.isFatal = 1; |
211 |
< |
simError(); |
668 |
> |
strcpy( info[i].mixingRule, globals->getMixingRule() ); |
669 |
> |
info[i].usePBC = globals->getPBC(); |
670 |
|
} |
671 |
< |
|
214 |
< |
#ifdef IS_MPI |
215 |
< |
strcpy( checkPointMsg, "ForceField creation successful" ); |
216 |
< |
MPIcheckPoint(); |
217 |
< |
#endif // is_mpi |
218 |
< |
|
671 |
> |
|
672 |
|
// get the components and calculate the tot_nMol and indvidual n_mol |
673 |
< |
the_components = the_globals->getComponents(); |
673 |
> |
|
674 |
> |
the_components = globals->getComponents(); |
675 |
|
components_nmol = new int[n_components]; |
222 |
– |
comp_stamps = new MoleculeStamp*[n_components]; |
676 |
|
|
677 |
< |
if( !the_globals->haveNMol() ){ |
677 |
> |
|
678 |
> |
if( !globals->haveNMol() ){ |
679 |
|
// we don't have the total number of molecules, so we assume it is |
680 |
|
// given in each component |
681 |
|
|
704 |
|
" Please give nMol in the components.\n" ); |
705 |
|
painCave.isFatal = 1; |
706 |
|
simError(); |
707 |
+ |
} |
708 |
+ |
|
709 |
+ |
// set the status, sample, and thermal kick times |
710 |
+ |
|
711 |
+ |
for(i=0; i<nInfo; i++){ |
712 |
+ |
|
713 |
+ |
if( globals->haveSampleTime() ){ |
714 |
+ |
info[i].sampleTime = globals->getSampleTime(); |
715 |
+ |
info[i].statusTime = info[i].sampleTime; |
716 |
+ |
info[i].thermalTime = info[i].sampleTime; |
717 |
+ |
} |
718 |
+ |
else{ |
719 |
+ |
info[i].sampleTime = globals->getRunTime(); |
720 |
+ |
info[i].statusTime = info[i].sampleTime; |
721 |
+ |
info[i].thermalTime = info[i].sampleTime; |
722 |
+ |
} |
723 |
|
|
724 |
+ |
if( globals->haveStatusTime() ){ |
725 |
+ |
info[i].statusTime = globals->getStatusTime(); |
726 |
+ |
} |
727 |
|
|
728 |
< |
// tot_nmol = the_globals->getNMol(); |
728 |
> |
if( globals->haveThermalTime() ){ |
729 |
> |
info[i].thermalTime = globals->getThermalTime(); |
730 |
> |
} |
731 |
> |
|
732 |
> |
// check for the temperature set flag |
733 |
> |
|
734 |
> |
if( globals->haveTempSet() ) info[i].setTemp = globals->getTempSet(); |
735 |
|
|
736 |
< |
// //we have the total number of molecules, now we check for molfractions |
258 |
< |
// for( i=0; i<n_components; i++ ){ |
736 |
> |
// get some of the tricky things that may still be in the globals |
737 |
|
|
738 |
< |
// if( !the_components[i]->haveMolFraction() ){ |
739 |
< |
|
740 |
< |
// if( !the_components[i]->haveNMol() ){ |
741 |
< |
// //we have a problem |
742 |
< |
// std::cerr << "SimSetup error. Neither molFraction nor " |
743 |
< |
// << " nMol was given in component |
744 |
< |
|
738 |
> |
double boxVector[3]; |
739 |
> |
if( globals->haveBox() ){ |
740 |
> |
boxVector[0] = globals->getBox(); |
741 |
> |
boxVector[1] = globals->getBox(); |
742 |
> |
boxVector[2] = globals->getBox(); |
743 |
> |
|
744 |
> |
info[i].setBox( boxVector ); |
745 |
> |
} |
746 |
> |
else if( globals->haveDensity() ){ |
747 |
> |
|
748 |
> |
double vol; |
749 |
> |
vol = (double)tot_nmol / globals->getDensity(); |
750 |
> |
boxVector[0] = pow( vol, ( 1.0 / 3.0 ) ); |
751 |
> |
boxVector[1] = boxVector[0]; |
752 |
> |
boxVector[2] = boxVector[0]; |
753 |
> |
|
754 |
> |
info[i].setBox( boxVector ); |
755 |
|
} |
756 |
+ |
else{ |
757 |
+ |
if( !globals->haveBoxX() ){ |
758 |
+ |
sprintf( painCave.errMsg, |
759 |
+ |
"SimSetup error, no periodic BoxX size given.\n" ); |
760 |
+ |
painCave.isFatal = 1; |
761 |
+ |
simError(); |
762 |
+ |
} |
763 |
+ |
boxVector[0] = globals->getBoxX(); |
764 |
+ |
|
765 |
+ |
if( !globals->haveBoxY() ){ |
766 |
+ |
sprintf( painCave.errMsg, |
767 |
+ |
"SimSetup error, no periodic BoxY size given.\n" ); |
768 |
+ |
painCave.isFatal = 1; |
769 |
+ |
simError(); |
770 |
+ |
} |
771 |
+ |
boxVector[1] = globals->getBoxY(); |
772 |
+ |
|
773 |
+ |
if( !globals->haveBoxZ() ){ |
774 |
+ |
sprintf( painCave.errMsg, |
775 |
+ |
"SimSetup error, no periodic BoxZ size given.\n" ); |
776 |
+ |
painCave.isFatal = 1; |
777 |
+ |
simError(); |
778 |
+ |
} |
779 |
+ |
boxVector[2] = globals->getBoxZ(); |
780 |
+ |
|
781 |
+ |
info[i].setBox( boxVector ); |
782 |
+ |
} |
783 |
|
|
784 |
+ |
} |
785 |
+ |
|
786 |
|
#ifdef IS_MPI |
787 |
< |
strcpy( checkPointMsg, "Have the number of components" ); |
787 |
> |
strcpy( checkPointMsg, "Succesfully gathered all information from Bass\n" ); |
788 |
|
MPIcheckPoint(); |
789 |
|
#endif // is_mpi |
790 |
|
|
791 |
< |
// make an array of molecule stamps that match the components used. |
275 |
< |
// also extract the used stamps out into a separate linked list |
791 |
> |
} |
792 |
|
|
277 |
– |
simnfo->nComponents = n_components; |
278 |
– |
simnfo->componentsNmol = components_nmol; |
279 |
– |
simnfo->compStamps = comp_stamps; |
280 |
– |
simnfo->headStamp = new LinkedMolStamp(); |
281 |
– |
|
282 |
– |
char* id; |
283 |
– |
LinkedMolStamp* headStamp = simnfo->headStamp; |
284 |
– |
LinkedMolStamp* currentStamp = NULL; |
285 |
– |
for( i=0; i<n_components; i++ ){ |
793 |
|
|
794 |
< |
id = the_components[i]->getType(); |
795 |
< |
comp_stamps[i] = NULL; |
796 |
< |
|
797 |
< |
// check to make sure the component isn't already in the list |
794 |
> |
void SimSetup::finalInfoCheck( void ){ |
795 |
> |
int index; |
796 |
> |
int usesDipoles; |
797 |
> |
int i; |
798 |
|
|
799 |
< |
comp_stamps[i] = headStamp->match( id ); |
800 |
< |
if( comp_stamps[i] == NULL ){ |
801 |
< |
|
802 |
< |
// extract the component from the list; |
803 |
< |
|
804 |
< |
currentStamp = the_stamps->extractMolStamp( id ); |
805 |
< |
if( currentStamp == NULL ){ |
799 |
> |
for(i=0; i<nInfo; i++){ |
800 |
> |
// check electrostatic parameters |
801 |
> |
|
802 |
> |
index = 0; |
803 |
> |
usesDipoles = 0; |
804 |
> |
while( (index < info[i].n_atoms) && !usesDipoles ){ |
805 |
> |
usesDipoles = (info[i].atoms[index])->hasDipole(); |
806 |
> |
index++; |
807 |
> |
} |
808 |
> |
|
809 |
> |
#ifdef IS_MPI |
810 |
> |
int myUse = usesDipoles; |
811 |
> |
MPI_Allreduce( &myUse, &usesDipoles, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD ); |
812 |
> |
#endif //is_mpi |
813 |
> |
|
814 |
> |
double theEcr, theEst; |
815 |
> |
|
816 |
> |
if (globals->getUseRF() ) { |
817 |
> |
info[i].useReactionField = 1; |
818 |
> |
|
819 |
> |
if( !globals->haveECR() ){ |
820 |
|
sprintf( painCave.errMsg, |
821 |
< |
"SimSetup error: Component \"%s\" was not found in the " |
822 |
< |
"list of declared molecules\n", |
823 |
< |
id ); |
824 |
< |
painCave.isFatal = 1; |
821 |
> |
"SimSetup Warning: using default value of 1/2 the smallest " |
822 |
> |
"box length for the electrostaticCutoffRadius.\n" |
823 |
> |
"I hope you have a very fast processor!\n"); |
824 |
> |
painCave.isFatal = 0; |
825 |
|
simError(); |
826 |
+ |
double smallest; |
827 |
+ |
smallest = info[i].boxL[0]; |
828 |
+ |
if (info[i].boxL[1] <= smallest) smallest = info[i].boxL[1]; |
829 |
+ |
if (info[i].boxL[2] <= smallest) smallest = info[i].boxL[2]; |
830 |
+ |
theEcr = 0.5 * smallest; |
831 |
+ |
} else { |
832 |
+ |
theEcr = globals->getECR(); |
833 |
|
} |
834 |
|
|
835 |
< |
headStamp->add( currentStamp ); |
836 |
< |
comp_stamps[i] = headStamp->match( id ); |
837 |
< |
} |
835 |
> |
if( !globals->haveEST() ){ |
836 |
> |
sprintf( painCave.errMsg, |
837 |
> |
"SimSetup Warning: using default value of 0.05 * the " |
838 |
> |
"electrostaticCutoffRadius for the electrostaticSkinThickness\n" |
839 |
> |
); |
840 |
> |
painCave.isFatal = 0; |
841 |
> |
simError(); |
842 |
> |
theEst = 0.05 * theEcr; |
843 |
> |
} else { |
844 |
> |
theEst= globals->getEST(); |
845 |
> |
} |
846 |
> |
|
847 |
> |
info[i].setEcr( theEcr, theEst ); |
848 |
> |
|
849 |
> |
if(!globals->haveDielectric() ){ |
850 |
> |
sprintf( painCave.errMsg, |
851 |
> |
"SimSetup Error: You are trying to use Reaction Field without" |
852 |
> |
"setting a dielectric constant!\n" |
853 |
> |
); |
854 |
> |
painCave.isFatal = 1; |
855 |
> |
simError(); |
856 |
> |
} |
857 |
> |
info[i].dielectric = globals->getDielectric(); |
858 |
> |
} |
859 |
> |
else { |
860 |
> |
if (usesDipoles) { |
861 |
> |
|
862 |
> |
if( !globals->haveECR() ){ |
863 |
> |
sprintf( painCave.errMsg, |
864 |
> |
"SimSetup Warning: using default value of 1/2 the smallest " |
865 |
> |
"box length for the electrostaticCutoffRadius.\n" |
866 |
> |
"I hope you have a very fast processor!\n"); |
867 |
> |
painCave.isFatal = 0; |
868 |
> |
simError(); |
869 |
> |
double smallest; |
870 |
> |
smallest = info[i].boxL[0]; |
871 |
> |
if (info[i].boxL[1] <= smallest) smallest = info[i].boxL[1]; |
872 |
> |
if (info[i].boxL[2] <= smallest) smallest = info[i].boxL[2]; |
873 |
> |
theEcr = 0.5 * smallest; |
874 |
> |
} else { |
875 |
> |
theEcr = globals->getECR(); |
876 |
> |
} |
877 |
> |
|
878 |
> |
if( !globals->haveEST() ){ |
879 |
> |
sprintf( painCave.errMsg, |
880 |
> |
"SimSetup Warning: using default value of 0.05 * the " |
881 |
> |
"electrostaticCutoffRadius for the " |
882 |
> |
"electrostaticSkinThickness\n" |
883 |
> |
); |
884 |
> |
painCave.isFatal = 0; |
885 |
> |
simError(); |
886 |
> |
theEst = 0.05 * theEcr; |
887 |
> |
} else { |
888 |
> |
theEst= globals->getEST(); |
889 |
> |
} |
890 |
> |
|
891 |
> |
info[i].setEcr( theEcr, theEst ); |
892 |
> |
} |
893 |
> |
} |
894 |
|
} |
895 |
|
|
896 |
|
#ifdef IS_MPI |
897 |
< |
strcpy( checkPointMsg, "Component stamps successfully extracted\n" ); |
897 |
> |
strcpy( checkPointMsg, "post processing checks out" ); |
898 |
|
MPIcheckPoint(); |
899 |
|
#endif // is_mpi |
316 |
– |
|
900 |
|
|
901 |
+ |
} |
902 |
|
|
903 |
< |
|
904 |
< |
// caclulate the number of atoms, bonds, bends and torsions |
321 |
< |
|
322 |
< |
tot_atoms = 0; |
323 |
< |
tot_bonds = 0; |
324 |
< |
tot_bends = 0; |
325 |
< |
tot_torsions = 0; |
326 |
< |
for( i=0; i<n_components; i++ ){ |
327 |
< |
|
328 |
< |
tot_atoms += components_nmol[i] * comp_stamps[i]->getNAtoms(); |
329 |
< |
tot_bonds += components_nmol[i] * comp_stamps[i]->getNBonds(); |
330 |
< |
tot_bends += components_nmol[i] * comp_stamps[i]->getNBends(); |
331 |
< |
tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions(); |
332 |
< |
} |
333 |
< |
|
334 |
< |
tot_SRI = tot_bonds + tot_bends + tot_torsions; |
335 |
< |
|
336 |
< |
simnfo->n_atoms = tot_atoms; |
337 |
< |
simnfo->n_bonds = tot_bonds; |
338 |
< |
simnfo->n_bends = tot_bends; |
339 |
< |
simnfo->n_torsions = tot_torsions; |
340 |
< |
simnfo->n_SRI = tot_SRI; |
341 |
< |
simnfo->n_mol = tot_nmol; |
903 |
> |
void SimSetup::initSystemCoords( void ){ |
904 |
> |
int i; |
905 |
|
|
906 |
< |
simnfo->molMembershipArray = new int[tot_atoms]; |
906 |
> |
std::cerr << "Setting atom Coords\n"; |
907 |
|
|
908 |
< |
#ifdef IS_MPI |
346 |
< |
|
347 |
< |
// divide the molecules among processors here. |
908 |
> |
(info[0].getConfiguration())->createArrays( info[0].n_atoms ); |
909 |
|
|
910 |
< |
mpiSim = new mpiSimulation( simnfo ); |
910 |
> |
for(i=0; i<info[0].n_atoms; i++) info[0].atoms[i]->setCoords(); |
911 |
|
|
912 |
< |
globalIndex = mpiSim->divideLabor(); |
913 |
< |
|
914 |
< |
// set up the local variables |
915 |
< |
|
916 |
< |
int localMol, allMol; |
917 |
< |
int local_atoms, local_bonds, local_bends, local_torsions, local_SRI; |
918 |
< |
|
919 |
< |
int* mol2proc = mpiSim->getMolToProcMap(); |
920 |
< |
int* molCompType = mpiSim->getMolComponentType(); |
921 |
< |
|
922 |
< |
allMol = 0; |
923 |
< |
localMol = 0; |
924 |
< |
local_atoms = 0; |
364 |
< |
local_bonds = 0; |
365 |
< |
local_bends = 0; |
366 |
< |
local_torsions = 0; |
367 |
< |
globalAtomIndex = 0; |
368 |
< |
|
369 |
< |
|
370 |
< |
for( i=0; i<n_components; i++ ){ |
371 |
< |
|
372 |
< |
for( j=0; j<components_nmol[i]; j++ ){ |
373 |
< |
|
374 |
< |
if( mol2proc[allMol] == worldRank ){ |
375 |
< |
|
376 |
< |
local_atoms += comp_stamps[i]->getNAtoms(); |
377 |
< |
local_bonds += comp_stamps[i]->getNBonds(); |
378 |
< |
local_bends += comp_stamps[i]->getNBends(); |
379 |
< |
local_torsions += comp_stamps[i]->getNTorsions(); |
380 |
< |
localMol++; |
381 |
< |
} |
382 |
< |
for (k = 0; k < comp_stamps[i]->getNAtoms(); k++) { |
383 |
< |
simnfo->molMembershipArray[globalAtomIndex] = allMol; |
384 |
< |
globalAtomIndex++; |
385 |
< |
} |
386 |
< |
|
387 |
< |
allMol++; |
388 |
< |
} |
912 |
> |
if( globals->haveInitialConfig() ){ |
913 |
> |
|
914 |
> |
InitializeFromFile* fileInit; |
915 |
> |
#ifdef IS_MPI // is_mpi |
916 |
> |
if( worldRank == 0 ){ |
917 |
> |
#endif //is_mpi |
918 |
> |
fileInit = new InitializeFromFile( globals->getInitialConfig() ); |
919 |
> |
#ifdef IS_MPI |
920 |
> |
}else fileInit = new InitializeFromFile( NULL ); |
921 |
> |
#endif |
922 |
> |
fileInit->readInit( info ); // default velocities on |
923 |
> |
|
924 |
> |
delete fileInit; |
925 |
|
} |
926 |
< |
local_SRI = local_bonds + local_bends + local_torsions; |
927 |
< |
|
928 |
< |
simnfo->n_atoms = mpiSim->getMyNlocal(); |
929 |
< |
|
930 |
< |
if( local_atoms != simnfo->n_atoms ){ |
926 |
> |
else{ |
927 |
> |
|
928 |
> |
#ifdef IS_MPI |
929 |
> |
|
930 |
> |
// no init from bass |
931 |
> |
|
932 |
|
sprintf( painCave.errMsg, |
933 |
< |
"SimSetup error: mpiSim's localAtom (%d) and SimSetup's" |
934 |
< |
" localAtom (%d) are not equal.\n", |
398 |
< |
simnfo->n_atoms, |
399 |
< |
local_atoms ); |
400 |
< |
painCave.isFatal = 1; |
933 |
> |
"Cannot intialize a parallel simulation without an initial configuration file.\n" ); |
934 |
> |
painCave.isFatal; |
935 |
|
simError(); |
936 |
+ |
|
937 |
+ |
#else |
938 |
+ |
|
939 |
+ |
initFromBass(); |
940 |
+ |
|
941 |
+ |
|
942 |
+ |
#endif |
943 |
|
} |
403 |
– |
|
404 |
– |
simnfo->n_bonds = local_bonds; |
405 |
– |
simnfo->n_bends = local_bends; |
406 |
– |
simnfo->n_torsions = local_torsions; |
407 |
– |
simnfo->n_SRI = local_SRI; |
408 |
– |
simnfo->n_mol = localMol; |
409 |
– |
|
410 |
– |
strcpy( checkPointMsg, "Passed nlocal consistency check." ); |
411 |
– |
MPIcheckPoint(); |
944 |
|
|
945 |
< |
|
945 |
> |
#ifdef IS_MPI |
946 |
> |
strcpy( checkPointMsg, "Successfully read in the initial configuration" ); |
947 |
> |
MPIcheckPoint(); |
948 |
|
#endif // is_mpi |
949 |
|
|
950 |
+ |
} |
951 |
|
|
417 |
– |
// create the atom and short range interaction arrays |
952 |
|
|
953 |
< |
Atom::createArrays(simnfo->n_atoms); |
954 |
< |
the_atoms = new Atom*[simnfo->n_atoms]; |
955 |
< |
the_molecules = new Molecule[simnfo->n_mol]; |
422 |
< |
int molIndex; |
953 |
> |
void SimSetup::makeOutNames( void ){ |
954 |
> |
|
955 |
> |
int k; |
956 |
|
|
424 |
– |
// initialize the molecule's stampID's |
425 |
– |
|
426 |
– |
#ifdef IS_MPI |
957 |
|
|
958 |
+ |
for(k=0; k<nInfo; k++){ |
959 |
|
|
960 |
< |
molIndex = 0; |
961 |
< |
for(i=0; i<mpiSim->getTotNmol(); i++){ |
962 |
< |
|
963 |
< |
if(mol2proc[i] == worldRank ){ |
964 |
< |
the_molecules[molIndex].setStampID( molCompType[i] ); |
965 |
< |
the_molecules[molIndex].setMyIndex( molIndex ); |
435 |
< |
the_molecules[molIndex].setGlobalIndex( i ); |
436 |
< |
molIndex++; |
437 |
< |
} |
438 |
< |
} |
439 |
< |
|
440 |
< |
#else // is_mpi |
441 |
< |
|
442 |
< |
molIndex = 0; |
443 |
< |
globalAtomIndex = 0; |
444 |
< |
for(i=0; i<n_components; i++){ |
445 |
< |
for(j=0; j<components_nmol[i]; j++ ){ |
446 |
< |
the_molecules[molIndex].setStampID( i ); |
447 |
< |
the_molecules[molIndex].setMyIndex( molIndex ); |
448 |
< |
the_molecules[molIndex].setGlobalIndex( molIndex ); |
449 |
< |
for (k = 0; k < comp_stamps[i]->getNAtoms(); k++) { |
450 |
< |
simnfo->molMembershipArray[globalAtomIndex] = molIndex; |
451 |
< |
globalAtomIndex++; |
960 |
> |
#ifdef IS_MPI |
961 |
> |
if( worldRank == 0 ){ |
962 |
> |
#endif // is_mpi |
963 |
> |
|
964 |
> |
if( globals->haveFinalConfig() ){ |
965 |
> |
strcpy( info[k].finalName, globals->getFinalConfig() ); |
966 |
|
} |
967 |
< |
molIndex++; |
967 |
> |
else{ |
968 |
> |
strcpy( info[k].finalName, inFileName ); |
969 |
> |
char* endTest; |
970 |
> |
int nameLength = strlen( info[k].finalName ); |
971 |
> |
endTest = &(info[k].finalName[nameLength - 5]); |
972 |
> |
if( !strcmp( endTest, ".bass" ) ){ |
973 |
> |
strcpy( endTest, ".eor" ); |
974 |
> |
} |
975 |
> |
else if( !strcmp( endTest, ".BASS" ) ){ |
976 |
> |
strcpy( endTest, ".eor" ); |
977 |
> |
} |
978 |
> |
else{ |
979 |
> |
endTest = &(info[k].finalName[nameLength - 4]); |
980 |
> |
if( !strcmp( endTest, ".bss" ) ){ |
981 |
> |
strcpy( endTest, ".eor" ); |
982 |
> |
} |
983 |
> |
else if( !strcmp( endTest, ".mdl" ) ){ |
984 |
> |
strcpy( endTest, ".eor" ); |
985 |
> |
} |
986 |
> |
else{ |
987 |
> |
strcat( info[k].finalName, ".eor" ); |
988 |
> |
} |
989 |
> |
} |
990 |
> |
} |
991 |
> |
|
992 |
> |
// make the sample and status out names |
993 |
> |
|
994 |
> |
strcpy( info[k].sampleName, inFileName ); |
995 |
> |
char* endTest; |
996 |
> |
int nameLength = strlen( info[k].sampleName ); |
997 |
> |
endTest = &(info[k].sampleName[nameLength - 5]); |
998 |
> |
if( !strcmp( endTest, ".bass" ) ){ |
999 |
> |
strcpy( endTest, ".dump" ); |
1000 |
> |
} |
1001 |
> |
else if( !strcmp( endTest, ".BASS" ) ){ |
1002 |
> |
strcpy( endTest, ".dump" ); |
1003 |
> |
} |
1004 |
> |
else{ |
1005 |
> |
endTest = &(info[k].sampleName[nameLength - 4]); |
1006 |
> |
if( !strcmp( endTest, ".bss" ) ){ |
1007 |
> |
strcpy( endTest, ".dump" ); |
1008 |
> |
} |
1009 |
> |
else if( !strcmp( endTest, ".mdl" ) ){ |
1010 |
> |
strcpy( endTest, ".dump" ); |
1011 |
> |
} |
1012 |
> |
else{ |
1013 |
> |
strcat( info[k].sampleName, ".dump" ); |
1014 |
> |
} |
1015 |
> |
} |
1016 |
> |
|
1017 |
> |
strcpy( info[k].statusName, inFileName ); |
1018 |
> |
nameLength = strlen( info[k].statusName ); |
1019 |
> |
endTest = &(info[k].statusName[nameLength - 5]); |
1020 |
> |
if( !strcmp( endTest, ".bass" ) ){ |
1021 |
> |
strcpy( endTest, ".stat" ); |
1022 |
> |
} |
1023 |
> |
else if( !strcmp( endTest, ".BASS" ) ){ |
1024 |
> |
strcpy( endTest, ".stat" ); |
1025 |
> |
} |
1026 |
> |
else{ |
1027 |
> |
endTest = &(info[k].statusName[nameLength - 4]); |
1028 |
> |
if( !strcmp( endTest, ".bss" ) ){ |
1029 |
> |
strcpy( endTest, ".stat" ); |
1030 |
> |
} |
1031 |
> |
else if( !strcmp( endTest, ".mdl" ) ){ |
1032 |
> |
strcpy( endTest, ".stat" ); |
1033 |
> |
} |
1034 |
> |
else{ |
1035 |
> |
strcat( info[k].statusName, ".stat" ); |
1036 |
> |
} |
1037 |
> |
} |
1038 |
> |
|
1039 |
> |
#ifdef IS_MPI |
1040 |
|
} |
1041 |
+ |
#endif // is_mpi |
1042 |
|
} |
1043 |
< |
|
1043 |
> |
} |
1044 |
|
|
458 |
– |
#endif // is_mpi |
1045 |
|
|
1046 |
+ |
void SimSetup::sysObjectsCreation( void ){ |
1047 |
+ |
|
1048 |
+ |
int i,k; |
1049 |
+ |
|
1050 |
+ |
// create the forceField |
1051 |
+ |
|
1052 |
+ |
createFF(); |
1053 |
|
|
1054 |
< |
if( simnfo->n_SRI ){ |
462 |
< |
|
463 |
< |
Exclude::createArray(simnfo->n_SRI); |
464 |
< |
the_excludes = new Exclude*[simnfo->n_SRI]; |
465 |
< |
for( int ex=0; ex<simnfo->n_SRI; ex++) the_excludes[ex] = new Exclude(ex); |
466 |
< |
simnfo->globalExcludes = new int; |
467 |
< |
simnfo->n_exclude = simnfo->n_SRI; |
468 |
< |
} |
469 |
< |
else{ |
470 |
< |
|
471 |
< |
Exclude::createArray( 1 ); |
472 |
< |
the_excludes = new Exclude*; |
473 |
< |
the_excludes[0] = new Exclude(0); |
474 |
< |
the_excludes[0]->setPair( 0,0 ); |
475 |
< |
simnfo->globalExcludes = new int; |
476 |
< |
simnfo->globalExcludes[0] = 0; |
477 |
< |
simnfo->n_exclude = 0; |
478 |
< |
} |
1054 |
> |
// extract componentList |
1055 |
|
|
1056 |
< |
// set the arrays into the SimInfo object |
1056 |
> |
compList(); |
1057 |
|
|
1058 |
< |
simnfo->atoms = the_atoms; |
483 |
< |
simnfo->molecules = the_molecules; |
484 |
< |
simnfo->nGlobalExcludes = 0; |
485 |
< |
simnfo->excludes = the_excludes; |
1058 |
> |
// calc the number of atoms, bond, bends, and torsions |
1059 |
|
|
1060 |
+ |
calcSysValues(); |
1061 |
|
|
1062 |
< |
// get some of the tricky things that may still be in the globals |
1062 |
> |
#ifdef IS_MPI |
1063 |
> |
// divide the molecules among the processors |
1064 |
> |
|
1065 |
> |
mpiMolDivide(); |
1066 |
> |
#endif //is_mpi |
1067 |
> |
|
1068 |
> |
// create the atom and SRI arrays. Also initialize Molecule Stamp ID's |
1069 |
> |
|
1070 |
> |
makeSysArrays(); |
1071 |
|
|
1072 |
< |
double boxVector[3]; |
1073 |
< |
if( the_globals->haveBox() ){ |
1074 |
< |
boxVector[0] = the_globals->getBox(); |
1075 |
< |
boxVector[1] = the_globals->getBox(); |
1076 |
< |
boxVector[2] = the_globals->getBox(); |
1077 |
< |
|
1078 |
< |
simnfo->setBox( boxVector ); |
1072 |
> |
// make and initialize the molecules (all but atomic coordinates) |
1073 |
> |
|
1074 |
> |
makeMolecules(); |
1075 |
> |
|
1076 |
> |
for(k=0; k<nInfo; k++){ |
1077 |
> |
info[k].identArray = new int[info[k].n_atoms]; |
1078 |
> |
for(i=0; i<info[k].n_atoms; i++){ |
1079 |
> |
info[k].identArray[i] = info[k].atoms[i]->getIdent(); |
1080 |
> |
} |
1081 |
|
} |
1082 |
< |
else if( the_globals->haveDensity() ){ |
1082 |
> |
} |
1083 |
|
|
500 |
– |
double vol; |
501 |
– |
vol = (double)tot_nmol / the_globals->getDensity(); |
502 |
– |
boxVector[0] = pow( vol, ( 1.0 / 3.0 ) ); |
503 |
– |
boxVector[1] = boxVector[0]; |
504 |
– |
boxVector[2] = boxVector[0]; |
1084 |
|
|
1085 |
< |
simnfo->setBox( boxVector ); |
507 |
< |
} |
508 |
< |
else{ |
509 |
< |
if( !the_globals->haveBoxX() ){ |
510 |
< |
sprintf( painCave.errMsg, |
511 |
< |
"SimSetup error, no periodic BoxX size given.\n" ); |
512 |
< |
painCave.isFatal = 1; |
513 |
< |
simError(); |
514 |
< |
} |
515 |
< |
boxVector[0] = the_globals->getBoxX(); |
1085 |
> |
void SimSetup::createFF( void ){ |
1086 |
|
|
1087 |
< |
if( !the_globals->haveBoxY() ){ |
518 |
< |
sprintf( painCave.errMsg, |
519 |
< |
"SimSetup error, no periodic BoxY size given.\n" ); |
520 |
< |
painCave.isFatal = 1; |
521 |
< |
simError(); |
522 |
< |
} |
523 |
< |
boxVector[1] = the_globals->getBoxY(); |
1087 |
> |
switch( ffCase ){ |
1088 |
|
|
1089 |
< |
if( !the_globals->haveBoxZ() ){ |
1090 |
< |
sprintf( painCave.errMsg, |
1091 |
< |
"SimSetup error, no periodic BoxZ size given.\n" ); |
528 |
< |
painCave.isFatal = 1; |
529 |
< |
simError(); |
530 |
< |
} |
531 |
< |
boxVector[2] = the_globals->getBoxZ(); |
1089 |
> |
case FF_DUFF: |
1090 |
> |
the_ff = new DUFF(); |
1091 |
> |
break; |
1092 |
|
|
1093 |
< |
simnfo->setBox( boxVector ); |
1093 |
> |
case FF_LJ: |
1094 |
> |
the_ff = new LJFF(); |
1095 |
> |
break; |
1096 |
> |
|
1097 |
> |
case FF_EAM: |
1098 |
> |
the_ff = new EAM_FF(); |
1099 |
> |
break; |
1100 |
> |
|
1101 |
> |
default: |
1102 |
> |
sprintf( painCave.errMsg, |
1103 |
> |
"SimSetup Error. Unrecognized force field in case statement.\n"); |
1104 |
> |
painCave.isFatal = 1; |
1105 |
> |
simError(); |
1106 |
|
} |
1107 |
|
|
1108 |
|
#ifdef IS_MPI |
1109 |
< |
strcpy( checkPointMsg, "Box size set up" ); |
1109 |
> |
strcpy( checkPointMsg, "ForceField creation successful" ); |
1110 |
|
MPIcheckPoint(); |
1111 |
|
#endif // is_mpi |
1112 |
|
|
1113 |
+ |
} |
1114 |
|
|
542 |
– |
// initialize the arrays |
1115 |
|
|
1116 |
< |
the_ff->setSimInfo( simnfo ); |
1116 |
> |
void SimSetup::compList( void ){ |
1117 |
|
|
1118 |
< |
makeMolecules(); |
1119 |
< |
simnfo->identArray = new int[simnfo->n_atoms]; |
1120 |
< |
for(i=0; i<simnfo->n_atoms; i++){ |
1121 |
< |
simnfo->identArray[i] = the_atoms[i]->getIdent(); |
1122 |
< |
} |
1118 |
> |
int i; |
1119 |
> |
char* id; |
1120 |
> |
LinkedMolStamp* headStamp = new LinkedMolStamp(); |
1121 |
> |
LinkedMolStamp* currentStamp = NULL; |
1122 |
> |
comp_stamps = new MoleculeStamp*[n_components]; |
1123 |
|
|
1124 |
< |
if (the_globals->getUseRF() ) { |
1125 |
< |
simnfo->useReactionField = 1; |
1124 |
> |
// make an array of molecule stamps that match the components used. |
1125 |
> |
// also extract the used stamps out into a separate linked list |
1126 |
|
|
1127 |
< |
if( !the_globals->haveECR() ){ |
1128 |
< |
sprintf( painCave.errMsg, |
1129 |
< |
"SimSetup Warning: using default value of 1/2 the smallest " |
1130 |
< |
"box length for the electrostaticCutoffRadius.\n" |
1131 |
< |
"I hope you have a very fast processor!\n"); |
1132 |
< |
painCave.isFatal = 0; |
1133 |
< |
simError(); |
562 |
< |
double smallest; |
563 |
< |
smallest = simnfo->boxLx; |
564 |
< |
if (simnfo->boxLy <= smallest) smallest = simnfo->boxLy; |
565 |
< |
if (simnfo->boxLz <= smallest) smallest = simnfo->boxLz; |
566 |
< |
simnfo->ecr = 0.5 * smallest; |
567 |
< |
} else { |
568 |
< |
simnfo->ecr = the_globals->getECR(); |
569 |
< |
} |
1127 |
> |
for(i=0; i<nInfo; i++){ |
1128 |
> |
info[i].nComponents = n_components; |
1129 |
> |
info[i].componentsNmol = components_nmol; |
1130 |
> |
info[i].compStamps = comp_stamps; |
1131 |
> |
info[i].headStamp = headStamp; |
1132 |
> |
} |
1133 |
> |
|
1134 |
|
|
1135 |
< |
if( !the_globals->haveEST() ){ |
1136 |
< |
sprintf( painCave.errMsg, |
1137 |
< |
"SimSetup Warning: using default value of 0.05 * the " |
1138 |
< |
"electrostaticCutoffRadius for the electrostaticSkinThickness\n" |
575 |
< |
); |
576 |
< |
painCave.isFatal = 0; |
577 |
< |
simError(); |
578 |
< |
simnfo->est = 0.05 * simnfo->ecr; |
579 |
< |
} else { |
580 |
< |
simnfo->est = the_globals->getEST(); |
581 |
< |
} |
1135 |
> |
for( i=0; i<n_components; i++ ){ |
1136 |
> |
|
1137 |
> |
id = the_components[i]->getType(); |
1138 |
> |
comp_stamps[i] = NULL; |
1139 |
|
|
1140 |
< |
if(!the_globals->haveDielectric() ){ |
1141 |
< |
sprintf( painCave.errMsg, |
1142 |
< |
"SimSetup Error: You are trying to use Reaction Field without" |
1143 |
< |
"setting a dielectric constant!\n" |
587 |
< |
); |
588 |
< |
painCave.isFatal = 1; |
589 |
< |
simError(); |
590 |
< |
} |
591 |
< |
simnfo->dielectric = the_globals->getDielectric(); |
592 |
< |
} else { |
593 |
< |
if (usesDipoles) { |
1140 |
> |
// check to make sure the component isn't already in the list |
1141 |
> |
|
1142 |
> |
comp_stamps[i] = headStamp->match( id ); |
1143 |
> |
if( comp_stamps[i] == NULL ){ |
1144 |
|
|
1145 |
< |
if( !the_globals->haveECR() ){ |
596 |
< |
sprintf( painCave.errMsg, |
597 |
< |
"SimSetup Warning: using default value of 1/2 the smallest " |
598 |
< |
"box length for the electrostaticCutoffRadius.\n" |
599 |
< |
"I hope you have a very fast processor!\n"); |
600 |
< |
painCave.isFatal = 0; |
601 |
< |
simError(); |
602 |
< |
double smallest; |
603 |
< |
smallest = simnfo->boxLx; |
604 |
< |
if (simnfo->boxLy <= smallest) smallest = simnfo->boxLy; |
605 |
< |
if (simnfo->boxLz <= smallest) smallest = simnfo->boxLz; |
606 |
< |
simnfo->ecr = 0.5 * smallest; |
607 |
< |
} else { |
608 |
< |
simnfo->ecr = the_globals->getECR(); |
609 |
< |
} |
1145 |
> |
// extract the component from the list; |
1146 |
|
|
1147 |
< |
if( !the_globals->haveEST() ){ |
1148 |
< |
sprintf( painCave.errMsg, |
1149 |
< |
"SimSetup Warning: using default value of 5%% of the " |
1150 |
< |
"electrostaticCutoffRadius for the " |
1151 |
< |
"electrostaticSkinThickness\n" |
1152 |
< |
); |
1153 |
< |
painCave.isFatal = 0; |
1154 |
< |
simError(); |
619 |
< |
simnfo->est = 0.05 * simnfo->ecr; |
620 |
< |
} else { |
621 |
< |
simnfo->est = the_globals->getEST(); |
1147 |
> |
currentStamp = stamps->extractMolStamp( id ); |
1148 |
> |
if( currentStamp == NULL ){ |
1149 |
> |
sprintf( painCave.errMsg, |
1150 |
> |
"SimSetup error: Component \"%s\" was not found in the " |
1151 |
> |
"list of declared molecules\n", |
1152 |
> |
id ); |
1153 |
> |
painCave.isFatal = 1; |
1154 |
> |
simError(); |
1155 |
|
} |
1156 |
+ |
|
1157 |
+ |
headStamp->add( currentStamp ); |
1158 |
+ |
comp_stamps[i] = headStamp->match( id ); |
1159 |
|
} |
1160 |
< |
} |
1160 |
> |
} |
1161 |
|
|
1162 |
|
#ifdef IS_MPI |
1163 |
< |
strcpy( checkPointMsg, "electrostatic parameters check out" ); |
1163 |
> |
strcpy( checkPointMsg, "Component stamps successfully extracted\n" ); |
1164 |
|
MPIcheckPoint(); |
1165 |
|
#endif // is_mpi |
1166 |
|
|
1167 |
< |
if( the_globals->haveInitialConfig() ){ |
1168 |
< |
|
1169 |
< |
InitializeFromFile* fileInit; |
1170 |
< |
#ifdef IS_MPI // is_mpi |
1171 |
< |
if( worldRank == 0 ){ |
1172 |
< |
#endif //is_mpi |
1173 |
< |
fileInit = new InitializeFromFile( the_globals->getInitialConfig() ); |
1167 |
> |
|
1168 |
> |
} |
1169 |
> |
|
1170 |
> |
void SimSetup::calcSysValues( void ){ |
1171 |
> |
int i, j, k; |
1172 |
> |
|
1173 |
> |
int *molMembershipArray; |
1174 |
> |
|
1175 |
> |
tot_atoms = 0; |
1176 |
> |
tot_bonds = 0; |
1177 |
> |
tot_bends = 0; |
1178 |
> |
tot_torsions = 0; |
1179 |
> |
for( i=0; i<n_components; i++ ){ |
1180 |
> |
|
1181 |
> |
tot_atoms += components_nmol[i] * comp_stamps[i]->getNAtoms(); |
1182 |
> |
tot_bonds += components_nmol[i] * comp_stamps[i]->getNBonds(); |
1183 |
> |
tot_bends += components_nmol[i] * comp_stamps[i]->getNBends(); |
1184 |
> |
tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions(); |
1185 |
> |
} |
1186 |
> |
|
1187 |
> |
tot_SRI = tot_bonds + tot_bends + tot_torsions; |
1188 |
> |
molMembershipArray = new int[tot_atoms]; |
1189 |
> |
|
1190 |
> |
for(i=0; i<nInfo; i++){ |
1191 |
> |
info[i].n_atoms = tot_atoms; |
1192 |
> |
info[i].n_bonds = tot_bonds; |
1193 |
> |
info[i].n_bends = tot_bends; |
1194 |
> |
info[i].n_torsions = tot_torsions; |
1195 |
> |
info[i].n_SRI = tot_SRI; |
1196 |
> |
info[i].n_mol = tot_nmol; |
1197 |
> |
|
1198 |
> |
info[i].molMembershipArray = molMembershipArray; |
1199 |
> |
} |
1200 |
> |
} |
1201 |
> |
|
1202 |
|
#ifdef IS_MPI |
639 |
– |
}else fileInit = new InitializeFromFile( NULL ); |
640 |
– |
#endif |
641 |
– |
fileInit->read_xyz( simnfo ); // default velocities on |
1203 |
|
|
1204 |
< |
delete fileInit; |
1205 |
< |
} |
1206 |
< |
else{ |
1204 |
> |
void SimSetup::mpiMolDivide( void ){ |
1205 |
> |
|
1206 |
> |
int i, j, k; |
1207 |
> |
int localMol, allMol; |
1208 |
> |
int local_atoms, local_bonds, local_bends, local_torsions, local_SRI; |
1209 |
|
|
1210 |
< |
#ifdef IS_MPI |
1210 |
> |
mpiSim = new mpiSimulation( info ); |
1211 |
> |
|
1212 |
> |
globalIndex = mpiSim->divideLabor(); |
1213 |
|
|
1214 |
< |
// no init from bass |
1214 |
> |
// set up the local variables |
1215 |
|
|
1216 |
< |
sprintf( painCave.errMsg, |
1217 |
< |
"Cannot intialize a parallel simulation without an initial configuration file.\n" ); |
653 |
< |
painCave.isFatal; |
654 |
< |
simError(); |
1216 |
> |
mol2proc = mpiSim->getMolToProcMap(); |
1217 |
> |
molCompType = mpiSim->getMolComponentType(); |
1218 |
|
|
1219 |
< |
#else |
1219 |
> |
allMol = 0; |
1220 |
> |
localMol = 0; |
1221 |
> |
local_atoms = 0; |
1222 |
> |
local_bonds = 0; |
1223 |
> |
local_bends = 0; |
1224 |
> |
local_torsions = 0; |
1225 |
> |
globalAtomIndex = 0; |
1226 |
|
|
658 |
– |
initFromBass(); |
1227 |
|
|
1228 |
+ |
for( i=0; i<n_components; i++ ){ |
1229 |
|
|
1230 |
< |
#endif |
1231 |
< |
} |
1230 |
> |
for( j=0; j<components_nmol[i]; j++ ){ |
1231 |
> |
|
1232 |
> |
if( mol2proc[allMol] == worldRank ){ |
1233 |
> |
|
1234 |
> |
local_atoms += comp_stamps[i]->getNAtoms(); |
1235 |
> |
local_bonds += comp_stamps[i]->getNBonds(); |
1236 |
> |
local_bends += comp_stamps[i]->getNBends(); |
1237 |
> |
local_torsions += comp_stamps[i]->getNTorsions(); |
1238 |
> |
localMol++; |
1239 |
> |
} |
1240 |
> |
for (k = 0; k < comp_stamps[i]->getNAtoms(); k++) { |
1241 |
> |
info[0].molMembershipArray[globalAtomIndex] = allMol; |
1242 |
> |
globalAtomIndex++; |
1243 |
> |
} |
1244 |
|
|
1245 |
< |
#ifdef IS_MPI |
1246 |
< |
strcpy( checkPointMsg, "Successfully read in the initial configuration" ); |
1245 |
> |
allMol++; |
1246 |
> |
} |
1247 |
> |
} |
1248 |
> |
local_SRI = local_bonds + local_bends + local_torsions; |
1249 |
> |
|
1250 |
> |
info[0].n_atoms = mpiSim->getMyNlocal(); |
1251 |
> |
|
1252 |
> |
if( local_atoms != info[0].n_atoms ){ |
1253 |
> |
sprintf( painCave.errMsg, |
1254 |
> |
"SimSetup error: mpiSim's localAtom (%d) and SimSetup's" |
1255 |
> |
" localAtom (%d) are not equal.\n", |
1256 |
> |
info[0].n_atoms, |
1257 |
> |
local_atoms ); |
1258 |
> |
painCave.isFatal = 1; |
1259 |
> |
simError(); |
1260 |
> |
} |
1261 |
> |
|
1262 |
> |
info[0].n_bonds = local_bonds; |
1263 |
> |
info[0].n_bends = local_bends; |
1264 |
> |
info[0].n_torsions = local_torsions; |
1265 |
> |
info[0].n_SRI = local_SRI; |
1266 |
> |
info[0].n_mol = localMol; |
1267 |
> |
|
1268 |
> |
strcpy( checkPointMsg, "Passed nlocal consistency check." ); |
1269 |
|
MPIcheckPoint(); |
1270 |
+ |
} |
1271 |
+ |
|
1272 |
|
#endif // is_mpi |
1273 |
|
|
1274 |
|
|
1275 |
< |
|
1276 |
< |
|
672 |
< |
|
1275 |
> |
void SimSetup::makeSysArrays( void ){ |
1276 |
> |
int i, j, k, l; |
1277 |
|
|
1278 |
+ |
Atom** the_atoms; |
1279 |
+ |
Molecule* the_molecules; |
1280 |
+ |
Exclude** the_excludes; |
1281 |
+ |
|
1282 |
|
|
1283 |
+ |
for(l=0; l<nInfo; l++){ |
1284 |
+ |
|
1285 |
+ |
// create the atom and short range interaction arrays |
1286 |
+ |
|
1287 |
+ |
the_atoms = new Atom*[info[l].n_atoms]; |
1288 |
+ |
the_molecules = new Molecule[info[l].n_mol]; |
1289 |
+ |
int molIndex; |
1290 |
+ |
|
1291 |
+ |
// initialize the molecule's stampID's |
1292 |
+ |
|
1293 |
|
#ifdef IS_MPI |
676 |
– |
if( worldRank == 0 ){ |
677 |
– |
#endif // is_mpi |
1294 |
|
|
679 |
– |
if( the_globals->haveFinalConfig() ){ |
680 |
– |
strcpy( simnfo->finalName, the_globals->getFinalConfig() ); |
681 |
– |
} |
682 |
– |
else{ |
683 |
– |
strcpy( simnfo->finalName, inFileName ); |
684 |
– |
char* endTest; |
685 |
– |
int nameLength = strlen( simnfo->finalName ); |
686 |
– |
endTest = &(simnfo->finalName[nameLength - 5]); |
687 |
– |
if( !strcmp( endTest, ".bass" ) ){ |
688 |
– |
strcpy( endTest, ".eor" ); |
689 |
– |
} |
690 |
– |
else if( !strcmp( endTest, ".BASS" ) ){ |
691 |
– |
strcpy( endTest, ".eor" ); |
692 |
– |
} |
693 |
– |
else{ |
694 |
– |
endTest = &(simnfo->finalName[nameLength - 4]); |
695 |
– |
if( !strcmp( endTest, ".bss" ) ){ |
696 |
– |
strcpy( endTest, ".eor" ); |
697 |
– |
} |
698 |
– |
else if( !strcmp( endTest, ".mdl" ) ){ |
699 |
– |
strcpy( endTest, ".eor" ); |
700 |
– |
} |
701 |
– |
else{ |
702 |
– |
strcat( simnfo->finalName, ".eor" ); |
703 |
– |
} |
704 |
– |
} |
705 |
– |
} |
1295 |
|
|
1296 |
< |
// make the sample and status out names |
1296 |
> |
molIndex = 0; |
1297 |
> |
for(i=0; i<mpiSim->getTotNmol(); i++){ |
1298 |
|
|
1299 |
< |
strcpy( simnfo->sampleName, inFileName ); |
1300 |
< |
char* endTest; |
1301 |
< |
int nameLength = strlen( simnfo->sampleName ); |
1302 |
< |
endTest = &(simnfo->sampleName[nameLength - 5]); |
1303 |
< |
if( !strcmp( endTest, ".bass" ) ){ |
714 |
< |
strcpy( endTest, ".dump" ); |
715 |
< |
} |
716 |
< |
else if( !strcmp( endTest, ".BASS" ) ){ |
717 |
< |
strcpy( endTest, ".dump" ); |
718 |
< |
} |
719 |
< |
else{ |
720 |
< |
endTest = &(simnfo->sampleName[nameLength - 4]); |
721 |
< |
if( !strcmp( endTest, ".bss" ) ){ |
722 |
< |
strcpy( endTest, ".dump" ); |
1299 |
> |
if(mol2proc[i] == worldRank ){ |
1300 |
> |
the_molecules[molIndex].setStampID( molCompType[i] ); |
1301 |
> |
the_molecules[molIndex].setMyIndex( molIndex ); |
1302 |
> |
the_molecules[molIndex].setGlobalIndex( i ); |
1303 |
> |
molIndex++; |
1304 |
|
} |
724 |
– |
else if( !strcmp( endTest, ".mdl" ) ){ |
725 |
– |
strcpy( endTest, ".dump" ); |
726 |
– |
} |
727 |
– |
else{ |
728 |
– |
strcat( simnfo->sampleName, ".dump" ); |
729 |
– |
} |
1305 |
|
} |
1306 |
|
|
1307 |
< |
strcpy( simnfo->statusName, inFileName ); |
1308 |
< |
nameLength = strlen( simnfo->statusName ); |
1309 |
< |
endTest = &(simnfo->statusName[nameLength - 5]); |
1310 |
< |
if( !strcmp( endTest, ".bass" ) ){ |
1311 |
< |
strcpy( endTest, ".stat" ); |
1312 |
< |
} |
1313 |
< |
else if( !strcmp( endTest, ".BASS" ) ){ |
1314 |
< |
strcpy( endTest, ".stat" ); |
1315 |
< |
} |
1316 |
< |
else{ |
1317 |
< |
endTest = &(simnfo->statusName[nameLength - 4]); |
1318 |
< |
if( !strcmp( endTest, ".bss" ) ){ |
1319 |
< |
strcpy( endTest, ".stat" ); |
1307 |
> |
#else // is_mpi |
1308 |
> |
|
1309 |
> |
molIndex = 0; |
1310 |
> |
globalAtomIndex = 0; |
1311 |
> |
for(i=0; i<n_components; i++){ |
1312 |
> |
for(j=0; j<components_nmol[i]; j++ ){ |
1313 |
> |
the_molecules[molIndex].setStampID( i ); |
1314 |
> |
the_molecules[molIndex].setMyIndex( molIndex ); |
1315 |
> |
the_molecules[molIndex].setGlobalIndex( molIndex ); |
1316 |
> |
for (k = 0; k < comp_stamps[i]->getNAtoms(); k++) { |
1317 |
> |
info[l].molMembershipArray[globalAtomIndex] = molIndex; |
1318 |
> |
globalAtomIndex++; |
1319 |
> |
} |
1320 |
> |
molIndex++; |
1321 |
|
} |
746 |
– |
else if( !strcmp( endTest, ".mdl" ) ){ |
747 |
– |
strcpy( endTest, ".stat" ); |
748 |
– |
} |
749 |
– |
else{ |
750 |
– |
strcat( simnfo->statusName, ".stat" ); |
751 |
– |
} |
1322 |
|
} |
1323 |
|
|
1324 |
< |
#ifdef IS_MPI |
755 |
< |
} |
1324 |
> |
|
1325 |
|
#endif // is_mpi |
757 |
– |
|
758 |
– |
// set the status, sample, and themal kick times |
759 |
– |
|
760 |
– |
if( the_globals->haveSampleTime() ){ |
761 |
– |
simnfo->sampleTime = the_globals->getSampleTime(); |
762 |
– |
simnfo->statusTime = simnfo->sampleTime; |
763 |
– |
simnfo->thermalTime = simnfo->sampleTime; |
764 |
– |
} |
765 |
– |
else{ |
766 |
– |
simnfo->sampleTime = the_globals->getRunTime(); |
767 |
– |
simnfo->statusTime = simnfo->sampleTime; |
768 |
– |
simnfo->thermalTime = simnfo->sampleTime; |
769 |
– |
} |
1326 |
|
|
771 |
– |
if( the_globals->haveStatusTime() ){ |
772 |
– |
simnfo->statusTime = the_globals->getStatusTime(); |
773 |
– |
} |
1327 |
|
|
1328 |
< |
if( the_globals->haveThermalTime() ){ |
776 |
< |
simnfo->thermalTime = the_globals->getThermalTime(); |
777 |
< |
} |
778 |
< |
|
779 |
< |
// check for the temperature set flag |
780 |
< |
|
781 |
< |
if( the_globals->haveTempSet() ) simnfo->setTemp = the_globals->getTempSet(); |
782 |
< |
|
783 |
< |
|
784 |
< |
// make the integrator |
785 |
< |
|
786 |
< |
|
787 |
< |
NVT* myNVT = NULL; |
788 |
< |
NPTi* myNPTi = NULL; |
789 |
< |
NPTf* myNPTf = NULL; |
790 |
< |
NPTim* myNPTim = NULL; |
791 |
< |
NPTfm* myNPTfm = NULL; |
792 |
< |
|
793 |
< |
switch( ensembleCase ){ |
794 |
< |
|
795 |
< |
case NVE_ENS: |
796 |
< |
new NVE( simnfo, the_ff ); |
797 |
< |
break; |
798 |
< |
|
799 |
< |
case NVT_ENS: |
800 |
< |
myNVT = new NVT( simnfo, the_ff ); |
801 |
< |
myNVT->setTargetTemp(the_globals->getTargetTemp()); |
802 |
< |
|
803 |
< |
if (the_globals->haveTauThermostat()) |
804 |
< |
myNVT->setTauThermostat(the_globals->getTauThermostat()); |
805 |
< |
|
806 |
< |
else { |
807 |
< |
sprintf( painCave.errMsg, |
808 |
< |
"SimSetup error: If you use the NVT\n" |
809 |
< |
" ensemble, you must set tauThermostat.\n"); |
810 |
< |
painCave.isFatal = 1; |
811 |
< |
simError(); |
812 |
< |
} |
813 |
< |
break; |
814 |
< |
|
815 |
< |
case NPTi_ENS: |
816 |
< |
myNPTi = new NPTi( simnfo, the_ff ); |
817 |
< |
myNPTi->setTargetTemp( the_globals->getTargetTemp()); |
818 |
< |
|
819 |
< |
if (the_globals->haveTargetPressure()) |
820 |
< |
myNPTi->setTargetPressure(the_globals->getTargetPressure()); |
821 |
< |
else { |
822 |
< |
sprintf( painCave.errMsg, |
823 |
< |
"SimSetup error: If you use a constant pressure\n" |
824 |
< |
" ensemble, you must set targetPressure in the BASS file.\n"); |
825 |
< |
painCave.isFatal = 1; |
826 |
< |
simError(); |
827 |
< |
} |
1328 |
> |
if( info[l].n_SRI ){ |
1329 |
|
|
1330 |
< |
if( the_globals->haveTauThermostat() ) |
1331 |
< |
myNPTi->setTauThermostat( the_globals->getTauThermostat() ); |
1332 |
< |
else{ |
1333 |
< |
sprintf( painCave.errMsg, |
1334 |
< |
"SimSetup error: If you use an NPT\n" |
1335 |
< |
" ensemble, you must set tauThermostat.\n"); |
1336 |
< |
painCave.isFatal = 1; |
836 |
< |
simError(); |
1330 |
> |
Exclude::createArray(info[l].n_SRI); |
1331 |
> |
the_excludes = new Exclude*[info[l].n_SRI]; |
1332 |
> |
for( int ex=0; ex<info[l].n_SRI; ex++){ |
1333 |
> |
the_excludes[ex] = new Exclude(ex); |
1334 |
> |
} |
1335 |
> |
info[l].globalExcludes = new int; |
1336 |
> |
info[l].n_exclude = info[l].n_SRI; |
1337 |
|
} |
838 |
– |
|
839 |
– |
if( the_globals->haveTauBarostat() ) |
840 |
– |
myNPTi->setTauBarostat( the_globals->getTauBarostat() ); |
1338 |
|
else{ |
1339 |
< |
sprintf( painCave.errMsg, |
1340 |
< |
"SimSetup error: If you use an NPT\n" |
1341 |
< |
" ensemble, you must set tauBarostat.\n"); |
1342 |
< |
painCave.isFatal = 1; |
1343 |
< |
simError(); |
1339 |
> |
|
1340 |
> |
Exclude::createArray( 1 ); |
1341 |
> |
the_excludes = new Exclude*; |
1342 |
> |
the_excludes[0] = new Exclude(0); |
1343 |
> |
the_excludes[0]->setPair( 0,0 ); |
1344 |
> |
info[l].globalExcludes = new int; |
1345 |
> |
info[l].globalExcludes[0] = 0; |
1346 |
> |
info[l].n_exclude = 0; |
1347 |
|
} |
848 |
– |
break; |
1348 |
|
|
1349 |
< |
case NPTf_ENS: |
851 |
< |
myNPTf = new NPTf( simnfo, the_ff ); |
852 |
< |
myNPTf->setTargetTemp( the_globals->getTargetTemp()); |
1349 |
> |
// set the arrays into the SimInfo object |
1350 |
|
|
1351 |
< |
if (the_globals->haveTargetPressure()) |
1352 |
< |
myNPTf->setTargetPressure(the_globals->getTargetPressure()); |
1353 |
< |
else { |
1354 |
< |
sprintf( painCave.errMsg, |
858 |
< |
"SimSetup error: If you use a constant pressure\n" |
859 |
< |
" ensemble, you must set targetPressure in the BASS file.\n"); |
860 |
< |
painCave.isFatal = 1; |
861 |
< |
simError(); |
862 |
< |
} |
1351 |
> |
info[l].atoms = the_atoms; |
1352 |
> |
info[l].molecules = the_molecules; |
1353 |
> |
info[l].nGlobalExcludes = 0; |
1354 |
> |
info[l].excludes = the_excludes; |
1355 |
|
|
1356 |
< |
if( the_globals->haveTauThermostat() ) |
865 |
< |
myNPTf->setTauThermostat( the_globals->getTauThermostat() ); |
866 |
< |
else{ |
867 |
< |
sprintf( painCave.errMsg, |
868 |
< |
"SimSetup error: If you use an NPT\n" |
869 |
< |
" ensemble, you must set tauThermostat.\n"); |
870 |
< |
painCave.isFatal = 1; |
871 |
< |
simError(); |
872 |
< |
} |
873 |
< |
|
874 |
< |
if( the_globals->haveTauBarostat() ) |
875 |
< |
myNPTf->setTauBarostat( the_globals->getTauBarostat() ); |
876 |
< |
else{ |
877 |
< |
sprintf( painCave.errMsg, |
878 |
< |
"SimSetup error: If you use an NPT\n" |
879 |
< |
" ensemble, you must set tauBarostat.\n"); |
880 |
< |
painCave.isFatal = 1; |
881 |
< |
simError(); |
882 |
< |
} |
883 |
< |
break; |
1356 |
> |
the_ff->setSimInfo( info ); |
1357 |
|
|
1358 |
< |
case NPTim_ENS: |
1359 |
< |
myNPTim = new NPTim( simnfo, the_ff ); |
887 |
< |
myNPTim->setTargetTemp( the_globals->getTargetTemp()); |
1358 |
> |
} |
1359 |
> |
} |
1360 |
|
|
1361 |
< |
if (the_globals->haveTargetPressure()) |
890 |
< |
myNPTim->setTargetPressure(the_globals->getTargetPressure()); |
891 |
< |
else { |
892 |
< |
sprintf( painCave.errMsg, |
893 |
< |
"SimSetup error: If you use a constant pressure\n" |
894 |
< |
" ensemble, you must set targetPressure in the BASS file.\n"); |
895 |
< |
painCave.isFatal = 1; |
896 |
< |
simError(); |
897 |
< |
} |
898 |
< |
|
899 |
< |
if( the_globals->haveTauThermostat() ) |
900 |
< |
myNPTim->setTauThermostat( the_globals->getTauThermostat() ); |
901 |
< |
else{ |
902 |
< |
sprintf( painCave.errMsg, |
903 |
< |
"SimSetup error: If you use an NPT\n" |
904 |
< |
" ensemble, you must set tauThermostat.\n"); |
905 |
< |
painCave.isFatal = 1; |
906 |
< |
simError(); |
907 |
< |
} |
1361 |
> |
void SimSetup::makeIntegrator( void ){ |
1362 |
|
|
1363 |
< |
if( the_globals->haveTauBarostat() ) |
910 |
< |
myNPTim->setTauBarostat( the_globals->getTauBarostat() ); |
911 |
< |
else{ |
912 |
< |
sprintf( painCave.errMsg, |
913 |
< |
"SimSetup error: If you use an NPT\n" |
914 |
< |
" ensemble, you must set tauBarostat.\n"); |
915 |
< |
painCave.isFatal = 1; |
916 |
< |
simError(); |
917 |
< |
} |
918 |
< |
break; |
1363 |
> |
int k; |
1364 |
|
|
1365 |
< |
case NPTfm_ENS: |
1366 |
< |
myNPTfm = new NPTfm( simnfo, the_ff ); |
1367 |
< |
myNPTfm->setTargetTemp( the_globals->getTargetTemp()); |
1368 |
< |
|
1369 |
< |
if (the_globals->haveTargetPressure()) |
1370 |
< |
myNPTfm->setTargetPressure(the_globals->getTargetPressure()); |
1371 |
< |
else { |
1372 |
< |
sprintf( painCave.errMsg, |
1373 |
< |
"SimSetup error: If you use a constant pressure\n" |
1374 |
< |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1375 |
< |
painCave.isFatal = 1; |
1376 |
< |
simError(); |
1377 |
< |
} |
1365 |
> |
NVT<RealIntegrator>* myNVT = NULL; |
1366 |
> |
NPTi<RealIntegrator>* myNPTi = NULL; |
1367 |
> |
NPTf<RealIntegrator>* myNPTf = NULL; |
1368 |
> |
NPTim<RealIntegrator>* myNPTim = NULL; |
1369 |
> |
NPTfm<RealIntegrator>* myNPTfm = NULL; |
1370 |
> |
ZConstraint<NVE<RealIntegrator> >* myNVEZCons = NULL; |
1371 |
> |
ZConstraint<NVT<RealIntegrator> >* myNVTZCons = NULL; |
1372 |
> |
ZConstraint<NPTi<RealIntegrator> >* myNPTiZCons = NULL; |
1373 |
> |
ZConstraint<NPTf<RealIntegrator> >* myNPTfZCons = NULL; |
1374 |
> |
ZConstraint<NPTim<RealIntegrator> >* myNPTimZCons = NULL; |
1375 |
> |
ZConstraint<NPTfm<RealIntegrator> >* myNPTfmZCons = NULL; |
1376 |
> |
|
1377 |
> |
for(k=0; k<nInfo; k++){ |
1378 |
|
|
1379 |
< |
if( the_globals->haveTauThermostat() ) |
1380 |
< |
myNPTfm->setTauThermostat( the_globals->getTauThermostat() ); |
1381 |
< |
else{ |
1382 |
< |
sprintf( painCave.errMsg, |
1383 |
< |
"SimSetup error: If you use an NPT\n" |
1379 |
> |
switch( ensembleCase ){ |
1380 |
> |
|
1381 |
> |
case NVE_ENS: |
1382 |
> |
new NVE<RealIntegrator>( &(info[k]), the_ff ); |
1383 |
> |
break; |
1384 |
> |
|
1385 |
> |
case NVT_ENS: |
1386 |
> |
myNVT = new NVT<RealIntegrator>( &(info[k]), the_ff ); |
1387 |
> |
myNVT->setTargetTemp(globals->getTargetTemp()); |
1388 |
> |
|
1389 |
> |
if (globals->haveTauThermostat()) |
1390 |
> |
myNVT->setTauThermostat(globals->getTauThermostat()); |
1391 |
> |
|
1392 |
> |
else { |
1393 |
> |
sprintf( painCave.errMsg, |
1394 |
> |
"SimSetup error: If you use the NVT\n" |
1395 |
> |
" ensemble, you must set tauThermostat.\n"); |
1396 |
> |
painCave.isFatal = 1; |
1397 |
> |
simError(); |
1398 |
> |
} |
1399 |
> |
break; |
1400 |
> |
|
1401 |
> |
case NPTi_ENS: |
1402 |
> |
myNPTi = new NPTi<RealIntegrator>( &(info[k]), the_ff ); |
1403 |
> |
myNPTi->setTargetTemp( globals->getTargetTemp() ); |
1404 |
> |
|
1405 |
> |
if (globals->haveTargetPressure()) |
1406 |
> |
myNPTi->setTargetPressure(globals->getTargetPressure()); |
1407 |
> |
else { |
1408 |
> |
sprintf( painCave.errMsg, |
1409 |
> |
"SimSetup error: If you use a constant pressure\n" |
1410 |
> |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1411 |
> |
painCave.isFatal = 1; |
1412 |
> |
simError(); |
1413 |
> |
} |
1414 |
> |
|
1415 |
> |
if( globals->haveTauThermostat() ) |
1416 |
> |
myNPTi->setTauThermostat( globals->getTauThermostat() ); |
1417 |
> |
else{ |
1418 |
> |
sprintf( painCave.errMsg, |
1419 |
> |
"SimSetup error: If you use an NPT\n" |
1420 |
> |
" ensemble, you must set tauThermostat.\n"); |
1421 |
> |
painCave.isFatal = 1; |
1422 |
> |
simError(); |
1423 |
> |
} |
1424 |
> |
|
1425 |
> |
if( globals->haveTauBarostat() ) |
1426 |
> |
myNPTi->setTauBarostat( globals->getTauBarostat() ); |
1427 |
> |
else{ |
1428 |
> |
sprintf( painCave.errMsg, |
1429 |
> |
"SimSetup error: If you use an NPT\n" |
1430 |
> |
" ensemble, you must set tauBarostat.\n"); |
1431 |
> |
painCave.isFatal = 1; |
1432 |
> |
simError(); |
1433 |
> |
} |
1434 |
> |
break; |
1435 |
> |
|
1436 |
> |
case NPTf_ENS: |
1437 |
> |
myNPTf = new NPTf<RealIntegrator>( &(info[k]), the_ff ); |
1438 |
> |
myNPTf->setTargetTemp( globals->getTargetTemp()); |
1439 |
> |
|
1440 |
> |
if (globals->haveTargetPressure()) |
1441 |
> |
myNPTf->setTargetPressure(globals->getTargetPressure()); |
1442 |
> |
else { |
1443 |
> |
sprintf( painCave.errMsg, |
1444 |
> |
"SimSetup error: If you use a constant pressure\n" |
1445 |
> |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1446 |
> |
painCave.isFatal = 1; |
1447 |
> |
simError(); |
1448 |
> |
} |
1449 |
> |
|
1450 |
> |
if( globals->haveTauThermostat() ) |
1451 |
> |
myNPTf->setTauThermostat( globals->getTauThermostat() ); |
1452 |
> |
else{ |
1453 |
> |
sprintf( painCave.errMsg, |
1454 |
> |
"SimSetup error: If you use an NPT\n" |
1455 |
|
" ensemble, you must set tauThermostat.\n"); |
1456 |
< |
painCave.isFatal = 1; |
1457 |
< |
simError(); |
1458 |
< |
} |
1459 |
< |
|
1460 |
< |
if( the_globals->haveTauBarostat() ) |
1461 |
< |
myNPTfm->setTauBarostat( the_globals->getTauBarostat() ); |
1462 |
< |
else{ |
1456 |
> |
painCave.isFatal = 1; |
1457 |
> |
simError(); |
1458 |
> |
} |
1459 |
> |
|
1460 |
> |
if( globals->haveTauBarostat() ) |
1461 |
> |
myNPTf->setTauBarostat( globals->getTauBarostat() ); |
1462 |
> |
else{ |
1463 |
> |
sprintf( painCave.errMsg, |
1464 |
> |
"SimSetup error: If you use an NPT\n" |
1465 |
> |
" ensemble, you must set tauBarostat.\n"); |
1466 |
> |
painCave.isFatal = 1; |
1467 |
> |
simError(); |
1468 |
> |
} |
1469 |
> |
break; |
1470 |
> |
|
1471 |
> |
case NPTim_ENS: |
1472 |
> |
myNPTim = new NPTim<RealIntegrator>( &(info[k]), the_ff ); |
1473 |
> |
myNPTim->setTargetTemp( globals->getTargetTemp()); |
1474 |
> |
|
1475 |
> |
if (globals->haveTargetPressure()) |
1476 |
> |
myNPTim->setTargetPressure(globals->getTargetPressure()); |
1477 |
> |
else { |
1478 |
> |
sprintf( painCave.errMsg, |
1479 |
> |
"SimSetup error: If you use a constant pressure\n" |
1480 |
> |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1481 |
> |
painCave.isFatal = 1; |
1482 |
> |
simError(); |
1483 |
> |
} |
1484 |
> |
|
1485 |
> |
if( globals->haveTauThermostat() ) |
1486 |
> |
myNPTim->setTauThermostat( globals->getTauThermostat() ); |
1487 |
> |
else{ |
1488 |
> |
sprintf( painCave.errMsg, |
1489 |
> |
"SimSetup error: If you use an NPT\n" |
1490 |
> |
" ensemble, you must set tauThermostat.\n"); |
1491 |
> |
painCave.isFatal = 1; |
1492 |
> |
simError(); |
1493 |
> |
} |
1494 |
> |
|
1495 |
> |
if( globals->haveTauBarostat() ) |
1496 |
> |
myNPTim->setTauBarostat( globals->getTauBarostat() ); |
1497 |
> |
else{ |
1498 |
|
sprintf( painCave.errMsg, |
1499 |
|
"SimSetup error: If you use an NPT\n" |
1500 |
|
" ensemble, you must set tauBarostat.\n"); |
1501 |
|
painCave.isFatal = 1; |
1502 |
|
simError(); |
1503 |
+ |
} |
1504 |
+ |
break; |
1505 |
+ |
|
1506 |
+ |
case NPTfm_ENS: |
1507 |
+ |
myNPTfm = new NPTfm<RealIntegrator>( &(info[k]), the_ff ); |
1508 |
+ |
myNPTfm->setTargetTemp( globals->getTargetTemp()); |
1509 |
+ |
|
1510 |
+ |
if (globals->haveTargetPressure()) |
1511 |
+ |
myNPTfm->setTargetPressure(globals->getTargetPressure()); |
1512 |
+ |
else { |
1513 |
+ |
sprintf( painCave.errMsg, |
1514 |
+ |
"SimSetup error: If you use a constant pressure\n" |
1515 |
+ |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1516 |
+ |
painCave.isFatal = 1; |
1517 |
+ |
simError(); |
1518 |
+ |
} |
1519 |
+ |
|
1520 |
+ |
if( globals->haveTauThermostat() ) |
1521 |
+ |
myNPTfm->setTauThermostat( globals->getTauThermostat() ); |
1522 |
+ |
else{ |
1523 |
+ |
sprintf( painCave.errMsg, |
1524 |
+ |
"SimSetup error: If you use an NPT\n" |
1525 |
+ |
" ensemble, you must set tauThermostat.\n"); |
1526 |
+ |
painCave.isFatal = 1; |
1527 |
+ |
simError(); |
1528 |
+ |
} |
1529 |
+ |
|
1530 |
+ |
if( globals->haveTauBarostat() ) |
1531 |
+ |
myNPTfm->setTauBarostat( globals->getTauBarostat() ); |
1532 |
+ |
else{ |
1533 |
+ |
sprintf( painCave.errMsg, |
1534 |
+ |
"SimSetup error: If you use an NPT\n" |
1535 |
+ |
" ensemble, you must set tauBarostat.\n"); |
1536 |
+ |
painCave.isFatal = 1; |
1537 |
+ |
simError(); |
1538 |
+ |
} |
1539 |
+ |
break; |
1540 |
+ |
|
1541 |
+ |
case NVEZCONS_ENS: |
1542 |
+ |
|
1543 |
+ |
|
1544 |
+ |
//setup index of z-constraint molecules, z-constraint sampel time |
1545 |
+ |
//and z-constraint force output name. These parameter should be known |
1546 |
+ |
//before constructing the z-constraint integrator |
1547 |
+ |
setupZConstraint(); |
1548 |
+ |
|
1549 |
+ |
myNVEZCons = new ZConstraint<NVE<RealIntegrator> >( &(info[k]), the_ff ); |
1550 |
+ |
|
1551 |
+ |
break; |
1552 |
+ |
|
1553 |
+ |
|
1554 |
+ |
case NVTZCONS_ENS: |
1555 |
+ |
|
1556 |
+ |
setupZConstraint(); |
1557 |
+ |
|
1558 |
+ |
myNVTZCons = new ZConstraint<NVT<RealIntegrator> >( &(info[k]), the_ff ); |
1559 |
+ |
myNVTZCons->setTargetTemp(globals->getTargetTemp()); |
1560 |
+ |
|
1561 |
+ |
if (globals->haveTauThermostat()) |
1562 |
+ |
myNVTZCons->setTauThermostat(globals->getTauThermostat()); |
1563 |
+ |
|
1564 |
+ |
else { |
1565 |
+ |
sprintf( painCave.errMsg, |
1566 |
+ |
"SimSetup error: If you use the NVT\n" |
1567 |
+ |
" ensemble, you must set tauThermostat.\n"); |
1568 |
+ |
painCave.isFatal = 1; |
1569 |
+ |
simError(); |
1570 |
+ |
} |
1571 |
+ |
break; |
1572 |
+ |
|
1573 |
+ |
case NPTiZCONS_ENS: |
1574 |
+ |
|
1575 |
+ |
setupZConstraint(); |
1576 |
+ |
|
1577 |
+ |
myNPTiZCons = new ZConstraint<NPTi<RealIntegrator> >( &(info[k]), the_ff ); |
1578 |
+ |
myNPTiZCons->setTargetTemp( globals->getTargetTemp() ); |
1579 |
+ |
|
1580 |
+ |
if (globals->haveTargetPressure()) |
1581 |
+ |
myNPTiZCons->setTargetPressure(globals->getTargetPressure()); |
1582 |
+ |
else { |
1583 |
+ |
sprintf( painCave.errMsg, |
1584 |
+ |
"SimSetup error: If you use a constant pressure\n" |
1585 |
+ |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1586 |
+ |
painCave.isFatal = 1; |
1587 |
+ |
simError(); |
1588 |
+ |
} |
1589 |
+ |
|
1590 |
+ |
if( globals->haveTauThermostat() ) |
1591 |
+ |
myNPTiZCons->setTauThermostat( globals->getTauThermostat() ); |
1592 |
+ |
else{ |
1593 |
+ |
sprintf( painCave.errMsg, |
1594 |
+ |
"SimSetup error: If you use an NPT\n" |
1595 |
+ |
" ensemble, you must set tauThermostat.\n"); |
1596 |
+ |
painCave.isFatal = 1; |
1597 |
+ |
simError(); |
1598 |
+ |
} |
1599 |
+ |
|
1600 |
+ |
if( globals->haveTauBarostat() ) |
1601 |
+ |
myNPTiZCons->setTauBarostat( globals->getTauBarostat() ); |
1602 |
+ |
else{ |
1603 |
+ |
sprintf( painCave.errMsg, |
1604 |
+ |
"SimSetup error: If you use an NPT\n" |
1605 |
+ |
" ensemble, you must set tauBarostat.\n"); |
1606 |
+ |
painCave.isFatal = 1; |
1607 |
+ |
simError(); |
1608 |
+ |
} |
1609 |
+ |
|
1610 |
+ |
break; |
1611 |
+ |
|
1612 |
+ |
case NPTfZCONS_ENS: |
1613 |
+ |
|
1614 |
+ |
setupZConstraint(); |
1615 |
+ |
|
1616 |
+ |
myNPTfZCons = new ZConstraint<NPTf<RealIntegrator> >( &(info[k]), the_ff ); |
1617 |
+ |
myNPTfZCons->setTargetTemp( globals->getTargetTemp()); |
1618 |
+ |
|
1619 |
+ |
if (globals->haveTargetPressure()) |
1620 |
+ |
myNPTfZCons->setTargetPressure(globals->getTargetPressure()); |
1621 |
+ |
else { |
1622 |
+ |
sprintf( painCave.errMsg, |
1623 |
+ |
"SimSetup error: If you use a constant pressure\n" |
1624 |
+ |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1625 |
+ |
painCave.isFatal = 1; |
1626 |
+ |
simError(); |
1627 |
+ |
} |
1628 |
+ |
|
1629 |
+ |
if( globals->haveTauThermostat() ) |
1630 |
+ |
myNPTfZCons->setTauThermostat( globals->getTauThermostat() ); |
1631 |
+ |
else{ |
1632 |
+ |
sprintf( painCave.errMsg, |
1633 |
+ |
"SimSetup error: If you use an NPT\n" |
1634 |
+ |
" ensemble, you must set tauThermostat.\n"); |
1635 |
+ |
painCave.isFatal = 1; |
1636 |
+ |
simError(); |
1637 |
+ |
} |
1638 |
+ |
|
1639 |
+ |
if( globals->haveTauBarostat() ) |
1640 |
+ |
myNPTfZCons->setTauBarostat( globals->getTauBarostat() ); |
1641 |
+ |
else{ |
1642 |
+ |
sprintf( painCave.errMsg, |
1643 |
+ |
"SimSetup error: If you use an NPT\n" |
1644 |
+ |
" ensemble, you must set tauBarostat.\n"); |
1645 |
+ |
painCave.isFatal = 1; |
1646 |
+ |
simError(); |
1647 |
+ |
} |
1648 |
+ |
|
1649 |
+ |
break; |
1650 |
+ |
|
1651 |
+ |
case NPTimZCONS_ENS: |
1652 |
+ |
|
1653 |
+ |
setupZConstraint(); |
1654 |
+ |
|
1655 |
+ |
myNPTimZCons = new ZConstraint<NPTim<RealIntegrator> >( &(info[k]), the_ff ); |
1656 |
+ |
myNPTimZCons->setTargetTemp( globals->getTargetTemp()); |
1657 |
+ |
|
1658 |
+ |
if (globals->haveTargetPressure()) |
1659 |
+ |
myNPTimZCons->setTargetPressure(globals->getTargetPressure()); |
1660 |
+ |
else { |
1661 |
+ |
sprintf( painCave.errMsg, |
1662 |
+ |
"SimSetup error: If you use a constant pressure\n" |
1663 |
+ |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1664 |
+ |
painCave.isFatal = 1; |
1665 |
+ |
simError(); |
1666 |
+ |
} |
1667 |
+ |
|
1668 |
+ |
if( globals->haveTauThermostat() ) |
1669 |
+ |
myNPTimZCons->setTauThermostat( globals->getTauThermostat() ); |
1670 |
+ |
else{ |
1671 |
+ |
sprintf( painCave.errMsg, |
1672 |
+ |
"SimSetup error: If you use an NPT\n" |
1673 |
+ |
" ensemble, you must set tauThermostat.\n"); |
1674 |
+ |
painCave.isFatal = 1; |
1675 |
+ |
simError(); |
1676 |
+ |
} |
1677 |
+ |
|
1678 |
+ |
if( globals->haveTauBarostat() ) |
1679 |
+ |
myNPTimZCons->setTauBarostat( globals->getTauBarostat() ); |
1680 |
+ |
else{ |
1681 |
+ |
sprintf( painCave.errMsg, |
1682 |
+ |
"SimSetup error: If you use an NPT\n" |
1683 |
+ |
" ensemble, you must set tauBarostat.\n"); |
1684 |
+ |
painCave.isFatal = 1; |
1685 |
+ |
simError(); |
1686 |
+ |
} |
1687 |
+ |
|
1688 |
+ |
break; |
1689 |
+ |
|
1690 |
+ |
case NPTfmZCONS_ENS: |
1691 |
+ |
|
1692 |
+ |
setupZConstraint(); |
1693 |
+ |
|
1694 |
+ |
myNPTfmZCons = new ZConstraint<NPTfm<RealIntegrator> >( &(info[k]), the_ff ); |
1695 |
+ |
myNPTfmZCons->setTargetTemp( globals->getTargetTemp()); |
1696 |
+ |
|
1697 |
+ |
if (globals->haveTargetPressure()) |
1698 |
+ |
myNPTfmZCons->setTargetPressure(globals->getTargetPressure()); |
1699 |
+ |
else { |
1700 |
+ |
sprintf( painCave.errMsg, |
1701 |
+ |
"SimSetup error: If you use a constant pressure\n" |
1702 |
+ |
" ensemble, you must set targetPressure in the BASS file.\n"); |
1703 |
+ |
painCave.isFatal = 1; |
1704 |
+ |
simError(); |
1705 |
+ |
} |
1706 |
+ |
|
1707 |
+ |
if( globals->haveTauThermostat() ) |
1708 |
+ |
myNPTfmZCons->setTauThermostat( globals->getTauThermostat() ); |
1709 |
+ |
else{ |
1710 |
+ |
sprintf( painCave.errMsg, |
1711 |
+ |
"SimSetup error: If you use an NPT\n" |
1712 |
+ |
" ensemble, you must set tauThermostat.\n"); |
1713 |
+ |
painCave.isFatal = 1; |
1714 |
+ |
simError(); |
1715 |
+ |
} |
1716 |
+ |
|
1717 |
+ |
if( globals->haveTauBarostat() ) |
1718 |
+ |
myNPTfmZCons->setTauBarostat( globals->getTauBarostat() ); |
1719 |
+ |
else{ |
1720 |
+ |
sprintf( painCave.errMsg, |
1721 |
+ |
"SimSetup error: If you use an NPT\n" |
1722 |
+ |
" ensemble, you must set tauBarostat.\n"); |
1723 |
+ |
painCave.isFatal = 1; |
1724 |
+ |
simError(); |
1725 |
+ |
} |
1726 |
+ |
break; |
1727 |
+ |
|
1728 |
+ |
|
1729 |
+ |
|
1730 |
+ |
default: |
1731 |
+ |
sprintf( painCave.errMsg, |
1732 |
+ |
"SimSetup Error. Unrecognized ensemble in case statement.\n"); |
1733 |
+ |
painCave.isFatal = 1; |
1734 |
+ |
simError(); |
1735 |
|
} |
953 |
– |
break; |
954 |
– |
|
955 |
– |
default: |
956 |
– |
sprintf( painCave.errMsg, |
957 |
– |
"SimSetup Error. Unrecognized ensemble in case statement.\n"); |
958 |
– |
painCave.isFatal = 1; |
959 |
– |
simError(); |
1736 |
|
} |
1737 |
+ |
} |
1738 |
|
|
1739 |
+ |
void SimSetup::initFortran( void ){ |
1740 |
|
|
1741 |
< |
#ifdef IS_MPI |
964 |
< |
mpiSim->mpiRefresh(); |
965 |
< |
#endif |
966 |
< |
|
967 |
< |
// initialize the Fortran |
968 |
< |
|
969 |
< |
|
970 |
< |
simnfo->refreshSim(); |
1741 |
> |
info[0].refreshSim(); |
1742 |
|
|
1743 |
< |
if( !strcmp( simnfo->mixingRule, "standard") ){ |
1743 |
> |
if( !strcmp( info[0].mixingRule, "standard") ){ |
1744 |
|
the_ff->initForceField( LB_MIXING_RULE ); |
1745 |
|
} |
1746 |
< |
else if( !strcmp( simnfo->mixingRule, "explicit") ){ |
1746 |
> |
else if( !strcmp( info[0].mixingRule, "explicit") ){ |
1747 |
|
the_ff->initForceField( EXPLICIT_MIXING_RULE ); |
1748 |
|
} |
1749 |
|
else{ |
1750 |
|
sprintf( painCave.errMsg, |
1751 |
|
"SimSetup Error: unknown mixing rule -> \"%s\"\n", |
1752 |
< |
simnfo->mixingRule ); |
1752 |
> |
info[0].mixingRule ); |
1753 |
|
painCave.isFatal = 1; |
1754 |
|
simError(); |
1755 |
|
} |
1760 |
|
"Successfully intialized the mixingRule for Fortran." ); |
1761 |
|
MPIcheckPoint(); |
1762 |
|
#endif // is_mpi |
1763 |
+ |
|
1764 |
|
} |
1765 |
|
|
1766 |
+ |
void SimSetup::setupZConstraint() |
1767 |
+ |
{ |
1768 |
+ |
int k; |
1769 |
|
|
1770 |
< |
void SimSetup::makeMolecules( void ){ |
996 |
< |
|
997 |
< |
int i, j, exI, exJ, tempEx, stampID, atomOffset, excludeOffset; |
998 |
< |
molInit info; |
999 |
< |
DirectionalAtom* dAtom; |
1000 |
< |
LinkedAssign* extras; |
1001 |
< |
LinkedAssign* current_extra; |
1002 |
< |
AtomStamp* currentAtom; |
1003 |
< |
BondStamp* currentBond; |
1004 |
< |
BendStamp* currentBend; |
1005 |
< |
TorsionStamp* currentTorsion; |
1006 |
< |
|
1007 |
< |
bond_pair* theBonds; |
1008 |
< |
bend_set* theBends; |
1009 |
< |
torsion_set* theTorsions; |
1010 |
< |
|
1011 |
< |
|
1012 |
< |
//init the forceField paramters |
1013 |
< |
|
1014 |
< |
the_ff->readParams(); |
1015 |
< |
|
1016 |
< |
|
1017 |
< |
// init the atoms |
1018 |
< |
|
1019 |
< |
double ux, uy, uz, u, uSqr; |
1020 |
< |
|
1021 |
< |
atomOffset = 0; |
1022 |
< |
excludeOffset = 0; |
1023 |
< |
for(i=0; i<simnfo->n_mol; i++){ |
1770 |
> |
for(k=0; k<nInfo; k++){ |
1771 |
|
|
1772 |
< |
stampID = the_molecules[i].getStampID(); |
1026 |
< |
|
1027 |
< |
info.nAtoms = comp_stamps[stampID]->getNAtoms(); |
1028 |
< |
info.nBonds = comp_stamps[stampID]->getNBonds(); |
1029 |
< |
info.nBends = comp_stamps[stampID]->getNBends(); |
1030 |
< |
info.nTorsions = comp_stamps[stampID]->getNTorsions(); |
1031 |
< |
info.nExcludes = info.nBonds + info.nBends + info.nTorsions; |
1032 |
< |
|
1033 |
< |
info.myAtoms = &the_atoms[atomOffset]; |
1034 |
< |
info.myExcludes = &the_excludes[excludeOffset]; |
1035 |
< |
info.myBonds = new Bond*[info.nBonds]; |
1036 |
< |
info.myBends = new Bend*[info.nBends]; |
1037 |
< |
info.myTorsions = new Torsion*[info.nTorsions]; |
1038 |
< |
|
1039 |
< |
theBonds = new bond_pair[info.nBonds]; |
1040 |
< |
theBends = new bend_set[info.nBends]; |
1041 |
< |
theTorsions = new torsion_set[info.nTorsions]; |
1042 |
< |
|
1043 |
< |
// make the Atoms |
1044 |
< |
|
1045 |
< |
for(j=0; j<info.nAtoms; j++){ |
1772 |
> |
if(globals->haveZConsTime()){ |
1773 |
|
|
1774 |
< |
currentAtom = comp_stamps[stampID]->getAtom( j ); |
1775 |
< |
if( currentAtom->haveOrientation() ){ |
1776 |
< |
|
1777 |
< |
dAtom = new DirectionalAtom(j + atomOffset); |
1778 |
< |
simnfo->n_oriented++; |
1052 |
< |
info.myAtoms[j] = dAtom; |
1053 |
< |
|
1054 |
< |
ux = currentAtom->getOrntX(); |
1055 |
< |
uy = currentAtom->getOrntY(); |
1056 |
< |
uz = currentAtom->getOrntZ(); |
1057 |
< |
|
1058 |
< |
uSqr = (ux * ux) + (uy * uy) + (uz * uz); |
1059 |
< |
|
1060 |
< |
u = sqrt( uSqr ); |
1061 |
< |
ux = ux / u; |
1062 |
< |
uy = uy / u; |
1063 |
< |
uz = uz / u; |
1064 |
< |
|
1065 |
< |
dAtom->setSUx( ux ); |
1066 |
< |
dAtom->setSUy( uy ); |
1067 |
< |
dAtom->setSUz( uz ); |
1068 |
< |
} |
1069 |
< |
else{ |
1070 |
< |
info.myAtoms[j] = new GeneralAtom(j + atomOffset); |
1071 |
< |
} |
1072 |
< |
info.myAtoms[j]->setType( currentAtom->getType() ); |
1073 |
< |
|
1074 |
< |
#ifdef IS_MPI |
1075 |
< |
|
1076 |
< |
info.myAtoms[j]->setGlobalIndex( globalIndex[j+atomOffset] ); |
1077 |
< |
|
1078 |
< |
#endif // is_mpi |
1079 |
< |
} |
1080 |
< |
|
1081 |
< |
// make the bonds |
1082 |
< |
for(j=0; j<info.nBonds; j++){ |
1083 |
< |
|
1084 |
< |
currentBond = comp_stamps[stampID]->getBond( j ); |
1085 |
< |
theBonds[j].a = currentBond->getA() + atomOffset; |
1086 |
< |
theBonds[j].b = currentBond->getB() + atomOffset; |
1087 |
< |
|
1088 |
< |
exI = theBonds[j].a; |
1089 |
< |
exJ = theBonds[j].b; |
1090 |
< |
|
1091 |
< |
// exclude_I must always be the smaller of the pair |
1092 |
< |
if( exI > exJ ){ |
1093 |
< |
tempEx = exI; |
1094 |
< |
exI = exJ; |
1095 |
< |
exJ = tempEx; |
1096 |
< |
} |
1097 |
< |
#ifdef IS_MPI |
1098 |
< |
tempEx = exI; |
1099 |
< |
exI = the_atoms[tempEx]->getGlobalIndex() + 1; |
1100 |
< |
tempEx = exJ; |
1101 |
< |
exJ = the_atoms[tempEx]->getGlobalIndex() + 1; |
1102 |
< |
|
1103 |
< |
the_excludes[j+excludeOffset]->setPair( exI, exJ ); |
1104 |
< |
#else // isn't MPI |
1105 |
< |
|
1106 |
< |
the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); |
1107 |
< |
#endif //is_mpi |
1774 |
> |
//add sample time of z-constraint into SimInfo's property list |
1775 |
> |
DoubleData* zconsTimeProp = new DoubleData(); |
1776 |
> |
zconsTimeProp->setID("zconstime"); |
1777 |
> |
zconsTimeProp->setData(globals->getZConsTime()); |
1778 |
> |
info[k].addProperty(zconsTimeProp); |
1779 |
|
} |
1780 |
< |
excludeOffset += info.nBonds; |
1781 |
< |
|
1782 |
< |
//make the bends |
1783 |
< |
for(j=0; j<info.nBends; j++){ |
1784 |
< |
|
1785 |
< |
currentBend = comp_stamps[stampID]->getBend( j ); |
1115 |
< |
theBends[j].a = currentBend->getA() + atomOffset; |
1116 |
< |
theBends[j].b = currentBend->getB() + atomOffset; |
1117 |
< |
theBends[j].c = currentBend->getC() + atomOffset; |
1118 |
< |
|
1119 |
< |
if( currentBend->haveExtras() ){ |
1120 |
< |
|
1121 |
< |
extras = currentBend->getExtras(); |
1122 |
< |
current_extra = extras; |
1123 |
< |
|
1124 |
< |
while( current_extra != NULL ){ |
1125 |
< |
if( !strcmp( current_extra->getlhs(), "ghostVectorSource" )){ |
1126 |
< |
|
1127 |
< |
switch( current_extra->getType() ){ |
1128 |
< |
|
1129 |
< |
case 0: |
1130 |
< |
theBends[j].ghost = |
1131 |
< |
current_extra->getInt() + atomOffset; |
1132 |
< |
theBends[j].isGhost = 1; |
1133 |
< |
break; |
1134 |
< |
|
1135 |
< |
case 1: |
1136 |
< |
theBends[j].ghost = |
1137 |
< |
(int)current_extra->getDouble() + atomOffset; |
1138 |
< |
theBends[j].isGhost = 1; |
1139 |
< |
break; |
1140 |
< |
|
1141 |
< |
default: |
1142 |
< |
sprintf( painCave.errMsg, |
1143 |
< |
"SimSetup Error: ghostVectorSource was neither a " |
1144 |
< |
"double nor an int.\n" |
1145 |
< |
"-->Bend[%d] in %s\n", |
1146 |
< |
j, comp_stamps[stampID]->getID() ); |
1147 |
< |
painCave.isFatal = 1; |
1148 |
< |
simError(); |
1149 |
< |
} |
1150 |
< |
} |
1151 |
< |
|
1152 |
< |
else{ |
1153 |
< |
|
1154 |
< |
sprintf( painCave.errMsg, |
1155 |
< |
"SimSetup Error: unhandled bend assignment:\n" |
1156 |
< |
" -->%s in Bend[%d] in %s\n", |
1157 |
< |
current_extra->getlhs(), |
1158 |
< |
j, comp_stamps[stampID]->getID() ); |
1159 |
< |
painCave.isFatal = 1; |
1160 |
< |
simError(); |
1161 |
< |
} |
1162 |
< |
|
1163 |
< |
current_extra = current_extra->getNext(); |
1164 |
< |
} |
1165 |
< |
} |
1166 |
< |
|
1167 |
< |
if( !theBends[j].isGhost ){ |
1168 |
< |
|
1169 |
< |
exI = theBends[j].a; |
1170 |
< |
exJ = theBends[j].c; |
1171 |
< |
} |
1172 |
< |
else{ |
1173 |
< |
|
1174 |
< |
exI = theBends[j].a; |
1175 |
< |
exJ = theBends[j].b; |
1176 |
< |
} |
1177 |
< |
|
1178 |
< |
// exclude_I must always be the smaller of the pair |
1179 |
< |
if( exI > exJ ){ |
1180 |
< |
tempEx = exI; |
1181 |
< |
exI = exJ; |
1182 |
< |
exJ = tempEx; |
1183 |
< |
} |
1184 |
< |
#ifdef IS_MPI |
1185 |
< |
tempEx = exI; |
1186 |
< |
exI = the_atoms[tempEx]->getGlobalIndex() + 1; |
1187 |
< |
tempEx = exJ; |
1188 |
< |
exJ = the_atoms[tempEx]->getGlobalIndex() + 1; |
1189 |
< |
|
1190 |
< |
the_excludes[j+excludeOffset]->setPair( exI, exJ ); |
1191 |
< |
#else // isn't MPI |
1192 |
< |
the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); |
1193 |
< |
#endif //is_mpi |
1780 |
> |
else{ |
1781 |
> |
sprintf( painCave.errMsg, |
1782 |
> |
"ZConstraint error: If you use an ZConstraint\n" |
1783 |
> |
" , you must set sample time.\n"); |
1784 |
> |
painCave.isFatal = 1; |
1785 |
> |
simError(); |
1786 |
|
} |
1787 |
< |
excludeOffset += info.nBends; |
1788 |
< |
|
1789 |
< |
for(j=0; j<info.nTorsions; j++){ |
1787 |
> |
|
1788 |
> |
if(globals->haveIndexOfAllZConsMols()){ |
1789 |
> |
|
1790 |
> |
//add index of z-constraint molecules into SimInfo's property list |
1791 |
> |
vector<int> tempIndex = globals->getIndexOfAllZConsMols(); |
1792 |
|
|
1793 |
< |
currentTorsion = comp_stamps[stampID]->getTorsion( j ); |
1794 |
< |
theTorsions[j].a = currentTorsion->getA() + atomOffset; |
1201 |
< |
theTorsions[j].b = currentTorsion->getB() + atomOffset; |
1202 |
< |
theTorsions[j].c = currentTorsion->getC() + atomOffset; |
1203 |
< |
theTorsions[j].d = currentTorsion->getD() + atomOffset; |
1793 |
> |
//sort the index |
1794 |
> |
sort(tempIndex.begin(), tempIndex.end()); |
1795 |
|
|
1796 |
< |
exI = theTorsions[j].a; |
1797 |
< |
exJ = theTorsions[j].d; |
1798 |
< |
|
1799 |
< |
// exclude_I must always be the smaller of the pair |
1209 |
< |
if( exI > exJ ){ |
1210 |
< |
tempEx = exI; |
1211 |
< |
exI = exJ; |
1212 |
< |
exJ = tempEx; |
1213 |
< |
} |
1214 |
< |
#ifdef IS_MPI |
1215 |
< |
tempEx = exI; |
1216 |
< |
exI = the_atoms[tempEx]->getGlobalIndex() + 1; |
1217 |
< |
tempEx = exJ; |
1218 |
< |
exJ = the_atoms[tempEx]->getGlobalIndex() + 1; |
1219 |
< |
|
1220 |
< |
the_excludes[j+excludeOffset]->setPair( exI, exJ ); |
1221 |
< |
#else // isn't MPI |
1222 |
< |
the_excludes[j+excludeOffset]->setPair( (exI+1), (exJ+1) ); |
1223 |
< |
#endif //is_mpi |
1796 |
> |
IndexData* zconsIndex = new IndexData(); |
1797 |
> |
zconsIndex->setID("zconsindex"); |
1798 |
> |
zconsIndex->setIndexData(tempIndex); |
1799 |
> |
info[k].addProperty(zconsIndex); |
1800 |
|
} |
1801 |
< |
excludeOffset += info.nTorsions; |
1226 |
< |
|
1227 |
< |
|
1228 |
< |
// send the arrays off to the forceField for init. |
1229 |
< |
|
1230 |
< |
the_ff->initializeAtoms( info.nAtoms, info.myAtoms ); |
1231 |
< |
the_ff->initializeBonds( info.nBonds, info.myBonds, theBonds ); |
1232 |
< |
the_ff->initializeBends( info.nBends, info.myBends, theBends ); |
1233 |
< |
the_ff->initializeTorsions( info.nTorsions, info.myTorsions, theTorsions ); |
1234 |
< |
|
1235 |
< |
|
1236 |
< |
the_molecules[i].initialize( info ); |
1237 |
< |
|
1238 |
< |
|
1239 |
< |
atomOffset += info.nAtoms; |
1240 |
< |
delete[] theBonds; |
1241 |
< |
delete[] theBends; |
1242 |
< |
delete[] theTorsions; |
1243 |
< |
} |
1244 |
< |
|
1245 |
< |
#ifdef IS_MPI |
1246 |
< |
sprintf( checkPointMsg, "all molecules initialized succesfully" ); |
1247 |
< |
MPIcheckPoint(); |
1248 |
< |
#endif // is_mpi |
1249 |
< |
|
1250 |
< |
// clean up the forcefield |
1251 |
< |
the_ff->calcRcut(); |
1252 |
< |
the_ff->cleanMe(); |
1253 |
< |
|
1254 |
< |
} |
1255 |
< |
|
1256 |
< |
void SimSetup::initFromBass( void ){ |
1257 |
< |
|
1258 |
< |
int i, j, k; |
1259 |
< |
int n_cells; |
1260 |
< |
double cellx, celly, cellz; |
1261 |
< |
double temp1, temp2, temp3; |
1262 |
< |
int n_per_extra; |
1263 |
< |
int n_extra; |
1264 |
< |
int have_extra, done; |
1265 |
< |
|
1266 |
< |
temp1 = (double)tot_nmol / 4.0; |
1267 |
< |
temp2 = pow( temp1, ( 1.0 / 3.0 ) ); |
1268 |
< |
temp3 = ceil( temp2 ); |
1269 |
< |
|
1270 |
< |
have_extra =0; |
1271 |
< |
if( temp2 < temp3 ){ // we have a non-complete lattice |
1272 |
< |
have_extra =1; |
1273 |
< |
|
1274 |
< |
n_cells = (int)temp3 - 1; |
1275 |
< |
cellx = simnfo->boxLx / temp3; |
1276 |
< |
celly = simnfo->boxLy / temp3; |
1277 |
< |
cellz = simnfo->boxLz / temp3; |
1278 |
< |
n_extra = tot_nmol - ( 4 * n_cells * n_cells * n_cells ); |
1279 |
< |
temp1 = ((double)n_extra) / ( pow( temp3, 3.0 ) - pow( n_cells, 3.0 ) ); |
1280 |
< |
n_per_extra = (int)ceil( temp1 ); |
1281 |
< |
|
1282 |
< |
if( n_per_extra > 4){ |
1801 |
> |
else{ |
1802 |
|
sprintf( painCave.errMsg, |
1803 |
< |
"SimSetup error. There has been an error in constructing" |
1804 |
< |
" the non-complete lattice.\n" ); |
1803 |
> |
"SimSetup error: If you use an ZConstraint\n" |
1804 |
> |
" , you must set index of z-constraint molecules.\n"); |
1805 |
|
painCave.isFatal = 1; |
1806 |
< |
simError(); |
1806 |
> |
simError(); |
1807 |
> |
|
1808 |
|
} |
1809 |
+ |
|
1810 |
+ |
//Determine the name of ouput file and add it into SimInfo's property list |
1811 |
+ |
//Be careful, do not use inFileName, since it is a pointer which |
1812 |
+ |
//point to a string at master node, and slave nodes do not contain that string |
1813 |
+ |
|
1814 |
+ |
string zconsOutput(info[k].finalName); |
1815 |
+ |
|
1816 |
+ |
zconsOutput = zconsOutput.substr(0, zconsOutput.rfind(".")) + ".fz"; |
1817 |
+ |
|
1818 |
+ |
StringData* zconsFilename = new StringData(); |
1819 |
+ |
zconsFilename->setID("zconsfilename"); |
1820 |
+ |
zconsFilename->setData(zconsOutput); |
1821 |
+ |
|
1822 |
+ |
info[k].addProperty(zconsFilename); |
1823 |
|
} |
1290 |
– |
else{ |
1291 |
– |
n_cells = (int)temp3; |
1292 |
– |
cellx = simnfo->boxLx / temp3; |
1293 |
– |
celly = simnfo->boxLy / temp3; |
1294 |
– |
cellz = simnfo->boxLz / temp3; |
1295 |
– |
} |
1296 |
– |
|
1297 |
– |
current_mol = 0; |
1298 |
– |
current_comp_mol = 0; |
1299 |
– |
current_comp = 0; |
1300 |
– |
current_atom_ndx = 0; |
1301 |
– |
|
1302 |
– |
for( i=0; i < n_cells ; i++ ){ |
1303 |
– |
for( j=0; j < n_cells; j++ ){ |
1304 |
– |
for( k=0; k < n_cells; k++ ){ |
1305 |
– |
|
1306 |
– |
makeElement( i * cellx, |
1307 |
– |
j * celly, |
1308 |
– |
k * cellz ); |
1309 |
– |
|
1310 |
– |
makeElement( i * cellx + 0.5 * cellx, |
1311 |
– |
j * celly + 0.5 * celly, |
1312 |
– |
k * cellz ); |
1313 |
– |
|
1314 |
– |
makeElement( i * cellx, |
1315 |
– |
j * celly + 0.5 * celly, |
1316 |
– |
k * cellz + 0.5 * cellz ); |
1317 |
– |
|
1318 |
– |
makeElement( i * cellx + 0.5 * cellx, |
1319 |
– |
j * celly, |
1320 |
– |
k * cellz + 0.5 * cellz ); |
1321 |
– |
} |
1322 |
– |
} |
1323 |
– |
} |
1324 |
– |
|
1325 |
– |
if( have_extra ){ |
1326 |
– |
done = 0; |
1327 |
– |
|
1328 |
– |
int start_ndx; |
1329 |
– |
for( i=0; i < (n_cells+1) && !done; i++ ){ |
1330 |
– |
for( j=0; j < (n_cells+1) && !done; j++ ){ |
1331 |
– |
|
1332 |
– |
if( i < n_cells ){ |
1333 |
– |
|
1334 |
– |
if( j < n_cells ){ |
1335 |
– |
start_ndx = n_cells; |
1336 |
– |
} |
1337 |
– |
else start_ndx = 0; |
1338 |
– |
} |
1339 |
– |
else start_ndx = 0; |
1340 |
– |
|
1341 |
– |
for( k=start_ndx; k < (n_cells+1) && !done; k++ ){ |
1342 |
– |
|
1343 |
– |
makeElement( i * cellx, |
1344 |
– |
j * celly, |
1345 |
– |
k * cellz ); |
1346 |
– |
done = ( current_mol >= tot_nmol ); |
1347 |
– |
|
1348 |
– |
if( !done && n_per_extra > 1 ){ |
1349 |
– |
makeElement( i * cellx + 0.5 * cellx, |
1350 |
– |
j * celly + 0.5 * celly, |
1351 |
– |
k * cellz ); |
1352 |
– |
done = ( current_mol >= tot_nmol ); |
1353 |
– |
} |
1354 |
– |
|
1355 |
– |
if( !done && n_per_extra > 2){ |
1356 |
– |
makeElement( i * cellx, |
1357 |
– |
j * celly + 0.5 * celly, |
1358 |
– |
k * cellz + 0.5 * cellz ); |
1359 |
– |
done = ( current_mol >= tot_nmol ); |
1360 |
– |
} |
1361 |
– |
|
1362 |
– |
if( !done && n_per_extra > 3){ |
1363 |
– |
makeElement( i * cellx + 0.5 * cellx, |
1364 |
– |
j * celly, |
1365 |
– |
k * cellz + 0.5 * cellz ); |
1366 |
– |
done = ( current_mol >= tot_nmol ); |
1367 |
– |
} |
1368 |
– |
} |
1369 |
– |
} |
1370 |
– |
} |
1371 |
– |
} |
1372 |
– |
|
1373 |
– |
|
1374 |
– |
for( i=0; i<simnfo->n_atoms; i++ ){ |
1375 |
– |
simnfo->atoms[i]->set_vx( 0.0 ); |
1376 |
– |
simnfo->atoms[i]->set_vy( 0.0 ); |
1377 |
– |
simnfo->atoms[i]->set_vz( 0.0 ); |
1378 |
– |
} |
1824 |
|
} |
1380 |
– |
|
1381 |
– |
void SimSetup::makeElement( double x, double y, double z ){ |
1382 |
– |
|
1383 |
– |
int k; |
1384 |
– |
AtomStamp* current_atom; |
1385 |
– |
DirectionalAtom* dAtom; |
1386 |
– |
double rotMat[3][3]; |
1387 |
– |
|
1388 |
– |
for( k=0; k<comp_stamps[current_comp]->getNAtoms(); k++ ){ |
1389 |
– |
|
1390 |
– |
current_atom = comp_stamps[current_comp]->getAtom( k ); |
1391 |
– |
if( !current_atom->havePosition() ){ |
1392 |
– |
sprintf( painCave.errMsg, |
1393 |
– |
"SimSetup:initFromBass error.\n" |
1394 |
– |
"\tComponent %s, atom %s does not have a position specified.\n" |
1395 |
– |
"\tThe initialization routine is unable to give a start" |
1396 |
– |
" position.\n", |
1397 |
– |
comp_stamps[current_comp]->getID(), |
1398 |
– |
current_atom->getType() ); |
1399 |
– |
painCave.isFatal = 1; |
1400 |
– |
simError(); |
1401 |
– |
} |
1402 |
– |
|
1403 |
– |
the_atoms[current_atom_ndx]->setX( x + current_atom->getPosX() ); |
1404 |
– |
the_atoms[current_atom_ndx]->setY( y + current_atom->getPosY() ); |
1405 |
– |
the_atoms[current_atom_ndx]->setZ( z + current_atom->getPosZ() ); |
1406 |
– |
|
1407 |
– |
if( the_atoms[current_atom_ndx]->isDirectional() ){ |
1408 |
– |
|
1409 |
– |
dAtom = (DirectionalAtom *)the_atoms[current_atom_ndx]; |
1410 |
– |
|
1411 |
– |
rotMat[0][0] = 1.0; |
1412 |
– |
rotMat[0][1] = 0.0; |
1413 |
– |
rotMat[0][2] = 0.0; |
1414 |
– |
|
1415 |
– |
rotMat[1][0] = 0.0; |
1416 |
– |
rotMat[1][1] = 1.0; |
1417 |
– |
rotMat[1][2] = 0.0; |
1418 |
– |
|
1419 |
– |
rotMat[2][0] = 0.0; |
1420 |
– |
rotMat[2][1] = 0.0; |
1421 |
– |
rotMat[2][2] = 1.0; |
1422 |
– |
|
1423 |
– |
dAtom->setA( rotMat ); |
1424 |
– |
} |
1425 |
– |
|
1426 |
– |
current_atom_ndx++; |
1427 |
– |
} |
1428 |
– |
|
1429 |
– |
current_mol++; |
1430 |
– |
current_comp_mol++; |
1431 |
– |
|
1432 |
– |
if( current_comp_mol >= components_nmol[current_comp] ){ |
1433 |
– |
|
1434 |
– |
current_comp_mol = 0; |
1435 |
– |
current_comp++; |
1436 |
– |
} |
1437 |
– |
} |