1#!/usr/bin/env python 2# 3# Author: Oliver J. Backhouse <olbackhouse@gmail.com> 4# George H. Booth <george.booth@kcl.ac.uk> 5# 6 7''' 8An example of restarting an AGF2 calculation. 9 10The agf2.chkfile module provides similar functionality to the existing 11chkfile utilities in pyscf, but prevents failure during MPI runs. 12''' 13 14import numpy 15from pyscf import gto, scf, agf2, lib 16 17mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='cc-pvdz', verbose=5) 18 19mf = scf.RHF(mol) 20mf.conv_tol = 1e-12 21# if we are using MPI, we only want pyscf to save a chkfile on the root process: 22if agf2.mpi_helper.rank == 0: 23 mf.chkfile = 'agf2.chk' 24mf.run() 25 26# Run an AGF2 calculation: 27gf2 = agf2.AGF2(mf) 28gf2.conv_tol = 1e-7 29gf2.max_cycle = 3 30gf2.run() 31 32# Restore the Mole and SCF first 33mol = agf2.chkfile.load_mol('agf2.chk') 34mf = scf.RHF(mol) 35mf.__dict__.update(agf2.chkfile.load('agf2.chk', 'scf')) 36 37# Restore the AGF2 calculation 38gf2a = agf2.AGF2(mf) 39gf2a.__dict__.update(agf2.chkfile.load_agf2('agf2.chk')[1]) 40gf2a.max_cycle = 50 41gf2a.run() 42