Attribute Error When Trying to Use Hydrogen Bond Lifetime Function

20 views
Skip to first unread message

Angela K

unread,
May 25, 2022, 9:50:07 AMMay 25
to MDnalysis discussion
Hi,

I am trying to calculate the lifetime of the hydrogen bonds in my simulation, but I am annoyingly not able to use the lifetime function (I get an Attribute error). I've checked & re-checked that I am importing the modules correctly, so I have no idea why this should be coming up.

Example code:

from MDAnalysis.analysis.hydrogenbonds.hbond_analysis import HydrogenBondAnalysis as HBA

hbonds = HBA(
    universe=u,
    donors_sel=None,
    hydrogens_sel="name HT1",
    acceptors_sel="name OT1 OT2",
    d_a_cutoff=3.0,
    d_h_a_angle_cutoff=150,
    update_selections=False
)

hbonds.run(
    start=None,
    stop=None,
    step=None,
    verbose=True
)

tau_timeseries, timeseries = hbonds.lifetime()

Then I get the following Attribute Error:

AttributeError Traceback (most recent call last) <ipython-input-18-f0f90b59372c> in <module> ----> 1 tau_timeseries, timeseries = hbonds.lifetime() AttributeError: 'HydrogenBondAnalysis' object has no attribute 'lifetime'

I've updated MDAnalysis & still get the same error! Any ideas?

Best wishes,

Angela

Irfan Alibay

unread,
May 25, 2022, 10:08:13 AMMay 25
to MDnalysis discussion
Hi,

> I've updated MDAnalysis & still get the same error

Could you please confirm what version of MDAnalysis you are using? What is the output of doing: python -c "import MDAnalysis as mda; print(mda.__version__)"?

Lifetime wasn't implemented until MDAnalysis 2.0.0, so that might be the issue here.

Best regards,

Irfan

Angela K

unread,
Jun 8, 2022, 8:56:52 AMJun 8
to MDnalysis discussion
Hi Irfan,

Yes I updated my MDAnalysis version & it was the source of the error.

Best wishes,

Angela
Reply all
Reply to author
Forward
0 new messages