-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #569 and allow mixing scalar and vector CVCs #571
Conversation
I am not very sure about the exact requirement on the sub-cvcs of linearcombination (and its subclasses). It seems that the function colvar::linearCombination::calc_value() actually requires sub-cvcs are either all scalars or all vectors of the same length(?), since it contains the following lines:
|
@HanatoK Ok with the quick fix for a clear bug but I don't know how to assess the removal of the same-type constraint, given how general that CVC is. What are the conditions that made you add the constraint in the first place? |
Yes. In the
which is not possible before this commit. |
|
My comments with a limited understanding on the details: I feel it is actually good to have some checks to guarantee that calc_value() and other member functions of linearCombination do not break down. If I understood correctly, the current constructor checks the types of sub-cvcs but not sizes if they are vectors. Function valc_value() may go wrong when the cvcs are vectors with different lengths? For the torchann subclass, I can only speak for myself. For the moment I am satisfied to be able to define cvcs using Cartesian coordinates (could be several cartesian cvcs with different number of atoms, since the sizes are not checked) or linear combinations of scalars, e.g. angles and bonds. The code should work when cvcs have different types, but it is not clear to me how useful this feature is in applications... |
When performing Lines 527 to 529 in 110b08f
Moreover, this check is more robust as it compares the sizes of two vectors if the types are vector: Lines 449 to 457 in 110b08f
So I think since the operands are checked in calc_value() , there is no need to check them again in the constructor.
|
Looks good! It seems the CodeQL check fails because the branch comes from another repo?
|
5c9dac7
to
b884352
Compare
This PR tries to fix #569. In addition, I think it is time to remove the constraint of using different types of nested CVCs.