From b56df96e2a0fe29a1df7050f6031f5bca073bc4e Mon Sep 17 00:00:00 2001 From: HanatoK Date: Mon, 14 Oct 2024 13:49:34 -0500 Subject: [PATCH] Only call calc_fit_gradients when atom groups have explicit gradients --- src/colvarcomp.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/colvarcomp.cpp b/src/colvarcomp.cpp index e6729f43a..024c00e50 100644 --- a/src/colvarcomp.cpp +++ b/src/colvarcomp.cpp @@ -533,8 +533,10 @@ void colvar::cvc::calc_Jacobian_derivative() void colvar::cvc::calc_fit_gradients() { - for (size_t ig = 0; ig < atom_groups.size(); ig++) { - atom_groups[ig]->calc_fit_gradients(); + if (is_enabled(f_cvc_explicit_gradient)) { + for (size_t ig = 0; ig < atom_groups.size(); ig++) { + atom_groups[ig]->calc_fit_gradients(); + } } }