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

HydrogenBondLifetimes (Autocorrelation) has an increasing value #2247

Closed
bieniekmateusz opened this issue Apr 14, 2019 · 4 comments · Fixed by #2256
Closed

HydrogenBondLifetimes (Autocorrelation) has an increasing value #2247

bieniekmateusz opened this issue Apr 14, 2019 · 4 comments · Fixed by #2256
Assignees

Comments

@bieniekmateusz
Copy link
Member

bieniekmateusz commented Apr 14, 2019

The autocorrelation has to be decreasing.

Adjusted test case from the test_waterdynamics.py file:

def test_HydrogenBondLifetimes_growing_continuous(universe):
    # The autocorrelation cannot grow
    hbl = waterdynamics.HydrogenBondLifetimes(
        universe, SELECTION1, SELECTION1, t0=0, tf=9, dtmax=5)
    hbl.run()
    print("results", hbl.timeseries)
    # Index 0 in frameX[0] refers to the continuous, 1 to intermittent
    assert all([frameX[0] > frameXplus1[0] for frameX, frameXplus1 in zip(hbl.timeseries, hbl.timeseries[1:])])

The current autocorrelation code in HydrogenBondLifetimes returns lifetimes that increase over time. We are planning to address this in the next Pull Request with @p-j-smith where we add the test case and use our standalone autocorrelation function.

  • Which version are you using? developing branch
  • Python 2.7
  • Linux Arch
bieniekmateusz added a commit to bieniekmateusz/mdanalysis that referenced this issue Apr 14, 2019
@orbeckst
Copy link
Member

Are you saying that the calculated ACF must be monotonically decreasing? Not even a little bit of noise allowed?

@bieniekmateusz
Copy link
Member Author

In the actual experiments I imagine the noise could create this kind of data. However, in the case of continuous ACF this cannot happen. This is because at each point t0, we take our bonds and check if they survive at every step up until a given tau, say tau=t4. If they leave at t3, we do not allow it to return, and so t4 is thrown away (we say it has left). So, by definition, the continuous ACF will be monotonically decreasing.

Now, some implementations of the intermittent ACF could lead to the noise you suggest. In our case, it is not possible: we say that if the molecule leaves only at t3 and returns at t4, with the intermittency=1, then we treat this bond as if it was there at every step from t0 to t4, including at t3. So again, it is not possible for the ACF to increase.

Paul & Mat

@richardjgowers
Copy link
Member

richardjgowers commented Apr 18, 2019 via email

@bieniekmateusz
Copy link
Member Author

@richardjgowers The HydrogenBondLifetimes does not do anything extra. We're hoping to finish soon submit the next PR. We're going to add a function to the Richard's HydrogenBond finder to get the autocorrelation directly.

Mat

p-j-smith pushed a commit to bieniekmateusz/mdanalysis that referenced this issue Oct 29, 2019
orbeckst added a commit that referenced this issue May 12, 2020
#2256)

