ssnam92 / KSPies

Kohn-Sham Python-based inversion Evaluation Software
Apache License 2.0
11 stars 4 forks source link

AttributeError: module 'kspies.kspies_fort' has no attribute 'einsum_ij_ijt_2t' #5

Closed SomeAnonimCoder closed 3 years ago

SomeAnonimCoder commented 3 years ago

Code from 1_test_script.py seems to be broken. In Jupyter notebook with python 3.8, pyscf==1.6.6 and kspies both installed via pip I have the following result:


!Expected -Ws = -14.57272496 !
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-097ee80df60b> in <module>
     19 mw1 = wy.RWY(mol, dm_rhf)
     20 mw1.reg = 1e-5
---> 21 mw1.run()
     22 mw1.info()
     23 

~/anaconda3/lib/python3.8/site-packages/kspies/wy.py in run(mw)
    116                           tol=mw.tol, options={'disp': False})
    117     else:
--> 118         mw.res = minimize(mw.eval_Ws, x0=mw.b, method=mw.method, jac=mw.eval_Gd, hess=mw.eval_Hs,
    119                           tol=mw.tol, options={'disp': False})
    120     mw.b = mw.res.x

~/anaconda3/lib/python3.8/site-packages/scipy/optimize/_minimize.py in minimize(fun, x0, args, method, jac, hess, hessp, bounds, constraints, tol, callback, options)
    631                                       callback=callback, **options)
    632     elif meth == 'trust-exact':
--> 633         return _minimize_trustregion_exact(fun, x0, args, jac, hess,
    634                                            callback=callback, **options)
    635     else:

~/anaconda3/lib/python3.8/site-packages/scipy/optimize/_trustregion_exact.py in _minimize_trustregion_exact(fun, x0, args, jac, hess, **trust_region_options)
     39         raise ValueError('Hessian matrix is required for trust region '
     40                          'exact minimization.')
---> 41     return _minimize_trust_region(fun, x0, args=args, jac=jac, hess=hess,
     42                                   subproblem=IterativeSubproblem,
     43                                   **trust_region_options)

~/anaconda3/lib/python3.8/site-packages/scipy/optimize/_trustregion.py in _minimize_trust_region(fun, x0, args, jac, hess, hessp, subproblem, initial_trust_radius, max_trust_radius, eta, gtol, maxiter, disp, return_all, callback, inexact, **unknown_options)
    175     if return_all:
    176         allvecs = [x]
--> 177     m = subproblem(x, fun, jac, hess, hessp)
    178     k = 0
    179 

~/anaconda3/lib/python3.8/site-packages/scipy/optimize/_trustregion_exact.py in __init__(self, x, fun, jac, hess, hessp, k_easy, k_hard)
    239         # The implemented SciPy wrapper does not return
    240         # the incomplete factorization needed by the method.
--> 241         self.cholesky, = get_lapack_funcs(('potrf',), (self.hess,))
    242 
    243         # Get info about Hessian

~/anaconda3/lib/python3.8/site-packages/scipy/optimize/_trustregion.py in hess(self)
     56         """Value of hessian of objective function at current iteration."""
     57         if self._h is None:
---> 58             self._h = self._hess(self._x)
     59         return self._h
     60 

~/anaconda3/lib/python3.8/site-packages/scipy/optimize/optimize.py in function_wrapper(*wrapper_args)
    325     def function_wrapper(*wrapper_args):
    326         ncalls[0] += 1
--> 327         return function(*(wrapper_args + args))
    328 
    329     return ncalls, function_wrapper

~/anaconda3/lib/python3.8/site-packages/kspies/wy.py in eval_Hs(self, b)
    371         """Summary: -d^2(Ws)/(b_t)(b_u)
    372         """
--> 373         self.solve(b)
    374         t = time.time()
    375 

~/anaconda3/lib/python3.8/site-packages/kspies/wy.py in solve(self, b)
    331             t = time.time()
    332             if kf_imported:
--> 333                 self.grad = kspies_fort.einsum_ij_ijt_2t((self.dm-self.dm_tar), self.Sijt, self.nbas, self.npot)
    334             else:
    335                 self.grad = np.einsum('ij,ijt->t', (self.dm-self.dm_tar), self.Sijt)

AttributeError: module 'kspies.kspies_fort' has no attribute 'einsum_ij_ijt_2t'```
ssnam92 commented 3 years ago

Could you please try:

  1. remove kspies_fort.py on the source directory (this file is a dummy and will be removed in the next release) (If you use miniconda, for example, the location will be /miniconda3/lib/python3.8/site-packages/kspies/

  2. If you don't have lapack, please install with conda install -c conda-forge lapack

  3. in the kspies source directory, re-compile fortran source For example, you installed lapack with step 2, compile command might be f2py -c --f90flags='-fopenmp' -lgomp -llapack -L/home/$USER/miniconda3/lib/ kspies_fort.f90 -m kspies_fort or assign any location that liblapack.so is in after -L

SomeAnonimCoder commented 3 years ago

Yes, that worked fine, but maybe you should fix that for correct pip installation work