ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new-templateless/OOPSE/libmdtools/SimInfo.cpp
(Generate patch)

Comparing:
trunk/OOPSE/libmdtools/SimInfo.cpp (file contents), Revision 781 by tim, Mon Sep 22 23:07:57 2003 UTC vs.
branches/new-templateless/OOPSE/libmdtools/SimInfo.cpp (file contents), Revision 852 by mmeineke, Thu Nov 6 18:20:47 2003 UTC

# Line 1 | Line 1
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;
# Line 61 | Line 61 | SimInfo::SimInfo(){
61  
62    myConfiguration = new SimState();
63  
64 +  properties = new GenericData();
65 +
66    wrapMeSimInfo( this );
67   }
68  
# Line 68 | Line 70 | SimInfo::~SimInfo(){
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]) {
# Line 94 | Line 91 | void SimInfo::setBoxM( double theBox[3][3] ){
91  
92   void SimInfo::setBoxM( double theBox[3][3] ){
93    
94 <  int i, j, status;
98 <  double smallestBoxL, maxCutoff;
94 >  int i, j;
95    double FortranHmat[9]; // to preserve compatibility with Fortran the
96                           // ordering in the array is as follows:
97                           // [ 0 3 6 ]
# Line 146 | Line 142 | void SimInfo::calcHmatInv( void ) {
142   }
143  
144   void SimInfo::calcHmatInv( void ) {
145 <  
145 >
146 >  int oldOrtho;
147    int i,j;
148    double smallDiag;
149    double tol;
# Line 156 | Line 153 | void SimInfo::calcHmatInv( void ) {
153  
154    // Check the inverse to make sure it is sane:
155  
156 <  matMul3( Hmat, HmatInv, sanity );
156 >  // matMul3( Hmat, HmatInv, sanity );
157      
158    // check to see if Hmat is orthorhombic
159 +
160    
161 <  smallDiag = Hmat[0][0];
162 <  if(smallDiag > Hmat[1][1]) smallDiag = Hmat[1][1];
163 <  if(smallDiag > Hmat[2][2]) smallDiag = Hmat[2][2];
161 >  oldOrtho = orthoRhombic;
162 >
163 >  smallDiag = fabs(Hmat[0][0]);
164 >  if(smallDiag > fabs(Hmat[1][1])) smallDiag = fabs(Hmat[1][1]);
165 >  if(smallDiag > fabs(Hmat[2][2])) smallDiag = fabs(Hmat[2][2]);
166    tol = smallDiag * 1E-6;
167  
168    orthoRhombic = 1;
# Line 171 | Line 171 | void SimInfo::calcHmatInv( void ) {
171      for (j = 0 ; j < 3; j++) {
172        if (i != j) {
173          if (orthoRhombic) {
174 <          if (Hmat[i][j] >= tol) orthoRhombic = 0;
174 >          if ( fabs(Hmat[i][j]) >= tol) orthoRhombic = 0;
175          }        
176        }
177      }
178    }
179 +  
180 +  if( oldOrtho != orthoRhombic ){
181 +    
182 +    if( orthoRhombic ){
183 +      sprintf( painCave.errMsg,
184 +               "Hmat is switching from Non-Orthorhombic to OrthoRhombic\n"
185 +               "       If this is a bad thing change the ortho tolerance in SimInfo.\n" );
186 +      simError();
187 +    }
188 +    else {
189 +      sprintf( painCave.errMsg,
190 +               "Hmat is switching from Orthorhombic to Non-OrthoRhombic\n"
191 +               "       If this is a bad thing change the ortho tolerance in SimInfo.\n" );
192 +      simError();
193 +    }
194 +  }
195   }
196  
197   double SimInfo::matDet3(double a[3][3]) {
# Line 302 | Line 318 | void SimInfo::calcBoxL( void ){
318   void SimInfo::calcBoxL( void ){
319  
320    double dx, dy, dz, dsq;
305  int i;
321  
322    // boxVol = Determinant of Hmat
323  
# Line 372 | Line 387 | void SimInfo::wrapVector( double thePos[3] ){
387  
388   void SimInfo::wrapVector( double thePos[3] ){
389  
390 <  int i, j, k;
390 >  int i;
391    double scaled[3];
392  
393    if( !orthoRhombic ){
# Line 410 | Line 425 | int SimInfo::getNDF(){
425  
426  
427   int SimInfo::getNDF(){
428 <  int ndf_local, ndf;
428 >  int ndf_local;
429    
430    ndf_local = 3 * n_atoms + 3 * n_oriented - n_constraints;
431  
# Line 426 | Line 441 | int SimInfo::getNDFraw() {
441   }
442  
443   int SimInfo::getNDFraw() {
444 <  int ndfRaw_local, ndfRaw;
444 >  int ndfRaw_local;
445  
446    // Raw degrees of freedom that we have to set
447    ndfRaw_local = 3 * n_atoms + 3 * n_oriented;
# Line 441 | Line 456 | int SimInfo::getNDFtranslational() {
456   }
457  
458   int SimInfo::getNDFtranslational() {
459 <  int ndfTrans_local, ndfTrans;
459 >  int ndfTrans_local;
460  
461    ndfTrans_local = 3 * n_atoms - n_constraints;
462  
# Line 517 | Line 532 | void SimInfo::setRcut( double theRcut ){
532  
533   void SimInfo::setRcut( double theRcut ){
534  
520  if( !haveOrigRcut ){
521    haveOrigRcut = 1;
522    origRcut = theRcut;
523  }
524
535    rCut = theRcut;
536    checkCutOffs();
537   }
538  
539 < void SimInfo::setEcr( double theEcr ){
539 > void SimInfo::setDefaultRcut( double theRcut ){
540  
541 <  if( !haveOrigEcr ){
542 <    haveOrigEcr = 1;
543 <    origEcr = theEcr;
534 <  }
541 >  haveOrigRcut = 1;
542 >  origRcut = theRcut;
543 >  rCut = theRcut;
544  
545 +  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
546 +
547 +  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
548 + }
549 +
550 + void SimInfo::setEcr( double theEcr ){
551 +
552    ecr = theEcr;
553    checkCutOffs();
554   }
555  
556 + void SimInfo::setDefaultEcr( double theEcr ){
557 +
558 +  haveOrigEcr = 1;
559 +  origEcr = theEcr;
560 +  
561 +  ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
562 +
563 +  ecr = theEcr;
564 +
565 +  notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
566 + }
567 +
568   void SimInfo::setEcr( double theEcr, double theEst ){
569  
570    est = theEst;
571    setEcr( theEcr );
572   }
573  
574 + void SimInfo::setDefaultEcr( double theEcr, double theEst ){
575  
576 +  est = theEst;
577 +  setDefaultEcr( theEcr );
578 + }
579 +
580 +
581   void SimInfo::checkCutOffs( void ){
582  
583    int cutChanged = 0;
# Line 610 | Line 644 | void SimInfo::checkCutOffs( void ){
644      ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0;
645      
646      if( cutChanged ){
613      
647        notifyFortranCutOffs( &rCut, &rList, &ecr, &est );
648      }
649      
# Line 627 | Line 660 | void SimInfo::checkCutOffs( void ){
660    
661   }
662  
663 < void SimInfo::addProperty(GenericData* prop){
663 > GenericData* SimInfo::getProperty(char* propName){
664  
665 <  map<string, GenericData*>::iterator result;
633 <  result = properties.find(prop->getID());
634 <  
635 <  //we can't simply use  properties[prop->getID()] = prop,
636 <  //it will cause memory leak if we already contain a propery which has the same name of prop
637 <  
638 <  if(result != properties.end()){
639 <    
640 <    delete (*result).second;
641 <    (*result).second = prop;
642 <      
643 <  }
644 <  else{
645 <
646 <    properties[prop->getID()] = prop;
647 <
648 <  }
649 <    
665 >  return properties->find( propName );
666   }
667  
652 GenericData* SimInfo::getProperty(const string& propName){
653
654  map<string, GenericData*>::iterator result;
655  
656  //string lowerCaseName = ();
657  
658  result = properties.find(propName);
659  
660  if(result != properties.end())
661    return (*result).second;  
662  else  
663    return NULL;  
664 }
665
666 vector<GenericData*> SimInfo::getProperties(){
667
668  vector<GenericData*> result;
669  map<string, GenericData*>::iterator i;
670  
671  for(i = properties.begin(); i != properties.end(); i++)
672    result.push_back((*i).second);
673    
674  return result;
675 }
676
668   double SimInfo::matTrace3(double m[3][3]){
669    double trace;
670    trace = m[0][0] + m[1][1] + m[2][2];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines