-
-
Notifications
You must be signed in to change notification settings - Fork 692
Expand file tree
/
Copy path40-customizing_hamiltonian.py
More file actions
45 lines (36 loc) · 997 Bytes
/
40-customizing_hamiltonian.py
File metadata and controls
45 lines (36 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
#
# Author: Qiming Sun <osirpt.sun@gmail.com>
#
import numpy
from pyscf import gto, scf, ao2mo, mcscf
'''
User-defined Hamiltonian for CASSCF module.
Defining Hamiltonian once for SCF object, the derivate post-HF method get the
Hamiltonian automatically.
'''
mol = gto.M()
mol.nelectron = 6
# incore_anyway=True ensures the customized Hamiltonian (the _eri attribute)
# to be used. Without this parameter, the MO integral transformation may
# ignore the customized Hamiltonian if memory is not enough.
mol.incore_anyway = True
#
# 1D anti-PBC Hubbard model at half filling
#
n = 12
h1 = numpy.zeros((n,n))
for i in range(n-1):
h1[i,i+1] = h1[i+1,i] = -1.0
h1[n-1,0] = h1[0,n-1] = -1.0
eri = numpy.zeros((n,n,n,n))
for i in range(n):
eri[i,i,i,i] = 2.0
mf = scf.RHF(mol)
mf.get_hcore = lambda *args: h1
mf.get_ovlp = lambda *args: numpy.eye(n)
mf._eri = ao2mo.restore(8, eri, n)
mf.init_guess = '1e'
mf.kernel()
mycas = mcscf.CASSCF(mf, 4, 4)
mycas.kernel()