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