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]) { |
142 |
|
} |
143 |
|
|
144 |
|
void SimInfo::calcHmatInv( void ) { |
145 |
< |
|
145 |
> |
|
146 |
> |
int oldOrtho; |
147 |
|
int i,j; |
148 |
|
double smallDiag; |
149 |
|
double tol; |
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; |
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]) { |
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 ){ |
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 ){ |
644 |
|
( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; |
645 |
|
|
646 |
|
if( cutChanged ){ |
622 |
– |
|
647 |
|
notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); |
648 |
|
} |
649 |
|
|
660 |
|
|
661 |
|
} |
662 |
|
|
663 |
< |
void SimInfo::addProperty(GenericData* prop){ |
663 |
> |
GenericData* SimInfo::getProperty(char* propName){ |
664 |
|
|
665 |
< |
map<string, GenericData*>::iterator result; |
642 |
< |
result = properties.find(prop->getID()); |
643 |
< |
|
644 |
< |
//we can't simply use properties[prop->getID()] = prop, |
645 |
< |
//it will cause memory leak if we already contain a propery which has the same name of prop |
646 |
< |
|
647 |
< |
if(result != properties.end()){ |
648 |
< |
|
649 |
< |
delete (*result).second; |
650 |
< |
(*result).second = prop; |
651 |
< |
|
652 |
< |
} |
653 |
< |
else{ |
654 |
< |
|
655 |
< |
properties[prop->getID()] = prop; |
656 |
< |
|
657 |
< |
} |
658 |
< |
|
665 |
> |
return properties->find( propName ); |
666 |
|
} |
667 |
|
|
661 |
– |
GenericData* SimInfo::getProperty(const string& propName){ |
662 |
– |
|
663 |
– |
map<string, GenericData*>::iterator result; |
664 |
– |
|
665 |
– |
//string lowerCaseName = (); |
666 |
– |
|
667 |
– |
result = properties.find(propName); |
668 |
– |
|
669 |
– |
if(result != properties.end()) |
670 |
– |
return (*result).second; |
671 |
– |
else |
672 |
– |
return NULL; |
673 |
– |
} |
674 |
– |
|
675 |
– |
vector<GenericData*> SimInfo::getProperties(){ |
676 |
– |
|
677 |
– |
vector<GenericData*> result; |
678 |
– |
map<string, GenericData*>::iterator i; |
679 |
– |
|
680 |
– |
for(i = properties.begin(); i != properties.end(); i++) |
681 |
– |
result.push_back((*i).second); |
682 |
– |
|
683 |
– |
return result; |
684 |
– |
} |
685 |
– |
|
668 |
|
double SimInfo::matTrace3(double m[3][3]){ |
669 |
|
double trace; |
670 |
|
trace = m[0][0] + m[1][1] + m[2][2]; |