72 void ComputeStir::initVars () {
77 Tensor rotXMat, invRotXMat, rotYMat, invRotYMat;
83 const int globalNumAtoms = molecule->
numAtoms;
91 startingTheta = ( (
simParams->stirStartingTheta) / 360) * (2 *
PI);
96 a = axisUnit.
x; b = axisUnit.
y; c = axisUnit.
z;
97 d = sqrt( (b * b) + (c * c) );
100 testA.
xx = 1.1; testA.
xy = 3; testA.
xz = 3;
108 rotXMat.
xx = 1; rotXMat.
xy = 0; rotXMat.
xz = 0;
109 rotXMat.
yx = 0; rotXMat.
yy = c/d; rotXMat.
yz = -b/d;
110 rotXMat.
zx = 0; rotXMat.
zy = b/d; rotXMat.
zz = c/d;
113 invRotXMat.
xx = 1; invRotXMat.
xy = 0; invRotXMat.
xz = 0;
114 invRotXMat.
yx = 0; invRotXMat.
yy = c/d; invRotXMat.
yz = b/d;
115 invRotXMat.
zx = 0; invRotXMat.
zy = -b/d; invRotXMat.
zz = c/d;
118 rotYMat.
xx = d; rotYMat.
xy = 0; rotYMat.
xz = -a;
119 rotYMat.
yx = 0; rotYMat.
yy = 1; rotYMat.
yz = 0;
120 rotYMat.
zx = a; rotYMat.
zy = 0; rotYMat.
zz = d;
123 invRotYMat.
xx = d; invRotYMat.
xy = 0; invRotYMat.
xz = a;
124 invRotYMat.
yx = 0; invRotYMat.
yy = 1; invRotYMat.
yz = 0;
125 invRotYMat.
zx =-a; invRotYMat.
zy = 0; invRotYMat.
zz = d;
135 temp = matMult (invRotYMat, rotYMat);
139 temp = matMult (invRotXMat, rotXMat);
148 leftMat = matMult (invRotXMat, invRotYMat);
151 rightMat = matMult ( rotYMat, rotXMat) ;
163 temp = matMult (leftMat,rightMat);
167 temp = arbRotMat (0.34);
173 for (
int i=0; i<globalNumAtoms; i++) {
195 Vector aligned_pos = rightMat * (pos - pivot);
197 if ( ! ((aligned_pos.
x == 0 ) && (aligned_pos.
y == 0) )) {
200 theta = atan (aligned_pos.
y/aligned_pos.
x);
201 if (aligned_pos.
x < 0) {
219 rotZMat.
xx = cos (theta) ; rotZMat.
xy = -sin (theta); rotZMat.
xz = 0;
220 rotZMat.
yx = sin (theta); rotZMat.
yy = cos(theta); rotZMat.
yz = 0;
221 rotZMat.
zx = 0; rotZMat.
zy = 0; rotZMat.
zz = 1;
225 temp =matMult (rotZMat, rightMat);
228 temp = matMult (leftMat,rightMat);
232 temp = matMult (leftMat, (matMult (rotZMat, rightMat) ) ) ;
239 return matMult (leftMat, (matMult (rotZMat, rightMat) ) );
242 void ComputeStir::printTensor (
Tensor &t) {
244 iout <<
"DEBUG: Tensor =" <<
"\n" <<
endi;
245 iout <<
"DEBUG: " << t.
xx <<
" " <<t.
xy <<
" " << t.
xz << \
246 "\nDEBUG: " << t.
yx <<
" " << t.
yy <<
" " << t.
yz << \
247 "\nDEBUG: " << t.
zx <<
" " << t.
zy <<
" " <<t.
zz <<
"\n" <<
endi;
251 return (x - projectionOnRay(dir, origin,x)).length();
256 Vector pos =rightMat * (x - pivot);
262 return origin + ( ( ((x - origin ).dot(dir) )/ \
271 rotZMat.
xx = cos (theta) ; rotZMat.
xy = -sin (theta); rotZMat.
xz = 0;
272 rotZMat.
yx = sin (theta); rotZMat.
yy = cos(theta); rotZMat.
yz = 0;
273 rotZMat.
zx = 0; rotZMat.
zy = 0; rotZMat.
zz = 1;
278 a.
x = radius; a.
y =0; a.
z = height;
283 a = (matMult(leftMat, rotZMat) * a) +pivot;
300 BigReal rayDist, height,targTheta,forceMag;
328 rayDist = distanceToRay(axisUnit,pivot,curPos);
329 proj = projectionOnRay (axisUnit,pivot,curPos);
330 height = findHeight (proj);
331 targTheta = (omega * currentStep) + \
335 targPos = placeThetaRadius (targTheta,height,rayDist);
340 forceDir = (cross(axisUnit, (curPos - proj))).unit();
341 forceMag = forceDir.
dot(targPos - curPos);
345 theForce = (
simParams->stirK) * forceMag * forceDir;
347 forces[i] += theForce;
348 extForce += theForce;
349 extVirial +=
outer(theForce,curPos);
353 sprintf (statbuf,
"DEBUG: step= %d atom i= %d globID= %d T= %g %g %g C= %g %g %g F= %g %g %g startTheta= %g targTheta= %g forceMag= %g F.len= %g FC.len= %g\n",currentStep,i,p[i].
id, targPos.
x, targPos.
y, targPos.
z, curPos.
x, curPos.
y, curPos.
z,theForce.
x, theForce.
y, theForce.
z, molecule->
get_stir_startTheta (p[i].
id), targTheta, forceMag, theForce.
length(), forces[i].
length());
static CollectionMgr * Object()
NAMD_HOST_DEVICE Position reverse_transform(Position data, const Transform &t) const
NAMD_HOST_DEVICE Tensor outer(const Vector &v1, const Vector &v2)
#define ADD_TENSOR_OBJECT(R, RL, D)
SimParameters * simParameters
virtual void doForce(FullAtom *p, Results *r)
std::ostream & endi(std::ostream &s)
SubmitReduction * willSubmit(int setID, int size=-1)
SubmitReduction * reduction
static ReductionMgr * Object(void)
Molecule stores the structural information for the system.
Bool is_atom_stirred(int atomnum) const
NAMD_HOST_DEVICE BigReal length(void) const
ComputeStir(ComputeID c, PatchID pid)
void get_stir_refPos(Vector &refPos, int atomnum) const
void put_stir_startTheta(Real theta, int atomnum) const
#define ADD_VECTOR_OBJECT(R, RL, D)
NAMD_HOST_DEVICE BigReal dot(const Vector &v2) const
void sendDataStream(const char *)
Real get_stir_startTheta(int atomnum) const