void colvar::distance_pairs::calc_value() { x.vector1d_value.resize(group1->size() * group2->size()); if (!is_enabled(f_cvc_pbc_minimum_image)) { size_t i1, i2; for (i1 = 0; i1 < group1->size(); i1++) { for (i2 = 0; i2 < group2->size(); i2++) { cvm::rvector const dv = (*group2)[i2].pos - (*group1)[i1].pos; cvm::real const d = dv.norm(); x.vector1d_value[i1*group2->size() + i2] = d; (*group1)[i1].grad = -1.0 * dv.unit(); (*group2)[i2].grad = dv.unit(); } } } else { size_t i1, i2; for (i1 = 0; i1 < group1->size(); i1++) { for (i2 = 0; i2 < group2->size(); i2++) { cvm::rvector const dv = cvm::position_distance((*group1)[i1].pos, (*group2)[i2].pos); cvm::real const d = dv.norm(); x.vector1d_value[i1*group2->size() + i2] = d; (*group1)[i1].grad = -1.0 * dv.unit(); (*group2)[i2].grad = dv.unit(); } } } }
void colvar::distance_pairs::calc_value() { x.vector1d_value.resize(group1.size() * group2.size()); if (b_no_PBC) { size_t i1, i2; for (i1 = 0; i1 < group1.size(); i1++) { for (i2 = 0; i2 < group2.size(); i2++) { cvm::rvector const dv = group2[i2].pos - group1[i1].pos; cvm::real const d = dv.norm(); x.vector1d_value[i1*group2.size() + i2] = d; group1[i1].grad = -1.0 * dv.unit(); group2[i2].grad = dv.unit(); } } } else { size_t i1, i2; for (i1 = 0; i1 < group1.size(); i1++) { for (i2 = 0; i2 < group2.size(); i2++) { cvm::rvector const dv = cvm::position_distance(group1[i1].pos, group2[i2].pos); cvm::real const d = dv.norm(); x.vector1d_value[i1*group2.size() + i2] = d; group1[i1].grad = -1.0 * dv.unit(); group2[i2].grad = dv.unit(); } } } }
void colvar::distance_pairs::apply_force(colvarvalue const &force) { if (b_no_PBC) { size_t i1, i2; for (i1 = 0; i1 < group1->size(); i1++) { for (i2 = 0; i2 < group2->size(); i2++) { cvm::rvector const dv = (*group2)[i2].pos - (*group1)[i1].pos; (*group1)[i1].apply_force(force[i1*group2->size() + i2] * (-1.0) * dv.unit()); (*group2)[i2].apply_force(force[i1*group2->size() + i2] * dv.unit()); } } } else { size_t i1, i2; for (i1 = 0; i1 < group1->size(); i1++) { for (i2 = 0; i2 < group2->size(); i2++) { cvm::rvector const dv = cvm::position_distance((*group1)[i1].pos, (*group2)[i2].pos); (*group1)[i1].apply_force(force[i1*group2->size() + i2] * (-1.0) * dv.unit()); (*group2)[i2].apply_force(force[i1*group2->size() + i2] * dv.unit()); } } } }