@@ -308,10 +308,12 @@ void AdjacencyMatrixBase::performTask( const std::string& controller, const unsi
308
308
// Update dynamic list indices for virial
309
309
unsigned base = 3 *getNumberOfAtoms (); for (unsigned j=0 ; j<9 ; ++j) myvals.updateIndex ( w_ind, base+j );
310
310
// And the indices for the derivatives of the row of the matrix
311
- unsigned nmat = getConstPntrToComponent (0 )->getPositionInMatrixStash (), nmat_ind = myvals.getNumberOfMatrixRowDerivatives ( nmat );
312
- std::vector<unsigned >& matrix_indices ( myvals.getMatrixRowDerivativeIndices ( nmat ) );
313
- matrix_indices[nmat_ind+0 ]=3 *index2+0 ; matrix_indices[nmat_ind+1 ]=3 *index2+1 ; matrix_indices[nmat_ind+2 ]=3 *index2+2 ;
314
- myvals.setNumberOfMatrixRowDerivatives ( nmat, nmat_ind+3 );
311
+ if ( chainContinuesAfterThisAction () ) {
312
+ unsigned nmat = getConstPntrToComponent (0 )->getPositionInMatrixStash (), nmat_ind = myvals.getNumberOfMatrixRowDerivatives ( nmat );
313
+ std::vector<unsigned >& matrix_indices ( myvals.getMatrixRowDerivativeIndices ( nmat ) );
314
+ matrix_indices[nmat_ind+0 ]=3 *index2+0 ; matrix_indices[nmat_ind+1 ]=3 *index2+1 ; matrix_indices[nmat_ind+2 ]=3 *index2+2 ;
315
+ myvals.setNumberOfMatrixRowDerivatives ( nmat, nmat_ind+3 );
316
+ }
315
317
}
316
318
317
319
// Calculate the components if we need them
@@ -352,18 +354,20 @@ void AdjacencyMatrixBase::performTask( const std::string& controller, const unsi
352
354
myvals.addDerivative ( z_index, base+1 , 0 ); myvals.addDerivative ( z_index, base+4 , 0 ); myvals.addDerivative ( z_index, base+7 , 0 );
353
355
myvals.addDerivative ( z_index, base+2 , -atom[0 ] ); myvals.addDerivative ( z_index, base+5 , -atom[1 ] ); myvals.addDerivative ( z_index, base+8 , -atom[2 ] );
354
356
for (unsigned k=0 ; k<9 ; ++k) { myvals.updateIndex ( x_index, base+k ); myvals.updateIndex ( y_index, base+k ); myvals.updateIndex ( z_index, base+k ); }
355
- for (unsigned k=1 ; k<4 ; ++k) {
356
- unsigned nmat = getConstPntrToComponent (k)->getPositionInMatrixStash (), nmat_ind = myvals.getNumberOfMatrixRowDerivatives ( nmat );
357
- std::vector<unsigned >& matrix_indices ( myvals.getMatrixRowDerivativeIndices ( nmat ) );
358
- matrix_indices[nmat_ind+0 ]=3 *index2+0 ; matrix_indices[nmat_ind+1 ]=3 *index2+1 ; matrix_indices[nmat_ind+2 ]=3 *index2+2 ;
359
- myvals.setNumberOfMatrixRowDerivatives ( nmat, nmat_ind+3 );
357
+ if ( chainContinuesAfterThisAction () ) {
358
+ for (unsigned k=1 ; k<4 ; ++k) {
359
+ unsigned nmat = getConstPntrToComponent (k)->getPositionInMatrixStash (), nmat_ind = myvals.getNumberOfMatrixRowDerivatives ( nmat );
360
+ std::vector<unsigned >& matrix_indices ( myvals.getMatrixRowDerivativeIndices ( nmat ) );
361
+ matrix_indices[nmat_ind+0 ]=3 *index2+0 ; matrix_indices[nmat_ind+1 ]=3 *index2+1 ; matrix_indices[nmat_ind+2 ]=3 *index2+2 ;
362
+ myvals.setNumberOfMatrixRowDerivatives ( nmat, nmat_ind+3 );
363
+ }
360
364
}
361
365
}
362
366
}
363
367
}
364
368
365
369
void AdjacencyMatrixBase::runEndOfRowJobs ( const unsigned & ind, const std::vector<unsigned > & indices, MultiValue& myvals ) const {
366
- if ( doNotCalculateDerivatives () ) return ;
370
+ if ( doNotCalculateDerivatives () || ! chainContinuesAfterThisAction () ) return ;
367
371
368
372
for (int k=0 ; k<getNumberOfComponents (); ++k) {
369
373
unsigned nmat = getConstPntrToComponent (k)->getPositionInMatrixStash (), nmat_ind = myvals.getNumberOfMatrixRowDerivatives ( nmat );
0 commit comments