pyscf 2.11.0__py3-none-macosx_11_0_arm64.whl → 2.12.1__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.
Files changed (120) hide show
  1. pyscf/__init__.py +1 -1
  2. pyscf/adc/__init__.py +2 -6
  3. pyscf/adc/radc.py +165 -34
  4. pyscf/adc/radc_amplitudes.py +3 -1
  5. pyscf/adc/radc_ao2mo.py +8 -6
  6. pyscf/adc/radc_ea.py +56 -24
  7. pyscf/adc/radc_ee.py +894 -15
  8. pyscf/adc/radc_ip.py +108 -50
  9. pyscf/adc/radc_ip_cvs.py +381 -21
  10. pyscf/adc/uadc.py +505 -62
  11. pyscf/adc/uadc_ao2mo.py +2 -5
  12. pyscf/adc/uadc_ea.py +573 -20
  13. pyscf/adc/uadc_ee.py +2720 -1677
  14. pyscf/adc/uadc_ip.py +403 -43
  15. pyscf/adc/uadc_ip_cvs.py +1007 -22
  16. pyscf/cc/__init__.py +120 -1
  17. pyscf/cc/rccsdt.py +1636 -0
  18. pyscf/cc/rccsdt_highm.py +260 -0
  19. pyscf/cc/rccsdtq.py +1130 -0
  20. pyscf/cc/rccsdtq_highm.py +375 -0
  21. pyscf/cc/uccsdt.py +2977 -0
  22. pyscf/cc/uccsdt_highm.py +377 -0
  23. pyscf/df/hessian/rhf.py +3 -0
  24. pyscf/df/hessian/rks.py +3 -0
  25. pyscf/df/hessian/uhf.py +3 -0
  26. pyscf/df/hessian/uks.py +3 -0
  27. pyscf/dft/libxc.py +4 -4
  28. pyscf/dft/numint2c.py +4 -0
  29. pyscf/fci/direct_spin1.py +27 -12
  30. pyscf/geomopt/ase_solver.py +159 -0
  31. pyscf/grad/rhf.py +6 -2
  32. pyscf/gto/eval_gto.py +2 -0
  33. pyscf/gto/mole.py +44 -28
  34. pyscf/gto/ppnl_velgauge.py +220 -0
  35. pyscf/lib/CMakeLists.txt +1 -0
  36. pyscf/lib/ccsdt/CMakeLists.txt +18 -0
  37. pyscf/lib/ccsdt/rccsdt.c +890 -0
  38. pyscf/lib/ccsdt/rccsdtq.c +1454 -0
  39. pyscf/lib/ccsdt/uccsdt.c +459 -0
  40. pyscf/lib/gto/CMakeLists.txt +2 -2
  41. pyscf/lib/gto/auto_ftao/ft_ao_ppnl_auto.c +465 -0
  42. pyscf/lib/gto/deriv1.c +58 -1
  43. pyscf/lib/gto/ft_ao.h +11 -0
  44. pyscf/lib/gto/ft_ao_ppnl.c +308 -0
  45. pyscf/lib/gto/grid_ao_drv.h +4 -0
  46. pyscf/lib/libagf2.dylib +0 -0
  47. pyscf/lib/libao2mo.dylib +0 -0
  48. pyscf/lib/libcc.dylib +0 -0
  49. pyscf/lib/libccsdt.dylib +0 -0
  50. pyscf/lib/libcgto.dylib +0 -0
  51. pyscf/lib/libcvhf.dylib +0 -0
  52. pyscf/lib/libdft.dylib +0 -0
  53. pyscf/lib/libfci.dylib +0 -0
  54. pyscf/lib/libmcscf.dylib +0 -0
  55. pyscf/lib/libmp.dylib +0 -0
  56. pyscf/lib/libnp_helper.dylib +0 -0
  57. pyscf/lib/libpbc.dylib +0 -0
  58. pyscf/lib/libpdft.dylib +0 -0
  59. pyscf/lib/libri.dylib +0 -0
  60. pyscf/lib/libxc_itrf.dylib +0 -0
  61. pyscf/lib/libxcfun_itrf.dylib +0 -0
  62. pyscf/lib/linalg_helper.py +4 -5
  63. pyscf/lib/misc.py +47 -26
  64. pyscf/lib/numpy_helper.py +102 -35
  65. pyscf/lib/pbc/cint2e.c +11 -0
  66. pyscf/lib/pbc/fill_ints.c +55 -30
  67. pyscf/lib/pbc/grid_ao.c +48 -0
  68. pyscf/lib/pbc/nr_direct.c +1 -0
  69. pyscf/mcpdft/otfnal.py +1 -1
  70. pyscf/mcscf/casci.py +1 -1
  71. pyscf/mrpt/__init__.py +1 -1
  72. pyscf/mrpt/dfnevpt2.py +222 -0
  73. pyscf/mrpt/nevpt2.py +18 -2
  74. pyscf/pbc/df/aft.py +2 -2
  75. pyscf/pbc/df/fft.py +2 -2
  76. pyscf/pbc/df/fft_jk.py +1 -12
  77. pyscf/pbc/df/incore.py +16 -2
  78. pyscf/pbc/dft/__init__.py +20 -4
  79. pyscf/pbc/dft/cdft.py +1 -1
  80. pyscf/pbc/dft/numint.py +1 -1
  81. pyscf/pbc/grad/krhf.py +23 -78
  82. pyscf/pbc/grad/kuhf.py +2 -1
  83. pyscf/pbc/grad/rhf.py +9 -2
  84. pyscf/pbc/gto/cell.py +38 -19
  85. pyscf/pbc/gto/pseudo/pp.py +1 -11
  86. pyscf/pbc/gto/pseudo/pp_int.py +47 -9
  87. pyscf/pbc/gto/pseudo/ppnl_velgauge.py +305 -0
  88. pyscf/pbc/scf/__init__.py +22 -6
  89. pyscf/pbc/scf/kghf.py +5 -1
  90. pyscf/pbc/scf/khf.py +8 -4
  91. pyscf/pbc/scf/krohf.py +4 -0
  92. pyscf/pbc/scf/kuhf.py +10 -2
  93. pyscf/pbc/scf/rsjk.py +2 -1
  94. pyscf/pbc/symm/space_group.py +1 -1
  95. pyscf/pbc/tdscf/rhf.py +43 -3
  96. pyscf/pbc/tdscf/rks.py +4 -1
  97. pyscf/pbc/tools/pyscf_ase.py +38 -18
  98. pyscf/scf/addons.py +24 -24
  99. pyscf/scf/ghf.py +2 -0
  100. pyscf/scf/hf.py +2 -0
  101. pyscf/scf/hf_symm.py +4 -4
  102. pyscf/scf/rohf.py +3 -0
  103. pyscf/scf/stability_slow.py +99 -0
  104. pyscf/scf/uhf.py +4 -1
  105. pyscf/scf/uhf_symm.py +3 -3
  106. pyscf/solvent/grad/pcm.py +2 -2
  107. pyscf/solvent/grad/smd_experiment.py +3 -2
  108. pyscf/solvent/hessian/pcm.py +2 -2
  109. pyscf/solvent/smd.py +53 -33
  110. pyscf/solvent/smd_experiment.py +3 -2
  111. pyscf/tdscf/rhf.py +80 -4
  112. pyscf/tdscf/uhf.py +15 -2
  113. pyscf/tools/qcschema.py +1 -1
  114. pyscf/x2c/x2c.py +2 -2
  115. {pyscf-2.11.0.dist-info → pyscf-2.12.1.dist-info}/METADATA +5 -5
  116. {pyscf-2.11.0.dist-info → pyscf-2.12.1.dist-info}/RECORD +120 -103
  117. {pyscf-2.11.0.dist-info → pyscf-2.12.1.dist-info}/WHEEL +1 -1
  118. {pyscf-2.11.0.dist-info → pyscf-2.12.1.dist-info}/licenses/LICENSE +0 -0
  119. {pyscf-2.11.0.dist-info → pyscf-2.12.1.dist-info}/licenses/NOTICE +0 -0
  120. {pyscf-2.11.0.dist-info → pyscf-2.12.1.dist-info}/top_level.txt +0 -0
pyscf/__init__.py CHANGED
@@ -35,7 +35,7 @@ to try out the package::
35
35
 
36
36
  '''
37
37
 
38
- __version__ = '2.11.0'
38
+ __version__ = '2.12.1'
39
39
 
40
40
  import os
41
41
  import sys
pyscf/adc/__init__.py CHANGED
@@ -31,14 +31,14 @@ from pyscf.adc import uadc_amplitudes
31
31
  from pyscf.adc import radc_ip
32
32
  from pyscf.adc import radc_ip_cvs
33
33
  from pyscf.adc import radc_ea
34
+ from pyscf.adc import radc_ee
34
35
  from pyscf.adc import uadc_ip
35
36
  from pyscf.adc import uadc_ip_cvs
36
37
  from pyscf.adc import uadc_ea
38
+ from pyscf.adc import uadc_ee
37
39
 
38
40
 
39
41
  def ADC(mf, frozen=None, mo_coeff=None, mo_occ=None):
40
- if not (frozen is None or frozen == 0):
41
- raise NotImplementedError
42
42
 
43
43
  if mf.istype('UHF'):
44
44
  return UADC(mf, frozen, mo_coeff, mo_occ)
@@ -54,8 +54,6 @@ ADC.__doc__ = uadc.UADC.__doc__
54
54
 
55
55
 
56
56
  def UADC(mf, frozen=None, mo_coeff=None, mo_occ=None):
57
- if not (frozen is None or frozen == 0):
58
- raise NotImplementedError
59
57
 
60
58
  if not (mf.istype('UHF') or mf.istype('ROHF')):
61
59
  mf = mf.to_uhf()
@@ -65,8 +63,6 @@ def UADC(mf, frozen=None, mo_coeff=None, mo_occ=None):
65
63
  UADC.__doc__ = uadc.UADC.__doc__
66
64
 
67
65
  def RADC(mf, frozen=None, mo_coeff=None, mo_occ=None):
68
- if not (frozen is None or frozen == 0):
69
- raise NotImplementedError
70
66
 
71
67
  mf = mf.remove_soscf()
72
68
  if not mf.istype('RHF'):
pyscf/adc/radc.py CHANGED
@@ -16,6 +16,7 @@
16
16
  # Samragni Banerjee <samragnibanerjee4@gmail.com>
17
17
  # James Serna <jamcar456@gmail.com>
18
18
  # Terrence Stahl <terrencestahl1@gmail.com>
19
+ # Ning-Yuan Chen <cny003@outlook.com>
19
20
  # Alexander Sokolov <alexander.y.sokolov@gmail.com>
20
21
  #
21
22
 
@@ -29,6 +30,8 @@ from pyscf.adc import radc_ao2mo
29
30
  from pyscf.adc import radc_amplitudes
30
31
  from pyscf import __config__
31
32
  from pyscf import df
33
+ from pyscf.mp import mp2
34
+ from pyscf.data.nist import HARTREE2EV
32
35
 
33
36
 
34
37
  # Excited-state kernel
@@ -64,7 +67,14 @@ def kernel(adc, nroots=1, guess=None, eris=None, verbose=None):
64
67
  imds = adc.get_imds(eris)
65
68
  matvec, diag = adc.gen_matvec(imds, eris)
66
69
 
67
- guess = adc.get_init_guess(nroots, diag, ascending = True)
70
+ if guess is None:
71
+ guess = adc.get_init_guess(nroots, diag, ascending = True)
72
+ elif isinstance(guess, str) and guess == "cis" and adc.method_type == "ee":
73
+ guess = adc.get_init_guess(nroots, diag, ascending = True, type = "cis", eris = eris)
74
+ elif hasattr(guess, '__len__'):
75
+ guess = adc.get_init_guess(nroots, diag, ascending = True, type = "read", ini = guess)
76
+ else:
77
+ raise NotImplementedError("Guess type not implemented")
68
78
 
69
79
  conv, adc.E, U = lib.linalg_helper.davidson_nosym1(
70
80
  lambda xs : [matvec(x) for x in xs],
@@ -73,7 +83,7 @@ def kernel(adc, nroots=1, guess=None, eris=None, verbose=None):
73
83
 
74
84
  adc.U = np.array(U).T.copy()
75
85
 
76
- if adc.compute_properties and adc.method_type != "ee":
86
+ if adc.compute_properties:
77
87
  adc.P,adc.X = adc.get_properties(nroots)
78
88
  else:
79
89
  adc.P = None
@@ -94,9 +104,12 @@ def kernel(adc, nroots=1, guess=None, eris=None, verbose=None):
94
104
 
95
105
  for n in range(nroots):
96
106
  print_string = ('%s root %d | Energy (Eh) = %14.10f | Energy (eV) = %12.8f ' %
97
- (adc.method, n, adc.E[n], adc.E[n]*27.2114))
107
+ (adc.method, n, adc.E[n], adc.E[n]*HARTREE2EV))
98
108
  if adc.compute_properties and adc.method_type != "ee":
99
109
  print_string += ("| Spec. factor = %10.8f " % adc.P[n])
110
+
111
+ if adc.compute_properties and adc.method_type == "ee":
112
+ print_string += ("| Osc. strength = %10.8f " % adc.P[n])
100
113
  print_string += ("| conv = %s" % conv[n])
101
114
  logger.info(adc, print_string)
102
115
 
@@ -108,14 +121,13 @@ def kernel(adc, nroots=1, guess=None, eris=None, verbose=None):
108
121
  return adc.E, adc.U, adc.P, adc.X
109
122
 
110
123
 
111
- def make_ref_rdm1(adc):
124
+ def make_ref_rdm1(adc, with_frozen=True, ao_repr=False):
112
125
 
113
126
  if adc.method not in ("adc(2)", "adc(2)-x", "adc(3)"):
114
127
  raise NotImplementedError(adc.method)
115
128
 
116
129
  t1 = adc.t1
117
130
  t2 = adc.t2
118
- t2_ce = t1[0][:]
119
131
  t1_ccee = t2[0][:]
120
132
 
121
133
  ######################
@@ -123,6 +135,11 @@ def make_ref_rdm1(adc):
123
135
  nocc = adc._nocc
124
136
  nvir = adc._nvir
125
137
 
138
+ if t1[0] is not None:
139
+ t2_ce = t1[0][:]
140
+ else:
141
+ t2_ce = np.zeros((nocc, nvir))
142
+
126
143
  nmo = nocc + nvir
127
144
 
128
145
  OPDM = np.zeros((nmo,nmo))
@@ -145,9 +162,13 @@ def make_ref_rdm1(adc):
145
162
 
146
163
  ####### ADC(3) SPIN ADAPTED REF OPDM WITH SQA ################
147
164
  if adc.method == "adc(3)":
148
- t3_ce = adc.t1[1][:]
149
165
  t2_ccee = t2[1][:]
150
166
 
167
+ if t1[1] is not None:
168
+ t3_ce = t1[1][:]
169
+ else:
170
+ t3_ce = np.zeros((nocc, nvir))
171
+
151
172
  #### OCC-OCC ###
152
173
  OPDM[:nocc, :nocc] -= 2 * lib.einsum('Iiab,Jiab->IJ',
153
174
  t1_ccee, t2_ccee, optimize = einsum_type)
@@ -167,7 +188,7 @@ def make_ref_rdm1(adc):
167
188
  OPDM[nocc:, :nocc] -= 1/2 * \
168
189
  lib.einsum('iIAa,ia->AI', t1_ccee, t2_ce, optimize = einsum_type)
169
190
 
170
- ##### VIR=VIR ###
191
+ ##### VIR-VIR ###
171
192
  OPDM[nocc:, nocc:] += 2 * lib.einsum('ijAa,ijBa->AB',
172
193
  t1_ccee, t2_ccee, optimize = einsum_type)
173
194
  OPDM[nocc:, nocc:] -= lib.einsum('ijAa,jiBa->AB', t1_ccee, t2_ccee, optimize = einsum_type)
@@ -175,9 +196,39 @@ def make_ref_rdm1(adc):
175
196
  t1_ccee, t2_ccee, optimize = einsum_type)
176
197
  OPDM[nocc:, nocc:] -= lib.einsum('ijBa,jiAa->AB', t1_ccee, t2_ccee, optimize = einsum_type)
177
198
 
199
+ if with_frozen and adc.frozen is not None:
200
+ nmo = adc.mo_occ.size
201
+ nocc = np.count_nonzero(adc.mo_occ > 0)
202
+ dm = np.zeros((nmo,nmo))
203
+ dm[np.diag_indices(nocc)] = 1
204
+ moidx = np.where(adc.get_frozen_mask())[0]
205
+ dm[moidx[:,None],moidx] = OPDM
206
+ OPDM = dm
207
+ if ao_repr:
208
+ mo = adc.mo_coeff_hf
209
+ OPDM = lib.einsum('pi,ij,qj->pq', mo, OPDM, mo)
210
+
211
+ elif ao_repr:
212
+ mo = adc.mo_coeff
213
+ OPDM = lib.einsum('pi,ij,qj->pq', mo, OPDM, mo)
214
+
178
215
  return 2 * OPDM
179
216
 
180
217
 
218
+ def get_frozen_mask(adc):
219
+
220
+ moidx = np.ones(adc.mo_occ.size, dtype=bool)
221
+ if adc.frozen is None:
222
+ pass
223
+ elif isinstance(adc.frozen, (int, np.integer)):
224
+ moidx[:adc.frozen] = False
225
+ elif hasattr(adc.frozen, '__len__'):
226
+ moidx[list(adc.frozen)] = False
227
+ else:
228
+ raise NotImplementedError
229
+ return moidx
230
+
231
+
181
232
  class RADC(lib.StreamObject):
182
233
  '''Ground state calculations
