Skip to content

Commit

Permalink
Print b3lyp warning when needed (issue pyscf#2029) (pyscf#2040)
Browse files Browse the repository at this point in the history
* Hide b3lyp warning (issue pyscf#2029)

* Backward compatibility for xcfun

* typo
  • Loading branch information
sunqm authored Jan 30, 2024
1 parent 35835bc commit a20dfb3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
19 changes: 11 additions & 8 deletions pyscf/dft/libxc.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,14 +767,7 @@ def _xc_key_without_underscore(xc_keys):
'TPSS0' : '.25*HF + .75*TPSS, TPSS',
}) # noqa: E501

# Issue 1480
if not hasattr(__config__, 'B3LYP_WITH_VWN5'):
warnings.warn('Since PySCF-2.3, B3LYP (and B3P86) are changed to the VWN-RPA variant, '
'corresponding to the original definition by Stephens et al. (issue 1480) '
'and the same as the B3LYP functional in Gaussian. '
'To restore the VWN5 definition, you can put the setting '
'"B3LYP_WITH_VWN5 = True" in pyscf_conf.py')
elif getattr(__config__, 'B3LYP_WITH_VWN5', False):
if getattr(__config__, 'B3LYP_WITH_VWN5', False):
XC_CODES['B3P86' ] = 'B3P86V5'
XC_CODES['B3LYP' ] = 'B3LYP5'
XC_CODES['X3LYP' ] = 'X3LYP5'
Expand Down Expand Up @@ -1102,6 +1095,16 @@ def parse_xc(description):
elif not isinstance(description, str): #isinstance(description, (tuple,list)):
return parse_xc('%s,%s' % tuple(description))

if (description.upper() in ('B3P86', 'B3LYP', 'X3LYP') and
not getattr(parse_xc, 'b3lyp5_warned', False) and
not hasattr(__config__, 'B3LYP_WITH_VWN5')):
parse_xc.b3lyp5_warned = True
warnings.warn('Since PySCF-2.3, B3LYP (and B3P86) are changed to the VWN-RPA variant, '
'corresponding to the original definition by Stephens et al. (issue 1480) '
'and the same as the B3LYP functional in Gaussian. '
'To restore the VWN5 definition, you can put the setting '
'"B3LYP_WITH_VWN5 = True" in pyscf_conf.py')

def assign_omega(omega, hyb_or_sr, lr=0):
if hyb[2] == omega or omega == 0:
hyb[0] += hyb_or_sr
Expand Down
7 changes: 6 additions & 1 deletion pyscf/dft/xcfun.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@
'B97XC' , 'B97_1XC' , 'B97_2XC' , 'M05XC' , 'TPSSH' ,
'HFLYP'}
RSH_XC = {'CAMB3LYP'}
MAX_DERIV_ORDER = ctypes.c_int.in_dll(_itrf, 'XCFUN_max_deriv_order').value

# The compatibility with the old libxcfun_itrf.so library
try:
MAX_DERIV_ORDER = ctypes.c_int.in_dll(_itrf, 'XCFUN_max_deriv_order').value
except ValueError:
MAX_DERIV_ORDER = 3

VV10_XC = {
'B97M_V' : (6.0, 0.01),
Expand Down

0 comments on commit a20dfb3

Please sign in to comment.