32 |
|
*/ |
33 |
|
|
34 |
|
#include "brains/Snapshot.hpp" |
35 |
+ |
#include "utils/NumericConstant.hpp" |
36 |
+ |
#include "utils/simError.h" |
37 |
|
#include "utils/Utility.hpp" |
36 |
– |
|
38 |
|
namespace oopse { |
39 |
|
|
40 |
+ |
void Snapshot::setHmat(const Mat3x3d& m) { |
41 |
+ |
const double orthoTolerance = NumericConstant::epsilon; |
42 |
+ |
hmat_ = m; |
43 |
+ |
invHmat_ = hmat_.inverse(); |
44 |
+ |
|
45 |
+ |
//prepare fortran Hmat |
46 |
+ |
double fortranHmat[9]; |
47 |
+ |
double fortranInvHmat[9]; |
48 |
+ |
hmat_.getArray(fortranHmat); |
49 |
+ |
invHmat_.getArray(fortranInvHmat); |
50 |
+ |
|
51 |
+ |
//determine whether the box is orthoTolerance or not |
52 |
+ |
int oldOrthoRhombic = orthoRhombic_; |
53 |
+ |
|
54 |
+ |
double smallDiag = fabs(hmat_(0, 0)); |
55 |
+ |
if(smallDiag > fabs(hmat_(1, 1))) smallDiag = fabs(hmat_(1, 1)); |
56 |
+ |
if(smallDiag > fabs(hmat_(2, 2))) smallDiag = fabs(hmat_(2, 2)); |
57 |
+ |
double tol = smallDiag * orthoTolerance; |
58 |
+ |
|
59 |
+ |
orthoRhombic_ = 1; |
60 |
+ |
|
61 |
+ |
for (int i = 0; i < 3; i++ ) { |
62 |
+ |
for (int j = 0 ; j < 3; j++) { |
63 |
+ |
if (i != j) { |
64 |
+ |
if (orthoRhombic_) { |
65 |
+ |
if ( fabs(hmat_(i, j)) >= tol) |
66 |
+ |
orthoRhombic_ = 0; |
67 |
+ |
} |
68 |
+ |
} |
69 |
+ |
} |
70 |
+ |
} |
71 |
+ |
|
72 |
+ |
if( oldOrthoRhombic != orthoRhombic_ ){ |
73 |
+ |
|
74 |
+ |
if( orthoRhombic_ ) { |
75 |
+ |
sprintf( painCave.errMsg, |
76 |
+ |
"OOPSE is switching from the default Non-Orthorhombic\n" |
77 |
+ |
"\tto the faster Orthorhombic periodic boundary computations.\n" |
78 |
+ |
"\tThis is usually a good thing, but if you wan't the\n" |
79 |
+ |
"\tNon-Orthorhombic computations, make the orthoBoxTolerance\n" |
80 |
+ |
"\tvariable ( currently set to %G ) smaller.\n", |
81 |
+ |
orthoTolerance); |
82 |
+ |
painCave.severity = OOPSE_INFO; |
83 |
+ |
simError(); |
84 |
+ |
} |
85 |
+ |
else { |
86 |
+ |
sprintf( painCave.errMsg, |
87 |
+ |
"OOPSE is switching from the faster Orthorhombic to the more\n" |
88 |
+ |
"\tflexible Non-Orthorhombic periodic boundary computations.\n" |
89 |
+ |
"\tThis is usually because the box has deformed under\n" |
90 |
+ |
"\tNPTf integration. If you wan't to live on the edge with\n" |
91 |
+ |
"\tthe Orthorhombic computations, make the orthoBoxTolerance\n" |
92 |
+ |
"\tvariable ( currently set to %G ) larger.\n", |
93 |
+ |
orthoTolerance); |
94 |
+ |
painCave.severity = OOPSE_WARNING; |
95 |
+ |
simError(); |
96 |
+ |
} |
97 |
+ |
} |
98 |
+ |
|
99 |
+ |
//notify fortran simulation box has changed |
100 |
+ |
setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_); |
101 |
+ |
} |
102 |
+ |
|
103 |
+ |
|
104 |
|
void Snapshot::wrapVector(Vector3d& pos) { |
105 |
|
|
106 |
|
int i; |