Skip to content

Commit

Permalink
Fix Colvars#569 and allow mixing scalar and vector CVCs
Browse files Browse the repository at this point in the history
  • Loading branch information
HanatoK committed Aug 30, 2023
1 parent 0292804 commit 4a66cb9
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/colvarcomp_combination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,8 @@ colvar::linearCombination::linearCombination(std::string const &conf): cvc(conf)
" expects one or more nesting components.\n");
return;
} else {
// TODO: Maybe we can add an option to allow mixing scalar and vector types,
// but that's a bit complicated so we just require a consistent type
// of nesting CVs.
x.type(cv[0]->value());
x.reset();
for (size_t i_cv = 1; i_cv < cv.size(); ++i_cv) {
const auto type_i = cv[i_cv]->value().type();
if (type_i != x.type()) {
cvm::error("Error: the type of sub-CVC " + cv[i_cv]->name +
" is " + colvarvalue::type_desc(type_i) + ", which is "
"different to the type of the first sub-CVC. Currently "
"only sub-CVCs of the same type are supported to be "
"nested.\n");
return;
}
}
}
use_explicit_gradients = true;
for (size_t i_cv = 0; i_cv < cv.size(); ++i_cv) {
Expand Down Expand Up @@ -317,7 +303,8 @@ void colvar::customColvar::apply_force(colvarvalue const &force) {
}
} else {
const colvarvalue& current_cv_value = cv[i_cv]->value();
colvarvalue cv_force(current_cv_value.type());
colvarvalue cv_force(current_cv_value);
cv_force.reset();
const cvm::real factor_polynomial = getPolynomialFactorOfCVGradient(i_cv);
for (size_t j_elem = 0; j_elem < current_cv_value.size(); ++j_elem) {
for (size_t c = 0; c < x.size(); ++c) {
Expand Down

0 comments on commit 4a66cb9

Please sign in to comment.