import numpy as np
import matplotlib.pyplot as plt
import scipy.io as sio
u = mda.Universe('nacl.xyz',dt=0.5)
H = u.select_atoms('bynum 20:260 and (name H)')
Cl = u.select_atoms('name Cl')
acceptors = u.select_atoms('bynum 19:260 and (name H)')
c_donor_indices = np.ravel(np.repeat(Cl.indices,16,axis=0))
print ([Cl.indices])
print ([H.indices])
donar = u.atoms[c_donor_indices]
print ([donar.indices])
hb_ac = hbonds.HydrogenBondAutoCorrel(u, acceptors = u.atoms.H,
hydrogens = u.atoms.H, donors = donar, bond_type='continuous',angle_crit=125,dist_crit=5.0,
sample_time = 5, nruns = 20, nsamples = 10000)
hb_ac.run()
However, for ion-water HB lifetime, I continue to get the same donor/hydrogen number size error.
I even checked the size of donor/hydrogen by printing them out which is also shown below. But I can't remove the error. Any suggestion would be highly appreciated.
[array([10, 11, 12, 13, 14, 15, 16, 17, 18, 19])] # number of chloride ions
[array([ 21, 22, 24, 25, 27, 28, 30, 31, 33, 34, 36, 37, 39,
40, 42, 43, 45, 46, 48, 49, 51, 52, 54, 55, 57, 58,
60, 61, 63, 64, 66, 67, 69, 70, 72, 73, 75, 76, 78,
79, 81, 82, 84, 85, 87, 88, 90, 91, 93, 94, 96, 97,
99, 100, 102, 103, 105, 106, 108, 109, 111, 112, 114, 115, 117,
118, 120, 121, 123, 124, 126, 127, 129, 130, 132, 133, 135, 136,
138, 139, 141, 142, 144, 145, 147, 148, 150, 151, 153, 154, 156,
157, 159, 160, 162, 163, 165, 166, 168, 169, 171, 172, 174, 175,
177, 178, 180, 181, 183, 184, 186, 187, 189, 190, 192, 193, 195,
196, 198, 199, 201, 202, 204, 205, 207, 208, 210, 211, 213, 214,
216, 217, 219, 220, 222, 223, 225, 226, 228, 229, 231, 232, 234,
235, 237, 238, 240, 241, 243, 244, 246, 247, 249, 250, 252, 253,
255, 256, 258, 259])] # number of hydrogens considers upto 259 although the actual number would go upto 283
[array([10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19])] # number of chloride ions repeated 16 times to match the size of hydrogen array
/home/rverma/.local/lib/python2.7/site-packages/MDAnalysis/core/topologyattrs.py:507: DeprecationWarning: Instant selector AtomGroup['<name>'] or AtomGroup.<name> is deprecated and will be removed in 1.0. Use AtomGroup.select_atoms('name <name>') instead.
DeprecationWarning)
Traceback (most recent call last):
File "shb_ion.py", line 21, in <module>
sample_time = 5, nruns = 20, nsamples = 1000)
File "/home/rverma/.local/lib/python2.7/site-packages/MDAnalysis/analysis/hbonds/hbond_autocorrel.py", line 228, in __init__
raise ValueError("Donors and Hydrogen groups must be matched")
ValueError: Donors and Hydrogen groups must be matched
Thanks,
Rahul