30 |
|
n_dipoles = 0; |
31 |
|
ndf = 0; |
32 |
|
ndfRaw = 0; |
33 |
+ |
nZconstraints = 0; |
34 |
|
the_integrator = NULL; |
35 |
|
setTemp = 0; |
36 |
|
thermalTime = 0.0; |
37 |
+ |
currentTime = 0.0; |
38 |
|
rCut = 0.0; |
39 |
+ |
ecr = 0.0; |
40 |
+ |
est = 0.0; |
41 |
+ |
oldEcr = 0.0; |
42 |
+ |
oldRcut = 0.0; |
43 |
|
|
44 |
+ |
haveOrigRcut = 0; |
45 |
+ |
haveOrigEcr = 0; |
46 |
+ |
boxIsInit = 0; |
47 |
+ |
|
48 |
+ |
|
49 |
+ |
|
50 |
|
usePBC = 0; |
51 |
|
useLJ = 0; |
52 |
|
useSticky = 0; |
55 |
|
useGB = 0; |
56 |
|
useEAM = 0; |
57 |
|
|
58 |
+ |
myConfiguration = new SimState(); |
59 |
+ |
|
60 |
|
wrapMeSimInfo( this ); |
61 |
|
} |
62 |
|
|
63 |
+ |
|
64 |
+ |
SimInfo::~SimInfo(){ |
65 |
+ |
|
66 |
+ |
delete myConfiguration; |
67 |
+ |
|
68 |
+ |
map<string, GenericData*>::iterator i; |
69 |
+ |
|
70 |
+ |
for(i = properties.begin(); i != properties.end(); i++) |
71 |
+ |
delete (*i).second; |
72 |
+ |
|
73 |
+ |
} |
74 |
+ |
|
75 |
|
void SimInfo::setBox(double newBox[3]) { |
76 |
|
|
77 |
|
int i, j; |
99 |
|
// [ 2 5 8 ] |
100 |
|
double FortranHmatInv[9]; // the inverted Hmat (for Fortran); |
101 |
|
|
102 |
+ |
|
103 |
+ |
if( !boxIsInit ) boxIsInit = 1; |
104 |
|
|
105 |
|
for(i=0; i < 3; i++) |
106 |
|
for (j=0; j < 3; j++) Hmat[i][j] = theBox[i][j]; |
107 |
|
|
80 |
– |
cerr |
81 |
– |
<< "setting Hmat ->\n" |
82 |
– |
<< "[ " << Hmat[0][0] << ", " << Hmat[0][1] << ", " << Hmat[0][2] << " ]\n" |
83 |
– |
<< "[ " << Hmat[1][0] << ", " << Hmat[1][1] << ", " << Hmat[1][2] << " ]\n" |
84 |
– |
<< "[ " << Hmat[2][0] << ", " << Hmat[2][1] << ", " << Hmat[2][2] << " ]\n"; |
85 |
– |
|
108 |
|
calcBoxL(); |
109 |
|
calcHmatInv(); |
110 |
|
|
117 |
|
|
118 |
|
setFortranBoxSize(FortranHmat, FortranHmatInv, &orthoRhombic); |
119 |
|
|
98 |
– |
smallestBoxL = boxLx; |
99 |
– |
if (boxLy < smallestBoxL) smallestBoxL = boxLy; |
100 |
– |
if (boxLz < smallestBoxL) smallestBoxL = boxLz; |
101 |
– |
|
102 |
– |
maxCutoff = smallestBoxL / 2.0; |
103 |
– |
|
104 |
– |
if (rList > maxCutoff) { |
105 |
– |
sprintf( painCave.errMsg, |
106 |
– |
"New Box size is forcing neighborlist radius down to %lf\n", |
107 |
– |
maxCutoff ); |
108 |
– |
painCave.isFatal = 0; |
109 |
– |
simError(); |
110 |
– |
|
111 |
– |
rList = maxCutoff; |
112 |
– |
|
113 |
– |
sprintf( painCave.errMsg, |
114 |
– |
"New Box size is forcing cutoff radius down to %lf\n", |
115 |
– |
maxCutoff - 1.0 ); |
116 |
– |
painCave.isFatal = 0; |
117 |
– |
simError(); |
118 |
– |
|
119 |
– |
rCut = rList - 1.0; |
120 |
– |
|
121 |
– |
// list radius changed so we have to refresh the simulation structure. |
122 |
– |
refreshSim(); |
123 |
– |
} |
124 |
– |
|
125 |
– |
if (rCut > maxCutoff) { |
126 |
– |
sprintf( painCave.errMsg, |
127 |
– |
"New Box size is forcing cutoff radius down to %lf\n", |
128 |
– |
maxCutoff ); |
129 |
– |
painCave.isFatal = 0; |
130 |
– |
simError(); |
131 |
– |
|
132 |
– |
status = 0; |
133 |
– |
LJ_new_rcut(&rCut, &status); |
134 |
– |
if (status != 0) { |
135 |
– |
sprintf( painCave.errMsg, |
136 |
– |
"Error in recomputing LJ shifts based on new rcut\n"); |
137 |
– |
painCave.isFatal = 1; |
138 |
– |
simError(); |
139 |
– |
} |
140 |
– |
} |
120 |
|
} |
121 |
|
|
122 |
|
|
132 |
|
double theBox[3][3]; |
133 |
|
int i, j; |
134 |
|
|
135 |
< |
cerr << "Scaling box by " << scale << "\n"; |
135 |
> |
// cerr << "Scaling box by " << scale << "\n"; |
136 |
|
|
137 |
|
for(i=0; i<3; i++) |
138 |
|
for (j=0; j<3; j++) theBox[i][j] = Hmat[i][j]*scale; |
291 |
|
|
292 |
|
dx = Hmat[0][0]; dy = Hmat[1][0]; dz = Hmat[2][0]; |
293 |
|
dsq = dx*dx + dy*dy + dz*dz; |
294 |
< |
boxLx = sqrt( dsq ); |
294 |
> |
boxL[0] = sqrt( dsq ); |
295 |
> |
maxCutoff = 0.5 * boxL[0]; |
296 |
|
|
297 |
|
// boxLy |
298 |
|
|
299 |
|
dx = Hmat[0][1]; dy = Hmat[1][1]; dz = Hmat[2][1]; |
300 |
|
dsq = dx*dx + dy*dy + dz*dz; |
301 |
< |
boxLy = sqrt( dsq ); |
301 |
> |
boxL[1] = sqrt( dsq ); |
302 |
> |
if( (0.5 * boxL[1]) < maxCutoff ) maxCutoff = 0.5 * boxL[1]; |
303 |
|
|
304 |
|
// boxLz |
305 |
|
|
306 |
|
dx = Hmat[0][2]; dy = Hmat[1][2]; dz = Hmat[2][2]; |
307 |
|
dsq = dx*dx + dy*dy + dz*dz; |
308 |
< |
boxLz = sqrt( dsq ); |
308 |
> |
boxL[2] = sqrt( dsq ); |
309 |
> |
if( (0.5 * boxL[2]) < maxCutoff ) maxCutoff = 0.5 * boxL[2]; |
310 |
|
|
311 |
+ |
checkCutOffs(); |
312 |
+ |
|
313 |
|
} |
314 |
|
|
315 |
|
|
363 |
|
ndf = ndf_local; |
364 |
|
#endif |
365 |
|
|
366 |
< |
ndf = ndf - 3; |
366 |
> |
ndf = ndf - 3 - nZconstraints; |
367 |
|
|
368 |
|
return ndf; |
369 |
|
} |
389 |
|
int isError; |
390 |
|
int n_global; |
391 |
|
int* excl; |
408 |
– |
|
409 |
– |
fInfo.rrf = 0.0; |
410 |
– |
fInfo.rt = 0.0; |
411 |
– |
fInfo.dielect = 0.0; |
392 |
|
|
393 |
< |
fInfo.rlist = rList; |
414 |
< |
fInfo.rcut = rCut; |
393 |
> |
fInfo.dielect = 0.0; |
394 |
|
|
395 |
|
if( useDipole ){ |
417 |
– |
fInfo.rrf = ecr; |
418 |
– |
fInfo.rt = ecr - est; |
396 |
|
if( useReactionField )fInfo.dielect = dielectric; |
397 |
|
} |
398 |
|
|
441 |
|
|
442 |
|
} |
443 |
|
|
444 |
+ |
|
445 |
+ |
void SimInfo::setRcut( double theRcut ){ |
446 |
+ |
|
447 |
+ |
if( !haveOrigRcut ){ |
448 |
+ |
haveOrigRcut = 1; |
449 |
+ |
origRcut = theRcut; |
450 |
+ |
} |
451 |
+ |
|
452 |
+ |
rCut = theRcut; |
453 |
+ |
checkCutOffs(); |
454 |
+ |
} |
455 |
+ |
|
456 |
+ |
void SimInfo::setEcr( double theEcr ){ |
457 |
+ |
|
458 |
+ |
if( !haveOrigEcr ){ |
459 |
+ |
haveOrigEcr = 1; |
460 |
+ |
origEcr = theEcr; |
461 |
+ |
} |
462 |
+ |
|
463 |
+ |
ecr = theEcr; |
464 |
+ |
checkCutOffs(); |
465 |
+ |
} |
466 |
+ |
|
467 |
+ |
void SimInfo::setEcr( double theEcr, double theEst ){ |
468 |
+ |
|
469 |
+ |
est = theEst; |
470 |
+ |
setEcr( theEcr ); |
471 |
+ |
} |
472 |
+ |
|
473 |
+ |
|
474 |
+ |
void SimInfo::checkCutOffs( void ){ |
475 |
+ |
|
476 |
+ |
int cutChanged = 0; |
477 |
+ |
|
478 |
+ |
|
479 |
+ |
|
480 |
+ |
if( boxIsInit ){ |
481 |
+ |
|
482 |
+ |
//we need to check cutOffs against the box |
483 |
+ |
|
484 |
+ |
if(( maxCutoff > rCut )&&(usePBC)){ |
485 |
+ |
if( rCut < origRcut ){ |
486 |
+ |
rCut = origRcut; |
487 |
+ |
if (rCut > maxCutoff) rCut = maxCutoff; |
488 |
+ |
|
489 |
+ |
sprintf( painCave.errMsg, |
490 |
+ |
"New Box size is setting the long range cutoff radius " |
491 |
+ |
"to %lf\n", |
492 |
+ |
rCut ); |
493 |
+ |
painCave.isFatal = 0; |
494 |
+ |
simError(); |
495 |
+ |
} |
496 |
+ |
} |
497 |
+ |
|
498 |
+ |
if( maxCutoff > ecr ){ |
499 |
+ |
if( ecr < origEcr ){ |
500 |
+ |
rCut = origEcr; |
501 |
+ |
if (ecr > maxCutoff) ecr = maxCutoff; |
502 |
+ |
|
503 |
+ |
sprintf( painCave.errMsg, |
504 |
+ |
"New Box size is setting the electrostaticCutoffRadius " |
505 |
+ |
"to %lf\n", |
506 |
+ |
ecr ); |
507 |
+ |
painCave.isFatal = 0; |
508 |
+ |
simError(); |
509 |
+ |
} |
510 |
+ |
} |
511 |
+ |
|
512 |
+ |
|
513 |
+ |
if ((rCut > maxCutoff)&&(usePBC)) { |
514 |
+ |
sprintf( painCave.errMsg, |
515 |
+ |
"New Box size is setting the long range cutoff radius " |
516 |
+ |
"to %lf\n", |
517 |
+ |
maxCutoff ); |
518 |
+ |
painCave.isFatal = 0; |
519 |
+ |
simError(); |
520 |
+ |
rCut = maxCutoff; |
521 |
+ |
} |
522 |
+ |
|
523 |
+ |
if( ecr > maxCutoff){ |
524 |
+ |
sprintf( painCave.errMsg, |
525 |
+ |
"New Box size is setting the electrostaticCutoffRadius " |
526 |
+ |
"to %lf\n", |
527 |
+ |
maxCutoff ); |
528 |
+ |
painCave.isFatal = 0; |
529 |
+ |
simError(); |
530 |
+ |
ecr = maxCutoff; |
531 |
+ |
} |
532 |
+ |
|
533 |
+ |
|
534 |
+ |
} |
535 |
+ |
|
536 |
+ |
|
537 |
+ |
if( (oldEcr != ecr) || ( oldRcut != rCut ) ) cutChanged = 1; |
538 |
+ |
|
539 |
+ |
// rlist is the 1.0 plus max( rcut, ecr ) |
540 |
+ |
|
541 |
+ |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
542 |
+ |
|
543 |
+ |
if( cutChanged ){ |
544 |
+ |
|
545 |
+ |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
546 |
+ |
} |
547 |
+ |
|
548 |
+ |
oldEcr = ecr; |
549 |
+ |
oldRcut = rCut; |
550 |
+ |
} |
551 |
+ |
|
552 |
+ |
void SimInfo::addProperty(GenericData* prop){ |
553 |
+ |
|
554 |
+ |
map<string, GenericData*>::iterator result; |
555 |
+ |
result = properties.find(prop->getID()); |
556 |
+ |
|
557 |
+ |
//we can't simply use properties[prop->getID()] = prop, |
558 |
+ |
//it will cause memory leak if we already contain a propery which has the same name of prop |
559 |
+ |
|
560 |
+ |
if(result != properties.end()){ |
561 |
+ |
|
562 |
+ |
delete (*result).second; |
563 |
+ |
(*result).second = prop; |
564 |
+ |
|
565 |
+ |
} |
566 |
+ |
else{ |
567 |
+ |
|
568 |
+ |
properties[prop->getID()] = prop; |
569 |
+ |
|
570 |
+ |
} |
571 |
+ |
|
572 |
+ |
} |
573 |
+ |
|
574 |
+ |
GenericData* SimInfo::getProperty(const string& propName){ |
575 |
+ |
|
576 |
+ |
map<string, GenericData*>::iterator result; |
577 |
+ |
|
578 |
+ |
//string lowerCaseName = (); |
579 |
+ |
|
580 |
+ |
result = properties.find(propName); |
581 |
+ |
|
582 |
+ |
if(result != properties.end()) |
583 |
+ |
return (*result).second; |
584 |
+ |
else |
585 |
+ |
return NULL; |
586 |
+ |
} |
587 |
+ |
|
588 |
+ |
vector<GenericData*> SimInfo::getProperties(){ |
589 |
+ |
|
590 |
+ |
vector<GenericData*> result; |
591 |
+ |
map<string, GenericData*>::iterator i; |
592 |
+ |
|
593 |
+ |
for(i = properties.begin(); i != properties.end(); i++) |
594 |
+ |
result.push_back((*i).second); |
595 |
+ |
|
596 |
+ |
return result; |
597 |
+ |
} |
598 |
+ |
|
599 |
+ |
|