Download this notebook (.ipynb + data files)
5. Multi-Slater Determinant Trial Wavefunction#
In this example, we will compute the AFQMC energy of the Hubbard model with \(U=8\) on a 6×6 square lattice with open boundary conditions at half filling. We will use a trial wavefunction consisting of two Slater determinants. Specifically, we will use
where
is the UHF ground state and \(|\Phi_{1}\rangle\) is the spin-reversed UHF ground state,
Since the Hamiltonian is spin-independent, \(|\Phi_{1}\rangle\) has the same energy as the UHF ground state \(|\Phi_{0}\rangle\). Their superposition restores the spin-flip symmetry that the UHF solution breaks, and in general its energy differs from the UHF energy.
# create scratch directory in notebook path
%mkdir -p {_dh[0]}/data
%cd -q {_dh[0]}/data
# setup the Hamiltonian
from safiretools import Lattice, LatticeHamiltonian
from safiretools import vis
lattice = Lattice.from_type(
"square", (6, 6), boundaries=("open", "open"), twists=(0.0, 0.0)
)
# plot the lattice for reality checks!
vis.plot_lattice(lattice)
# make the Hamiltonian
hamiltonian = LatticeHamiltonian.from_lattice(lattice, U=8.0)
Hartree-Fock overestimates magnetic order, so a UHF solution at the bare \(U=8\) is too strongly polarized to be a good trial wavefunction. Instead, we solve UHF for a Hubbard model with a smaller effective interaction \(U_\mathrm{eff}\) and use its orbitals as the trial wavefunction. The AFQMC run itself still uses the Hamiltonian with \(U=8\). For a way to tune \(U_\mathrm{eff}\) self-consistently, see Stripes and the Square Hubbard Model.
# run AutoHF to get UHF solution
from autohf import AutoHFHamiltonian
Ueff = 2.75
# make the effective Hamiltonian
effective_hamiltonian = LatticeHamiltonian.from_lattice(lattice, U=Ueff)
# convert safiretools Hamiltonian to AutoHFHamiltonian
autohf_hamiltonian = AutoHFHamiltonian(effective_hamiltonian)
from autohf import solve_hf
nelec=(18,18)
settings = dict(
ansatz = 'SD_ROT',
steps = 100,
nelec = nelec,
batch_size = 100,
seed = 42
)
results = solve_hf(hamiltonian=autohf_hamiltonian,settings=settings)
5.1. Construct and Save the Trial Wavefunction#
A trial wavefunction can be written to SAFIRE’s HDF5 format by building a NOMSDWavefunction from safiretools and calling its to_hdf5() method.
In general, the trial wavefunction in AFQMC is a linear combination of Slater determinants,
where \(C_n\) are complex-valued coefficients, and \(|\Phi_n\rangle\) are Slater determinants which are not necessarily orthogonal to each other. Here, we will specify Slater determinants as Slater matrices
where the row index \(i\) of \(\Phi_{ip}\) is the basis index, the column index \(p\) is the electron index, and \(M,N\) are the number of basis functions and electrons, respectively. SAFIRE uses the convention that orbitals are columns of the Slater matrices. A collinear Slater determinant is a pair of Slater matrices, one for the \(N_{\uparrow}\) spin-up electrons and one for the \(N_{\downarrow}\) spin-down electrons.
In the code block below, we manually construct Slater matrices from the UHF orbitals that we got from AutoHF above.
# construct the multi-Slater trial AND save
import numpy as np
from safiretools import NOMSDWavefunction
# get the orbitals from the AutoHF results.
orbitals_up = results[0]['orbitals'][0]
orbitals_down = results[0]['orbitals'][1]
# The columns of the Slater matrices are the HF orbitals
# A UHF-like Slater determinant is a pair of Slater matrices
# the spin-up orbitals, with shape (Nsites × Nup),
# the spin-down orbitals, with shape (Nsites × Ndown)
#
phi_up = orbitals_up[:,:nelec[0]]
phi_down = orbitals_down[:,:nelec[1]]
phi_0 = (phi_up, phi_down) # |phi_0> = |phi_up> X |phi_down>
# now make the spin-reversed Slater determinant.
phi_1 = (phi_down, phi_up) # |phi_1> = |phi_down> X |phi_up>
# numpy.stack is a convenient way to stack the determinants of each spin channel
wfn = NOMSDWavefunction(
coeffs=np.array([1.0, 1.0]),
dets=(np.stack([phi_0[0], phi_1[0]]), np.stack([phi_0[1], phi_1[1]]))
)
from safiretools import write_jobfile
# write input file, which also writes the wavefunction and the Hamiltonian to HDF5
write_jobfile(
"afqmc.json",
{
"seed": 42,
"execute": {
"wavefunction": wfn,
"hamiltonian": hamiltonian,
"timestep": 0.01,
"steps": 10000,
"equilibration_steps": 500,
"measure_interval": 10, # in units of steps
"population_control_interval": 10, # in units of steps
"walker_ortho_interval": 10, # in units of steps
"num_walkers": 1600
}
}
)
!mpirun -n 16 $AFQMC_EXEC afqmc.json
# analyze results
from safiretools import Results
results = Results("afqmc.results.h5")
vis.plot_timeseries(results)