pyscf 2.6.2__py3-none-macosx_11_0_arm64.whl → 2.7.0__py3-none-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyscf/__init__.py +2 -2
- pyscf/adc/__init__.py +3 -8
- pyscf/adc/dfadc.py +22 -6
- pyscf/adc/radc.py +106 -15
- pyscf/adc/radc_amplitudes.py +7 -1
- pyscf/adc/radc_ao2mo.py +4 -2
- pyscf/adc/radc_ea.py +524 -8
- pyscf/adc/radc_ip.py +492 -60
- pyscf/adc/radc_ip_cvs.py +4 -2
- pyscf/adc/uadc.py +116 -27
- pyscf/adc/uadc_amplitudes.py +215 -20
- pyscf/adc/uadc_ao2mo.py +30 -9
- pyscf/adc/uadc_ea.py +34 -44
- pyscf/adc/uadc_ip.py +9 -4
- pyscf/adc/uadc_ip_cvs.py +4 -1
- pyscf/agf2/__init__.py +2 -2
- pyscf/agf2/aux_space.py +1 -1
- pyscf/agf2/chkfile.py +1 -1
- pyscf/ao2mo/outcore.py +6 -4
- pyscf/cc/__init__.py +21 -3
- pyscf/cc/bccd.py +0 -46
- pyscf/cc/ccsd.py +16 -8
- pyscf/cc/uccsd.py +1 -1
- pyscf/data/elements.py +1 -1
- pyscf/df/__init__.py +2 -1
- pyscf/df/addons.py +79 -51
- pyscf/df/autoaux.py +191 -0
- pyscf/df/df.py +5 -1
- pyscf/df/grad/casscf.py +0 -41
- pyscf/df/hessian/rhf.py +2 -10
- pyscf/df/hessian/rks.py +1 -7
- pyscf/df/hessian/uhf.py +3 -13
- pyscf/df/hessian/uks.py +1 -8
- pyscf/df/incore.py +17 -5
- pyscf/dft/dks.py +1 -1
- pyscf/dft/libxc.py +65 -639
- pyscf/dft/numint.py +7 -3
- pyscf/dft/radi.py +39 -5
- pyscf/dft/rks.py +1 -1
- pyscf/dft/xc_deriv.py +1 -1
- pyscf/dft/xcfun.py +53 -2
- pyscf/eph/eph_fd.py +1 -1
- pyscf/eph/rhf.py +6 -36
- pyscf/eph/rks.py +0 -4
- pyscf/eph/uhf.py +1 -7
- pyscf/eph/uks.py +1 -7
- pyscf/fci/addons.py +117 -2
- pyscf/fci/cistring.py +1 -1
- pyscf/fci/direct_nosym.py +3 -3
- pyscf/fci/direct_spin0_symm.py +22 -43
- pyscf/fci/direct_spin1.py +65 -9
- pyscf/fci/direct_spin1_symm.py +49 -14
- pyscf/fci/direct_uhf.py +4 -4
- pyscf/fci/selected_ci_symm.py +1 -1
- pyscf/grad/lagrange.py +11 -3
- pyscf/grad/mp2.py +1 -1
- pyscf/grad/sacasscf.py +1 -1
- pyscf/grad/tdrks.py +1 -1
- pyscf/gto/basis/__init__.py +7 -0
- pyscf/gto/basis/bse.py +68 -15
- pyscf/gto/basis/parse_cp2k_pp.py +1 -1
- pyscf/gto/basis/parse_nwchem.py +1 -1
- pyscf/gto/basis/parse_nwchem_ecp.py +2 -1
- pyscf/gto/basis/sap_grasp_large.dat +2438 -0
- pyscf/gto/basis/sap_grasp_small.dat +1434 -0
- pyscf/gto/mole.py +99 -44
- pyscf/gw/gw_ac.py +2 -2
- pyscf/gw/gw_cd.py +2 -2
- pyscf/gw/rpa.py +2 -2
- pyscf/gw/ugw_ac.py +2 -2
- pyscf/gw/urpa.py +1 -1
- pyscf/hessian/rhf.py +30 -128
- pyscf/hessian/rks.py +1 -6
- pyscf/hessian/uhf.py +28 -138
- pyscf/hessian/uks.py +1 -8
- pyscf/lib/ao2mo/nr_ao2mo.c +1 -1
- pyscf/lib/ao2mo/nrr_ao2mo.c +1 -1
- pyscf/lib/ao2mo/r_ao2mo.c +1 -1
- pyscf/lib/cc/ccsd_pack.c +1 -1
- pyscf/lib/cc/ccsd_t.c +6 -6
- pyscf/lib/cc/uccsd_t.c +4 -4
- pyscf/lib/deps/include/XCFun/XCFunExport.h +1 -0
- pyscf/lib/dft/grid_common.c +1 -1
- pyscf/lib/dft/libxc_itrf.c +4 -1
- pyscf/lib/dft/xcfun_itrf.c +1 -1
- pyscf/lib/diis.py +1 -1
- pyscf/lib/exceptions.py +3 -0
- pyscf/lib/gto/fill_grids_int2c.c +11 -9
- pyscf/lib/gto/fill_int2e.c +7 -5
- pyscf/lib/gto/fill_r_4c.c +1 -1
- pyscf/lib/gto/ft_ao.c +1 -1
- pyscf/lib/gto/ft_ao.h +1 -1
- pyscf/lib/gto/gto.h +2 -2
- pyscf/lib/gto/nr_ecp.c +3 -2
- pyscf/lib/libagf2.dylib +0 -0
- pyscf/lib/libao2mo.dylib +0 -0
- pyscf/lib/libcc.dylib +0 -0
- pyscf/lib/libcgto.dylib +0 -0
- pyscf/lib/libcvhf.dylib +0 -0
- pyscf/lib/libdft.dylib +0 -0
- pyscf/lib/libfci.dylib +0 -0
- pyscf/lib/libmcscf.dylib +0 -0
- pyscf/lib/libnp_helper.dylib +0 -0
- pyscf/lib/libpbc.dylib +0 -0
- pyscf/lib/libri.dylib +0 -0
- pyscf/lib/libxc_itrf.dylib +0 -0
- pyscf/lib/libxcfun_itrf.dylib +0 -0
- pyscf/lib/linalg_helper.py +112 -192
- pyscf/lib/mcscf/fci_contract.c +2 -2
- pyscf/lib/misc.py +47 -14
- pyscf/lib/numpy_helper.py +1 -1
- pyscf/lib/pbc/nr_ecp.c +10 -3
- pyscf/lib/pbc/pbc.h +1 -1
- pyscf/lib/vhf/nr_sgx_direct.c +8 -6
- pyscf/lib/vhf/optimizer.c +2 -2
- pyscf/lo/iao.py +1 -1
- pyscf/lo/ibo.py +3 -3
- pyscf/lo/pipek_jacobi.py +1 -1
- pyscf/mcscf/__init__.py +2 -2
- pyscf/mcscf/addons.py +3 -3
- pyscf/mcscf/apc.py +2 -2
- pyscf/mcscf/casci.py +8 -6
- pyscf/mcscf/chkfile.py +70 -41
- pyscf/mcscf/dmet_cas.py +2 -2
- pyscf/mcscf/mc1step.py +62 -38
- pyscf/mcscf/newton_casscf.py +5 -5
- pyscf/mcscf/ucasci.py +1 -1
- pyscf/mcscf/umc1step.py +44 -25
- pyscf/md/integrators.py +3 -3
- pyscf/mp/mp2.py +6 -5
- pyscf/mp/ump2.py +7 -6
- pyscf/pbc/adc/kadc_rhf.py +1 -1
- pyscf/pbc/adc/kadc_rhf_amplitudes.py +2 -2
- pyscf/pbc/ao2mo/eris.py +1 -1
- pyscf/pbc/cc/kccsd_rhf.py +3 -3
- pyscf/pbc/cc/kccsd_t_rhf.py +2 -2
- pyscf/pbc/ci/kcis_rhf.py +2 -2
- pyscf/pbc/df/aft.py +2 -2
- pyscf/pbc/df/aft_ao2mo.py +1 -1
- pyscf/pbc/df/df.py +84 -11
- pyscf/pbc/df/df_jk.py +2 -1
- pyscf/pbc/df/fft.py +6 -2
- pyscf/pbc/df/fft_ao2mo.py +4 -0
- pyscf/pbc/df/fft_jk.py +11 -3
- pyscf/pbc/df/ft_ao.py +4 -3
- pyscf/pbc/df/gdf_builder.py +5 -4
- pyscf/pbc/df/incore.py +1 -1
- pyscf/pbc/df/mdf.py +6 -3
- pyscf/pbc/df/rsdf.py +2 -2
- pyscf/pbc/df/rsdf_builder.py +11 -6
- pyscf/pbc/df/rsdf_helper.py +1 -1
- pyscf/pbc/dft/cdft.py +5 -5
- pyscf/pbc/dft/multigrid/multigrid.py +19 -26
- pyscf/pbc/dft/multigrid/multigrid_pair.py +1 -1
- pyscf/pbc/dft/multigrid/pp.py +1 -1
- pyscf/pbc/dft/numint.py +30 -21
- pyscf/pbc/eph/eph_fd.py +1 -1
- pyscf/pbc/geomopt/geometric_solver.py +1 -1
- pyscf/pbc/gto/cell.py +37 -19
- pyscf/pbc/gto/ecp.py +12 -12
- pyscf/pbc/gto/eval_gto.py +2 -2
- pyscf/pbc/gto/pseudo/pp.py +1 -1
- pyscf/pbc/gw/krgw_ac.py +4 -4
- pyscf/pbc/gw/krgw_cd.py +4 -4
- pyscf/pbc/gw/kugw_ac.py +3 -3
- pyscf/pbc/lib/kpts_helper.py +4 -3
- pyscf/pbc/lib/linalg_helper.py +1 -1
- pyscf/pbc/mp/kmp2.py +1 -1
- pyscf/pbc/mpitools/mpi.py +1 -1
- pyscf/pbc/scf/addons.py +15 -11
- pyscf/pbc/scf/cphf.py +1 -1
- pyscf/pbc/scf/ghf.py +1 -1
- pyscf/pbc/scf/hf.py +21 -24
- pyscf/pbc/scf/kghf.py +33 -29
- pyscf/pbc/scf/khf.py +71 -26
- pyscf/pbc/scf/krohf.py +5 -7
- pyscf/pbc/scf/kuhf.py +53 -22
- pyscf/pbc/scf/rsjk.py +13 -9
- pyscf/pbc/scf/scfint.py +1 -1
- pyscf/pbc/scf/stability.py +1 -1
- pyscf/pbc/scf/uhf.py +3 -1
- pyscf/pbc/symm/symmetry.py +2 -2
- pyscf/pbc/tdscf/kproxy.py +1 -1
- pyscf/pbc/tdscf/kproxy_supercell.py +2 -2
- pyscf/pbc/tdscf/krhf.py +215 -133
- pyscf/pbc/tdscf/krhf_slow_supercell.py +1 -1
- pyscf/pbc/tdscf/krks.py +1 -45
- pyscf/pbc/tdscf/kuhf.py +58 -105
- pyscf/pbc/tdscf/kuks.py +0 -56
- pyscf/pbc/tdscf/proxy.py +1 -1
- pyscf/pbc/tdscf/rhf.py +111 -3
- pyscf/pbc/tdscf/rks.py +2 -1
- pyscf/pbc/tdscf/uhf.py +203 -1
- pyscf/pbc/tdscf/uks.py +2 -1
- pyscf/pbc/tools/k2gamma.py +7 -4
- pyscf/pbc/tools/pbc.py +63 -56
- pyscf/pbc/tools/pyscf_ase.py +0 -1
- pyscf/pbc/tools/pywannier90.py +1 -1
- pyscf/qmmm/mm_mole.py +1 -1
- pyscf/scf/_response_functions.py +2 -2
- pyscf/scf/_vhf.py +14 -10
- pyscf/scf/addons.py +29 -15
- pyscf/scf/cphf.py +14 -52
- pyscf/scf/dhf.py +39 -10
- pyscf/scf/dispersion.py +9 -8
- pyscf/scf/ghf.py +25 -13
- pyscf/scf/ghf_symm.py +2 -2
- pyscf/scf/hf.py +245 -29
- pyscf/scf/rohf.py +37 -5
- pyscf/scf/stability.py +142 -112
- pyscf/scf/ucphf.py +21 -16
- pyscf/scf/uhf.py +95 -58
- pyscf/sgx/sgx.py +1 -1
- pyscf/sgx/sgx_jk.py +4 -4
- pyscf/solvent/_ddcosmo_tdscf_grad.py +1 -1
- pyscf/solvent/ddcosmo.py +1 -1
- pyscf/solvent/pol_embed.py +1 -1
- pyscf/soscf/ciah.py +1 -1
- pyscf/soscf/newton_ah.py +1 -1
- pyscf/symm/__init__.py +1 -1
- pyscf/symm/addons.py +5 -5
- pyscf/tdscf/_lr_eig.py +505 -0
- pyscf/tdscf/common_slow.py +1 -1
- pyscf/tdscf/dhf.py +41 -37
- pyscf/tdscf/dks.py +0 -4
- pyscf/tdscf/ghf.py +91 -71
- pyscf/tdscf/gks.py +16 -16
- pyscf/tdscf/proxy.py +2 -2
- pyscf/tdscf/rhf.py +143 -96
- pyscf/tdscf/rks.py +15 -14
- pyscf/tdscf/uhf.py +117 -70
- pyscf/tdscf/uks.py +17 -18
- pyscf/tools/fcidump.py +3 -0
- pyscf/x2c/sfx2c1e.py +1 -1
- pyscf/x2c/tdscf.py +4 -4
- pyscf/x2c/x2c.py +15 -11
- {pyscf-2.6.2.dist-info → pyscf-2.7.0.dist-info}/METADATA +24 -24
- {pyscf-2.6.2.dist-info → pyscf-2.7.0.dist-info}/NOTICE +3 -1
- {pyscf-2.6.2.dist-info → pyscf-2.7.0.dist-info}/RECORD +242 -240
- {pyscf-2.6.2.dist-info → pyscf-2.7.0.dist-info}/WHEEL +1 -1
- pyscf/dft/gen_libxc_param.py +0 -35
- pyscf/dft/gen_xcfun_param.py +0 -209
- {pyscf-2.6.2.dist-info → pyscf-2.7.0.dist-info}/LICENSE +0 -0
- {pyscf-2.6.2.dist-info → pyscf-2.7.0.dist-info}/top_level.txt +0 -0
pyscf/gto/mole.py
CHANGED
|
@@ -319,7 +319,7 @@ def format_atom(atoms, origin=0, axes=None,
|
|
|
319
319
|
coordinates to AU, rotate and shift the molecule.
|
|
320
320
|
If the :attr:`~Mole.atom` is a string, it takes ";" and "\\n"
|
|
321
321
|
for the mark to separate atoms; "," and arbitrary length of blank space
|
|
322
|
-
to
|
|
322
|
+
to separate the individual terms for an atom. Blank line will be ignored.
|
|
323
323
|
|
|
324
324
|
Args:
|
|
325
325
|
atoms : list or str
|
|
@@ -459,7 +459,7 @@ def format_basis(basis_tab, sort_basis=True):
|
|
|
459
459
|
if len(_basis) == 0:
|
|
460
460
|
raise BasisNotFoundError('Basis not found for %s' % symb)
|
|
461
461
|
|
|
462
|
-
# Sort basis
|
|
462
|
+
# Sort basis according to angular momentum. This is important for method
|
|
463
463
|
# decontract_basis, which assumes that basis functions with the same
|
|
464
464
|
# angular momentum are grouped together. Related to issue #1620 #1770
|
|
465
465
|
if sort_basis:
|
|
@@ -497,7 +497,7 @@ def _generate_basis_converter():
|
|
|
497
497
|
_basis = load(raw_basis, _std_symbol_without_ghost(symb))
|
|
498
498
|
elif (any(isinstance(x, str) for x in raw_basis)
|
|
499
499
|
# The first element is the basis of internal format
|
|
500
|
-
or not isinstance(raw_basis[0][0], int)):
|
|
500
|
+
or not isinstance(raw_basis[0][0], (numpy.integer, int))):
|
|
501
501
|
stdsymb = _std_symbol_without_ghost(symb)
|
|
502
502
|
_basis = []
|
|
503
503
|
for rawb in raw_basis:
|
|
@@ -572,7 +572,7 @@ def to_uncontracted_cartesian_basis(mol):
|
|
|
572
572
|
'''
|
|
573
573
|
return decontract_basis(mol, to_cart=True)
|
|
574
574
|
|
|
575
|
-
def decontract_basis(mol, atoms=None, to_cart=False):
|
|
575
|
+
def decontract_basis(mol, atoms=None, to_cart=False, aggregate=False):
|
|
576
576
|
'''Decontract the basis of a Mole or a Cell. Returns a Mole (Cell) object
|
|
577
577
|
with the uncontracted basis environment and a list of coefficients that
|
|
578
578
|
transform the uncontracted basis to the original basis. Each element in
|
|
@@ -584,6 +584,9 @@ def decontract_basis(mol, atoms=None, to_cart=False):
|
|
|
584
584
|
are decontracted
|
|
585
585
|
to_cart: bool
|
|
586
586
|
Decontract basis and transfer to Cartesian basis
|
|
587
|
+
aggregate: bool
|
|
588
|
+
Whether to aggregate the transformation coefficients into a giant
|
|
589
|
+
transformation matrix
|
|
587
590
|
|
|
588
591
|
Examples:
|
|
589
592
|
|
|
@@ -602,17 +605,27 @@ def decontract_basis(mol, atoms=None, to_cart=False):
|
|
|
602
605
|
bas_exps = mol.bas_exps()
|
|
603
606
|
def _to_full_contraction(mol, bas_idx):
|
|
604
607
|
es = numpy.hstack([bas_exps[i] for i in bas_idx])
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
608
|
+
_, e_idx, rev_idx = numpy.unique(es.round(9), True, True)
|
|
609
|
+
if aggregate:
|
|
610
|
+
cs = scipy.linalg.block_diag(
|
|
611
|
+
*[mol._libcint_ctr_coeff(i) for i in bas_idx])
|
|
612
|
+
if len(es) != len(e_idx):
|
|
613
|
+
cs_new = numpy.zeros((e_idx.size, cs.shape[1]))
|
|
614
|
+
for i, j in enumerate(rev_idx):
|
|
615
|
+
cs_new[j] += cs[i]
|
|
616
|
+
es = es[e_idx][::-1]
|
|
617
|
+
cs = cs_new[::-1]
|
|
618
|
+
yield es, cs
|
|
619
|
+
else:
|
|
620
|
+
if len(es) != len(e_idx):
|
|
621
|
+
raise RuntimeError('Duplicated pGTOs across shells')
|
|
622
|
+
for i in bas_idx:
|
|
623
|
+
yield bas_exps[i], mol._libcint_ctr_coeff(i)
|
|
612
624
|
|
|
613
625
|
_bas = []
|
|
614
|
-
|
|
626
|
+
env = [mol._env.copy()]
|
|
615
627
|
contr_coeff = []
|
|
628
|
+
pexp = env[0].size
|
|
616
629
|
|
|
617
630
|
lmax = mol._bas[:,ANG_OF].max()
|
|
618
631
|
if mol.cart:
|
|
@@ -648,7 +661,7 @@ def decontract_basis(mol, atoms=None, to_cart=False):
|
|
|
648
661
|
continue
|
|
649
662
|
|
|
650
663
|
lmax = mol._bas[ib0:ib1,ANG_OF].max()
|
|
651
|
-
|
|
664
|
+
|
|
652
665
|
for l in range(lmax+1):
|
|
653
666
|
bas_idx = ib0 + numpy.where(mol._bas[ib0:ib1,ANG_OF] == l)[0]
|
|
654
667
|
if len(bas_idx) == 0:
|
|
@@ -656,30 +669,27 @@ def decontract_basis(mol, atoms=None, to_cart=False):
|
|
|
656
669
|
if bas_idx[0] + len(bas_idx) != bas_idx[-1] + 1:
|
|
657
670
|
raise NotImplementedError('Discontinuous bases of same angular momentum')
|
|
658
671
|
|
|
659
|
-
mol_exps, b_coeff
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
norm = gto_norm(l, mol_exps)
|
|
666
|
-
if atoms is None:
|
|
672
|
+
for mol_exps, b_coeff in _to_full_contraction(mol, bas_idx):
|
|
673
|
+
nprim, nc = b_coeff.shape
|
|
674
|
+
bs = numpy.zeros((nprim, BAS_SLOTS), dtype=numpy.int32)
|
|
675
|
+
bs[:,ATOM_OF] = ia
|
|
676
|
+
bs[:,ANG_OF ] = l
|
|
677
|
+
bs[:,NCTR_OF] = bs[:,NPRIM_OF] = 1
|
|
667
678
|
bs[:,PTR_EXP] = pexp + numpy.arange(nprim)
|
|
668
679
|
bs[:,PTR_COEFF] = pexp + numpy.arange(nprim, nprim*2)
|
|
669
|
-
|
|
670
|
-
|
|
680
|
+
norm = gto_norm(l, mol_exps)
|
|
681
|
+
env.append(mol_exps)
|
|
682
|
+
env.append(norm)
|
|
671
683
|
pexp += nprim * 2
|
|
672
|
-
|
|
673
|
-
bs[:,PTR_EXP] = _env.size + numpy.arange(nprim)
|
|
674
|
-
bs[:,PTR_COEFF] = _env.size + numpy.arange(nprim, nprim*2)
|
|
675
|
-
_env = np.hstack([_env, mol_exps, norm])
|
|
676
|
-
_bas.append(bs)
|
|
684
|
+
_bas.append(bs)
|
|
677
685
|
|
|
678
|
-
|
|
679
|
-
|
|
686
|
+
c = numpy.einsum('pi,p,xm->pxim', b_coeff, 1./norm, c2s[l])
|
|
687
|
+
contr_coeff.append(c.reshape(nprim * c2s[l].shape[0], -1))
|
|
680
688
|
|
|
681
689
|
pmol._bas = numpy.asarray(numpy.vstack(_bas), dtype=numpy.int32)
|
|
682
|
-
pmol._env =
|
|
690
|
+
pmol._env = numpy.hstack(env)
|
|
691
|
+
if aggregate:
|
|
692
|
+
contr_coeff = scipy.linalg.block_diag(*contr_coeff)
|
|
683
693
|
return pmol, contr_coeff
|
|
684
694
|
|
|
685
695
|
def format_ecp(ecp_tab):
|
|
@@ -1244,12 +1254,12 @@ def unpack(moldic):
|
|
|
1244
1254
|
def dumps(mol):
|
|
1245
1255
|
'''Serialize Mole object to a JSON formatted str.
|
|
1246
1256
|
'''
|
|
1247
|
-
exclude_keys = {'output', 'stdout', '_keys',
|
|
1248
|
-
|
|
1249
|
-
|
|
1257
|
+
exclude_keys = {'output', 'stdout', '_keys', '_ctx_lock',
|
|
1258
|
+
# Constructing in function loads
|
|
1259
|
+
'symm_orb', 'irrep_id', 'irrep_name'}
|
|
1250
1260
|
# FIXME: nparray and kpts for cell objects may need to be excluded
|
|
1251
1261
|
nparray_keys = {'_atm', '_bas', '_env', '_ecpbas',
|
|
1252
|
-
|
|
1262
|
+
'_symm_orig', '_symm_axes'}
|
|
1253
1263
|
|
|
1254
1264
|
moldic = dict(mol.__dict__)
|
|
1255
1265
|
for k in exclude_keys:
|
|
@@ -1961,7 +1971,7 @@ def same_mol(mol1, mol2, tol=1e-5, cmp_basis=True, ignore_chiral=False):
|
|
|
1961
1971
|
is_same_mol = same_mol
|
|
1962
1972
|
|
|
1963
1973
|
def chiral_mol(mol1, mol2=None):
|
|
1964
|
-
'''Detect whether the given
|
|
1974
|
+
'''Detect whether the given molecule is chiral molecule or two molecules
|
|
1965
1975
|
are chiral isomers.
|
|
1966
1976
|
'''
|
|
1967
1977
|
if mol2 is None:
|
|
@@ -2197,7 +2207,7 @@ class MoleBase(lib.StreamObject):
|
|
|
2197
2207
|
subgroup
|
|
2198
2208
|
|
|
2199
2209
|
atom : list or str
|
|
2200
|
-
To define
|
|
2210
|
+
To define molecular structure. The internal format is
|
|
2201
2211
|
|
|
2202
2212
|
| atom = [[atom1, (x, y, z)],
|
|
2203
2213
|
| [atom2, (x, y, z)],
|
|
@@ -2457,7 +2467,7 @@ class MoleBase(lib.StreamObject):
|
|
|
2457
2467
|
atom=None, basis=None, unit=None, nucmod=None, ecp=None, pseudo=None,
|
|
2458
2468
|
charge=None, spin=0, symmetry=None, symmetry_subgroup=None,
|
|
2459
2469
|
cart=None, magmom=None):
|
|
2460
|
-
'''Setup
|
|
2470
|
+
'''Setup molecule and initialize some control parameters. Whenever you
|
|
2461
2471
|
change the value of the attributes of :class:`Mole`, you need call
|
|
2462
2472
|
this function to refresh the internal data of Mole.
|
|
2463
2473
|
|
|
@@ -2473,7 +2483,7 @@ class MoleBase(lib.StreamObject):
|
|
|
2473
2483
|
max_memory : int, float
|
|
2474
2484
|
Allowd memory in MB. If given, overwrite :attr:`Mole.max_memory`
|
|
2475
2485
|
atom : list or str
|
|
2476
|
-
To define
|
|
2486
|
+
To define molecular structure.
|
|
2477
2487
|
basis : dict or str
|
|
2478
2488
|
To define basis set.
|
|
2479
2489
|
nucmod : dict or str
|
|
@@ -2750,7 +2760,7 @@ class MoleBase(lib.StreamObject):
|
|
|
2750
2760
|
' X Y Z unit Magmom\n')
|
|
2751
2761
|
for ia,atom in enumerate(self._atom):
|
|
2752
2762
|
coorda = tuple([x * param.BOHR for x in atom[1]])
|
|
2753
|
-
coordb = tuple(
|
|
2763
|
+
coordb = tuple(atom[1])
|
|
2754
2764
|
magmom = self.magmom[ia]
|
|
2755
2765
|
self.stdout.write('[INPUT]%3d %-4s %16.12f %16.12f %16.12f AA '
|
|
2756
2766
|
'%16.12f %16.12f %16.12f Bohr %4.1f\n'
|
|
@@ -3070,7 +3080,7 @@ class MoleBase(lib.StreamObject):
|
|
|
3070
3080
|
logger.info(mol, 'New geometry')
|
|
3071
3081
|
for ia, atom in enumerate(mol._atom):
|
|
3072
3082
|
coorda = tuple([x * param.BOHR for x in atom[1]])
|
|
3073
|
-
coordb = tuple(
|
|
3083
|
+
coordb = tuple(atom[1])
|
|
3074
3084
|
coords = coorda + coordb
|
|
3075
3085
|
logger.info(mol, ' %3d %-4s %16.12f %16.12f %16.12f AA '
|
|
3076
3086
|
'%16.12f %16.12f %16.12f Bohr\n',
|
|
@@ -3431,6 +3441,11 @@ class MoleBase(lib.StreamObject):
|
|
|
3431
3441
|
| 1 : hermitian
|
|
3432
3442
|
| 2 : anti-hermitian
|
|
3433
3443
|
|
|
3444
|
+
shls_slice : 4-element, 6-element or 8-element tuple
|
|
3445
|
+
Label the start-stop shells for each index in the integral.
|
|
3446
|
+
For example, the 8-element tuple for the 2-electron integral
|
|
3447
|
+
tensor (ij|kl) = intor('int2e') are specified as
|
|
3448
|
+
(ish_start, ish_end, jsh_start, jsh_end, ksh_start, ksh_end, lsh_start, lsh_end)
|
|
3434
3449
|
grids : ndarray
|
|
3435
3450
|
Coordinates of grids for the int1e_grids integrals
|
|
3436
3451
|
|
|
@@ -3748,7 +3763,7 @@ class Mole(MoleBase):
|
|
|
3748
3763
|
def ao2mo(self, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e',
|
|
3749
3764
|
**kwargs):
|
|
3750
3765
|
'''Integral transformation for arbitrary orbitals and arbitrary
|
|
3751
|
-
integrals. See more
|
|
3766
|
+
integrals. See more detailed documentation in func:`ao2mo.kernel`.
|
|
3752
3767
|
|
|
3753
3768
|
Args:
|
|
3754
3769
|
mo_coeffs (an np array or a list of arrays) : A matrix of orbital
|
|
@@ -3800,7 +3815,7 @@ class Mole(MoleBase):
|
|
|
3800
3815
|
return ao2mo.kernel(self, mo_coeffs, erifile, dataname, intor, **kwargs)
|
|
3801
3816
|
|
|
3802
3817
|
def to_cell(self, a, dimension=3):
|
|
3803
|
-
'''Put a molecule in a cell with periodic boundary
|
|
3818
|
+
'''Put a molecule in a cell with periodic boundary conditions
|
|
3804
3819
|
|
|
3805
3820
|
Args:
|
|
3806
3821
|
a : (3,3) ndarray
|
|
@@ -4054,7 +4069,7 @@ def fakemol_for_charges(coords, expnt=1e16):
|
|
|
4054
4069
|
# approximate point charge with gaussian distribution exp(-1e16*r^2)
|
|
4055
4070
|
fakebas[:,PTR_EXP] = ptr
|
|
4056
4071
|
fakebas[:,PTR_COEFF] = ptr+1
|
|
4057
|
-
fakeenv.append([expnt, 1/(2*numpy.sqrt(numpy.pi)*gaussian_int(2,expnt))])
|
|
4072
|
+
fakeenv.append([expnt, 1 / (2*numpy.sqrt(numpy.pi)*gaussian_int(2,expnt))])
|
|
4058
4073
|
ptr += 2
|
|
4059
4074
|
else:
|
|
4060
4075
|
assert expnt.size == nbas
|
|
@@ -4071,6 +4086,46 @@ def fakemol_for_charges(coords, expnt=1e16):
|
|
|
4071
4086
|
fakemol._built = True
|
|
4072
4087
|
return fakemol
|
|
4073
4088
|
|
|
4089
|
+
def fakemol_for_cgtf_charge(coord, expnt=1e16, contr_coeff=1):
|
|
4090
|
+
'''Constructs a "fake" Mole object that has a Gaussian charge
|
|
4091
|
+
distribution at the specified coordinate (coord). The charge
|
|
4092
|
+
can be given as a linear combination of Gaussians with
|
|
4093
|
+
exponents expnt and contraction coefficients contr_coeff.
|
|
4094
|
+
'''
|
|
4095
|
+
assert coord.shape[0] == 1
|
|
4096
|
+
expnt = numpy.asarray(expnt).ravel()
|
|
4097
|
+
contr_coeff = numpy.asarray(contr_coeff).ravel()
|
|
4098
|
+
|
|
4099
|
+
fakeatm = numpy.zeros((1,ATM_SLOTS), dtype=numpy.int32)
|
|
4100
|
+
fakebas = numpy.zeros((1,BAS_SLOTS), dtype=numpy.int32)
|
|
4101
|
+
fakeenv = [0] * PTR_ENV_START
|
|
4102
|
+
ptr = PTR_ENV_START
|
|
4103
|
+
fakeatm[:,PTR_COORD] = numpy.arange(ptr, ptr+3, 3)
|
|
4104
|
+
fakeenv.append(coord.ravel())
|
|
4105
|
+
ptr += 3
|
|
4106
|
+
fakebas[:,ATOM_OF] = 0#numpy.arange(nbas)
|
|
4107
|
+
fakebas[:,NPRIM_OF] = contr_coeff.size
|
|
4108
|
+
fakebas[:,NCTR_OF] = 1
|
|
4109
|
+
if expnt.size == 1:
|
|
4110
|
+
expnt = expnt[0]
|
|
4111
|
+
fakebas[:,PTR_EXP] = ptr
|
|
4112
|
+
fakebas[:,PTR_COEFF] = ptr+1
|
|
4113
|
+
fakeenv.append([expnt, 1 / (2*numpy.sqrt(numpy.pi)*gaussian_int(2,expnt))])
|
|
4114
|
+
ptr += 2
|
|
4115
|
+
else:
|
|
4116
|
+
assert expnt.size == contr_coeff.size
|
|
4117
|
+
fakebas[:,PTR_EXP] = ptr
|
|
4118
|
+
fakebas[:,PTR_COEFF] = ptr + contr_coeff.size
|
|
4119
|
+
coeff = contr_coeff / (2 * numpy.sqrt(numpy.pi) * gaussian_int(2, expnt))
|
|
4120
|
+
fakeenv.append(numpy.vstack((expnt, coeff)).ravel())
|
|
4121
|
+
|
|
4122
|
+
fakemol = Mole()
|
|
4123
|
+
fakemol._atm = fakeatm
|
|
4124
|
+
fakemol._bas = fakebas
|
|
4125
|
+
fakemol._env = numpy.hstack(fakeenv)
|
|
4126
|
+
fakemol._built = True
|
|
4127
|
+
return fakemol
|
|
4128
|
+
|
|
4074
4129
|
def classify_ecp_pseudo(mol, ecp, pp):
|
|
4075
4130
|
'''
|
|
4076
4131
|
Check whether ecp keywords are presented in pp and whether pp keywords are
|
pyscf/gw/gw_ac.py
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
Spin-restricted G0W0 approximation with analytic continuation
|
|
21
21
|
This implementation has N^4 scaling, and is faster than GW-CD (N^4)
|
|
22
22
|
and analytic GW (N^6) methods.
|
|
23
|
-
GW-AC is recommended for valence states only, and is
|
|
23
|
+
GW-AC is recommended for valence states only, and is inaccurate for core states.
|
|
24
24
|
|
|
25
25
|
Method:
|
|
26
26
|
See T. Zhu and G.K.-L. Chan, arxiv:2007.03148 (2020) for details
|
|
@@ -230,7 +230,7 @@ def _get_scaled_legendre_roots(nw):
|
|
|
230
230
|
|
|
231
231
|
def _get_clenshaw_curtis_roots(nw):
|
|
232
232
|
"""
|
|
233
|
-
Clenshaw-Curtis
|
|
233
|
+
Clenshaw-Curtis quadrature on [0,inf)
|
|
234
234
|
Ref: J. Chem. Phys. 132, 234114 (2010)
|
|
235
235
|
Returns:
|
|
236
236
|
freqs : 1D ndarray
|
pyscf/gw/gw_cd.py
CHANGED
|
@@ -192,7 +192,7 @@ def get_rho_response_R(gw, omega, Lpq):
|
|
|
192
192
|
|
|
193
193
|
def get_sigmaR_diag(gw, omega, orbp, ef, Lpq):
|
|
194
194
|
'''
|
|
195
|
-
Compute self-energy for poles inside
|
|
195
|
+
Compute self-energy for poles inside contour
|
|
196
196
|
(more and more expensive away from Fermi surface)
|
|
197
197
|
'''
|
|
198
198
|
mo_energy = gw._scf.mo_energy
|
|
@@ -234,7 +234,7 @@ def _get_scaled_legendre_roots(nw):
|
|
|
234
234
|
|
|
235
235
|
def _get_clenshaw_curtis_roots(nw):
|
|
236
236
|
"""
|
|
237
|
-
Clenshaw-Curtis
|
|
237
|
+
Clenshaw-Curtis quadrature on [0,inf)
|
|
238
238
|
Ref: J. Chem. Phys. 132, 234114 (2010)
|
|
239
239
|
Returns:
|
|
240
240
|
freqs : 1D ndarray
|
pyscf/gw/rpa.py
CHANGED
|
@@ -21,7 +21,7 @@ Spin-restricted random phase approximation (direct RPA/dRPA in chemistry)
|
|
|
21
21
|
with N^4 scaling
|
|
22
22
|
|
|
23
23
|
Method:
|
|
24
|
-
Main routines are based on GW-AC method
|
|
24
|
+
Main routines are based on GW-AC method described in:
|
|
25
25
|
T. Zhu and G.K.-L. Chan, J. Chem. Theory. Comput. 17, 727-741 (2021)
|
|
26
26
|
X. Ren et al., New J. Phys. 14, 053020 (2012)
|
|
27
27
|
"""
|
|
@@ -172,7 +172,7 @@ def _get_scaled_legendre_roots(nw, x0=0.5):
|
|
|
172
172
|
|
|
173
173
|
def _get_clenshaw_curtis_roots(nw):
|
|
174
174
|
"""
|
|
175
|
-
Clenshaw-Curtis
|
|
175
|
+
Clenshaw-Curtis quadrature on [0,inf)
|
|
176
176
|
Ref: J. Chem. Phys. 132, 234114 (2010)
|
|
177
177
|
|
|
178
178
|
Returns:
|
pyscf/gw/ugw_ac.py
CHANGED
|
@@ -21,7 +21,7 @@ Spin-unrestricted G0W0 approximation with analytic continuation
|
|
|
21
21
|
|
|
22
22
|
This implementation has N^4 scaling, and is faster than GW-CD (N^4)
|
|
23
23
|
and analytic GW (N^6) methods.
|
|
24
|
-
GW-AC is recommended for valence states only, and is
|
|
24
|
+
GW-AC is recommended for valence states only, and is inaccurate for core states.
|
|
25
25
|
|
|
26
26
|
Method:
|
|
27
27
|
See T. Zhu and G.K.-L. Chan, arxiv:2007.03148 (2020) for details
|
|
@@ -277,7 +277,7 @@ def _get_scaled_legendre_roots(nw):
|
|
|
277
277
|
|
|
278
278
|
def _get_clenshaw_curtis_roots(nw):
|
|
279
279
|
"""
|
|
280
|
-
Clenshaw-Curtis
|
|
280
|
+
Clenshaw-Curtis quadrature on [0,inf)
|
|
281
281
|
Ref: J. Chem. Phys. 132, 234114 (2010)
|
|
282
282
|
Returns:
|
|
283
283
|
freqs : 1D ndarray
|
pyscf/gw/urpa.py
CHANGED
|
@@ -21,7 +21,7 @@ Spin-unrestricted random phase approximation (direct RPA/dRPA in chemistry)
|
|
|
21
21
|
with N^4 scaling
|
|
22
22
|
|
|
23
23
|
Method:
|
|
24
|
-
Main routines are based on GW-AC method
|
|
24
|
+
Main routines are based on GW-AC method described in:
|
|
25
25
|
T. Zhu and G.K.-L. Chan, J. Chem. Theory. Comput. 17, 727-741 (2021)
|
|
26
26
|
X. Ren et al., New J. Phys. 14, 053020 (2012)
|
|
27
27
|
"""
|
pyscf/hessian/rhf.py
CHANGED
|
@@ -53,20 +53,13 @@ def hess_elec(hessobj, mo_energy=None, mo_coeff=None, mo_occ=None,
|
|
|
53
53
|
max_memory, log)
|
|
54
54
|
|
|
55
55
|
if h1ao is None:
|
|
56
|
-
h1ao = hessobj.make_h1(mo_coeff, mo_occ,
|
|
56
|
+
h1ao = hessobj.make_h1(mo_coeff, mo_occ, None, atmlst, log)
|
|
57
57
|
t1 = log.timer_debug1('making H1', *time0)
|
|
58
58
|
if mo1 is None or mo_e1 is None:
|
|
59
59
|
mo1, mo_e1 = hessobj.solve_mo1(mo_energy, mo_coeff, mo_occ, h1ao,
|
|
60
60
|
None, atmlst, max_memory, log)
|
|
61
61
|
t1 = log.timer_debug1('solving MO1', *t1)
|
|
62
62
|
|
|
63
|
-
if isinstance(h1ao, str):
|
|
64
|
-
h1ao = lib.chkfile.load(h1ao, 'scf_f1ao')
|
|
65
|
-
h1ao = {int(k): h1ao[k] for k in h1ao}
|
|
66
|
-
if isinstance(mo1, str):
|
|
67
|
-
mo1 = lib.chkfile.load(mo1, 'scf_mo1')
|
|
68
|
-
mo1 = {int(k): mo1[k] for k in mo1}
|
|
69
|
-
|
|
70
63
|
nao, nmo = mo_coeff.shape
|
|
71
64
|
mocc = mo_coeff[:,mo_occ>0]
|
|
72
65
|
s1a = -mol.intor('int1e_ipovlp', comp=3)
|
|
@@ -136,9 +129,12 @@ def _partial_hess_ejk(hessobj, mo_energy=None, mo_coeff=None, mo_occ=None,
|
|
|
136
129
|
ip1ip2_opt = _make_vhfopt(mol, dm0, 'ip1ip2', 'int2e_ip1ip2')
|
|
137
130
|
ipvip1_opt = _make_vhfopt(mol, dm0, 'ipvip1', 'int2e_ipvip1ipvip2')
|
|
138
131
|
aoslices = mol.aoslice_by_atom()
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
132
|
+
|
|
133
|
+
natm = len(atmlst)
|
|
134
|
+
e1 = numpy.zeros((natm, natm, 3, 3))
|
|
135
|
+
ej = numpy.zeros((natm, natm, 3, 3))
|
|
136
|
+
ek = numpy.zeros((natm, natm, 3, 3))
|
|
137
|
+
|
|
142
138
|
for i0, ia in enumerate(atmlst):
|
|
143
139
|
shl0, shl1, p0, p1 = aoslices[ia]
|
|
144
140
|
shls_slice = (shl0, shl1) + (0, mol.nbas)*3
|
|
@@ -159,24 +155,24 @@ def _partial_hess_ejk(hessobj, mo_energy=None, mo_coeff=None, mo_occ=None,
|
|
|
159
155
|
vk1 = vk1.reshape(3,3,nao,nao)
|
|
160
156
|
t1 = log.timer_debug1('contracting int2e_ipvip1 for atom %d'%ia, *t1)
|
|
161
157
|
|
|
162
|
-
ej[i0,i0] += numpy.einsum('xypq,pq->xy', vj1_diag[:,:,p0:p1], dm0[p0:p1])*2
|
|
163
|
-
ek[i0,i0] += numpy.einsum('xypq,pq->xy', vk1_diag[:,:,p0:p1], dm0[p0:p1])
|
|
164
|
-
e1[i0,i0] -= numpy.einsum('xypq,pq->xy', s1aa[:,:,p0:p1], dme0[p0:p1])*2
|
|
158
|
+
ej[i0, i0] += numpy.einsum('xypq,pq->xy', vj1_diag[:,:,p0:p1], dm0[p0:p1])*2
|
|
159
|
+
ek[i0, i0] += numpy.einsum('xypq,pq->xy', vk1_diag[:,:,p0:p1], dm0[p0:p1])
|
|
160
|
+
e1[i0, i0] -= numpy.einsum('xypq,pq->xy', s1aa[:,:,p0:p1], dme0[p0:p1])*2
|
|
165
161
|
|
|
166
162
|
for j0, ja in enumerate(atmlst[:i0+1]):
|
|
167
163
|
q0, q1 = aoslices[ja][2:]
|
|
168
164
|
# *2 for +c.c.
|
|
169
|
-
ej[i0,j0] += numpy.einsum('xypq,pq->xy', vj1[:,:,q0:q1], dm0[q0:q1])*4
|
|
170
|
-
ek[i0,j0] += numpy.einsum('xypq,pq->xy', vk1[:,:,q0:q1], dm0[q0:q1])
|
|
171
|
-
e1[i0,j0] -= numpy.einsum('xypq,pq->xy', s1ab[:,:,p0:p1,q0:q1], dme0[p0:p1,q0:q1])*2
|
|
165
|
+
ej[i0, j0] += numpy.einsum('xypq,pq->xy', vj1[:,:,q0:q1], dm0[q0:q1])*4
|
|
166
|
+
ek[i0, j0] += numpy.einsum('xypq,pq->xy', vk1[:,:,q0:q1], dm0[q0:q1])
|
|
167
|
+
e1[i0, j0] -= numpy.einsum('xypq,pq->xy', s1ab[:,:,p0:p1,q0:q1], dme0[p0:p1,q0:q1])*2
|
|
172
168
|
|
|
173
169
|
h1ao = hcore_deriv(ia, ja)
|
|
174
|
-
e1[i0,j0] += numpy.einsum('xypq,pq->xy', h1ao, dm0)
|
|
170
|
+
e1[i0, j0] += numpy.einsum('xypq,pq->xy', h1ao, dm0)
|
|
175
171
|
|
|
176
172
|
for j0 in range(i0):
|
|
177
|
-
e1[j0,i0] = e1[i0,j0].T
|
|
178
|
-
ej[j0,i0] = ej[i0,j0].T
|
|
179
|
-
ek[j0,i0] = ek[i0,j0].T
|
|
173
|
+
e1[j0, i0] = e1[i0, j0].T
|
|
174
|
+
ej[j0, i0] = ej[i0, j0].T
|
|
175
|
+
ek[j0, i0] = ek[i0, j0].T
|
|
180
176
|
|
|
181
177
|
log.timer('RHF partial hessian', *time0)
|
|
182
178
|
return e1, ej, ek
|
|
@@ -237,16 +233,8 @@ def make_h1(hessobj, mo_coeff, mo_occ, chkfile=None, atmlst=None, verbose=None):
|
|
|
237
233
|
vhf[:,p0:p1] += vj2 - vk2*.5
|
|
238
234
|
h1 = vhf + vhf.transpose(0,2,1)
|
|
239
235
|
h1 += hcore_deriv(ia)
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
h1ao[ia] = h1
|
|
243
|
-
else:
|
|
244
|
-
key = 'scf_f1ao/%d' % ia
|
|
245
|
-
lib.chkfile.save(chkfile, key, h1)
|
|
246
|
-
if chkfile is None:
|
|
247
|
-
return h1ao
|
|
248
|
-
else:
|
|
249
|
-
return chkfile
|
|
236
|
+
h1ao[ia] = h1
|
|
237
|
+
return h1ao
|
|
250
238
|
|
|
251
239
|
def get_hcore(mol):
|
|
252
240
|
'''Part of the second derivatives of core Hamiltonian'''
|
|
@@ -295,7 +283,7 @@ def _get_jk(mol, intor, comp, aosym, script_dms,
|
|
|
295
283
|
lib.hermi_triu(vs[k], hermi=hermi, inplace=True)
|
|
296
284
|
return vs
|
|
297
285
|
|
|
298
|
-
def solve_mo1(mf, mo_energy, mo_coeff, mo_occ,
|
|
286
|
+
def solve_mo1(mf, mo_energy, mo_coeff, mo_occ, h1ao,
|
|
299
287
|
fx=None, atmlst=None, max_memory=4000, verbose=None,
|
|
300
288
|
max_cycle=50, level_shift=0):
|
|
301
289
|
'''Solve the first order equation
|
|
@@ -335,12 +323,7 @@ def solve_mo1(mf, mo_energy, mo_coeff, mo_occ, h1ao_or_chkfile,
|
|
|
335
323
|
s1ao[:,p0:p1] += s1a[:,p0:p1]
|
|
336
324
|
s1ao[:,:,p0:p1] += s1a[:,p0:p1].transpose(0,2,1)
|
|
337
325
|
s1vo.append(_ao2mo(s1ao))
|
|
338
|
-
|
|
339
|
-
key = 'scf_f1ao/%d' % ia
|
|
340
|
-
h1ao = lib.chkfile.load(h1ao_or_chkfile, key)
|
|
341
|
-
else:
|
|
342
|
-
h1ao = h1ao_or_chkfile[ia]
|
|
343
|
-
h1vo.append(_ao2mo(h1ao))
|
|
326
|
+
h1vo.append(_ao2mo(h1ao[ia]))
|
|
344
327
|
|
|
345
328
|
h1vo = numpy.vstack(h1vo)
|
|
346
329
|
s1vo = numpy.vstack(s1vo)
|
|
@@ -352,18 +335,10 @@ def solve_mo1(mf, mo_energy, mo_coeff, mo_occ, h1ao_or_chkfile,
|
|
|
352
335
|
|
|
353
336
|
for k in range(ia1-ia0):
|
|
354
337
|
ia = atmlst[k+ia0]
|
|
355
|
-
|
|
356
|
-
key = 'scf_mo1/%d' % ia
|
|
357
|
-
lib.chkfile.save(h1ao_or_chkfile, key, mo1[k])
|
|
358
|
-
else:
|
|
359
|
-
mo1s[ia] = mo1[k]
|
|
338
|
+
mo1s[ia] = mo1[k]
|
|
360
339
|
e1s[ia] = e1[k].reshape(3,nocc,nocc)
|
|
361
340
|
mo1 = e1 = None
|
|
362
|
-
|
|
363
|
-
if isinstance(h1ao_or_chkfile, str):
|
|
364
|
-
return h1ao_or_chkfile, e1s
|
|
365
|
-
else:
|
|
366
|
-
return mo1s, e1s
|
|
341
|
+
return mo1s, e1s
|
|
367
342
|
|
|
368
343
|
def gen_vind(mf, mo_coeff, mo_occ):
|
|
369
344
|
nao, nmo = mo_coeff.shape
|
|
@@ -428,8 +403,7 @@ def gen_hop(hobj, mo_energy=None, mo_coeff=None, mo_occ=None, verbose=None):
|
|
|
428
403
|
max_memory, log)
|
|
429
404
|
de2 += hobj.hess_nuc()
|
|
430
405
|
|
|
431
|
-
|
|
432
|
-
hobj.make_h1(mo_coeff, mo_occ, hobj.chkfile, atmlst, log)
|
|
406
|
+
h1ao_cache = hobj.make_h1(mo_coeff, mo_occ, None, atmlst, log)
|
|
433
407
|
|
|
434
408
|
aoslices = mol.aoslice_by_atom()
|
|
435
409
|
s1a = -mol.intor('int1e_ipovlp', comp=3)
|
|
@@ -442,8 +416,7 @@ def gen_hop(hobj, mo_energy=None, mo_coeff=None, mo_occ=None, verbose=None):
|
|
|
442
416
|
s1ao = 0
|
|
443
417
|
for ia in range(natm):
|
|
444
418
|
shl0, shl1, p0, p1 = aoslices[ia]
|
|
445
|
-
|
|
446
|
-
h1ao += numpy.einsum('x,xij->ij', x[ia], h1ao_i)
|
|
419
|
+
h1ao += numpy.einsum('x,xij->ij', x[ia], h1ao_cache[ia])
|
|
447
420
|
s1ao_i = numpy.zeros((3,nao,nao))
|
|
448
421
|
s1ao_i[:,p0:p1] += s1a[:,p0:p1]
|
|
449
422
|
s1ao_i[:,:,p0:p1] += s1a[:,p0:p1].transpose(0,2,1)
|
|
@@ -460,8 +433,7 @@ def gen_hop(hobj, mo_energy=None, mo_coeff=None, mo_occ=None, verbose=None):
|
|
|
460
433
|
|
|
461
434
|
for ja in range(natm):
|
|
462
435
|
q0, q1 = aoslices[ja][2:]
|
|
463
|
-
|
|
464
|
-
hx[ja] += numpy.einsum('xpq,pq->x', h1ao, dm1) * 4
|
|
436
|
+
hx[ja] += numpy.einsum('xpq,pq->x', h1ao_cache[ja], dm1) * 4
|
|
465
437
|
hx[ja] -= numpy.einsum('xpq,pq->x', s1a[:,q0:q1], dme1[q0:q1]) * 2
|
|
466
438
|
hx[ja] -= numpy.einsum('xpq,qp->x', s1a[:,q0:q1], dme1[:,q0:q1]) * 2
|
|
467
439
|
return hx.ravel()
|
|
@@ -481,16 +453,15 @@ class HessianBase(lib.StreamObject):
|
|
|
481
453
|
level_shift = 0
|
|
482
454
|
|
|
483
455
|
_keys = {
|
|
484
|
-
'mol', 'base', '
|
|
456
|
+
'mol', 'base', 'atmlst', 'de', 'max_cycle', 'level_shift'
|
|
485
457
|
}
|
|
486
458
|
|
|
487
459
|
def __init__(self, scf_method):
|
|
488
460
|
self.verbose = scf_method.verbose
|
|
489
461
|
self.stdout = scf_method.stdout
|
|
490
462
|
self.mol = scf_method.mol
|
|
491
|
-
self.chkfile = scf_method.chkfile
|
|
492
|
-
self.max_memory = self.mol.max_memory
|
|
493
463
|
self.base = scf_method
|
|
464
|
+
self.max_memory = self.mol.max_memory
|
|
494
465
|
self.atmlst = range(self.mol.natm)
|
|
495
466
|
self.de = numpy.zeros((0,0,3,3)) # (A,B,dR_A,dR_B)
|
|
496
467
|
|
|
@@ -572,9 +543,9 @@ class HessianBase(lib.StreamObject):
|
|
|
572
543
|
return hcore + hcore.conj().transpose(0,1,3,2)
|
|
573
544
|
return get_hcore
|
|
574
545
|
|
|
575
|
-
def solve_mo1(self, mo_energy, mo_coeff, mo_occ,
|
|
546
|
+
def solve_mo1(self, mo_energy, mo_coeff, mo_occ, h1ao,
|
|
576
547
|
fx=None, atmlst=None, max_memory=4000, verbose=None):
|
|
577
|
-
return solve_mo1(self.base, mo_energy, mo_coeff, mo_occ,
|
|
548
|
+
return solve_mo1(self.base, mo_energy, mo_coeff, mo_occ, h1ao,
|
|
578
549
|
fx, atmlst, max_memory, verbose,
|
|
579
550
|
max_cycle=self.max_cycle, level_shift=self.level_shift)
|
|
580
551
|
|
|
@@ -619,72 +590,3 @@ class Hessian(HessianBase):
|
|
|
619
590
|
from pyscf import scf
|
|
620
591
|
scf.hf.RHF.Hessian = lib.class_as_method(Hessian)
|
|
621
592
|
scf.rohf.ROHF.Hessian = lib.invalid_method('Hessian')
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
if __name__ == '__main__':
|
|
625
|
-
from pyscf import scf
|
|
626
|
-
|
|
627
|
-
mol = gto.Mole()
|
|
628
|
-
mol.verbose = 0
|
|
629
|
-
mol.output = None
|
|
630
|
-
mol.atom = [
|
|
631
|
-
[1 , (1. , 0. , 0.000)],
|
|
632
|
-
[1 , (0. , 1. , 0.000)],
|
|
633
|
-
[1 , (0. , -1.517 , 1.177)],
|
|
634
|
-
[1 , (0. , 1.517 , 1.177)] ]
|
|
635
|
-
mol.basis = '631g'
|
|
636
|
-
mol.unit = 'B'
|
|
637
|
-
mol.build()
|
|
638
|
-
mf = scf.RHF(mol)
|
|
639
|
-
mf.conv_tol = 1e-14
|
|
640
|
-
mf.scf()
|
|
641
|
-
n3 = mol.natm * 3
|
|
642
|
-
hobj = mf.Hessian()
|
|
643
|
-
e2 = hobj.kernel().transpose(0,2,1,3).reshape(n3,n3)
|
|
644
|
-
print(lib.fp(e2) - -0.50693144355876429)
|
|
645
|
-
#from hessian import rhf_o0
|
|
646
|
-
#e2ref = rhf_o0.Hessian(mf).kernel().transpose(0,2,1,3).reshape(n3,n3)
|
|
647
|
-
#print numpy.linalg.norm(e2-e2ref)
|
|
648
|
-
#print numpy.allclose(e2,e2ref)
|
|
649
|
-
|
|
650
|
-
def grad_full(ia, inc):
|
|
651
|
-
coord = mol.atom_coord(ia).copy()
|
|
652
|
-
ptr = mol._atm[ia,gto.PTR_COORD]
|
|
653
|
-
de = []
|
|
654
|
-
for i in range(3):
|
|
655
|
-
mol._env[ptr+i] = coord[i] + inc
|
|
656
|
-
mf = scf.RHF(mol).run(conv_tol=1e-14)
|
|
657
|
-
e1a = mf.nuc_grad_method().kernel()
|
|
658
|
-
mol._env[ptr+i] = coord[i] - inc
|
|
659
|
-
mf = scf.RHF(mol).run(conv_tol=1e-14)
|
|
660
|
-
e1b = mf.nuc_grad_method().kernel()
|
|
661
|
-
mol._env[ptr+i] = coord[i]
|
|
662
|
-
de.append((e1a-e1b)/(2*inc))
|
|
663
|
-
return de
|
|
664
|
-
e2ref = [grad_full(ia, .5e-4) for ia in range(mol.natm)]
|
|
665
|
-
e2ref = numpy.asarray(e2ref).reshape(n3,n3)
|
|
666
|
-
print(numpy.linalg.norm(e2-e2ref))
|
|
667
|
-
print(abs(e2-e2ref).max())
|
|
668
|
-
print(numpy.allclose(e2,e2ref,atol=1e-6))
|
|
669
|
-
|
|
670
|
-
# \partial^2 E / \partial R \partial R'
|
|
671
|
-
e2 = hobj.partial_hess_elec(mf.mo_energy, mf.mo_coeff, mf.mo_occ)
|
|
672
|
-
e2 += hobj.hess_nuc(mol)
|
|
673
|
-
e2 = e2.transpose(0,2,1,3).reshape(n3,n3)
|
|
674
|
-
def grad_partial_R(ia, inc):
|
|
675
|
-
coord = mol.atom_coord(ia).copy()
|
|
676
|
-
ptr = mol._atm[ia,gto.PTR_COORD]
|
|
677
|
-
de = []
|
|
678
|
-
for i in range(3):
|
|
679
|
-
mol._env[ptr+i] = coord[i] + inc
|
|
680
|
-
e1a = mf.nuc_grad_method().kernel()
|
|
681
|
-
mol._env[ptr+i] = coord[i] - inc
|
|
682
|
-
e1b = mf.nuc_grad_method().kernel()
|
|
683
|
-
mol._env[ptr+i] = coord[i]
|
|
684
|
-
de.append((e1a-e1b)/(2*inc))
|
|
685
|
-
return de
|
|
686
|
-
e2ref = [grad_partial_R(ia, .5e-4) for ia in range(mol.natm)]
|
|
687
|
-
e2ref = numpy.asarray(e2ref).reshape(n3,n3)
|
|
688
|
-
print(numpy.linalg.norm(e2-e2ref))
|
|
689
|
-
print(abs(e2-e2ref).max())
|
|
690
|
-
print(numpy.allclose(e2,e2ref,atol=1e-8))
|
pyscf/hessian/rks.py
CHANGED
|
@@ -161,12 +161,7 @@ def make_h1(hessobj, mo_coeff, mo_occ, chkfile=None, atmlst=None, verbose=None):
|
|
|
161
161
|
h1ao[ia] += veff + veff.transpose(0,2,1)
|
|
162
162
|
h1ao[ia] += hcore_deriv(ia)
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
return h1ao
|
|
166
|
-
else:
|
|
167
|
-
for ia in atmlst:
|
|
168
|
-
lib.chkfile.save(chkfile, 'scf_f1ao/%d'%ia, h1ao[ia])
|
|
169
|
-
return chkfile
|
|
164
|
+
return h1ao
|
|
170
165
|
|
|
171
166
|
XX, XY, XZ = 4, 5, 6
|
|
172
167
|
YX, YY, YZ = 5, 7, 8
|