Update Colvars library to version 2025-04-18
The following is a list of pull requests relevant to LAMMPS in the Colvars repository since 2024-08-06: - 752 New tool poisson_integrator_conv https://github.com/Colvars/colvars/pull/752 (@jhenin) - 733 Custom grids for all biases https://github.com/Colvars/colvars/pull/733 (@giacomofiorin, @jhenin) - 776 Avoid error in acos and asin with fast-math https://github.com/Colvars/colvars/pull/776 (@jhenin) - 773 fix: fix the clang build test failure of OPES https://github.com/Colvars/colvars/pull/773 (@HanatoK) - 768 fix: clamp the input values of asin and acos in case of fast math on aarch64 https://github.com/Colvars/colvars/pull/768 (@HanatoK) - 761 Add debug code for the Jacobi failure https://github.com/Colvars/colvars/pull/761 (@HanatoK) - 759 min_image fix; Saves long runs from crashes; https://github.com/Colvars/colvars/pull/759 (@PolyachenkoYA) - 757 Fix MSVC OpenMP issue https://github.com/Colvars/colvars/pull/757 (@HanatoK) - 755 Fix indentation of 'Init CVC' message in standard output https://github.com/Colvars/colvars/pull/755 (@jhenin) - 750 Optimize and simplify the calculation of dihedral gradients https://github.com/Colvars/colvars/pull/750 (@HanatoK) - 749 Add references to new Colvars paper https://github.com/Colvars/colvars/pull/749 (@jhenin, @giacomofiorin) - 740 Report the specific C++ standard at init time, stop warning about C++97/03 https://github.com/Colvars/colvars/pull/740 (@giacomofiorin) - 731 Improve detection of hard/mathematical boundaries https://github.com/Colvars/colvars/pull/731 (@giacomofiorin) - 729 Optimize the fit gradients https://github.com/Colvars/colvars/pull/729 (@HanatoK, @jhenin) - 728 Fix undefined behavior when getting the current working directory from std::filesystem https://github.com/Colvars/colvars/pull/728 (@giacomofiorin) - 727 Add patchversion scripting command https://github.com/Colvars/colvars/pull/727 (@giacomofiorin) - 724 Fix gradients and metric functions of distanceDir https://github.com/Colvars/colvars/pull/724 (@giacomofiorin) - 715 Add missing rotation in orientation component https://github.com/Colvars/colvars/pull/715 (@giacomofiorin) - 713 fix: try to solve #87 for non-scala components https://github.com/Colvars/colvars/pull/713 (@HanatoK) - 709 Implementation of OPES in Colvars https://github.com/Colvars/colvars/pull/709 (@HanatoK, @giacomofiorin, @jhenin) - 706 BUGFIX for Segmentation fault in colvarbias_meta::calc_energy() with useGrids off https://github.com/Colvars/colvars/pull/706 (@alphataubio) - 570 enable use of CVs defined by PyTorch neural network models https://github.com/Colvars/colvars/pull/570 (@zwpku, @giacomofiorin, @HanatoK, @jhenin) Authors: @alphataubio, @EzryStIago, @giacomofiorin, @HanatoK, @jhenin, @PolyachenkoYA, @zwpku
This commit is contained in:
@ -267,74 +267,22 @@ void colvar::dihedral::calc_value()
|
||||
|
||||
void colvar::dihedral::calc_gradients()
|
||||
{
|
||||
cvm::rvector A = cvm::rvector::outer(r12, r23);
|
||||
cvm::real rA = A.norm();
|
||||
cvm::rvector B = cvm::rvector::outer(r23, r34);
|
||||
cvm::real rB = B.norm();
|
||||
cvm::rvector C = cvm::rvector::outer(r23, A);
|
||||
cvm::real rC = C.norm();
|
||||
// Eqs. (27i) ~ (27l) from https://doi.org/10.1002/(SICI)1096-987X(19960715)17:9<1132::AID-JCC5>3.0.CO;2-T.
|
||||
|
||||
cvm::real const cos_phi = (A*B)/(rA*rB);
|
||||
cvm::real const sin_phi = (C*B)/(rC*rB);
|
||||
const cvm::rvector A = cvm::rvector::outer(r12, r23);
|
||||
const cvm::rvector B = cvm::rvector::outer(r23, r34);
|
||||
const cvm::real nG = r23.norm();
|
||||
const cvm::real A2 = A.norm2();
|
||||
const cvm::real B2 = B.norm2();
|
||||
|
||||
cvm::rvector f1, f2, f3;
|
||||
|
||||
rB = 1.0/rB;
|
||||
B *= rB;
|
||||
|
||||
if (cvm::fabs(sin_phi) > 0.1) {
|
||||
rA = 1.0/rA;
|
||||
A *= rA;
|
||||
cvm::rvector const dcosdA = rA*(cos_phi*A-B);
|
||||
cvm::rvector const dcosdB = rB*(cos_phi*B-A);
|
||||
// rA = 1.0;
|
||||
|
||||
cvm::real const K = (1.0/sin_phi) * (180.0/PI);
|
||||
|
||||
f1 = K * cvm::rvector::outer(r23, dcosdA);
|
||||
f3 = K * cvm::rvector::outer(dcosdB, r23);
|
||||
f2 = K * (cvm::rvector::outer(dcosdA, r12)
|
||||
+ cvm::rvector::outer(r34, dcosdB));
|
||||
}
|
||||
else {
|
||||
rC = 1.0/rC;
|
||||
C *= rC;
|
||||
cvm::rvector const dsindC = rC*(sin_phi*C-B);
|
||||
cvm::rvector const dsindB = rB*(sin_phi*B-C);
|
||||
// rC = 1.0;
|
||||
|
||||
cvm::real const K = (-1.0/cos_phi) * (180.0/PI);
|
||||
|
||||
f1.x = K*((r23.y*r23.y + r23.z*r23.z)*dsindC.x
|
||||
- r23.x*r23.y*dsindC.y
|
||||
- r23.x*r23.z*dsindC.z);
|
||||
f1.y = K*((r23.z*r23.z + r23.x*r23.x)*dsindC.y
|
||||
- r23.y*r23.z*dsindC.z
|
||||
- r23.y*r23.x*dsindC.x);
|
||||
f1.z = K*((r23.x*r23.x + r23.y*r23.y)*dsindC.z
|
||||
- r23.z*r23.x*dsindC.x
|
||||
- r23.z*r23.y*dsindC.y);
|
||||
|
||||
f3 = cvm::rvector::outer(dsindB, r23);
|
||||
f3 *= K;
|
||||
|
||||
f2.x = K*(-(r23.y*r12.y + r23.z*r12.z)*dsindC.x
|
||||
+(2.0*r23.x*r12.y - r12.x*r23.y)*dsindC.y
|
||||
+(2.0*r23.x*r12.z - r12.x*r23.z)*dsindC.z
|
||||
+dsindB.z*r34.y - dsindB.y*r34.z);
|
||||
f2.y = K*(-(r23.z*r12.z + r23.x*r12.x)*dsindC.y
|
||||
+(2.0*r23.y*r12.z - r12.y*r23.z)*dsindC.z
|
||||
+(2.0*r23.y*r12.x - r12.y*r23.x)*dsindC.x
|
||||
+dsindB.x*r34.z - dsindB.z*r34.x);
|
||||
f2.z = K*(-(r23.x*r12.x + r23.y*r12.y)*dsindC.z
|
||||
+(2.0*r23.z*r12.x - r12.z*r23.x)*dsindC.x
|
||||
+(2.0*r23.z*r12.y - r12.z*r23.y)*dsindC.y
|
||||
+dsindB.y*r34.x - dsindB.x*r34.y);
|
||||
}
|
||||
const cvm::real K = 180.0/PI;
|
||||
const cvm::rvector f1 = K * nG / A2 * A;
|
||||
const cvm::rvector f2 = K * ((r12 * r23 / (A2 * nG)) * A + (r34 * r23 / (B2 * nG)) * B);
|
||||
const cvm::rvector f3 = K * nG / B2 * B;
|
||||
|
||||
group1->set_weighted_gradient(-f1);
|
||||
group2->set_weighted_gradient(-f2 + f1);
|
||||
group3->set_weighted_gradient(-f3 + f2);
|
||||
group2->set_weighted_gradient( f2 + f1);
|
||||
group3->set_weighted_gradient(-f3 - f2);
|
||||
group4->set_weighted_gradient(f3);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user