183
234
 
@@ -211,14 +262,14 @@ class RADC(lib.StreamObject):
211
262
 
212
263
  _keys = {
213
264
  'tol_residual','conv_tol', 'e_corr', 'method', 'method_type', 'mo_coeff',
214
- 'mol', 'mo_energy', 'incore_complete',
265
+ 'mo_coeff_hf', 'mol', 'mo_energy', 'incore_complete',
215
266
  'scf_energy', 'e_tot', 't1', 't2', 'frozen', 'chkfile',
216
267
  'max_space', 'mo_occ', 'max_cycle', 'imds', 'with_df', 'compute_properties',
217
268
  'approx_trans_moments', 'evec_print_tol', 'spec_factor_print_tol',
218
- 'E', 'U', 'P', 'X', 'ncvs', 'dip_mom', 'dip_mom_nuc'
269
+ 'E', 'U', 'P', 'X', 'ncvs', 'dip_mom', 'dip_mom_nuc', 'if_heri_eris'
219
270
  }
220
271
 
221
- def __init__(self, mf, frozen=0, mo_coeff=None, mo_occ=None):
272
+ def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):
222
273
 
223
274
  if 'dft' in str(mf.__module__):
224
275
  raise NotImplementedError('DFT reference for UADC')
@@ -243,16 +294,45 @@ class RADC(lib.StreamObject):
243
294
  self.frozen = frozen
244
295
  self.incore_complete = self.incore_complete or self.mol.incore_anyway
245
296
 
246
- self.mo_coeff = mo_coeff
247
297
  self.mo_occ = mo_occ
248
298
  self.e_corr = None
249
299
  self.t1 = None
250
300
  self.t2 = None
251
301
  self.imds = lambda:None
252
302
  self._nocc = mf.mol.nelectron//2
253
- self._nmo = mo_coeff.shape[1]
254
- self._nvir = self._nmo - self._nocc
303
+ self.mo_coeff = mo_coeff
304
+ self.mo_coeff_hf = mo_coeff
255
305
  self.mo_energy = mf.mo_energy
306
+ self.if_heri_eris = False
307
+ self._nmo = None
308
+ mask = self.get_frozen_mask()
309
+ if frozen is None:
310
+ self._nmo = mo_coeff.shape[1]
311
+ elif isinstance(frozen, (int, np.integer)):
312
+ self._nmo = mo_coeff.shape[1]-frozen
313
+ elif hasattr(frozen, '__len__'):
314
+ self._nmo = mo_coeff.shape[1]-len(frozen)
315
+ else:
316
+ raise NotImplementedError
317
+ if frozen is not None:
318
+ maskocc = mf.mo_occ>1e-6
319
+ occ = maskocc & mask
320
+ self._nocc = int(occ.sum())
321
+ self.mo_coeff = mo_coeff[:,mask]
322
+ if self._nocc == 0:
323
+ raise ValueError("No occupied orbitals found")
324
+ if mo_coeff is self._scf.mo_coeff and self._scf.converged:
325
+ self.mo_energy = self.mo_energy[mask]
326
+ else:
327
+ dm = self._scf.make_rdm1(mo_coeff, self.mo_occ)
328
+ vhf = self._scf.get_veff(self.mol, dm)
329
+ fockao = self._scf.get_fock(vhf=vhf, dm=dm)
330
+ fock = self.mo_coeff.conj().T.dot(fockao).dot(self.mo_coeff)
331
+ self.mo_energy = fock.diagonal().real
332
+ self.scf_energy = self._scf.energy_tot(dm=dm, vhf=vhf)
333
+ self._nvir = self._nmo - self._nocc
334
+ if self._nvir == 0:
335
+ raise ValueError("No virtual orbitals found")
256
336
  self.chkfile = mf.chkfile
257
337
  self.method = "adc(2)"
258
338
  self.method_type = "ip"
@@ -273,7 +353,7 @@ class RADC(lib.StreamObject):
273
353
 
274
354
  for i in range(dip_ints.shape[0]):
275
355
  dip = dip_ints[i,:,:]
276
- dip_mom[i,:,:] = np.dot(mo_coeff.T, np.dot(dip, mo_coeff))
356
+ dip_mom[i,:,:] = np.dot(self.mo_coeff.T, np.dot(dip, self.mo_coeff))
277
357
 
278
358
  self.dip_mom = dip_mom
279
359
 
@@ -285,6 +365,7 @@ class RADC(lib.StreamObject):
285
365
  compute_energy = radc_amplitudes.compute_energy
286
366
  transform_integrals = radc_ao2mo.transform_integrals_incore
287
367
  make_ref_rdm1 = make_ref_rdm1
368
+ get_frozen_mask = get_frozen_mask
288
369
 
289
370
  def dump_flags(self, verbose=None):
290
371
  logger.info(self, '')
@@ -321,6 +402,17 @@ class RADC(lib.StreamObject):
321
402
  nao_pair = nao * (nao+1) // 2
322
403
  mem_incore = (max(nao_pair**2, nmo**4) + nmo_pair**2) * 8/1e6
323
404
  mem_now = lib.current_memory()[0]
405
+ nocc_fr = self._scf.mol.nelectron//2 - self._nocc
406
+ nvir_fr = self._scf.mo_coeff.shape[1] - self._nmo - nocc_fr
407
+
408
+ logger.info(self, '******** ADC Orbital Information ********')
409
+ logger.info(self, 'Number of Frozen Occupied Orbitals: %d', nocc_fr)
410
+ logger.info(self, 'Number of Frozen Virtual Orbitals: %d', nvir_fr)
411
+ logger.info(self, 'Number of Active Occupied Orbitals: %d', self._nocc)
412
+ logger.info(self, 'Number of Active Virtual Orbitals: %d', self._nvir)
413
+ if hasattr(self.frozen, '__len__'):
414
+ logger.info(self, 'Frozen Orbital List: %s', self.frozen)
415
+ logger.info(self, '*****************************************')
324
416
 
325
417
  if getattr(self, 'with_df', None) or getattr(self._scf, 'with_df', None):
326
418
  if getattr(self, 'with_df', None):
@@ -363,23 +455,35 @@ class RADC(lib.StreamObject):
363
455
  nao_pair = nao * (nao+1) // 2
364
456
  mem_incore = (max(nao_pair**2, nmo**4) + nmo_pair**2) * 8/1e6
365
457
  mem_now = lib.current_memory()[0]
366
-
367
- if getattr(self, 'with_df', None) or getattr(self._scf, 'with_df', None):
368
- if getattr(self, 'with_df', None):
369
- self.with_df = self.with_df
370
- else:
371
- self.with_df = self._scf.with_df
372
-
373
- def df_transform():
374
- return radc_ao2mo.transform_integrals_df(self)
375
- self.transform_integrals = df_transform
376
- elif (self._scf._eri is None or
377
- (mem_incore+mem_now >= self.max_memory and not self.incore_complete)):
378
- def outcore_transform():
379
- return radc_ao2mo.transform_integrals_outcore(self)
380
- self.transform_integrals = outcore_transform
381
-
382
- eris = self.transform_integrals()
458
+ nocc_fr = self._scf.mol.nelectron//2 - self._nocc
459
+ nvir_fr = self._scf.mo_coeff.shape[1] - self._nmo - nocc_fr
460
+
461
+ logger.info(self, '******** ADC Orbital Information ********')
462
+ logger.info(self, 'Number of Frozen Occupied Orbitals: %d', nocc_fr)
463
+ logger.info(self, 'Number of Frozen Virtual Orbitals: %d', nvir_fr)
464
+ logger.info(self, 'Number of Active Occupied Orbitals: %d', self._nocc)
465
+ logger.info(self, 'Number of Active Virtual Orbitals: %d', self._nvir)
466
+ if hasattr(self.frozen, '__len__'):
467
+ logger.info(self, 'Frozen Orbital List: %s', self.frozen)
468
+ logger.info(self, '*****************************************')
469
+
470
+ if eris is None:
471
+ if getattr(self, 'with_df', None) or getattr(self._scf, 'with_df', None):
472
+ if getattr(self, 'with_df', None):
473
+ self.with_df = self.with_df
474
+ else:
475
+ self.with_df = self._scf.with_df
476
+
477
+ def df_transform():
478
+ return radc_ao2mo.transform_integrals_df(self)
479
+ self.transform_integrals = df_transform
480
+ elif (self._scf._eri is None or
481
+ (mem_incore+mem_now >= self.max_memory and not self.incore_complete)):
482
+ def outcore_transform():
483
+ return radc_ao2mo.transform_integrals_outcore(self)
484
+ self.transform_integrals = outcore_transform
485
+
486
+ eris = self.transform_integrals()
383
487
 
384
488
  self.e_corr, self.t1, self.t2 = radc_amplitudes.compute_amplitudes_energy(
385
489
  self, eris=eris, verbose=self.verbose)
@@ -402,7 +506,10 @@ class RADC(lib.StreamObject):
402
506
  else:
403
507
  raise NotImplementedError(self.method_type)
404
508
  self._adc_es = adc_es
405
- return e_exc, v_exc, spec_fac, x
509
+ if self.if_heri_eris:
510
+ return e_exc, v_exc, spec_fac, x, eris
511
+ else:
512
+ return e_exc, v_exc, spec_fac, x
406
513
 
407
514
  def _finalize(self):
408
515
  '''Hook for dumping results and clearing up the object.'''
@@ -454,8 +561,32 @@ class RADC(lib.StreamObject):
454
561
  def compute_dyson_mo(self):
455
562
  return self._adc_es.compute_dyson_mo()
456
563
 
457
- def make_rdm1(self):
458
- return self._adc_es.make_rdm1()
564
+ def make_rdm1(self, with_frozen=True, ao_repr=False):
565
+ list_rdm1 = self._adc_es._make_rdm1()
566
+
567
+ if with_frozen and self.frozen is not None:
568
+ nmo = self.mo_occ.size
569
+ nocc = np.count_nonzero(self.mo_occ > 0)
570
+ moidx = np.where(self.get_frozen_mask())[0]
571
+ for i in range(self._adc_es.U.shape[1]):
572
+ rdm1 = list_rdm1[i]
573
+ dm = np.zeros((nmo,nmo))
574
+ dm[np.diag_indices(nocc)] = 2
575
+ dm[moidx[:,None],moidx] = rdm1
576
+ rdm1 = dm
577
+ if ao_repr:
578
+ mo = self.mo_coeff_hf
579
+ rdm1 = lib.einsum('pi,ij,qj->pq', mo, rdm1, mo)
580
+ list_rdm1[i] = rdm1
581
+
582
+ elif ao_repr:
583
+ mo = self.mo_coeff
584
+ for i in range(self._adc_es.U.shape[1]):
585
+ rdm1 = list_rdm1[i]
586
+ rdm1 = lib.einsum('pi,ij,qj->pq', mo, rdm1, mo)
587
+ list_rdm1[i] = rdm1
588
+
589
+ return list_rdm1
459
590
 
460
591
 
461
592
  if __name__ == '__main__':
@@ -117,7 +117,9 @@ def compute_amplitudes(myadc, eris):
117
117
  t1_3 = None
118
118
  t2_1_vvvv = None
119
119
 
120
- if (myadc.method == "adc(2)-x" and myadc.approx_trans_moments is False) or (myadc.method == "adc(3)"):
120
+ if ((myadc.method == "adc(2)" and myadc.method_type == "ee" and myadc.approx_trans_moments is False)
121
+ or (myadc.method =="adc(2)-x" and myadc.approx_trans_moments is False)
122
+ or (myadc.method == "adc(3)")):
121
123
 
122
124
  # Compute second-order doubles t2 (tijab)
123
125
 
pyscf/adc/radc_ao2mo.py CHANGED
@@ -44,11 +44,12 @@ def transform_integrals_incore(myadc):
44
44
  eris.ovvv = ao2mo.general(myadc._scf._eri, (occ, vir, vir, vir), compact=True).reshape(nocc, nvir, -1).copy() # noqa: E501
45
45
  eris.vvvv = None
46
46
 
47
- if ((myadc.method == "adc(2)-x" and myadc.approx_trans_moments is False)
48
- or (myadc.method == "adc(2)-x" and myadc.method_type == "ee")
47
+ if ((myadc.method == "adc(2)" and myadc.method_type == "ee" and myadc.approx_trans_moments is False)
48
+ or (myadc.method == "adc(2)-x" and myadc.approx_trans_moments is False)
49
+ or (myadc.method == "adc(2)-x" and myadc.approx_trans_moments is True and myadc.method_type in ("ea","ee"))
49
50
  or (myadc.method == "adc(3)")):
50
51
  eris.vvvv = ao2mo.general(myadc._scf._eri, (vir, vir, vir, vir),
51
- compact=False).reshape(nvir, nvir, nvir, nvir)
52
+ compact=False).reshape(nvir, nvir, nvir, nvir)
52
53
  eris.vvvv = np.ascontiguousarray(eris.vvvv.transpose(0,2,1,3))
53
54
  eris.vvvv = eris.vvvv.reshape(nvir*nvir, nvir*nvir)
54
55
 
@@ -155,8 +156,9 @@ def transform_integrals_outcore(myadc):
155
156
 
156
157
  ############### forming eris_vvvv ########################################
157
158
 
158
- if ((myadc.method == "adc(2)-x" and myadc.approx_trans_moments is False)
159
- or (myadc.method == "adc(2)-x" and myadc.method_type == "ee")
159
+ if ((myadc.method == "adc(2)" and myadc.method_type == "ee" and myadc.approx_trans_moments is False)
160
+ or (myadc.method == "adc(2)-x" and myadc.approx_trans_moments is False)
161
+ or (myadc.method == "adc(2)-x" and myadc.approx_trans_moments is True and myadc.method_type in ("ea","ee"))
160
162
  or (myadc.method == "adc(3)")):
161
163
 
162
164
  eris.vvvv = []
@@ -177,7 +179,7 @@ def transform_integrals_outcore(myadc):
177
179
 
178
180
  with lib.H5TmpFile() as tmpf:
179
181
  ao2mo.outcore.general(mol, (orb_slice, vir, vir, vir), tmpf,
180
- max_memory=avail_mem, ioblk_size=100, compact=False)
182
+ max_memory=avail_mem, ioblk_size=100, compact=False)
181
183
  vvvv = tmpf['eri_mo'][:]
