Skip to content
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

Implementations of 2 new cvs: native contact fraction Q and angles between two vectors #327

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

yihengwuKP
Copy link
Collaborator

Hi I've implemented two new cvs: 1. angle between two vectors 2. native contact fraction Q. Please let me know if anything needs to be modified! I've added another python script under colvars contacts.py for Q, but the vector angles are added in angles.py. I've implemented testing for Q and its derivatives in example/openmm/cv_Q.

Copy link

trunk-io bot commented Jul 9, 2024

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

update the examples, this is simply a better choice of
the contacts. Otherwise it contains bonded pairs which
will always be there.
return remapped_contacts


@multicomponent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is @multicomponent really needed here? AFAICT, this returns a scalar?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, I think perhaps I copied some other code with the multicomponent. I'll fix it!

return vector_angle


def vector_angle(p1, p2, p3, p4):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be able to reduce some code duplication by having our angle function taking four arguments and then change the Angle class call a lambda that calls angle with one of the arguments repeated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, that sounds cool

Comment on lines 15 to 25
def remap_indices(contacts, sorted_unique_indices):
# create the mapping from old indices to new indices
old_indices = np.array(sorted_unique_indices)
new_indices = np.arange(len(sorted_unique_indices))
index_mapping = np.zeros(old_indices.max() + 1, dtype=new_indices.dtype)
index_mapping = index_mapping.at[old_indices].set(new_indices)

contacts = np.array(contacts)
remapped_contacts = index_mapping[contacts]

return remapped_contacts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to check, but this looks like something that could be accomplished, by using argsort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants