MDAnalysis / mdanalysis

MDAnalysis is a Python library to analyze molecular dynamics simulations.
https://mdanalysis.org
Other
1.29k stars 647 forks source link

ValueError: The array returned by a function changed size between calls #1884

Closed cy16f01 closed 6 years ago

cy16f01 commented 6 years ago

I have run the HB auto-correlation code and here is my full/actual code as follows:-

import MDAnalysis as mda
from MDAnalysis.analysis import hbonds
import matplotlib.pyplot as plt
%matplotlib inline
u = mda.Universe('nptmd.tpr','nptmd.xtc')
H = u.select_atoms('byres(name OW HW1 HW2 and around 5.6 name N)') # since i want to calculate the water molecules within 5.6pm of N atom
A = u.select_atoms('byres(name OW HW1 HW2 and around 5.6 name N)') # since i want to calculate the water molecules within 5.6pm of N atom
D = u.select_atoms('byres(name OW HW1 HW2 and around 5.6 name N)') # since i want to calculate the water molecules within 5.6pm of N atom
hb_ac = hbonds.HydrogenBondAutoCorrel(u, acceptors=A, hydrogens=H, donors=D,bond_type='continuous',
                            sample_time=10,nruns=20000,nsamples=20,pbc=True,angle_crit=130.0, dist_crit=3.0)
hb_ac.run()
hb_ac.solve()
time = hb_ac.solution['time']
results = hb_ac.solution['results']
fit=hb_ac.solution['fit']
tau = hb_ac.solution['tau']
estimate = hb_ac.solution['estimate']
print("{time} {results}".format(time=time,results=results))
print("{time} {estimate}".format(time=time,estimate=estimate))
plt.figure(1,figsize=(15,5))
plt.figure(1,figsize=(15,5))
plt.subplot(121)
plt.xlabel('time')
plt.ylabel('HBLc')
plt.title('HBL Continuos')
plt.plot(time,results, 'ro')
plt.plot(time,estimate)
plt.show()
print (tau)

1] But after running the code i get the error as:- ValueError Traceback (most recent call last)

in () 10 sample_time=10,nruns=20000,nsamples=20,pbc=True,angle_crit=130.0, dist_crit=3.0) 11 hb_ac.run() ---> 12 hb_ac.solve() 13 time = hb_ac.solution['time'] 14 results = hb_ac.solution['results'] ~/anaconda3/lib/python3.6/site-packages/MDAnalysis/analysis/hbonds/hbond_autocorrel.py in solve(self, p_guess) 504 505 p, cov, infodict, mesg, ier = scipy.optimize.leastsq( --> 506 err, p_guess, args=(time, results), full_output=True) 507 self.solution['fit'] = p 508 A1, tau1, tau2 = p ~/anaconda3/lib/python3.6/site-packages/scipy/optimize/minpack.py in leastsq(func, x0, args, Dfun, full_output, col_deriv, ftol, xtol, gtol, maxfev, epsfcn, factor, diag) 385 maxfev = 200*(n + 1) 386 retval = _minpack._lmdif(func, x0, args, full_output, ftol, xtol, --> 387 gtol, maxfev, epsfcn, factor, diag) 388 else: 389 if col_deriv: ValueError: The array returned by a function changed size between calls What does this mean? How is the function changing the size between calls..?? 2] Is the order `results` `time` `tau` `estimate` `fit` sequential..? Do they need to be given in ordered/sequentailly in order to calculate one after the other..?? Any suggestions are appreciated.
richardjgowers commented 6 years ago

This has been fixed in 0.18.0 of mdanalysis, what version are you running?

cy16f01 commented 6 years ago

I am using 0.17.0 version.

cy16f01 commented 6 years ago

@richardjgowers, @orbeckst How can i upgrade it to 0.18.0..?? Do i have to uninstall the current version and the again install the new version..?? Any links that i can follow..??

Thank you.

orbeckst commented 6 years ago

https://www.mdanalysis.org/2018/04/22/release-0.18.0/

-- Oliver Beckstein email: orbeckst@gmail.com

Am May 5, 2018 um 01:30 schrieb cy16f01 notifications@github.com:

@richardjgowers, @orbeckst How can i upgrade it to 0.18.0..?? Do i have to uninstall the current version and the again install the new version..?? Any links that i can follow..??

Thank you.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.