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