Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using functionals from libxc #30

Open
hsulab opened this issue Nov 14, 2020 · 4 comments
Open

Error when using functionals from libxc #30

hsulab opened this issue Nov 14, 2020 · 4 comments

Comments

@hsulab
Copy link

hsulab commented Nov 14, 2020

Dear Developers and Users,

I would like to compare the electronic parameters generated from various functionals. But I have ran into some errors in using both LDA and GGA functionals.

About codes, I use openblas to compile hotbit and install the pylibxc based on libxc-5.0.0.

Using LDA PW92 from libxc,

>>> calc = KSAllElectron('Pt', scalarrel = True, xc = 'pw92')
>>> calc.run()
*******************************************
Kohn-Sham all-electron calculation for Pt
*******************************************
Using scalar relativistic corrections.
max 5 nodes, 3000 grid points
Pt xc=pw92 charge=0.0 conf:none

Start iteration...
iter   0, dn=1.5e+02>1.0e-07, max 14 sp-iter
iter  10, dn=2.3e+00>1.0e-07, max 10 sp-iter
Traceback (most recent call last):
  File "/home/hotbit/parametrization/atom.py", line 330, in run
    d_enl_max, itmax=self.solve_eigenstates(it)
  File "/home/hotbit/parametrization/atom.py", line 419, in solve_eigenstates
    assert c0[-2]<0 and c0[-1]<0
AssertionError

Using GGA PBE from libxc,

>>> calc = KSAllElectron('Pt', scalarrel = True, xc = 'pbe')
>>> calc.run()
*******************************************
Kohn-Sham all-electron calculation for Pt
*******************************************
Using scalar relativistic corrections.
max 5 nodes, 3000 grid points
Pt xc=pbe charge=0.0 conf:none

Start iteration...
Traceback (most recent call last):
  File "/home/hotbit/parametrization/atom.py", line 326, in run
    self.veff=self.mix*self.calculate_veff()+(1-self.mix)*self.veff
  File "/home/hotbit/parametrization/atom.py", line 263, in calculate_veff
    self.vxc=self.xcf.vxc(self.dens)
  File "/home/hotbit/parametrization/pylibxc_interface.py", line 90, in vxc
    if self._xGGA: v_x -= self.v_gga(res['vsigma'][0], drho_dr)
ValueError: non-broadcastable output operand with shape (1,) doesn't match the broadcast shape (3000,)

Could you give me some advice on these errors? Is there a docker for hotbit+libxc to run some calculations successfully?

Many thanks,
Jiayan

@hsulab
Copy link
Author

hsulab commented Nov 14, 2020

Another error for Carbon using pw92,

*******************************************
Kohn-Sham all-electron calculation for  C
*******************************************
Using scalar relativistic corrections.
max 1 nodes, 1000 grid points
C xc=pw92 charge=0.0 conf:none

Start iteration...
iter   0, dn=4.1e+00>1.0e-07, max 7 sp-iter
iter  10, dn=9.6e-02>1.0e-07, max 5 sp-iter
iter  20, dn=6.4e-03>1.0e-07, max 4 sp-iter
iter  30, dn=3.4e-04>1.0e-07, max 3 sp-iter
iter  40, dn=1.9e-05>1.0e-07, max 3 sp-iter
iter  50, dn=1.3e-06>1.0e-07, max 2 sp-iter
iter  60, dn=1.1e-07>1.0e-07, max 2 sp-iter
Traceback (most recent call last):
  File "/home/hotbit/parametrization/atom.py", line 347, in run
    self.calculate_energies(echo=True)
  File "/home/hotbit/parametrization/atom.py", line 177, in calculate_energies
    self.exc=self.xcf.exc(self.dens)
  File "/home/hotbit/parametrization/pylibxc_interface.py", line 68, in exc
    e_xc = e_x + e_c
NameError: name 'e_x' is not defined

It seems there is something wrong with the functionals using separate exchange and correlation.

Not familiar with the specific code implementation, I donot know if this is right.I just the simply change the following codes,

    def exc(self, rho):
        """ Returns exchange-correlation energy for density rho. """
        inp = {'rho':rho}
        if self._anyGGA:
            if not hasattr(self, 'grid'): raise ValueError(_ERR_NOGRID)
            drho_dr = where( rho<self.mini, 0.0, self.grid.derivative(rho))
            inp['sigma'] = drho_dr * drho_dr

        if self._sep_xc:
            # calculate exchange energy (density)
            res = self._pylibxc_x.compute(inp, do_exc=True, do_vxc=False)
            **e_x = res['zk'][0] # jx**
            # calculate correlation energy (density)
            res = self._pylibxc_c.compute(inp, do_exc=True, do_vxc=False)
            e_c = res['zk'][0]
            e_xc = e_x + e_c
        else:
            res = self._pylibxc_xc.compute(inp, do_exc=True, do_vxc=False)
            e_xc = res['zk'][0]

        return e_xc

In addition, the energy unit used in hotbit is Hartree. The output energy from internal PW92 is also in Hartree while the outputs from pylibxc seem to be in eV. I wonder if the unit of length is correct as Bohr?

@Yinhe-Wang
Copy link

Hi Jiayan and developer,

I came across the same issue while trying to use PBE functional from libxc and I got the same error as you did. Did you find the solution to this problem? If yes, could you please give me some advice?

Many thanks.

@GengSS
Copy link

GengSS commented May 10, 2022

Hi,
I encountered into the same error when using PBE functional from pylibxc.
Any suggestions are appreciated!

Best,
Geng

@hsulab
Copy link
Author

hsulab commented May 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants