| 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] Vardeman & Gezelter, in progress (2009). |
| 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 |
+ |
#include <cstdio> |
| 56 |
+ |
|
| 57 |
|
namespace OpenMD { |
| 58 |
|
|
| 59 |
|
void Snapshot::setHmat(const Mat3x3d& m) { |
| 60 |
|
hmat_ = m; |
| 61 |
|
invHmat_ = hmat_.inverse(); |
| 62 |
|
|
| 60 |
– |
|
| 63 |
|
//prepare fortran Hmat |
| 64 |
|
RealType fortranHmat[9]; |
| 65 |
|
RealType fortranInvHmat[9]; |
| 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"); |
| 178 |
|
} |
| 179 |
|
return COMw_; |
| 180 |
|
} |
| 185 |
– |
|
| 181 |
|
} |
| 182 |
|
|