Skip to content

Wrong rdf values from InterRDF_s when given 'density=True' #2811

Description

@VOD555

Expected behavior

If we set density=True, the results from rdf.InterRDF_s should be the same as rdf.InterRDF when given a single-atom to single-atom pair.

See also MDAnalysis/pmda#120

Actual behavior

The results from rdf.InterRDF_s will be 1/N of rdf.InterRDF.
Where N = nA * nB, and nA, nB are the number of atoms in atomgroup A and atomgroup B.

Code to reproduce the behavior

import MDAnalysis as mda
from MDAnalysisTests.datafiles import GRO_MEMPROT, XTC_MEMPROT
from pmda.rdf import InterRDF_s
from MDAnalysis.analysis import rdf

u = mda.Universe(GRO_MEMPROT, XTC_MEMPROT)

s1 = u.select_atoms('name ZND and resid 289')
s2 = u.select_atoms('(name OD1 or name OD2) and resid 51 and sphzone 5.0
                         (resid 289)')
s3 = u.select_atoms('name ZND and (resid 291 or resid 292)')
s4 = u.select_atoms('(name OD1 or name OD2) and sphzone 5.0 (resid 291)')
ags = [[s1, s2], [s3, s4]]

rdfs = InterRDF_s(u, ags, density=True)
rdfs.run()


ref_s1 = u.select_atoms('name ZND and resid 289')
ref_s2 = u.select_atoms('name OD1 and resid 51 and sphzone 5.0 (resid 289)')
ref_rdf = rdf.InterRDF(ref_s1, ref_s2, density=True)
ref_rdf.run()

from numpy.testing import assert_almost_equal

assert_almost_equal(rdf_ref.rdf, rdfs[0][0][0])

Current version of MDAnalysis

  • Which version are you using?
    MDAnalysis1.0.0
  • Which version of Python?
    python 3.6
  • Which operating system?
    Ubuntu 18.04

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions