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
Restyling for reweighting implementation #400
Comments
Hi @invemichele, I would agree with simplifying the integral calculation as you suggest. I just have one suggestion on the changes. Currently the integration is just done by summing over the grid points (and as c(t) is a ratio of two integrals there is no need to consider the volume of the grid bins). However, strictly speaking this is not correct numerical integration, it would be better to use something like trapezoidal rule for the integration so that the points at the edges have different weights. In many cases the integrated functions might be zero at the edges of the grid so this would not matter. But anyway I think it would be better to do it exactly. In the VES code I have done all integrals by using trapezoidal rule. For the multidimensional case is just a product of one-dimensional trapezoidal rules. There is a function in src/ves/GridIntegrationWeights.cpp that for a given grid just gives a std::vector of the size of the grid with all the integration weights. It also handles the periodic case correctly. I could add that function to the Grid class. Then one could do something like: std::vector weights = BiasGrid_->getIntegrationWeights(); As for the changing the keywords, it would not make sense to keep the REWEIGHTING_NGRID keywords. But the developers should comment what is the exact policy of "breaking inputs". As for changing the default for REWEIGHTING_NHILLS from 50 to 1. I am not sure about that, there is of course some overhead in doing the integration (especially for more than 2 dimension) and perhaps doing the calculation of c(t) every time a Gaussian is added it is not needed as the changes in c(t) are not that great. Or do you have experience where it is really important to calculate c(t) at every Gaussian addition? Regards, |
Ciao Omar, Anyway, it is probably a good idea to implement a proper integration method in the grid class, as you suggested, and in that case it could be used here as well. Regarding the choice for default |
Ciao, Sounds very good. |
I agree it would be good to have the integrate method in the grid class. |
Hi all, please also check #399 which looks related for what I understand (or maybe not). I am not sure I am following everything about the integration stuff. Anyway, the way grids are implemented in plumed you can write the potential as an analytical function within each grid "cube". Maybe you might want to try to integrate that function? Or maybe the methods you proposed are equally good or better. |
Hi @GiovanniBussi You are right, my integration method does not consider the spline interpolation. Then probably the small difference I saw in 1D when doubling A last possibility would be to keep both implementation, and switch to the faster one only in case the user sets |
Hi everybody,
I don't know if there are cases in which ignoring the spline interpolation can give rise to big differences, for alanine dipeptide this is not the case, there is virtually no difference at all. I also ran some simulations with a much bigger bias grid
From these tests looks like with the new implementation there is no overhead in keeping NHILLS=1. I made some changes to my previous pull request:
To be honest I don't know, probably I exaggerated since I broke backward compatibility, and I arbitrary chose to take away the possibility to increase the precision of the rct calculation (to not confuse the user, since it is not a perceivable difference, as far as I understand). Of course feel free to change these things! Probably the bug fix #399 should be included in old plumed versions. Michele |
@GiovanniBussi @invemichele I think this is good. While about #399 I think it still need to be double check. Anyway it would be good to have the feature improved and fully working for plumed 2.5 |
My only doubt is that I discussed exactly this possibility (using a single grid) with @gtribello before he merged the first implementation and apparently there was some reason to use a double grid. So I would feel better if @gtribello confirms it's ok before we remove the feature. |
Hi everybody,
I think there is room for improvement in the current implementation of the reweighting, and I would be happy to contribute.
In particular the way the integral for c(t) is now calculated is, I believe, unnecessarily cumbersome. It comes directly from the
Grid::integrate()
function, which is not used anywhere else in the code (or at least not in the master branch).I think that a simple direct summation over the grid points is faster, works in any dimension (solving #328 ), and does not have any downside effect since the reweighting is only available when using a grid bias.
This also avoids calling
getBiasAndDerivatives
which unnecessarily returns the derivatives.I implemented this changes in a pull request, together with the support for the non well-tempered case (I don't see why not having it) and a fix for the overflow of c(t) in case of very high bias values.
Please let me know if I am missing a piece of the picture, and I am misunderstanding the code.
More in general I believe that also the user interface should be changed. In particular it does not make much sense to calculate the reweighting on a grid different from the bias one, and thus ask the user for
REWEIGHTING_NGRID
. especially because (if I understand the code correctly) the method called isGrid::getValue(const vector<double> & x)
, which callsGrid::getIndices(const vector<double> & x)
, which returnsfloor((x[i]-min_[i])/dx_[i])
, thus as a matter of fact, if we double the number of reweighting bins, there is no difference in the value of c(t), except for some small border effect.Thus
REWEIGHTING_NGRID
could be dropped in favor of a flag likeCALC_RCT
orCALC_REWEIGHTING
. It is fine to leave theREWEIGHTING_NHILLS
option, but I would change the default frequency to 1, and let the user choose if increasing it.Of course these are just suggestions, driven by my typical usage, but might not be best suited for all the possible scenarios.
I hope this can be useful.
The text was updated successfully, but these errors were encountered: