# | Line 1 | Line 1 | |
---|---|---|
1 | < | /* |
1 | > | /* |
2 | * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. | |
3 | * | |
4 | * The University of Notre Dame grants you ("Licensee") a | |
# | Line 39 | Line 39 | |
39 | * such damages. | |
40 | */ | |
41 | ||
42 | < | /** |
43 | < | * @file Snapshot.cpp |
44 | < | * @author tlin |
45 | < | * @date 11/11/2004 |
46 | < | * @time 10:56am |
47 | < | * @version 1.0 |
48 | < | */ |
42 | > | /** |
43 | > | * @file Snapshot.cpp |
44 | > | * @author tlin |
45 | > | * @date 11/11/2004 |
46 | > | * @time 10:56am |
47 | > | * @version 1.0 |
48 | > | */ |
49 | ||
50 | #include "brains/Snapshot.hpp" | |
51 | #include "utils/NumericConstant.hpp" | |
# | Line 53 | Line 53 | namespace oopse { | |
53 | #include "utils/Utility.hpp" | |
54 | namespace oopse { | |
55 | ||
56 | < | void Snapshot::setHmat(const Mat3x3d& m) { |
56 | > | void Snapshot::setHmat(const Mat3x3d& m) { |
57 | const double orthoTolerance = NumericConstant::epsilon; | |
58 | hmat_ = m; | |
59 | invHmat_ = hmat_.inverse(); | |
# | Line 75 | Line 75 | void Snapshot::setHmat(const Mat3x3d& m) { | |
75 | orthoRhombic_ = 1; | |
76 | ||
77 | for (int i = 0; i < 3; i++ ) { | |
78 | < | for (int j = 0 ; j < 3; j++) { |
79 | < | if (i != j) { |
80 | < | if (orthoRhombic_) { |
81 | < | if ( fabs(hmat_(i, j)) >= tol) |
82 | < | orthoRhombic_ = 0; |
83 | < | } |
84 | < | } |
85 | < | } |
78 | > | for (int j = 0 ; j < 3; j++) { |
79 | > | if (i != j) { |
80 | > | if (orthoRhombic_) { |
81 | > | if ( fabs(hmat_(i, j)) >= tol) |
82 | > | orthoRhombic_ = 0; |
83 | > | } |
84 | > | } |
85 | > | } |
86 | } | |
87 | ||
88 | if( oldOrthoRhombic != orthoRhombic_ ){ | |
89 | ||
90 | < | if( orthoRhombic_ ) { |
91 | < | sprintf( painCave.errMsg, |
92 | < | "OOPSE is switching from the default Non-Orthorhombic\n" |
93 | < | "\tto the faster Orthorhombic periodic boundary computations.\n" |
94 | < | "\tThis is usually a good thing, but if you wan't the\n" |
95 | < | "\tNon-Orthorhombic computations, make the orthoBoxTolerance\n" |
96 | < | "\tvariable ( currently set to %G ) smaller.\n", |
97 | < | orthoTolerance); |
98 | < | painCave.severity = OOPSE_INFO; |
99 | < | simError(); |
100 | < | } |
101 | < | else { |
102 | < | sprintf( painCave.errMsg, |
103 | < | "OOPSE is switching from the faster Orthorhombic to the more\n" |
104 | < | "\tflexible Non-Orthorhombic periodic boundary computations.\n" |
105 | < | "\tThis is usually because the box has deformed under\n" |
106 | < | "\tNPTf integration. If you wan't to live on the edge with\n" |
107 | < | "\tthe Orthorhombic computations, make the orthoBoxTolerance\n" |
108 | < | "\tvariable ( currently set to %G ) larger.\n", |
109 | < | orthoTolerance); |
110 | < | painCave.severity = OOPSE_WARNING; |
111 | < | simError(); |
112 | < | } |
90 | > | if( orthoRhombic_ ) { |
91 | > | sprintf( painCave.errMsg, |
92 | > | "OOPSE is switching from the default Non-Orthorhombic\n" |
93 | > | "\tto the faster Orthorhombic periodic boundary computations.\n" |
94 | > | "\tThis is usually a good thing, but if you wan't the\n" |
95 | > | "\tNon-Orthorhombic computations, make the orthoBoxTolerance\n" |
96 | > | "\tvariable ( currently set to %G ) smaller.\n", |
97 | > | orthoTolerance); |
98 | > | painCave.severity = OOPSE_INFO; |
99 | > | simError(); |
100 | > | } |
101 | > | else { |
102 | > | sprintf( painCave.errMsg, |
103 | > | "OOPSE is switching from the faster Orthorhombic to the more\n" |
104 | > | "\tflexible Non-Orthorhombic periodic boundary computations.\n" |
105 | > | "\tThis is usually because the box has deformed under\n" |
106 | > | "\tNPTf integration. If you wan't to live on the edge with\n" |
107 | > | "\tthe Orthorhombic computations, make the orthoBoxTolerance\n" |
108 | > | "\tvariable ( currently set to %G ) larger.\n", |
109 | > | orthoTolerance); |
110 | > | painCave.severity = OOPSE_WARNING; |
111 | > | simError(); |
112 | > | } |
113 | } | |
114 | ||
115 | //notify fortran simulation box has changed | |
116 | setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_); | |
117 | < | } |
117 | > | } |
118 | ||
119 | ||
120 | < | void Snapshot::wrapVector(Vector3d& pos) { |
120 | > | void Snapshot::wrapVector(Vector3d& pos) { |
121 | ||
122 | int i; | |
123 | Vector3d scaled; | |
124 | ||
125 | if( !orthoRhombic_ ){ | |
126 | ||
127 | < | // calc the scaled coordinates. |
128 | < | scaled = invHmat_* pos; |
127 | > | // calc the scaled coordinates. |
128 | > | scaled = invHmat_* pos; |
129 | ||
130 | < | // wrap the scaled coordinates |
131 | < | for (i = 0; i < 3; ++i) { |
132 | < | scaled[i] -= roundMe(scaled[i]); |
133 | < | } |
130 | > | // wrap the scaled coordinates |
131 | > | for (i = 0; i < 3; ++i) { |
132 | > | scaled[i] -= roundMe(scaled[i]); |
133 | > | } |
134 | ||
135 | < | // calc the wrapped real coordinates from the wrapped scaled coordinates |
136 | < | pos = hmat_ * scaled; |
135 | > | // calc the wrapped real coordinates from the wrapped scaled coordinates |
136 | > | pos = hmat_ * scaled; |
137 | ||
138 | } else {//if it is orthoRhombic, we could improve efficiency by only caculating the diagonal element | |
139 | ||
140 | < | // calc the scaled coordinates. |
141 | < | for (i=0; i<3; i++) { |
142 | < | scaled[i] = pos[i] * invHmat_(i, i); |
143 | < | } |
140 | > | // calc the scaled coordinates. |
141 | > | for (i=0; i<3; i++) { |
142 | > | scaled[i] = pos[i] * invHmat_(i, i); |
143 | > | } |
144 | ||
145 | < | // wrap the scaled coordinates |
146 | < | for (i = 0; i < 3; ++i) { |
147 | < | scaled[i] -= roundMe(scaled[i]); |
148 | < | } |
145 | > | // wrap the scaled coordinates |
146 | > | for (i = 0; i < 3; ++i) { |
147 | > | scaled[i] -= roundMe(scaled[i]); |
148 | > | } |
149 | ||
150 | < | // calc the wrapped real coordinates from the wrapped scaled coordinates |
151 | < | for (i=0; i<3; i++) { |
152 | < | pos[i] = scaled[i] * hmat_(i, i); |
153 | < | } |
150 | > | // calc the wrapped real coordinates from the wrapped scaled coordinates |
151 | > | for (i=0; i<3; i++) { |
152 | > | pos[i] = scaled[i] * hmat_(i, i); |
153 | > | } |
154 | ||
155 | } | |
156 | ||
157 | < | } |
157 | > | } |
158 | ||
159 | } | |
160 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |