1#!/usr/bin/env python 2# 3# Author: Qiming Sun <osirpt.sun@gmail.com> 4# 5 6''' 7Solve FCI problem with given 1-electron and 2-electron Hamiltonian 8''' 9 10import numpy 11from pyscf import fci 12 13numpy.random.seed(12) 14norb = 6 15h1 = numpy.random.random((norb,norb)) 16h2 = numpy.random.random((norb,norb,norb,norb)) 17# Restore permutation symmetry 18h1 = h1 + h1.T 19h2 = h2 + h2.transpose(1,0,2,3) 20h2 = h2 + h2.transpose(0,1,3,2) 21h2 = h2 + h2.transpose(2,3,0,1) 22 23# 24# Generally, direct_spin1.kernel can handle all systems. 25# 26e, fcivec = fci.direct_spin1.kernel(h1, h2, norb, 8, verbose=5) 27 28# 29# A better way is to create a FCI (=FCISolver) object because FCI object offers 30# more options to control the calculation. 31# 32cisolver = fci.direct_spin1.FCI() 33cisolver.max_cycle = 100 34cisolver.conv_tol = 1e-8 35e, fcivec = cisolver.kernel(h1, h2, norb, 8) 36e, fcivec = cisolver.kernel(h1, h2, norb, (5,4)) # 5 alpha, 4 beta electrons 37e, fcivec = cisolver.kernel(h1, h2, norb, (3,1)) # 3 alpha, 1 beta electrons 38 39# 40# If you are sure the system ground state is singlet, you can use spin0 solver. 41# Spin symmetry is considered in spin0 solver to reduce cimputation cost. 42# 43cisolver = fci.direct_spin0.FCI() 44cisolver.verbose = 5 45e, fcivec = cisolver.kernel(h1, h2, norb, 8) 46 47