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

More features from hack-the-tree #1033

Merged
merged 18 commits into from Mar 6, 2024
Merged

More features from hack-the-tree #1033

merged 18 commits into from Mar 6, 2024

Conversation

gtribello
Copy link
Member

Description

These commits contain the new implementations of the actions belonging to the mapping module. This is PATH, GPROPERTYMAP, PCAVARS, pathtools, ADAPTIVE_PATH and the GEOMETRIC_PATH. These functionalities can be simplified because we can now pass vectors and matrices between actions.

I think there is less controversial stuff here as I am mostly changing code that I authored. The only action I have written that was not authored by me is RMSD. This now calls the Tools::RMSD class directly (rather than using the reference module). Furthermore, I have made the command RMSD a shortcut so colvar::RMSD is now called RMSD_SCALAR. To be clear, however, you can still call RMSD with the old syntax:

rmsd: RMSD REFERENCE=myref.pdb TYPE=OPTIMAL

The difference is that if myref.pdb contains a list of reference structures you call a class called RMSD_VECTOR that was authored by me that calculates a vector of RMSD values from the reference structures. Alternatively, if you do:

rmsd: RMSD REFERENCE=myref.pdb TYPE=OPTIMAL DISPLACEMENT 

Then RMSD_VECTOR is called again as you are calculating the vector of RMSD displacements for each atom.

Target release

I would like my code to appear in release 2.10 (ideally but I understand if that is too big an ask).

Type of contribution
  • changes to code or doc authored by PLUMED developers, or additions of code in the core or within the default modules
  • changes to a module not authored by you
  • new module contribution or edit of a module authored by you
Copyright
  • I agree to transfer the copyright of the code I have written to the PLUMED developers or to the author of the code I am modifying.
  • the module I added or modified contains a COPYRIGHT file with the correct license information. Code should be released under an open source license. I also used the command cd src && ./header.sh mymodulename in order to make sure the headers of the module are correct.
Tests
  • I added a new regtest or modified an existing regtest to validate my changes.
  • I verified that all regtests are passed successfully on GitHub Actions.

