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