@@ -122,7 +122,7 @@ unsigned QuaternionBondProductMatrix::getNumberOfDerivatives() {
122
122
}
123
123
124
124
unsigned QuaternionBondProductMatrix::getNumberOfColumns () const {
125
- const ActionWithMatrix* am=dynamic_cast <const ActionWithMatrix*>( getPntrToArgument (4 )->getPntrToAction () ); plumed_assert ( am );
125
+ const ActionWithMatrix* am=dynamic_cast <const ActionWithMatrix*>( getPntrToArgument (4 )->getPntrToAction () ); plumed_assert ( am );
126
126
if ( getPntrToArgument (4 )->isSymmetric () && am->getNumberOfColumns ()==getPntrToArgument (4 )->getShape ()[1 ]-1 ) return am->getNumberOfColumns () + 1 ;
127
127
return am->getNumberOfColumns ();
128
128
}
@@ -245,15 +245,15 @@ void QuaternionBondProductMatrix::performTask( const std::string& controller, co
245
245
}
246
246
// had to split because bond's derivatives depend on the value of the overall quaternion component
247
247
if ( !doNotCalculateDerivatives () ) {
248
- unsigned ostrn = getConstPntrToComponent (0 )->getPositionInStream ();
249
- for (unsigned i=0 ; i<4 ; ++i) {
250
- tempDot=dotProduct (Vector4d (quat[0 ],-quat[1 ],-quat[2 ],-quat[3 ]), dqt[1 ].getCol (i))*normFac;
251
- if ( i>0 ) {
252
- plumed_assert ( !stored[4 +i] ); unsigned find = getPntrToArgument (4 +i)->getIndexInStore ( index1*getPntrToArgument (4 +i)->getShape ()[1 ] + ind2 );
253
- myvals.addDerivative ( ostrn, base + find, tempDot ); myvals.updateIndex ( ostrn, base + find );
254
- }
255
- base += getPntrToArgument (4 +i)->getNumberOfStoredValues ();
248
+ unsigned ostrn = getConstPntrToComponent (0 )->getPositionInStream ();
249
+ for (unsigned i=0 ; i<4 ; ++i) {
250
+ tempDot=dotProduct (Vector4d (quat[0 ],-quat[1 ],-quat[2 ],-quat[3 ]), dqt[1 ].getCol (i))*normFac;
251
+ if ( i>0 ) {
252
+ plumed_assert ( !stored[4 +i] ); unsigned find = getPntrToArgument (4 +i)->getIndexInStore ( index1*getPntrToArgument (4 +i)->getShape ()[1 ] + ind2 );
253
+ myvals.addDerivative ( ostrn, base + find, tempDot ); myvals.updateIndex ( ostrn, base + find );
256
254
}
255
+ base += getPntrToArgument (4 +i)->getNumberOfStoredValues ();
256
+ }
257
257
}
258
258
259
259
// i component
@@ -269,19 +269,19 @@ void QuaternionBondProductMatrix::performTask( const std::string& controller, co
269
269
if ( doNotCalculateDerivatives () ) continue ;
270
270
tempDot=(dotProduct (Vector4d (quat[1 ],quat[0 ],quat[3 ],-quat[2 ]), dqt[0 ].getCol (i)) + pref2*quatTemp[(5 -i)%4 ])*normFac;
271
271
addDerivativeOnVectorArgument ( stored[i], 1 , i, index1, tempDot, myvals);
272
- base += getPntrToArgument (i)->getNumberOfStoredValues ();
272
+ base += getPntrToArgument (i)->getNumberOfStoredValues ();
273
273
}
274
274
275
- if ( !doNotCalculateDerivatives () ) {
276
- unsigned ostrn = getConstPntrToComponent (1 )->getPositionInStream ();
277
- for (unsigned i=0 ; i<4 ; ++i) {
278
- tempDot=dotProduct (Vector4d (quat[1 ],quat[0 ],quat[3 ],-quat[2 ]), dqt[1 ].getCol (i))*normFac;
279
- if ( i>0 ) {
280
- plumed_assert ( !stored[4 +i] ); unsigned find = getPntrToArgument (4 +i)->getIndexInStore ( index1*getPntrToArgument (4 +i)->getShape ()[1 ] + ind2 );
281
- myvals.addDerivative ( ostrn, base + find, tempDot+(-bond[i]*normFac*normFac*xf) ); myvals.updateIndex ( ostrn, base + find );
282
- }
283
- base += getPntrToArgument (4 +i)->getNumberOfStoredValues ();
275
+ if ( !doNotCalculateDerivatives () ) {
276
+ unsigned ostrn = getConstPntrToComponent (1 )->getPositionInStream ();
277
+ for (unsigned i=0 ; i<4 ; ++i) {
278
+ tempDot=dotProduct (Vector4d (quat[1 ],quat[0 ],quat[3 ],-quat[2 ]), dqt[1 ].getCol (i))*normFac;
279
+ if ( i>0 ) {
280
+ plumed_assert ( !stored[4 +i] ); unsigned find = getPntrToArgument (4 +i)->getIndexInStore ( index1*getPntrToArgument (4 +i)->getShape ()[1 ] + ind2 );
281
+ myvals.addDerivative ( ostrn, base + find, tempDot+(-bond[i]*normFac*normFac*xf) ); myvals.updateIndex ( ostrn, base + find );
284
282
}
283
+ base += getPntrToArgument (4 +i)->getNumberOfStoredValues ();
284
+ }
285
285
}
286
286
287
287
@@ -303,15 +303,15 @@ void QuaternionBondProductMatrix::performTask( const std::string& controller, co
303
303
}
304
304
305
305
if ( !doNotCalculateDerivatives () ) {
306
- unsigned ostrn = getConstPntrToComponent (2 )->getPositionInStream ();
307
- for (unsigned i=0 ; i<4 ; ++i) {
308
- tempDot=dotProduct (Vector4d (quat[2 ],-quat[3 ],quat[0 ],quat[1 ]), dqt[1 ].getCol (i))*normFac;
309
- if ( i>0 ) {
310
- plumed_assert ( !stored[4 +i] ); unsigned find = getPntrToArgument (4 +i)->getIndexInStore ( index1*getPntrToArgument (4 +i)->getShape ()[1 ] + ind2 );
311
- myvals.addDerivative ( ostrn, base + find, tempDot+(-bond[i]*normFac*normFac*yf) ); myvals.updateIndex ( ostrn, base + find );
312
- }
313
- base += getPntrToArgument (4 +i)->getNumberOfStoredValues ();
306
+ unsigned ostrn = getConstPntrToComponent (2 )->getPositionInStream ();
307
+ for (unsigned i=0 ; i<4 ; ++i) {
308
+ tempDot=dotProduct (Vector4d (quat[2 ],-quat[3 ],quat[0 ],quat[1 ]), dqt[1 ].getCol (i))*normFac;
309
+ if ( i>0 ) {
310
+ plumed_assert ( !stored[4 +i] ); unsigned find = getPntrToArgument (4 +i)->getIndexInStore ( index1*getPntrToArgument (4 +i)->getShape ()[1 ] + ind2 );
311
+ myvals.addDerivative ( ostrn, base + find, tempDot+(-bond[i]*normFac*normFac*yf) ); myvals.updateIndex ( ostrn, base + find );
314
312
}
313
+ base += getPntrToArgument (4 +i)->getNumberOfStoredValues ();
314
+ }
315
315
}
316
316
317
317
// k component
@@ -337,8 +337,8 @@ void QuaternionBondProductMatrix::performTask( const std::string& controller, co
337
337
for (unsigned i=0 ; i<4 ; ++i) {
338
338
tempDot=dotProduct (Vector4d (quat[3 ],quat[2 ],-quat[1 ],quat[0 ]), dqt[1 ].getCol (i))*normFac;
339
339
if ( i>0 ) {
340
- plumed_assert ( !stored[4 +i] ); unsigned find = getPntrToArgument (4 +i)->getIndexInStore ( index1*getPntrToArgument (4 +i)->getShape ()[1 ] + ind2 );
341
- myvals.addDerivative ( ostrn, base + find, tempDot+(-bond[i]*normFac*normFac*zf) ); myvals.updateIndex ( ostrn, base + find );
340
+ plumed_assert ( !stored[4 +i] ); unsigned find = getPntrToArgument (4 +i)->getIndexInStore ( index1*getPntrToArgument (4 +i)->getShape ()[1 ] + ind2 );
341
+ myvals.addDerivative ( ostrn, base + find, tempDot+(-bond[i]*normFac*normFac*zf) ); myvals.updateIndex ( ostrn, base + find );
342
342
}
343
343
base += getPntrToArgument (4 +i)->getNumberOfStoredValues ();
344
344
}
0 commit comments