| 1 |
< |
#include <cstdlib> |
| 2 |
< |
#include <cstring> |
| 3 |
< |
#include <cmath> |
| 1 |
> |
#include <stdlib.h> |
| 2 |
> |
#include <string.h> |
| 3 |
> |
#include <math.h> |
| 4 |
|
|
| 5 |
|
#include <iostream> |
| 6 |
|
using namespace std; |
| 61 |
|
|
| 62 |
|
myConfiguration = new SimState(); |
| 63 |
|
|
| 64 |
+ |
properties = new GenericData(); |
| 65 |
+ |
|
| 66 |
|
wrapMeSimInfo( this ); |
| 67 |
|
} |
| 68 |
|
|
| 70 |
|
SimInfo::~SimInfo(){ |
| 71 |
|
|
| 72 |
|
delete myConfiguration; |
| 73 |
< |
|
| 72 |
< |
map<string, GenericData*>::iterator i; |
| 73 |
< |
|
| 74 |
< |
for(i = properties.begin(); i != properties.end(); i++) |
| 75 |
< |
delete (*i).second; |
| 76 |
< |
|
| 73 |
> |
delete properties; |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
void SimInfo::setBox(double newBox[3]) { |
| 405 |
|
|
| 406 |
|
|
| 407 |
|
int SimInfo::getNDF(){ |
| 408 |
< |
int ndf_local, ndf; |
| 408 |
> |
int ndf_local; |
| 409 |
|
|
| 410 |
|
ndf_local = 3 * n_atoms + 3 * n_oriented - n_constraints; |
| 411 |
|
|
| 421 |
|
} |
| 422 |
|
|
| 423 |
|
int SimInfo::getNDFraw() { |
| 424 |
< |
int ndfRaw_local, ndfRaw; |
| 424 |
> |
int ndfRaw_local; |
| 425 |
|
|
| 426 |
|
// Raw degrees of freedom that we have to set |
| 427 |
|
ndfRaw_local = 3 * n_atoms + 3 * n_oriented; |
| 436 |
|
} |
| 437 |
|
|
| 438 |
|
int SimInfo::getNDFtranslational() { |
| 439 |
< |
int ndfTrans_local, ndfTrans; |
| 439 |
> |
int ndfTrans_local; |
| 440 |
|
|
| 441 |
|
ndfTrans_local = 3 * n_atoms - n_constraints; |
| 442 |
|
|
| 512 |
|
|
| 513 |
|
void SimInfo::setRcut( double theRcut ){ |
| 514 |
|
|
| 518 |
– |
if( !haveOrigRcut ){ |
| 519 |
– |
haveOrigRcut = 1; |
| 520 |
– |
origRcut = theRcut; |
| 521 |
– |
} |
| 522 |
– |
|
| 515 |
|
rCut = theRcut; |
| 516 |
|
checkCutOffs(); |
| 517 |
|
} |
| 518 |
|
|
| 519 |
< |
void SimInfo::setEcr( double theEcr ){ |
| 519 |
> |
void SimInfo::setDefaultRcut( double theRcut ){ |
| 520 |
> |
|
| 521 |
> |
haveOrigRcut = 1; |
| 522 |
> |
origRcut = theRcut; |
| 523 |
> |
rCut = theRcut; |
| 524 |
|
|
| 525 |
< |
if( !haveOrigEcr ){ |
| 530 |
< |
haveOrigEcr = 1; |
| 531 |
< |
origEcr = theEcr; |
| 532 |
< |
} |
| 525 |
> |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
| 526 |
|
|
| 527 |
+ |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
| 528 |
+ |
} |
| 529 |
+ |
|
| 530 |
+ |
void SimInfo::setEcr( double theEcr ){ |
| 531 |
+ |
|
| 532 |
|
ecr = theEcr; |
| 533 |
|
checkCutOffs(); |
| 534 |
|
} |
| 535 |
|
|
| 536 |
+ |
void SimInfo::setDefaultEcr( double theEcr ){ |
| 537 |
+ |
|
| 538 |
+ |
haveOrigEcr = 1; |
| 539 |
+ |
origEcr = theEcr; |
| 540 |
+ |
|
| 541 |
+ |
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
| 542 |
+ |
|
| 543 |
+ |
ecr = theEcr; |
| 544 |
+ |
|
| 545 |
+ |
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
| 546 |
+ |
} |
| 547 |
+ |
|
| 548 |
|
void SimInfo::setEcr( double theEcr, double theEst ){ |
| 549 |
|
|
| 550 |
|
est = theEst; |
| 551 |
|
setEcr( theEcr ); |
| 552 |
|
} |
| 553 |
|
|
| 554 |
+ |
void SimInfo::setDefaultEcr( double theEcr, double theEst ){ |
| 555 |
|
|
| 556 |
+ |
est = theEst; |
| 557 |
+ |
setDefaultEcr( theEcr ); |
| 558 |
+ |
} |
| 559 |
+ |
|
| 560 |
+ |
|
| 561 |
|
void SimInfo::checkCutOffs( void ){ |
| 562 |
|
|
| 563 |
|
int cutChanged = 0; |
| 624 |
|
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
| 625 |
|
|
| 626 |
|
if( cutChanged ){ |
| 611 |
– |
|
| 627 |
|
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
| 628 |
|
} |
| 629 |
|
|
| 640 |
|
|
| 641 |
|
} |
| 642 |
|
|
| 643 |
< |
void SimInfo::addProperty(GenericData* prop){ |
| 643 |
> |
GenericData* SimInfo::getProperty(char* propName){ |
| 644 |
|
|
| 645 |
< |
map<string, GenericData*>::iterator result; |
| 631 |
< |
result = properties.find(prop->getID()); |
| 632 |
< |
|
| 633 |
< |
//we can't simply use properties[prop->getID()] = prop, |
| 634 |
< |
//it will cause memory leak if we already contain a propery which has the same name of prop |
| 635 |
< |
|
| 636 |
< |
if(result != properties.end()){ |
| 637 |
< |
|
| 638 |
< |
delete (*result).second; |
| 639 |
< |
(*result).second = prop; |
| 640 |
< |
|
| 641 |
< |
} |
| 642 |
< |
else{ |
| 643 |
< |
|
| 644 |
< |
properties[prop->getID()] = prop; |
| 645 |
< |
|
| 646 |
< |
} |
| 647 |
< |
|
| 645 |
> |
return properties->find( propName ); |
| 646 |
|
} |
| 647 |
|
|
| 650 |
– |
GenericData* SimInfo::getProperty(const string& propName){ |
| 651 |
– |
|
| 652 |
– |
map<string, GenericData*>::iterator result; |
| 653 |
– |
|
| 654 |
– |
//string lowerCaseName = (); |
| 655 |
– |
|
| 656 |
– |
result = properties.find(propName); |
| 657 |
– |
|
| 658 |
– |
if(result != properties.end()) |
| 659 |
– |
return (*result).second; |
| 660 |
– |
else |
| 661 |
– |
return NULL; |
| 662 |
– |
} |
| 663 |
– |
|
| 664 |
– |
vector<GenericData*> SimInfo::getProperties(){ |
| 665 |
– |
|
| 666 |
– |
vector<GenericData*> result; |
| 667 |
– |
map<string, GenericData*>::iterator i; |
| 668 |
– |
|
| 669 |
– |
for(i = properties.begin(); i != properties.end(); i++) |
| 670 |
– |
result.push_back((*i).second); |
| 671 |
– |
|
| 672 |
– |
return result; |
| 673 |
– |
} |
| 674 |
– |
|
| 648 |
|
double SimInfo::matTrace3(double m[3][3]){ |
| 649 |
|
double trace; |
| 650 |
|
trace = m[0][0] + m[1][1] + m[2][2]; |