182
184
  vvvv = vvvv.reshape(orb_slice.shape[1], vir.shape[1], vir.shape[1], vir.shape[1])
183
185
  vvvv = np.ascontiguousarray(vvvv.transpose(0,2,1,3)).reshape(-1, nvir, nvir * nvir)
pyscf/adc/radc_ea.py CHANGED
@@ -16,6 +16,7 @@
16
16
  # Samragni Banerjee <samragnibanerjee4@gmail.com>
17
17
  # James Serna <jamcar456@gmail.com>
18
18
  # Terrence Stahl <>
19
+ # Ning-Yuan Chen <cny003@outlook.com>
19
20
  # Alexander Sokolov <alexander.y.sokolov@gmail.com>
20
21
 
21
22
  '''
@@ -28,6 +29,7 @@ from pyscf.adc import radc
28
29
  from pyscf.adc import radc_ao2mo
29
30
  from pyscf.adc import dfadc
30
31
  from pyscf import symm
32
+ from pyscf.data.nist import HARTREE2EV
31
33
 
32
34
 
33
35
  def get_imds(adc, eris=None):
@@ -785,7 +787,7 @@ def analyze_eigenvector(adc):
785
787
  iter_num += 1
786
788
 
787
789
  logger.info(adc, '%s | root %d | Energy (eV) = %12.8f | norm(1p) = %6.4f | norm(1h2p) = %6.4f ',
788
- adc.method, I, adc.E[I]*27.2114, U1dotU1, U2dotU2)
790
+ adc.method, I, adc.E[I]*HARTREE2EV, U1dotU1, U2dotU2)
789
791
 
790
792
  if singles_val:
791
793
  logger.info(adc, "\n1p block: ")
@@ -835,7 +837,7 @@ def analyze_spec_factor(adc):
835
837
  continue
836
838
 
837
839
  logger.info(adc, '%s | root %d | Energy (eV) = %12.8f \n',
838
- adc.method, i, adc.E[i]*27.2114)
840
+ adc.method, i, adc.E[i]*HARTREE2EV)
839
841
  logger.info(adc, " HF MO Spec. Contribution Orbital symmetry")
840
842
  logger.info(adc, "-----------------------------------------------------------")
841
843
 
@@ -923,7 +925,6 @@ def make_rdm1_eigenvectors(adc, L, R):
923
925
  R = np.array(R).ravel()
924
926
 
925
927
  t1_ccee = adc.t2[0][:]
926
- t2_ce = adc.t1[0][:]
927
928
 
928
929
  nocc = adc._nocc
929
930
  nvir = adc._nvir
@@ -931,13 +932,19 @@ def make_rdm1_eigenvectors(adc, L, R):
931
932
  n_singles = nvir
932
933
  n_doubles = nvir * nvir * nocc
933
934
 
935
+ if adc.t1[0] is not None:
936
+ t2_ce = adc.t1[0]
937
+ else:
938
+ t2_ce = np.zeros((nocc, nvir))
939
+
940
+ occ_list = range(nocc)
941
+
934
942
  s1 = 0
935
943
  f1 = n_singles
936
944
  s2 = f1
937
945
  f2 = s2 + n_doubles
938
946
 
939
947
  rdm1 = np.zeros((nmo,nmo))
940
- kd_oc = np.identity(nocc)
941
948
 
942
949
  L1 = L[s1:f1]
943
950
  L2 = L[s2:f2]
@@ -952,13 +959,13 @@ def make_rdm1_eigenvectors(adc, L, R):
952
959
 
953
960
  ############# block- ij
954
961
  ### 000 ###
955
- rdm1[:nocc, :nocc] += 2 * einsum('a,a,IJ->IJ', L1, R1, kd_oc, optimize = einsum_type)
962
+ rdm1[occ_list, occ_list] += 2 * einsum('a,a->', L1, R1, optimize = einsum_type)
956
963
 
957
964
  ### 101 ###
958
965
  rdm1[:nocc, :nocc] -= 2 * einsum('Jab,Iab->IJ', L2, R2, optimize = einsum_type)
959
966
  rdm1[:nocc, :nocc] += 1 * einsum('Jab,Iba->IJ', L2, R2, optimize = einsum_type)
960
- rdm1[:nocc, :nocc] += 4 * einsum('iab,iab,IJ->IJ', L2, R2, kd_oc, optimize = einsum_type)
961
- rdm1[:nocc, :nocc] -= 2 * einsum('iab,iba,IJ->IJ', L2, R2, kd_oc, optimize = einsum_type)
967
+ rdm1[occ_list, occ_list] += 4 * einsum('iab,iab->', L2, R2, optimize = einsum_type)
968
+ rdm1[occ_list, occ_list] -= 2 * einsum('iab,iba->', L2, R2, optimize = einsum_type)
962
969
 
963
970
  ### 020 ###
964
971
  rdm1[:nocc, :nocc] -= 2 * einsum('a,a,Iibc,Jibc->IJ', L1, R1,
@@ -1038,11 +1045,15 @@ def make_rdm1_eigenvectors(adc, L, R):
1038
1045
 
1039
1046
  ####### ADC(3) SPIN ADAPTED EXCITED STATE OPDM WITH SQA ################
1040
1047
  if adc.method == "adc(3)":
1041
- ### Redudant Variables used for names from SQA
1048
+ ### Redundant Variables used for names from SQA
1042
1049
  einsum_type = True
1043
- t3_ce = adc.t1[1][:]
1044
1050
  t2_ccee = adc.t2[1][:]
1045
1051
 
1052
+ if adc.t1[1] is not None:
1053
+ t3_ce = adc.t1[1]
1054
+ else:
1055
+ t3_ce = np.zeros((nocc, nvir))
1056
+
1046
1057
  ############# block- ij
1047
1058
  # 120 #
1048
1059
  rdm1[:nocc, :nocc] -= 2 * einsum('Jab,a,Ib->IJ', L2, R1, t2_ce, optimize = einsum_type)
@@ -1468,10 +1479,11 @@ class RADCEA(radc.RADC):
1468
1479
 
1469
1480
  _keys = {
1470
1481
  'tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff',
1471
- 'mo_energy', 't1', 'max_space', 't2', 'max_cycle',
1482
+ 'mo_coeff_hf', 'mo_energy', 't1', 'max_space', 't2', 'max_cycle',
1472
1483
  'nmo', 'transform_integrals', 'with_df', 'compute_properties',
1473
1484
  'approx_trans_moments', 'E', 'U', 'P', 'X',
1474
1485
  'evec_print_tol', 'spec_factor_print_tol',
1486
+ '_make_rdm1', 'frozen', 'mo_occ'
1475
1487
  }
1476
1488
 
1477
1489
  def __init__(self, adc):
@@ -1494,12 +1506,15 @@ class RADCEA(radc.RADC):
1494
1506
  self._nvir = adc._nvir
1495
1507
  self._nmo = adc._nmo
1496
1508
  self.mo_coeff = adc.mo_coeff
1509
+ self.mo_coeff_hf = adc.mo_coeff_hf
1497
1510
  self.mo_energy = adc.mo_energy
1498
1511
  self.nmo = adc._nmo
1499
1512
  self.transform_integrals = adc.transform_integrals
1500
1513
  self.with_df = adc.with_df
1501
1514
  self.compute_properties = adc.compute_properties
1502
1515
  self.approx_trans_moments = adc.approx_trans_moments
1516
+ self.frozen = adc.frozen
1517
+ self.mo_occ = adc.mo_occ
1503
1518
 
1504
1519
  self.evec_print_tol = adc.evec_print_tol
1505
1520
  self.spec_factor_print_tol = adc.spec_factor_print_tol
@@ -1509,6 +1524,8 @@ class RADCEA(radc.RADC):
1509
1524
  self.P = adc.P
1510
1525
  self.X = adc.X
1511
1526
 
1527
+ self._adc_es = self
1528
+
1512
1529
  kernel = radc.kernel
1513
1530
  get_imds = get_imds
1514
1531
  matvec = matvec
@@ -1521,21 +1538,36 @@ class RADCEA(radc.RADC):
1521
1538
  analyze_spec_factor = analyze_spec_factor
1522
1539
  analyze_eigenvector = analyze_eigenvector
1523
1540
  compute_dyson_mo = compute_dyson_mo
1524
- make_rdm1 = make_rdm1
1525
-
1526
- def get_init_guess(self, nroots=1, diag=None, ascending=True):
1527
- if diag is None :
1528
- diag = self.get_diag()
1529
- idx = None
1530
- if ascending:
1531
- idx = np.argsort(diag)
1541
+ _make_rdm1 = make_rdm1
1542
+
1543
+ def get_init_guess(self, nroots=1, diag=None, ascending=True, type=None, ini=None):
1544
+ if (type=="read"):
1545
+ logger.info(self, "obtain initial guess from input variable")
1546
+ ncore = self._nocc
1547
+ nextern = self._nvir
1548
+ n_singles = nextern
1549
+ n_doubles = ncore * nextern * nextern
1550
+ dim = n_singles + n_doubles
1551
+ if isinstance(ini, list):
1552
+ g = np.array(ini)
1553
+ else:
1554
+ g = ini
1555
+ if g.shape[0] != dim or g.shape[1] != nroots:
1556
+ raise ValueError(f"Shape of guess should be ({dim},{nroots})")
1557
+
1532
1558
  else:
1533
- idx = np.argsort(diag)[::-1]
1534
- guess = np.zeros((diag.shape[0], nroots))
1535
- min_shape = min(diag.shape[0], nroots)
1536
- guess[:min_shape,:min_shape] = np.identity(min_shape)
1537
- g = np.zeros((diag.shape[0], nroots))
1538
- g[idx] = guess.copy()
1559
+ if diag is None :
1560
+ diag = self.get_diag()
1561
+ idx = None
1562
+ if ascending:
1563
+ idx = np.argsort(diag)
1564
+ else:
1565
+ idx = np.argsort(diag)[::-1]
1566
+ guess = np.zeros((diag.shape[0], nroots))
1567
+ min_shape = min(diag.shape[0], nroots)
1568
+ guess[:min_shape,:min_shape] = np.identity(min_shape)
1569
+ g = np.zeros((diag.shape[0], nroots))
1570
+ g[idx] = guess.copy()
1539
1571
  guess = []
1540
1572
  for p in range(g.shape[1]):
1541
1573
  guess.append(g[:,p])