pekkosk / hotbit

ASE density-functional tight-binding calculator
GNU General Public License v2.0
63 stars 35 forks source link

a possible bug in hb2skf.py #32

Open GengSS opened 2 years ago

GengSS commented 2 years ago

Hi I am using the hb2skf.py code to convert the hotbit parameter to the skf file. Here is the procedure:

  1. I went to the example folder AuAu_parametrization
  2. I renamed the Au_Au_repulsion.par file to Au_Au.par
  3. then I copied the hb2skf.py from the source code to the current example folder AuAu_parametrization
  4. run the python code by 'python hb2skf.py Au Au'

Then I encountered an error like this:

Fitting a spline basis function in the range between 0.494382851691 and 0.594382851691
DEBUG  t=[0.49438285 0.51438285 0.53438285 0.55438285 0.57438285 0.59438285]

DEBUG  start=0.494382851691
Traceback (most recent call last):
  File "hb2skf.py", line 276, in <module>
    generate_DFTBplus_repulsion(tmp,
  File "hb2skf.py", line 129, in generate_DFTBplus_repulsion
    splParams, fitCovariances = curve_fit(splinefit, [t, start], data)
  File "/u/home/g/gengsun/anaconda3/lib/python3.8/site-packages/scipy/optimize/minpack.py", line 742, in curve_fit
    xdata = np.asarray_chkfinite(xdata, float)
  File "/u/home/g/gengsun/anaconda3/lib/python3.8/site-packages/numpy/lib/function_base.py", line 486, in asarray_chkfinite
    a = asarray(a, dtype=dtype, order=order)
  File "/u/home/g/gengsun/anaconda3/lib/python3.8/site-packages/numpy/core/_asarray.py", line 102, in asarray
    return array(a, dtype, copy=False, order=order)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

In which, I modified the hb2skf.py to print the two lines starting with DEBUG. It seems that the curve_fit function complains about the input [t, start]. 't' is a numpy array, but 'start' is a float. This is a little bit strange to me. Is there anything wrong in my usage of the code? or is this a bug?

Thanks. Best,

Geng

pekkosk commented 2 years ago

It's a bug. But have you used the newest version of the script? It ought to be fixed there.

GengSS commented 2 years ago

Hi pekkosk, Thank you for your comments, Indeed, I used the old code. The newest version works smoothly. Best, Geng