59 |
|
hmat_ = m; |
60 |
|
invHmat_ = hmat_.inverse(); |
61 |
|
|
62 |
– |
|
62 |
|
//prepare fortran Hmat |
63 |
|
RealType fortranHmat[9]; |
64 |
|
RealType fortranInvHmat[9]; |
114 |
|
} |
115 |
|
|
116 |
|
//notify fortran simulation box has changed |
117 |
< |
setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_); |
117 |
> |
// setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_); |
118 |
|
} |
119 |
|
|
120 |
|
|
121 |
|
void Snapshot::wrapVector(Vector3d& pos) { |
122 |
+ |
|
123 |
+ |
Vector3d scaled = scaleVector(pos); |
124 |
+ |
|
125 |
+ |
for (int i = 0; i < 3; i++) |
126 |
+ |
scaled[i] -= roundMe(scaled[i]); |
127 |
|
|
128 |
< |
int i; |
129 |
< |
Vector3d scaled; |
128 |
> |
if( !orthoRhombic_ ) |
129 |
> |
pos = hmat_ * scaled; |
130 |
> |
else { |
131 |
|
|
127 |
– |
if( !orthoRhombic_ ){ |
128 |
– |
|
129 |
– |
// calc the scaled coordinates. |
130 |
– |
scaled = invHmat_* pos; |
131 |
– |
|
132 |
– |
// wrap the scaled coordinates |
133 |
– |
for (i = 0; i < 3; ++i) { |
134 |
– |
scaled[i] -= roundMe(scaled[i]); |
135 |
– |
} |
136 |
– |
|
132 |
|
// calc the wrapped real coordinates from the wrapped scaled coordinates |
133 |
< |
pos = hmat_ * scaled; |
133 |
> |
for (int i=0; i<3; i++) { |
134 |
> |
pos[i] = scaled[i] * hmat_(i, i); |
135 |
> |
} |
136 |
> |
} |
137 |
> |
} |
138 |
|
|
139 |
< |
} else {//if it is orthoRhombic, we could improve efficiency by only caculating the diagonal element |
139 |
> |
inline Vector3d Snapshot::scaleVector(Vector3d& pos) { |
140 |
|
|
141 |
< |
// calc the scaled coordinates. |
143 |
< |
for (i=0; i<3; i++) { |
144 |
< |
scaled[i] = pos[i] * invHmat_(i, i); |
145 |
< |
} |
146 |
< |
|
147 |
< |
// wrap the scaled coordinates |
148 |
< |
for (i = 0; i < 3; ++i) { |
149 |
< |
scaled[i] -= roundMe(scaled[i]); |
150 |
< |
} |
141 |
> |
Vector3d scaled; |
142 |
|
|
143 |
< |
// calc the wrapped real coordinates from the wrapped scaled coordinates |
144 |
< |
for (i=0; i<3; i++) { |
145 |
< |
pos[i] = scaled[i] * hmat_(i, i); |
146 |
< |
} |
147 |
< |
|
143 |
> |
if( !orthoRhombic_ ) |
144 |
> |
scaled = invHmat_* pos; |
145 |
> |
else { |
146 |
> |
// calc the scaled coordinates. |
147 |
> |
for (int i=0; i<3; i++) |
148 |
> |
scaled[i] = pos[i] * invHmat_(i, i); |
149 |
|
} |
150 |
|
|
151 |
+ |
return scaled; |
152 |
|
} |
153 |
< |
|
153 |
> |
|
154 |
|
Vector3d Snapshot::getCOM() { |
155 |
|
if( !hasCOM_ ) { |
156 |
|
sprintf( painCave.errMsg, "COM was requested before COM was computed!\n"); |
177 |
|
} |
178 |
|
return COMw_; |
179 |
|
} |
187 |
– |
|
180 |
|
} |
181 |
|
|