6 |
|
* redistribute this software in source and binary code form, provided |
7 |
|
* that the following conditions are met: |
8 |
|
* |
9 |
< |
* 1. Acknowledgement of the program authors must be made in any |
10 |
< |
* publication of scientific results based in part on use of the |
11 |
< |
* program. An acceptable form of acknowledgement is citation of |
12 |
< |
* the article in which the program was described (Matthew |
13 |
< |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
< |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
< |
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
< |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
< |
* |
18 |
< |
* 2. Redistributions of source code must retain the above copyright |
9 |
> |
* 1. Redistributions of source code must retain the above copyright |
10 |
|
* notice, this list of conditions and the following disclaimer. |
11 |
|
* |
12 |
< |
* 3. Redistributions in binary form must reproduce the above copyright |
12 |
> |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
|
* notice, this list of conditions and the following disclaimer in the |
14 |
|
* documentation and/or other materials provided with the |
15 |
|
* distribution. |
28 |
|
* arising out of the use of or inability to use software, even if the |
29 |
|
* University of Notre Dame has been advised of the possibility of |
30 |
|
* such damages. |
31 |
+ |
* |
32 |
+ |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
+ |
* research, please cite the appropriate papers when you publish your |
34 |
+ |
* work. Good starting points are: |
35 |
+ |
* |
36 |
+ |
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
+ |
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
+ |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
+ |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
40 |
+ |
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
|
*/ |
42 |
|
|
43 |
|
/** |
52 |
|
#include "utils/NumericConstant.hpp" |
53 |
|
#include "utils/simError.h" |
54 |
|
#include "utils/Utility.hpp" |
55 |
< |
namespace oopse { |
55 |
> |
#include <cstdio> |
56 |
|
|
57 |
+ |
namespace OpenMD { |
58 |
+ |
|
59 |
|
void Snapshot::setHmat(const Mat3x3d& m) { |
57 |
– |
const double orthoTolerance = NumericConstant::epsilon; |
60 |
|
hmat_ = m; |
61 |
|
invHmat_ = hmat_.inverse(); |
62 |
|
|
63 |
|
//prepare fortran Hmat |
64 |
< |
double fortranHmat[9]; |
65 |
< |
double fortranInvHmat[9]; |
64 |
> |
RealType fortranHmat[9]; |
65 |
> |
RealType fortranInvHmat[9]; |
66 |
|
hmat_.getArray(fortranHmat); |
67 |
|
invHmat_.getArray(fortranInvHmat); |
68 |
|
|
69 |
|
//determine whether the box is orthoTolerance or not |
70 |
|
int oldOrthoRhombic = orthoRhombic_; |
71 |
|
|
72 |
< |
double smallDiag = fabs(hmat_(0, 0)); |
72 |
> |
RealType smallDiag = fabs(hmat_(0, 0)); |
73 |
|
if(smallDiag > fabs(hmat_(1, 1))) smallDiag = fabs(hmat_(1, 1)); |
74 |
|
if(smallDiag > fabs(hmat_(2, 2))) smallDiag = fabs(hmat_(2, 2)); |
75 |
< |
double tol = smallDiag * orthoTolerance; |
75 |
> |
RealType tol = smallDiag * orthoTolerance_; |
76 |
|
|
77 |
|
orthoRhombic_ = 1; |
78 |
|
|
91 |
|
|
92 |
|
if( orthoRhombic_ ) { |
93 |
|
sprintf( painCave.errMsg, |
94 |
< |
"OOPSE is switching from the default Non-Orthorhombic\n" |
94 |
> |
"OpenMD is switching from the default Non-Orthorhombic\n" |
95 |
|
"\tto the faster Orthorhombic periodic boundary computations.\n" |
96 |
|
"\tThis is usually a good thing, but if you want the\n" |
97 |
|
"\tNon-Orthorhombic computations, make the orthoBoxTolerance\n" |
98 |
|
"\tvariable ( currently set to %G ) smaller.\n", |
99 |
< |
orthoTolerance); |
100 |
< |
painCave.severity = OOPSE_INFO; |
99 |
> |
orthoTolerance_); |
100 |
> |
painCave.severity = OPENMD_INFO; |
101 |
|
simError(); |
102 |
|
} |
103 |
|
else { |
104 |
|
sprintf( painCave.errMsg, |
105 |
< |
"OOPSE is switching from the faster Orthorhombic to the more\n" |
105 |
> |
"OpenMD is switching from the faster Orthorhombic to the more\n" |
106 |
|
"\tflexible Non-Orthorhombic periodic boundary computations.\n" |
107 |
|
"\tThis is usually because the box has deformed under\n" |
108 |
|
"\tNPTf integration. If you want to live on the edge with\n" |
109 |
|
"\tthe Orthorhombic computations, make the orthoBoxTolerance\n" |
110 |
|
"\tvariable ( currently set to %G ) larger.\n", |
111 |
< |
orthoTolerance); |
112 |
< |
painCave.severity = OOPSE_WARNING; |
111 |
> |
orthoTolerance_); |
112 |
> |
painCave.severity = OPENMD_WARNING; |
113 |
|
simError(); |
114 |
|
} |
115 |
|
} |
116 |
|
|
117 |
|
//notify fortran simulation box has changed |
118 |
< |
setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_); |
118 |
> |
// setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_); |
119 |
|
} |
120 |
|
|
121 |
|
|
122 |
|
void Snapshot::wrapVector(Vector3d& pos) { |
123 |
+ |
|
124 |
+ |
Vector3d scaled = scaleVector(pos); |
125 |
+ |
|
126 |
+ |
for (int i = 0; i < 3; i++) |
127 |
+ |
scaled[i] -= roundMe(scaled[i]); |
128 |
|
|
129 |
< |
int i; |
130 |
< |
Vector3d scaled; |
129 |
> |
if( !orthoRhombic_ ) |
130 |
> |
pos = hmat_ * scaled; |
131 |
> |
else { |
132 |
|
|
125 |
– |
if( !orthoRhombic_ ){ |
126 |
– |
|
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 |
– |
} |
134 |
– |
|
133 |
|
// calc the wrapped real coordinates from the wrapped scaled coordinates |
134 |
< |
pos = hmat_ * scaled; |
134 |
> |
for (int i=0; i<3; i++) { |
135 |
> |
pos[i] = scaled[i] * hmat_(i, i); |
136 |
> |
} |
137 |
> |
} |
138 |
> |
} |
139 |
|
|
140 |
< |
} else {//if it is orthoRhombic, we could improve efficiency by only caculating the diagonal element |
140 |
> |
inline Vector3d Snapshot::scaleVector(Vector3d& pos) { |
141 |
|
|
142 |
< |
// 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 |
< |
} |
142 |
> |
Vector3d scaled; |
143 |
|
|
144 |
< |
// calc the wrapped real coordinates from the wrapped scaled coordinates |
145 |
< |
for (i=0; i<3; i++) { |
146 |
< |
pos[i] = scaled[i] * hmat_(i, i); |
147 |
< |
} |
148 |
< |
|
144 |
> |
if( !orthoRhombic_ ) |
145 |
> |
scaled = invHmat_* pos; |
146 |
> |
else { |
147 |
> |
// calc the scaled coordinates. |
148 |
> |
for (int i=0; i<3; i++) |
149 |
> |
scaled[i] = pos[i] * invHmat_(i, i); |
150 |
|
} |
151 |
|
|
152 |
+ |
return scaled; |
153 |
|
} |
154 |
< |
|
154 |
> |
|
155 |
> |
Vector3d Snapshot::getCOM() { |
156 |
> |
if( !hasCOM_ ) { |
157 |
> |
sprintf( painCave.errMsg, "COM was requested before COM was computed!\n"); |
158 |
> |
painCave.severity = OPENMD_ERROR; |
159 |
> |
simError(); |
160 |
> |
} |
161 |
> |
return COM_; |
162 |
> |
} |
163 |
> |
|
164 |
> |
Vector3d Snapshot::getCOMvel() { |
165 |
> |
if( !hasCOM_ ) { |
166 |
> |
sprintf( painCave.errMsg, "COMvel was requested before COM was computed!\n"); |
167 |
> |
painCave.severity = OPENMD_ERROR; |
168 |
> |
simError(); |
169 |
> |
} |
170 |
> |
return COMvel_; |
171 |
> |
} |
172 |
> |
|
173 |
> |
Vector3d Snapshot::getCOMw() { |
174 |
> |
if( !hasCOM_ ) { |
175 |
> |
sprintf( painCave.errMsg, "COMw was requested before COM was computed!\n"); |
176 |
> |
painCave.severity = OPENMD_ERROR; |
177 |
> |
simError(); |
178 |
> |
} |
179 |
> |
return COMw_; |
180 |
> |
} |
181 |
|
} |
182 |
|
|