Download this notebook (.ipynb + data files)
6. Hubbard Model on a Honeycomb Lattice#
6.1. Set Up the Hamiltonian#
# create scratch directory in notebook path
%mkdir -p {_dh[0]}/data
%cd -q {_dh[0]}/data
# setup the Hamiltonian
from safiretools import Lattice
from safiretools import vis
from safiretools import LatticeHamiltonian
lattice = Lattice.from_type(
"honeycomb", (4, 4), boundaries=("periodic", "periodic"), twists=(0.0, 0.0)
)
# plot the lattice for reality checks!
vis.plot_lattice(lattice)
# make the Hamiltonian
hamiltonian = LatticeHamiltonian.from_lattice(lattice, U=6.0)
# run AutoHF and save wavefunction as trial wavefunction
import numpy as np
from autohf import solve_hf, AutoHFHamiltonian
from safiretools import Wavefunction
# Typically, we want to use a Ueff to generate a trial wavefunction
# since HF's critical U is lower than the correct critical U
Ueff = 3.0
# make the effective Hamiltonian
effective_hamiltonian = LatticeHamiltonian.from_lattice(lattice, U=Ueff)
# convert safiretools Hamiltonian to AutoHFHamiltonian
autohf_hamiltonian = AutoHFHamiltonian(effective_hamiltonian)
# set the number of electrons!!
nelec=(16-1,16-1)
settings = dict(
ansatz = 'SD_ROT',
steps = 100,
nelec = nelec,
batch_size = 100,
seed = 42
)
results = solve_hf(hamiltonian=autohf_hamiltonian,settings=settings)
wavefunction = Wavefunction.from_single_determinant(
tuple(np.asarray(o) for o in results[0]["orbitals"])
)
6.2. Write Input File#
For more information about the input file, see Understanding the JSON Job File.
from safiretools import write_jobfile
# write input file
write_jobfile(
"afqmc.json",
{
"seed": 42,
"execute": {
"wavefunction": wavefunction,
"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
}
}
)
6.3. Run AFQMC#
!mpirun -n 16 $AFQMC_EXEC afqmc.json
6.4. Analyze the Results#
# analyze results
from safiretools import Results
results = Results("afqmc.results.h5")
vis.plot_timeseries(results)