Skip to content

Commit

Permalink
a few tiny details (fixed by ruff) and two typos
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton authored and sunqm committed Oct 22, 2023
1 parent a24be93 commit 5b2f8a8
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pyscf/grad/cmspdft.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def trans_rdm12 (ci1, ci0, *args, **kwargs):
ci_arr = np.asarray (mc.ci)

mc_grad = mc.nuc_grad_method ()
Lis = math.pi * (np.random.rand ((3)) - 0.5)
Lis = math.pi * (np.random.rand (3) - 0.5)
eris = mc.ao2mo (mc.mo_coeff)

dw_test = diab_response (mc_grad, Lis, mo=mc.mo_coeff, ci=mc.ci,
Expand Down
6 changes: 3 additions & 3 deletions pyscf/grad/mspdft.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from mrh.my_pyscf.fci.csf import CSFFCISolver
except ModuleNotFoundError:
# dummy
class CSFFCISolver (object):
class CSFFCISolver :
pass

def _unpack_state (state):
Expand Down Expand Up @@ -656,9 +656,9 @@ def is_prec (self, xis):

def do_sing_warn (self):
if self.sing_warned: return
self.log.warn (('Model-space frame-rotation Hessian is singular! '
self.log.warn ('Model-space frame-rotation Hessian is singular! '
'Response equations may not be solvable to arbitrary '
'precision!'))
'precision!')
self.sing_warned = True


Expand Down
2 changes: 1 addition & 1 deletion pyscf/grad/test/test_grad_cmspdft.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
H 1.102430 0.000000 -0.920125'''
mol_nosymm = gto.M (atom = h2co_casscf66_631g_xyz, basis = '6-31g', symmetry = False, output='/dev/null', verbose = 0)
mol_symm = gto.M (atom = h2co_casscf66_631g_xyz, basis = '6-31g', symmetry = True, output='/dev/null', verbose = 0)
Lis = math.pi * (np.random.rand ((1)) - 0.5)
Lis = math.pi * (np.random.rand (1) - 0.5)
def get_mc_ref (mol, ri=False, sam=False):
mf = scf.RHF (mol)
if ri: mf = mf.density_fit (auxbasis = df.aug_etb (mol))
Expand Down
2 changes: 1 addition & 1 deletion pyscf/mcdcft/mcdcft.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def __init__(self, scf, ncas, nelecas, my_ot=None, ot_name=None, grids_level=Non
# I think this is the same DFCASSCF problem as with the DF-SACASSCF gradients earlier
super().__init__()
keys = set(('e_ot', 'e_mcscf', 'e_states'))
self._keys = set ((self.__dict__.keys())).union(keys)
self._keys = set (self.__dict__.keys()).union(keys)
self.grids_level = grids_level
if my_ot is not None:
self._init_ot_grids(my_ot, ot_name, grids_level=grids_level)
Expand Down
2 changes: 1 addition & 1 deletion pyscf/mcpdft/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def CASCIPDFT (mc_or_mf_or_mol, ot, ncas, nelecas, ncore=None, **kwargs):
CASSCF=CASSCFPDFT
CASCI=CASCIPDFT

class MultiStateMCPDFTSolver ():
class MultiStateMCPDFTSolver :
pass
# tag

Expand Down
2 changes: 1 addition & 1 deletion pyscf/mcpdft/_dms.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from pyscf import dmrgscf
DMRGCI = dmrgscf.DMRGCI
except ImportError:
class DMRGCI (object):
class DMRGCI :
pass

def _get_fcisolver (mc, ci, state=0):
Expand Down
2 changes: 1 addition & 1 deletion pyscf/mcpdft/lpdft.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def __init__(self, mc):
self.si_pdft = None
self.veff1 = None
self.veff2 = None
self._keys = set((self.__dict__.keys())).union(keys)
self._keys = set(self.__dict__.keys()).union(keys)

@property
def e_states(self):
Expand Down
6 changes: 3 additions & 3 deletions pyscf/mcpdft/mcpdft.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def _get_e_decomp(mc, ot, mo_coeff, ci, e_nuc, h, nelecas):
return e_1e, e_coul, e_otxc, e_ncwfn


class _mcscf_env(object):
class _mcscf_env:
'''Prevent MC-SCF step of MC-PDFT from overwriting redefined
quantities e_states and e_tot '''

Expand Down Expand Up @@ -365,7 +365,7 @@ def __exit__(self, type, value, traceback):
self.mc._in_mcscf_env = False


class _PDFT():
class _PDFT:
# Metaclass parent; unusable on its own
'''MC-PDFT child class. All total energy quantities (e_tot,
e_states) are MC-PDFT total energies:
Expand Down Expand Up @@ -411,7 +411,7 @@ def __init__(self, scf, ncas, nelecas, my_ot=None, grids_level=None,
'mcscf_mcpdft_conv_tol_ci_fp', 1e-8)
self.mcscf_kernel = self._mc_class.kernel
self._in_mcscf_env = False
self._keys = set((self.__dict__.keys())).union(keys)
self._keys = set(self.__dict__.keys()).union(keys)
if grids_level is not None:
grids_attr['level'] = grids_level
if my_ot is not None:
Expand Down
6 changes: 3 additions & 3 deletions pyscf/mcpdft/mspdft.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ def si_newton (mc, ci=None, objfn=None, max_cyc=None, conv_tol=None,
if conv:
log.note ("{} optimization CONVERGED".format (hdr))
else:
log.note (("{} optimization did not converge after {} "
"cycles".format (hdr, it)))
log.note ("{} optimization did not converge after {} "
"cycles".format (hdr, it))

return conv, list (ci)

Expand Down Expand Up @@ -262,7 +262,7 @@ def __init__(self, mc, diabatizer, diabatize, diabatization):
self.diabatization = diabatization
self.si_mcscf = None
self.si_pdft = None
self._keys = set ((self.__dict__.keys ())).union (keys)
self._keys = set (self.__dict__.keys ()).union (keys)

@property
def e_states (self):
Expand Down
4 changes: 2 additions & 2 deletions pyscf/mcpdft/otfnal.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,11 +739,11 @@ def get_transfnal (mol, otxc):
xc_base = OT_HYB_ALIAS.get (xc_base.upper (), xc_base)
if ',' not in xc_base and _libxc.is_hybrid_or_rsh (xc_base):
raise NotImplementedError (
('Aliased or built-in translated hybrid or range-separated '
'Aliased or built-in translated hybrid or range-separated '
'functionals\nother than those listed in otfnal.OT_HYB_ALIAS. '
'Build a compound functional\nstring with a comma separating the '
'exchange and correlation parts, or use\notfnal.make_hybrid_fnal '
'instead.')
'instead.'
)
ks = dft.RKS (mol)
ks.xc = xc_base
Expand Down
2 changes: 1 addition & 1 deletion pyscf/mcpdft/pdft_eff.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


# TODO: outcore implementation; can I use properties instead of copying?
class _ERIS(object):
class _ERIS:
'''Stores two-body PDFT on-top effective integral arrays in a form
compatible with existing MC-SCF kernel and derivative functions.
Unlike actual eris, PDFT 2-electron effective integrals have 24-fold
Expand Down
4 changes: 2 additions & 2 deletions pyscf/mcpdft/tfnal_derivs.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ def contract_fot(otfnal, fot, rho0, Pi0, rho1, Pi1, unpack=True,
vrho1, vPi1 = _unpack_sigma_vector(v1, rho0p, Pi0p)
if ggrad:
if vot_packed is None:
raise RuntimeError(("Cannot evaluate fot.x in terms of "
"unpacked density gradients without vot_packed"))
raise RuntimeError("Cannot evaluate fot.x in terms of "
"unpacked density gradients without vot_packed")
vrho2, vPi2 = _unpack_sigma_vector(vot_packed, rho1p, Pi1p)
if vrho1.shape[0] > 1: vrho1[1:4, :] += vrho2[1:4, :]
if vPi1.shape[0] > 1: vPi1[1:4, :] += vPi2[1:4, :]
Expand Down
2 changes: 1 addition & 1 deletion pyscf/mcpdft/xmspdft.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def safock_energy(mc, **kwargs):
'''
dsa_fock = np.zeros(
int(mc.fcisolver.nroots * (mc.fcisolver.nroots - 1) / 2))
# TODO fix, this redundacy...no need to compute fock matrix twice..
# TODO fix, this redundancy...no need to compute fock matrix twice..
e_states, _ = diagonalize_safock(mc)

return np.dot(e_states, mc.weights), dsa_fock, None
Expand Down
2 changes: 1 addition & 1 deletion pyscf/prop/dip_moment/test/test_mcpdft_pdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_mc_ref (mol, ri=False, sa2=False):
# ref = ref.reshape (2,2,4,3)[int(ri)]
# else:
# ref = np.load (os.path.join (topdir, 'h2co_tpbe66_631g_grad_num.npy'))[int(ri)]
#this refernce is obtained by mcpdft numerical differentiation in pyscf
#this reference is obtained by mcpdft numerical differentiation in pyscf
#using central differences with a second order accuracy and step size of 1e-4
ref = np.load (os.path.join (topdir, 'h2co_tpbe66_631g_edipole_num.npy'))[int(ri)]
return mc.run (), ref
Expand Down

0 comments on commit 5b2f8a8

Please sign in to comment.