* Summary of changes

  The main issue with HydrogenBondLifetimes (besides the bug #2247) is that it defined 
  its own definition of a hydrogen bond, without allowing the user to change it. 
  It should be clear that the hydrogen bonds first have to be computed by the user, 
  and then the autocorrelation for the bonds can be found. 
  This is achieved with the  autocorrelation() function, which is now made available in a 
  separate module, `MDAnalysis.lib.correlations` so that it can be used by any code.

   * Provides well defined autocorrelation which can be used for both, SurvivalProbability and HydrogenLifetimes (and more?) in new module MDAnalysis/lib/correlations.py
   * Autocorrelation function and intermittency function are now independant with their own test cases
   * Removed the class HydrogenBondLifetimes and moved the autocorrelation functionality into the hbond_analysis class as a .autocorrelation method. This method should replace also hbond_autocorrel.py file in the future.
   * New test cases for the method .autocorrelation (HydrogenBondAnalysis) were added
   * Added a test cases that, with our definition of intermittency, would fail in the case of the hbond_autocorrel.py.
   * Fixes the issue #2247 

* Detailed code comments
  * new module MDAnalysis/lib/correlations.py
  * Extracting the autocorrelation and intermittency from SP into their own functions with their own test cases.
  * A more general documentation in the autocorrelation.
  * The documentation updated with the code. The HydrogenBondAnalysis
     should ideally be extracted from the HydrogenBondLifetime and fed into
     it in the constructor.
  * Removed the class HydrogenBondLifetimes and moved the autocorrelation
     functionality into the hbond_analysis class as a .autocorrelation
     method. This method should replace also hbond_autocorrel.py file. Test
     cases for the new method .autocorrelation are added.
  * Updated logging.
  * Added __future__ imports.
  * Remove deprecation warning for HydrogenBondLifetime.
     This function will be removed in a future PR once a replacement that uses the 
     new hydrogen bond class is in place.
  * Added checks for parameters types and dimensions.
  * reST citations 
* Detailed test comments
  * Updated test cases to illuminate the bug in #2247.
  * Correction for the test to make it consistent with the previous author's test. 
     Our end index is inclusive (5th frame, giving 6 frames). But the other author's 
     analysis was done on 0-4 frames (5 frames).
  * Exhaustive testing for autocorrelation. It will now return 1 at tau=0.
     Now the function can be embedded into HydrogenBondLifetime.
  * Exceptions marked as not covered

Co-authored-by: Paul Smith <[email protected]>
Co-authored-by: Oliver Beckstein <[email protected]>
bieniekmateusz added a commit to bieniekmateusz/mdanalysis that referenced this issue Jun 25, 2020
…ydrogen bond implementation. Fixes MDAnalysis#2547 and we depracate the waterdynamic.HydrogenBondLifetime because of MDAnalysis#2247.

co-authored-by: p-j-smith <[email protected]>
bieniekmateusz added a commit to bieniekmateusz/mdanalysis that referenced this issue Jun 25, 2020
…ydrogen bond implementation. Fixes MDAnalysis#2547 and we depracate the waterdynamic.HydrogenBondLifetime because of MDAnalysis#2247.

co-authored-by: p-j-smith <[email protected]>
orbeckst pushed a commit that referenced this issue Jul 12, 2020
* Fixes #2547 
* The standalone autocorrelation function is now used to calculate the hydrogen bond lifetime in the new
   implementation of the hydrogen bond analysis class.
* Added ability to select groups between which to find hydrogen bonds.:
   new parameter "between" for hydrogen binding (backwards compatible): The `between` keyword can 
   be used to specify pairs of groups between which hydrogen bonds will be calculated. 
   Hydrogen bonds found other pairs of atom groups will be discarded.
* We deprecate the waterdynamics.HydrogenBondLifetime class because of #2247.
* Basic unit tests added to check the integration of the separate components
* add docs with example
* update CHANGELOG

co-authored-by: p-j-smith <[email protected]>
PicoCentauri pushed a commit to PicoCentauri/mdanalysis that referenced this issue Mar 30, 2021
* Fixes MDAnalysis#2547 
* The standalone autocorrelation function is now used to calculate the hydrogen bond lifetime in the new
   implementation of the hydrogen bond analysis class.
* Added ability to select groups between which to find hydrogen bonds.:
   new parameter "between" for hydrogen binding (backwards compatible): The `between` keyword can 
   be used to specify pairs of groups between which hydrogen bonds will be calculated. 
   Hydrogen bonds found other pairs of atom groups will be discarded.
* We deprecate the waterdynamics.HydrogenBondLifetime class because of MDAnalysis#2247.
* Basic unit tests added to check the integration of the separate components
* add docs with example
* update CHANGELOG

co-authored-by: p-j-smith <[email protected]>
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 a pull request may close this issue.

3 participants