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/dft/numint.py
CHANGED
|
@@ -2633,7 +2633,7 @@ def get_rho(ni, mol, dm, grids, max_memory=2000):
|
|
|
2633
2633
|
class LibXCMixin:
|
|
2634
2634
|
libxc = libxc
|
|
2635
2635
|
|
|
2636
|
-
omega = None # RSH
|
|
2636
|
+
omega = None # RSH parameter
|
|
2637
2637
|
|
|
2638
2638
|
####################
|
|
2639
2639
|
# Overwrite following functions to use custom XC functional
|
|
@@ -2654,6 +2654,10 @@ class LibXCMixin:
|
|
|
2654
2654
|
return self.libxc.eval_xc(xc_code, rho, spin, relativity, deriv,
|
|
2655
2655
|
omega, verbose)
|
|
2656
2656
|
|
|
2657
|
+
def eval_xc1(self, xc_code, rho, spin=0, deriv=1, omega=None):
|
|
2658
|
+
if omega is None: omega = self.omega
|
|
2659
|
+
return self.libxc.eval_xc1(xc_code, rho, spin, deriv, omega)
|
|
2660
|
+
|
|
2657
2661
|
def eval_xc_eff(self, xc_code, rho, deriv=1, omega=None, xctype=None,
|
|
2658
2662
|
verbose=None):
|
|
2659
2663
|
r'''Returns the derivative tensor against the density parameters
|
|
@@ -2693,12 +2697,12 @@ class LibXCMixin:
|
|
|
2693
2697
|
else:
|
|
2694
2698
|
spin = 0
|
|
2695
2699
|
|
|
2696
|
-
out = self.
|
|
2700
|
+
out = self.eval_xc1(xc_code, rho, spin, deriv, omega)
|
|
2697
2701
|
evfk = [out[0]]
|
|
2698
2702
|
for order in range(1, deriv+1):
|
|
2699
2703
|
evfk.append(xc_deriv.transform_xc(rho, out, xctype, spin, order))
|
|
2700
2704
|
if deriv < 3:
|
|
2701
|
-
#
|
|
2705
|
+
# Returns at least [e, v, f, k] terms
|
|
2702
2706
|
evfk.extend([None] * (3 - deriv))
|
|
2703
2707
|
return evfk
|
|
2704
2708
|
|
pyscf/dft/radi.py
CHANGED
|
@@ -21,10 +21,20 @@
|
|
|
21
21
|
import numpy
|
|
22
22
|
from pyscf.data import radii
|
|
23
23
|
from pyscf.data.elements import charge as elements_proton
|
|
24
|
+
from pyscf import __config__
|
|
24
25
|
|
|
25
26
|
BRAGG_RADII = radii.BRAGG
|
|
26
27
|
COVALENT_RADII = radii.COVALENT
|
|
27
28
|
|
|
29
|
+
# The effective atomic radius in Treutler's original paper (JCP 102, 346) was
|
|
30
|
+
# omitted in PySCF versions 2.6 and earlier. This can cause discrepancies in the
|
|
31
|
+
# numerical grids when compared to other software (See issue #2178 for details).
|
|
32
|
+
# Note that using the atom-specific radius may slightly alter the results of
|
|
33
|
+
# numerical integration, potentially leading to differences of ~ 1e-6 per atom
|
|
34
|
+
# in total energy.
|
|
35
|
+
# Disable this flag to make DFT grids consistent with old PySCF versions.
|
|
36
|
+
ATOM_SPECIFIC_TREUTLER_GRIDS = getattr(__config__, 'ATOM_SPECIFIC_TREUTLER_GRIDS', True)
|
|
37
|
+
|
|
28
38
|
# P.M.W. Gill, B.G. Johnson, J.A. Pople, Chem. Phys. Letters 209 (1993) 506-512
|
|
29
39
|
SG1RADII = numpy.array((
|
|
30
40
|
0,
|
|
@@ -95,15 +105,41 @@ def gauss_chebyshev(n, *args, **kwargs):
|
|
|
95
105
|
dr = fac * numpy.sin(x1)**4 * ln2/(1+xi)
|
|
96
106
|
return r, dr
|
|
97
107
|
|
|
98
|
-
|
|
99
|
-
|
|
108
|
+
# Individually optimized Treutler/Ahlrichs radius parameter.
|
|
109
|
+
# H - Kr are taken from the original paper JCP 102, 346 (1995)
|
|
110
|
+
# Other elements are copied from Psi4 source code
|
|
111
|
+
_treutler_ahlrichs_xi = [1.0, # Ghost
|
|
112
|
+
0.8, 0.9, # 1s
|
|
113
|
+
1.8, 1.4, 1.3, 1.1, 0.9, 0.9, 0.9, 0.9, # 2s2p
|
|
114
|
+
1.4, 1.3, 1.3, 1.2, 1.1, 1.0, 1.0, 1.0, # 3s3p
|
|
115
|
+
1.5, 1.4, # 4s
|
|
116
|
+
1.3, 1.2, 1.2, 1.2, 1.2, 1.2, 1.2, 1.1, 1.1, 1.1, # 3d
|
|
117
|
+
1.1, 1.0, 0.9, 0.9, 0.9, 0.9, # 4p
|
|
118
|
+
2.000, 1.700, # 5s
|
|
119
|
+
1.500, 1.500, 1.350, 1.350, 1.250, 1.200, 1.250, 1.300, 1.500, 1.500, # 4d
|
|
120
|
+
1.300, 1.200, 1.200, 1.150, 1.150, 1.150, # 5p
|
|
121
|
+
2.500, 2.200, # 6s
|
|
122
|
+
2.500, 1.500, 1.500, 1.500, 1.500, 1.500, 1.500, # La, Ce-Eu
|
|
123
|
+
1.500, 1.500, 1.500, 1.500, 1.500, 1.500, 1.500, 1.500, # Gd, Tb-Lu
|
|
124
|
+
1.500, 1.500, 1.500, 1.500, 1.500, 1.500, 1.500, 1.500, 1.500, # 5d
|
|
125
|
+
1.500, 1.500, 1.500, 1.500, 1.500, 1.500, # 6p
|
|
126
|
+
2.500, 2.100, # 7s
|
|
127
|
+
3.685, 1.500, 1.500, 1.500, 1.500, 1.500, 1.500,
|
|
128
|
+
1.500, 1.500, 1.500, 1.500, 1.500, 1.500, 1.500, 1.500,
|
|
129
|
+
] # noqa: E124
|
|
130
|
+
|
|
131
|
+
def treutler_ahlrichs(n, chg, *args, **kwargs):
|
|
100
132
|
'''
|
|
101
133
|
Treutler-Ahlrichs [JCP 102, 346 (1995); DOI:10.1063/1.469408] (M4) radial grids
|
|
102
134
|
'''
|
|
135
|
+
if ATOM_SPECIFIC_TREUTLER_GRIDS:
|
|
136
|
+
xi = _treutler_ahlrichs_xi[chg]
|
|
137
|
+
else:
|
|
138
|
+
xi = 1.
|
|
103
139
|
r = numpy.empty(n)
|
|
104
140
|
dr = numpy.empty(n)
|
|
105
141
|
step = numpy.pi / (n+1)
|
|
106
|
-
ln2 =
|
|
142
|
+
ln2 = xi / numpy.log(2)
|
|
107
143
|
for i in range(n):
|
|
108
144
|
x = numpy.cos((i+1)*step)
|
|
109
145
|
r [i] = -ln2*(1+x)**.6 * numpy.log((1-x)/2)
|
|
@@ -113,8 +149,6 @@ def treutler_ahlrichs(n, *args, **kwargs):
|
|
|
113
149
|
treutler = treutler_ahlrichs
|
|
114
150
|
|
|
115
151
|
|
|
116
|
-
|
|
117
|
-
|
|
118
152
|
def becke_atomic_radii_adjust(mol, atomic_radii):
|
|
119
153
|
'''Becke atomic radii adjust function'''
|
|
120
154
|
# Becke atomic size adjustment. J. Chem. Phys. 88, 2547
|
pyscf/dft/rks.py
CHANGED
pyscf/dft/xc_deriv.py
CHANGED
|
@@ -455,7 +455,7 @@ def _stack_fggg(fggg, axis=0, rho=None):
|
|
|
455
455
|
@lru_cache(100)
|
|
456
456
|
def _product_uniq_indices(nvars, order):
|
|
457
457
|
'''
|
|
458
|
-
Indexing the symmetry unique elements in
|
|
458
|
+
Indexing the symmetry unique elements in cartesian product
|
|
459
459
|
'''
|
|
460
460
|
# n = 0
|
|
461
461
|
# for i range(nvars):
|
pyscf/dft/xcfun.py
CHANGED
|
@@ -36,10 +36,61 @@ _itrf = lib.load_library('libxcfun_itrf')
|
|
|
36
36
|
_itrf.xcfun_splash.restype = ctypes.c_char_p
|
|
37
37
|
_itrf.xcfun_version.restype = ctypes.c_char_p
|
|
38
38
|
_itrf.XCFUN_eval_xc.restype = ctypes.c_int
|
|
39
|
+
_itrf.xcfun_enumerate_parameters.restype = ctypes.c_char_p
|
|
40
|
+
_itrf.XCFUN_xc_type.restype = ctypes.c_int
|
|
41
|
+
_itrf.xcfun_describe_short.restype = ctypes.c_char_p
|
|
42
|
+
_itrf.xcfun_describe_short.argtype = [ctypes.c_char_p]
|
|
43
|
+
_itrf.xcfun_describe_long.restype = ctypes.c_char_p
|
|
44
|
+
_itrf.xcfun_describe_long.argtype = [ctypes.c_char_p]
|
|
39
45
|
|
|
40
46
|
__version__ = _itrf.xcfun_version().decode("UTF-8")
|
|
41
47
|
__reference__ = _itrf.xcfun_splash().decode("UTF-8")
|
|
42
48
|
|
|
49
|
+
def print_XC_CODES():
|
|
50
|
+
'''
|
|
51
|
+
Dump the built-in xcfun XC_CODES in a readable format.
|
|
52
|
+
'''
|
|
53
|
+
lda_ids = []
|
|
54
|
+
gga_ids = []
|
|
55
|
+
mgga_ids = []
|
|
56
|
+
xc_codes = {}
|
|
57
|
+
|
|
58
|
+
print('XC = XC_CODES = {')
|
|
59
|
+
for i in range(78):
|
|
60
|
+
name = _itrf.xcfun_enumerate_parameters(ctypes.c_int(i))
|
|
61
|
+
sdescr = _itrf.xcfun_describe_short(name)
|
|
62
|
+
#ldescr = _itrf.xcfun_describe_long(ctypes.c_int(i))
|
|
63
|
+
if sdescr is not None:
|
|
64
|
+
name = name.decode('UTF-8')
|
|
65
|
+
key = f"'{name}'"
|
|
66
|
+
sdescr = sdescr.decode('UTF-8')
|
|
67
|
+
print(f'{key:<16s}: {i:2d}, #{sdescr}')
|
|
68
|
+
xc_codes[name] = i
|
|
69
|
+
|
|
70
|
+
fntype = _itrf.XCFUN_xc_type(ctypes.c_int(i))
|
|
71
|
+
if fntype == 0:
|
|
72
|
+
lda_ids.append(i)
|
|
73
|
+
elif fntype == 1:
|
|
74
|
+
gga_ids.append(i)
|
|
75
|
+
elif fntype == 2:
|
|
76
|
+
mgga_ids.append(i)
|
|
77
|
+
|
|
78
|
+
alias = {
|
|
79
|
+
'SLATER': 'SLATERX',
|
|
80
|
+
'LDA' : 'SLATERX',
|
|
81
|
+
'VWN' : 'VWN5C',
|
|
82
|
+
'VWN5' : 'VWN5C',
|
|
83
|
+
'B88' : 'BECKEX',
|
|
84
|
+
'LYP' : 'LYPC',
|
|
85
|
+
}
|
|
86
|
+
for k, v in alias.items():
|
|
87
|
+
key = f"'{k}'"
|
|
88
|
+
print(f'{key:<16s}: {xc_codes[v]:2d}, # {v}')
|
|
89
|
+
print('}')
|
|
90
|
+
print('LDA_IDS = %s' % lda_ids)
|
|
91
|
+
print('GGA_IDS = %s' % gga_ids)
|
|
92
|
+
print('MGGA_IDS = %s' % mgga_ids)
|
|
93
|
+
|
|
43
94
|
XC = XC_CODES = {
|
|
44
95
|
'SLATERX' : 0, #Slater LDA exchange
|
|
45
96
|
'PW86X' : 1, #PW86 exchange
|
|
@@ -449,7 +500,7 @@ def parse_xc(description):
|
|
|
449
500
|
fac, key = token.split('*')
|
|
450
501
|
if fac[0].isalpha():
|
|
451
502
|
fac, key = key, fac
|
|
452
|
-
fac = sign * float(fac.replace('
|
|
503
|
+
fac = sign * float(fac.replace('E_', 'E-'))
|
|
453
504
|
else:
|
|
454
505
|
fac, key = sign, token
|
|
455
506
|
|
|
@@ -833,7 +884,7 @@ XC_D0000003 = 119
|
|
|
833
884
|
|
|
834
885
|
def eval_xc(xc_code, rho, spin=0, relativity=0, deriv=1, omega=None, verbose=None):
|
|
835
886
|
r'''Interface to call xcfun library to evaluate XC functional, potential
|
|
836
|
-
and functional derivatives. Return
|
|
887
|
+
and functional derivatives. Return derivatives following libxc convention.
|
|
837
888
|
|
|
838
889
|
See also :func:`pyscf.dft.libxc.eval_xc`
|
|
839
890
|
'''
|
pyscf/eph/eph_fd.py
CHANGED
|
@@ -101,7 +101,7 @@ def kernel(mf, disp=1e-4, mo_rep=False, cutoff_frequency=CUTOFF_FREQUENCY, keep_
|
|
|
101
101
|
omega, vec = get_mode(mf, cutoff_frequency, keep_imag_frequency)
|
|
102
102
|
mass = mol.atom_mass_list() * MP_ME
|
|
103
103
|
vec = rhf_eph._freq_mass_weighted_vec(vec, omega, mass)
|
|
104
|
-
mols_a, mols_b = gen_moles(mol, disp/2.0) # generate a bunch of molecules with disp/2 on each
|
|
104
|
+
mols_a, mols_b = gen_moles(mol, disp/2.0) # generate a bunch of molecules with disp/2 on each cartesian coord
|
|
105
105
|
mfset = run_mfs(mf, mols_a, mols_b) # run mean field calculations on all these molecules
|
|
106
106
|
vmat = get_vmat(mf, mfset, disp) # extracting <p|dV|q>/dR
|
|
107
107
|
if mo_rep:
|
pyscf/eph/rhf.py
CHANGED
|
@@ -23,7 +23,7 @@ Analytical electron-phonon matrix for restricted hartree fock
|
|
|
23
23
|
import numpy as np
|
|
24
24
|
import scipy.linalg
|
|
25
25
|
from pyscf.hessian import rhf
|
|
26
|
-
from pyscf.lib import logger
|
|
26
|
+
from pyscf.lib import logger
|
|
27
27
|
from pyscf.scf._response_functions import _gen_rhf_response
|
|
28
28
|
from pyscf import __config__
|
|
29
29
|
from pyscf.data.nist import HARTREE2WAVENUMBER, MP_ME
|
|
@@ -37,16 +37,16 @@ def kernel(ephobj, mo_energy=None, mo_coeff=None, mo_occ=None, mo_rep=False):
|
|
|
37
37
|
if mo_coeff is None: mo_coeff = ephobj.base.mo_coeff
|
|
38
38
|
if mo_occ is None: mo_occ = ephobj.base.mo_occ
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
assert ephobj.chkfile is not None, 'chkfile is required to save first order orbitals'
|
|
40
|
+
h1ao = ephobj.make_h1(mo_coeff, mo_occ)
|
|
41
|
+
mo1, mo_e1 = ephobj.solve_mo1(mo_energy, mo_coeff, mo_occ, h1ao)
|
|
43
42
|
|
|
44
|
-
de = ephobj.hess_elec(mo_energy, mo_coeff, mo_occ
|
|
43
|
+
de = ephobj.hess_elec(mo_energy, mo_coeff, mo_occ,
|
|
44
|
+
mo1=mo1, mo_e1=mo_e1, h1ao=h1ao)
|
|
45
45
|
ephobj.de = de + ephobj.hess_nuc(ephobj.mol)
|
|
46
46
|
|
|
47
47
|
omega, vec = ephobj.get_mode(ephobj.mol, ephobj.de)
|
|
48
48
|
ephobj.omega, ephobj.vec = omega, vec
|
|
49
|
-
ephobj.eph = ephobj.get_eph(
|
|
49
|
+
ephobj.eph = ephobj.get_eph(mo1, omega, vec, mo_rep)
|
|
50
50
|
return ephobj.eph, ephobj.omega
|
|
51
51
|
|
|
52
52
|
def solve_hmat(mol, hmat, cutoff_frequency=CUTOFF_FREQUENCY,
|
|
@@ -143,10 +143,6 @@ def _freq_mass_weighted_vec(vec, omega, mass):
|
|
|
143
143
|
return vec
|
|
144
144
|
|
|
145
145
|
def get_eph(ephobj, mo1, omega, vec, mo_rep):
|
|
146
|
-
if isinstance(mo1, str):
|
|
147
|
-
mo1 = chkfile.load(mo1, 'scf_mo1')
|
|
148
|
-
mo1 = {int(k): mo1[k] for k in mo1}
|
|
149
|
-
|
|
150
146
|
mol = ephobj.mol
|
|
151
147
|
mf = ephobj.base
|
|
152
148
|
vnuc_deriv = ephobj.vnuc_generator(mol)
|
|
@@ -209,29 +205,3 @@ class EPH(rhf.Hessian):
|
|
|
209
205
|
get_eph = get_eph
|
|
210
206
|
vnuc_generator = vnuc_generator
|
|
211
207
|
kernel = kernel
|
|
212
|
-
|
|
213
|
-
if __name__ == '__main__':
|
|
214
|
-
from pyscf import gto, scf
|
|
215
|
-
|
|
216
|
-
mol = gto.M()
|
|
217
|
-
mol.atom = [['O', [0.000000000000, -0.000000000775, 0.923671924285]],
|
|
218
|
-
['H', [-0.000000000000, -1.432564848017, 2.125164039823]],
|
|
219
|
-
['H', [0.000000000000, 1.432564848792, 2.125164035930]]]
|
|
220
|
-
mol.unit = 'Bohr'
|
|
221
|
-
mol.basis = 'sto3g'
|
|
222
|
-
mol.verbose=4
|
|
223
|
-
mol.build() # this is a pre-computed relaxed geometry
|
|
224
|
-
|
|
225
|
-
mf = scf.RHF(mol)
|
|
226
|
-
mf.conv_tol = 1e-16
|
|
227
|
-
mf.conv_tol_grad = 1e-10
|
|
228
|
-
mf.kernel()
|
|
229
|
-
|
|
230
|
-
myeph = EPH(mf)
|
|
231
|
-
|
|
232
|
-
grad = mf.nuc_grad_method().kernel()
|
|
233
|
-
print("Force on the atoms/au:")
|
|
234
|
-
print(grad)
|
|
235
|
-
|
|
236
|
-
eph, omega = myeph.kernel(mo_rep=True)
|
|
237
|
-
print(np.amax(eph))
|
pyscf/eph/rks.py
CHANGED
|
@@ -100,10 +100,6 @@ def _get_vxc_deriv1(hessobj, mo_coeff, mo_occ, max_memory):
|
|
|
100
100
|
return vmat
|
|
101
101
|
|
|
102
102
|
def get_eph(ephobj, mo1, omega, vec, mo_rep):
|
|
103
|
-
if isinstance(mo1, str):
|
|
104
|
-
mo1 = lib.chkfile.load(mo1, 'scf_mo1')
|
|
105
|
-
mo1 = {int(k): mo1[k] for k in mo1}
|
|
106
|
-
|
|
107
103
|
mol = ephobj.mol
|
|
108
104
|
mf = ephobj.base
|
|
109
105
|
ni = mf._numint
|
pyscf/eph/uhf.py
CHANGED
|
@@ -54,18 +54,12 @@ def uhf_deriv_generator(mf, mo_coeff, mo_occ):
|
|
|
54
54
|
return fx
|
|
55
55
|
|
|
56
56
|
def get_eph(ephobj, mo1, omega, vec, mo_rep):
|
|
57
|
-
if isinstance(mo1, str):
|
|
58
|
-
mo1 = lib.chkfile.load(mo1, 'scf_mo1')
|
|
59
|
-
mo1a = mo1['0']
|
|
60
|
-
mo1b = mo1['1']
|
|
61
|
-
mo1a = {int(k): mo1a[k] for k in mo1a}
|
|
62
|
-
mo1b = {int(k): mo1b[k] for k in mo1b}
|
|
63
|
-
|
|
64
57
|
mol = ephobj.mol
|
|
65
58
|
mf = ephobj.base
|
|
66
59
|
vnuc_deriv = ephobj.vnuc_generator(mol)
|
|
67
60
|
aoslices = mol.aoslice_by_atom()
|
|
68
61
|
|
|
62
|
+
mo1a, mo1b = mo1
|
|
69
63
|
mo_coeff, mo_occ = mf.mo_coeff, mf.mo_occ
|
|
70
64
|
vind = uhf_deriv_generator(mf, mf.mo_coeff, mf.mo_occ)
|
|
71
65
|
nao, nmo = mo_coeff[0].shape
|
pyscf/eph/uks.py
CHANGED
|
@@ -124,13 +124,6 @@ def _get_vxc_deriv1(hessobj, mo_coeff, mo_occ, max_memory):
|
|
|
124
124
|
return vmata, vmatb
|
|
125
125
|
|
|
126
126
|
def get_eph(ephobj, mo1, omega, vec, mo_rep):
|
|
127
|
-
if isinstance(mo1, str):
|
|
128
|
-
mo1 = lib.chkfile.load(mo1, 'scf_mo1')
|
|
129
|
-
mo1a = mo1['0']
|
|
130
|
-
mo1b = mo1['1']
|
|
131
|
-
mo1a = {int(k): mo1a[k] for k in mo1a}
|
|
132
|
-
mo1b = {int(k): mo1b[k] for k in mo1b}
|
|
133
|
-
|
|
134
127
|
mol = ephobj.mol
|
|
135
128
|
mf = ephobj.base
|
|
136
129
|
ni = mf._numint
|
|
@@ -141,6 +134,7 @@ def get_eph(ephobj, mo1, omega, vec, mo_rep):
|
|
|
141
134
|
vnuc_deriv = ephobj.vnuc_generator(mol)
|
|
142
135
|
aoslices = mol.aoslice_by_atom()
|
|
143
136
|
|
|
137
|
+
mo1a, mo1b = mo1
|
|
144
138
|
mo_coeff, mo_occ = mf.mo_coeff, mf.mo_occ
|
|
145
139
|
vind = uhf_deriv_generator(mf, mf.mo_coeff, mf.mo_occ)
|
|
146
140
|
mem_now = lib.current_memory()[0]
|
pyscf/fci/addons.py
CHANGED
|
@@ -224,7 +224,7 @@ def cylindrical_init_guess(mol, norb, nelec, orbsym, wfnsym=0, singlet=True,
|
|
|
224
224
|
ci_1[addr_x_a,addr_y_b] = numpy.sqrt(.5)
|
|
225
225
|
ci_1[addr_y_a,addr_x_b] =-numpy.sqrt(.5)
|
|
226
226
|
else:
|
|
227
|
-
# TODO: Other direct-product to direct-sum
|
|
227
|
+
# TODO: Other direct-product to direct-sum transformation
|
|
228
228
|
# which involves CG coefficients.
|
|
229
229
|
ci_1[addra,addrb] = 1
|
|
230
230
|
ci0.append(ci_1.ravel())
|
|
@@ -316,7 +316,7 @@ def guess_wfnsym(ci, norb, nelec, orbsym):
|
|
|
316
316
|
else:
|
|
317
317
|
wfnsym = [_guess_wfnsym(c, strsa, strsb, orbsym) for c in ci]
|
|
318
318
|
if any(wfnsym[0] != x for x in wfnsym):
|
|
319
|
-
warnings.warn('Different wfnsym %s found in different CI
|
|
319
|
+
warnings.warn('Different wfnsym %s found in different CI vectors' % wfnsym)
|
|
320
320
|
wfnsym = wfnsym[0]
|
|
321
321
|
return wfnsym
|
|
322
322
|
|
|
@@ -703,6 +703,121 @@ def transform_ci(ci, nelec, u):
|
|
|
703
703
|
ci = lib.dot(ci, trans_ci_b)
|
|
704
704
|
return ci
|
|
705
705
|
|
|
706
|
+
def civec_spinless_repr_generator(ci0_r, norb, nelec_r):
|
|
707
|
+
'''Put CI vectors in the spinless representation; i.e., map
|
|
708
|
+
norb -> 2 * norb
|
|
709
|
+
(neleca, nelecb) -> (neleca+nelecb, 0)
|
|
710
|
+
This permits linear combinations of CI vectors with different
|
|
711
|
+
M == neleca-nelecb at the price of higher memory cost. This function
|
|
712
|
+
does NOT change the datatype.
|
|
713
|
+
|
|
714
|
+
Args:
|
|
715
|
+
ci0_r: sequence or generator of ndarray of length nprods
|
|
716
|
+
CAS-CI vectors in the spin-pure representation
|
|
717
|
+
norb: integer
|
|
718
|
+
Number of orbitals
|
|
719
|
+
nelec_r: sequence of tuple of length (2)
|
|
720
|
+
(neleca, nelecb) for each element of ci0_r
|
|
721
|
+
|
|
722
|
+
Returns:
|
|
723
|
+
ci1_r_gen: callable that returns a generator of length nprods
|
|
724
|
+
generates spinless CAS-CI vectors
|
|
725
|
+
ss2spinless: callable
|
|
726
|
+
Put a CAS-CI vector in the spinless representation
|
|
727
|
+
Args:
|
|
728
|
+
ci0: ndarray
|
|
729
|
+
CAS-CI vector
|
|
730
|
+
ne: tuple of length 2
|
|
731
|
+
neleca, nelecb of target Hilbert space
|
|
732
|
+
Returns:
|
|
733
|
+
ci1: ndarray
|
|
734
|
+
spinless CAS-CI vector
|
|
735
|
+
spinless2ss: callable
|
|
736
|
+
Perform the reverse operation on a spinless CAS-CI vector
|
|
737
|
+
Args:
|
|
738
|
+
ci2: ndarray
|
|
739
|
+
spinless CAS-CI vector
|
|
740
|
+
ne: tuple of length 2
|
|
741
|
+
neleca, nelecb target Hilbert space
|
|
742
|
+
Returns:
|
|
743
|
+
ci3: ndarray
|
|
744
|
+
CAS-CI vector of ci2 in the (neleca, nelecb) Hilbert space
|
|
745
|
+
'''
|
|
746
|
+
nelec_r_tot = [sum (n) for n in nelec_r]
|
|
747
|
+
if len(set(nelec_r_tot)) > 1:
|
|
748
|
+
raise NotImplementedError("Different particle-number subspaces")
|
|
749
|
+
nelec = nelec_r_tot[0]
|
|
750
|
+
addrs = {}
|
|
751
|
+
ndet_sp = {}
|
|
752
|
+
for ne in set(nelec_r):
|
|
753
|
+
neleca, nelecb = _unpack_nelec(ne)
|
|
754
|
+
ndeta = cistring.num_strings(norb, neleca)
|
|
755
|
+
ndetb = cistring.num_strings(norb, nelecb)
|
|
756
|
+
strsa = cistring.addrs2str(norb, neleca, list(range(ndeta)))
|
|
757
|
+
strsb = cistring.addrs2str(norb, nelecb, list(range(ndetb)))
|
|
758
|
+
strs = numpy.add.outer(strsa, numpy.left_shift(strsb, norb)).ravel()
|
|
759
|
+
addrs[ne] = cistring.strs2addr(2*norb, nelec, strs)
|
|
760
|
+
ndet_sp[ne] = (ndeta,ndetb)
|
|
761
|
+
strs = strsa = strsb = None
|
|
762
|
+
ndet = cistring.num_strings(2*norb, nelec)
|
|
763
|
+
def ss2spinless(ci0, ne, buf=None):
|
|
764
|
+
if buf is None:
|
|
765
|
+
ci1 = numpy.empty(ndet, dtype=ci0.dtype)
|
|
766
|
+
else:
|
|
767
|
+
ci1 = numpy.asarray(buf).flat[:ndet]
|
|
768
|
+
ci1[:] = 0.0
|
|
769
|
+
ci1[addrs[ne]] = ci0[:,:].ravel ()
|
|
770
|
+
neleca, nelecb = _unpack_nelec (ne)
|
|
771
|
+
if abs(neleca*nelecb)%2: ci1[:] *= -1
|
|
772
|
+
# Sign comes from changing representation:
|
|
773
|
+
# ... a2' a1' a0' ... b2' b1' b0' |vac>
|
|
774
|
+
# ->
|
|
775
|
+
# ... b2' b1' b0' .. a2' a1' a0' |vac>
|
|
776
|
+
# i.e., strictly decreasing from left to right
|
|
777
|
+
# (the ordinality of spin-down is conventionally greater than spin-up)
|
|
778
|
+
return ci1[:,None]
|
|
779
|
+
def spinless2ss(ci2, ne):
|
|
780
|
+
''' Generate the spin-separated CI vector in a particular M
|
|
781
|
+
Hilbert space from a spinless CI vector '''
|
|
782
|
+
ci3 = ci2[addrs[ne]].reshape(ndet_sp[ne])
|
|
783
|
+
neleca, nelecb = _unpack_nelec (ne)
|
|
784
|
+
if abs(neleca*nelecb)%2: ci3[:] *= -1
|
|
785
|
+
return ci3
|
|
786
|
+
def ci1_r_gen(buf=None):
|
|
787
|
+
if callable(ci0_r):
|
|
788
|
+
ci0_r_gen = ci0_r()
|
|
789
|
+
else:
|
|
790
|
+
ci0_r_gen = (c for c in ci0_r)
|
|
791
|
+
for ci0, ne in zip(ci0_r_gen, nelec_r):
|
|
792
|
+
# Doing this in two lines saves memory: ci0 is overwritten
|
|
793
|
+
ci0 = ss2spinless(ci0, ne)
|
|
794
|
+
yield ci0
|
|
795
|
+
return ci1_r_gen, ss2spinless, spinless2ss
|
|
796
|
+
|
|
797
|
+
def civec_spinless_repr(ci0_r, norb, nelec_r):
|
|
798
|
+
'''Put CI vectors in the spinless representation; i.e., map
|
|
799
|
+
norb -> 2 * norb
|
|
800
|
+
(neleca, nelecb) -> (neleca+nelecb, 0)
|
|
801
|
+
This permits linear combinations of CI vectors with different
|
|
802
|
+
M == neleca-nelecb at the price of higher memory cost. This function
|
|
803
|
+
does NOT change the datatype.
|
|
804
|
+
|
|
805
|
+
Args:
|
|
806
|
+
ci0_r: sequence or generator of ndarray of length nprods
|
|
807
|
+
CAS-CI vectors in the spin-pure representation
|
|
808
|
+
norb: integer
|
|
809
|
+
Number of orbitals
|
|
810
|
+
nelec_r: sequence of tuple of length (2)
|
|
811
|
+
(neleca, nelecb) for each element of ci0_r
|
|
812
|
+
|
|
813
|
+
Returns:
|
|
814
|
+
ci1_r: ndarray of shape (nprods, ndet_spinless)
|
|
815
|
+
spinless CAS-CI vectors
|
|
816
|
+
'''
|
|
817
|
+
ci1_r_gen, *_ = civec_spinless_repr_generator(ci0_r, norb, nelec_r)
|
|
818
|
+
ci1_r = numpy.stack([x.copy() for x in ci1_r_gen()], axis=0)
|
|
819
|
+
return ci1_r
|
|
820
|
+
|
|
706
821
|
|
|
707
822
|
def _unpack_nelec(nelec, spin=None):
|
|
708
823
|
if spin is None:
|
pyscf/fci/cistring.py
CHANGED
|
@@ -200,7 +200,7 @@ def gen_linkstr_index(orb_list, nocc, strs=None, tril=False):
|
|
|
200
200
|
For given string str0, index[str0] is (nocc+nocc*nvir) x 4 array.
|
|
201
201
|
The first nocc rows [i(:occ),i(:occ),str0,sign] are occupied-occupied
|
|
202
202
|
excitations, which do not change the string. The next nocc*nvir rows
|
|
203
|
-
[a(:vir),i(:occ),str1,sign] are occupied-virtual
|
|
203
|
+
[a(:vir),i(:occ),str1,sign] are occupied-virtual excitations, starting from
|
|
204
204
|
str0, annihilating i, creating a, to get str1.
|
|
205
205
|
'''
|
|
206
206
|
if strs is None:
|
pyscf/fci/direct_nosym.py
CHANGED
|
@@ -125,7 +125,7 @@ def contract_2e(eri, fcivec, norb, nelec, link_index=None):
|
|
|
125
125
|
outI += contract_2e(eriI, ciR, norb, nelec, link_index=link_index)
|
|
126
126
|
out = outR.astype(numpy.complex128)
|
|
127
127
|
out.imag = outI
|
|
128
|
-
return
|
|
128
|
+
return out
|
|
129
129
|
|
|
130
130
|
def absorb_h1e(h1e, eri, norb, nelec, fac=1):
|
|
131
131
|
'''Modify 2e Hamiltonian to include 1e Hamiltonian contribution.
|
|
@@ -204,11 +204,11 @@ class FCISolver(direct_spin1.FCISolver):
|
|
|
204
204
|
return scipy.linalg.eigh(op)
|
|
205
205
|
|
|
206
206
|
# TODO: check the hermitian of Hamiltonian then determine whether to
|
|
207
|
-
# call the non-hermitian
|
|
207
|
+
# call the non-hermitian diagonalization solver davidson_nosym1
|
|
208
208
|
|
|
209
209
|
warnings.warn('direct_nosym.kernel is not able to diagonalize '
|
|
210
210
|
'non-Hermitian Hamiltonian. If h1e and h2e is not '
|
|
211
|
-
'hermtian, calling symmetric
|
|
211
|
+
'hermtian, calling symmetric diagonalization in eig '
|
|
212
212
|
'can lead to wrong results.')
|
|
213
213
|
|
|
214
214
|
self.converged, e, ci = \
|
pyscf/fci/direct_spin0_symm.py
CHANGED
|
@@ -74,15 +74,20 @@ def get_init_guess(norb, nelec, nroots, hdiag, orbsym, wfnsym=0):
|
|
|
74
74
|
strsa = cistring.gen_strings4orblist(range(norb), neleca)
|
|
75
75
|
na = len(strsa)
|
|
76
76
|
airreps = direct_spin1_symm._gen_strs_irrep(strsa, orbsym)
|
|
77
|
-
hdiag = hdiag.reshape(na,na)
|
|
78
77
|
|
|
79
78
|
sym_allowed = (airreps[:,None] ^ airreps) == wfnsym
|
|
80
79
|
idx = numpy.arange(na)
|
|
81
80
|
sym_allowed[idx[:,None] < idx] = False
|
|
82
81
|
idx_a, idx_b = numpy.where(sym_allowed)
|
|
83
82
|
|
|
83
|
+
hdiag = hdiag.reshape(na,na)[idx_a,idx_b]
|
|
84
|
+
if hdiag.size <= nroots:
|
|
85
|
+
hdiag_indices = numpy.arange(hdiag.size)
|
|
86
|
+
else:
|
|
87
|
+
hdiag_indices = numpy.argpartition(hdiag, nroots-1)[:nroots]
|
|
88
|
+
|
|
84
89
|
ci0 = []
|
|
85
|
-
for k in
|
|
90
|
+
for k in hdiag_indices:
|
|
86
91
|
addra, addrb = idx_a[k], idx_b[k]
|
|
87
92
|
x = numpy.zeros((na, na))
|
|
88
93
|
if addra == addrb:
|
|
@@ -92,61 +97,35 @@ def get_init_guess(norb, nelec, nroots, hdiag, orbsym, wfnsym=0):
|
|
|
92
97
|
ci0.append(x.ravel().view(direct_spin1.FCIvector))
|
|
93
98
|
|
|
94
99
|
if len(ci0) == 0:
|
|
95
|
-
raise
|
|
100
|
+
raise lib.exceptions.WfnSymmetryError(
|
|
101
|
+
f'Initial guess for symmetry {wfnsym} not found')
|
|
96
102
|
return ci0
|
|
97
103
|
|
|
98
104
|
def get_init_guess_cyl_sym(norb, nelec, nroots, hdiag, orbsym, wfnsym=0):
|
|
99
105
|
neleca, nelecb = direct_spin1._unpack_nelec(nelec)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
wfnsym_in_d2h = wfnsym % 10
|
|
105
|
-
wfn_momentum = symm.basis.linearmole_irrep2momentum(wfnsym)
|
|
106
|
-
na = len(strsa)
|
|
107
|
-
hdiag = hdiag.reshape(na,na)
|
|
108
|
-
degen = orbsym.degen_mapping
|
|
106
|
+
na = cistring.num_strings(norb, neleca)
|
|
107
|
+
ci0_guess = direct_spin1_symm.get_init_guess_cyl_sym(
|
|
108
|
+
norb, nelec, nroots, hdiag, orbsym, wfnsym)
|
|
109
109
|
ci0 = []
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
idx = numpy.arange(na)
|
|
117
|
-
sym_allowed[idx[:,None] < idx] = False
|
|
118
|
-
|
|
119
|
-
idx_a, idx_b = numpy.where(sym_allowed)
|
|
120
|
-
for k in hdiag[idx_a,idx_b].argsort():
|
|
121
|
-
addra, addrb = idx_a[k], idx_b[k]
|
|
122
|
-
ca = direct_spin1_symm._cyl_sym_csf2civec(strsa, addra, orbsym, degen)
|
|
123
|
-
cb = direct_spin1_symm._cyl_sym_csf2civec(strsa, addrb, orbsym, degen)
|
|
124
|
-
if wfn_momentum > 0 or wfnsym in (0, 5):
|
|
125
|
-
x = ca.real[:,None] * cb.real
|
|
126
|
-
x-= ca.imag[:,None] * cb.imag
|
|
127
|
-
else:
|
|
128
|
-
x = ca.imag[:,None] * cb.real
|
|
129
|
-
x+= ca.real[:,None] * cb.imag
|
|
130
|
-
if addra == addrb:
|
|
131
|
-
norm = numpy.linalg.norm(x)
|
|
132
|
-
else:
|
|
133
|
-
x = x + x.T
|
|
134
|
-
norm = numpy.linalg.norm(x)
|
|
135
|
-
if norm < 1e-3:
|
|
136
|
-
continue
|
|
110
|
+
for x in ci0_guess:
|
|
111
|
+
x = x.reshape(na, na)
|
|
112
|
+
x = x + x.T
|
|
113
|
+
norm = numpy.linalg.norm(x)
|
|
114
|
+
if norm < 1e-3:
|
|
115
|
+
continue
|
|
137
116
|
x *= 1./norm
|
|
138
117
|
ci0.append(x.ravel().view(direct_spin1.FCIvector))
|
|
139
|
-
iroot += 1
|
|
140
|
-
if iroot >= nroots:
|
|
141
|
-
break
|
|
142
118
|
|
|
143
119
|
if len(ci0) == 0:
|
|
144
|
-
raise
|
|
120
|
+
raise lib.exceptions.WfnSymmetryError(
|
|
121
|
+
f'Initial guess for symmetry {wfnsym} not found')
|
|
145
122
|
return ci0
|
|
146
123
|
|
|
147
124
|
|
|
148
125
|
class FCISolver(direct_spin0.FCISolver):
|
|
149
126
|
|
|
127
|
+
_keys = {'wfnsym', 'sym_allowed_idx'}
|
|
128
|
+
|
|
150
129
|
davidson_only = getattr(__config__, 'fci_direct_spin1_symm_FCI_davidson_only', True)
|
|
151
130
|
pspace_size = getattr(__config__, 'fci_direct_spin1_symm_FCI_pspace_size', 400)
|
|
152
131
|
|