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