src/generic/DumpPDB.cpp Fixed Show fixed Hide fixed
src/colvar/RMSDShortcut.cpp Fixed Show fixed Hide fixed
src/colvar/RMSDShortcut.cpp Fixed Show fixed Hide fixed
if( getNumberOfComponents()==2 && getPntrToComponent(1)->forcesWereAdded() ) {
unsigned natoms = getPntrToArgument(0)->getShape()[0] / 3;
std::vector<Vector> pos( natoms ), der( natoms ), direction( natoms );
double r = calculateRMSD( 0, pos, der, direction );

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable r is not used.
src/colvar/RMSDVector.cpp Fixed Show fixed Hide fixed
src/generic/DumpPDB.cpp Fixed Show fixed Hide fixed
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 94.87179% with 52 lines in your changes are missing coverage. Please review.

Project coverage is 83.37%. Comparing base (79c832a) to head (ae826e0).
Report is 7 commits behind head on master.

❗ Current head ae826e0 differs from pull request most recent head 00db9a6. Consider uploading reports for the commit 00db9a6 to get more accurate results

Files Patch % Lines
src/generic/DumpPDB.cpp 88.31% 9 Missing ⚠️
src/reference/MultiDomainRMSD.cpp 0.00% 6 Missing ⚠️
src/reference/ReferenceArguments.cpp 37.50% 5 Missing ⚠️
src/cltools/Benchmark.cpp 0.00% 4 Missing ⚠️
src/colvar/RMSDVector.cpp 97.51% 4 Missing ⚠️
src/mapping/Path.cpp 94.52% 4 Missing ⚠️
src/mapping/PathReparameterization.cpp 93.33% 4 Missing ⚠️
src/mapping/PathTools.cpp 97.91% 4 Missing ⚠️
src/mapping/PCAVars.cpp 96.10% 3 Missing ⚠️
src/mapping/PathDisplacements.cpp 95.65% 3 Missing ⚠️
... and 4 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1033      +/-   ##
==========================================
- Coverage   84.08%   83.37%   -0.72%     
==========================================
  Files         623      618       -5     
  Lines       58949    59099     +150     
==========================================
- Hits        49569    49272     -297     
- Misses       9380     9827     +447     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -1,3 +1,4 @@
plumed_modules=adjmat
Copy link
Member

Choose a reason for hiding this comment

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

@gtribello why does this need adjmat?

Copy link
Member Author

Choose a reason for hiding this comment

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

I will try to explain this here but it would be good to have a chat about how to proceed here. My preference would be to move some files around a little bit and then submit another PR.

So a plumed input file that could be created for doing DRMSD (remember DRMSD is a shortcut) is as follows (it is not done this way. Although the way described below is probably better. That is another change that should perhaps be made).

# Create a vector to hold the reference distances
dref: CONSTANT VALUES=1.1,1,3,1.4....
# Calculate all the distances
d: DISTANCES ATOMS1=1,2 ATOMS2=3,4 ...
# Calculate the displacement vector
dis: DISPLACEMENT ARG=d,dref
# Transpose the displacement vector
disT: TRANSPOSE ARG=dis
# Matrix multiply the transpose by the displacement to get the distance
d: MATRIX_PRODUCT_DIAGONAL ARG=disT,dis

This uses functionality for dealing with matrices. All of this functionality is currently in adjmat as I wrote all the matrix stuff initially with adjacency matrices in mind. I then started using it in other places because matrix multiplication is really useful! So I should probably have a rethink of how the files are organised into modules. That is quite a big job though that should maybe be done in a different PR.

Copy link
Member

Choose a reason for hiding this comment

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

One issue that I see with the shortcuts is the following.

In a recent commit e912958 I used a short script to remove unneeded dependencies. The script looks like this:

for file in */Makefile ; do

if grep -q "USE=" $file ; then
  deps=$(grep USE= $file | awk '{for(i=2;i<=NF;i++) print($i "/")}')
  for dep in $deps ; do
    git grep -q "^ *# *include \"$dep" ${file%Makefile}  || echo ERROR $file $dep
  done
fi

done

It checks if a module was USEd by mistake. And the fact that the build with all modules enables (on GitHub Actions) confirms that all needed modules where USEd.

However, we now have other dependencies that are a bit more difficult to track. For instance, the code might build with a set of modules, some action would seem available, but then would lead to an error at runtime because they generate a shortcut that need another module.

I don't have a solution however...

Copy link
Member

Choose a reason for hiding this comment

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

Why is this in the setup subdirectory? Here we only keep Actions that inherits from ActionSetup. These actions are supposed to be before other actions because they affect how other action works. Such as UNITS, LOAD, or RESTART. I now see that there are many other actions in this directory now, I guess they ended up here by mistake, or is there something that I missed?

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved DRMSD to the setup directory because it is a shortcut. It works by creating a longer (more-complicated) input file that uses other action. Consequently, functions in the DRMSD class are only called during setup. I can move this back to Colvar if you prefer.

The other things that I put in setup are Constant.cpp, Ones.cpp and PDB2Constant.cpp. These all create constants (Ones.cpp and PDB2Constant.cpp are actually shortcuts that create Constant actions). In other words, these actions create a value during setup that then does not change during the simulation. I think it makes sense for these to be in setup.

Copy link
Member

Choose a reason for hiding this comment

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

I see. I noticed now that with commit 79c832a (the big merge) you actually changed the meaning of ActionSetup.

Before: an action that should be at the beginning of the file because it changes how other actions are processed. Think about UNITS

Now: this is true only if you don't have a LABEL keyword

The point of having a separate base class was to enforce this with dynamic cast.

Maybe could you restore this? I guess you can simply use an empty calculate function if the purpose is to avoid calculations, right?

src/tools/RMSD.h Outdated Show resolved Hide resolved
@GiovanniBussi
Copy link
Member

@gtribello I added a few comments inline. I made a quick test and I noticed that RMSD is faster than before. I think that the reason is that you avoid using the reference module now, and directly use the tool (as it was in the earliest versions).

BTW I noticed that RMSD gives a segmentation fault using the benchmark trajectories after the 4th step. There might be a bug somewhere, but it looks like also previous versions of plumed have the same problem, so it's likely unrelated to this PR.

@GiovanniBussi
Copy link
Member

NB: the segmentation fault I was mentioning was a real bug, only showing up when all the atoms are arranged in a straight line (which happens in the benchmark trajectories). This is fixed in this commit now: f1da0a9

@gtribello gtribello merged commit 6a56f54 into master Mar 6, 2024
34 checks passed
@gtribello gtribello deleted the htt-new-paths-2 branch March 6, 2024 09:33
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

4 participants