This is migrated from an issue by Ryan Levy. I updated the code snippet based on changes in afqmctools. I'm not 100% convinced that this is an issue - there isn't really a guarantee that the orbitals should be real even if a no twist is used. Keeping it for now anyway.
Due to imaginary noise in the Hamiltonian with a real twist, the returned orbitals are accidentally complex
MWE:
import afqmctools.systems.lattice as lat
import afqmctools.hamiltonian.model.builder as ham
import afqmctools.utils.io as io
from afqmctools.wavefunction.free_electron import free_electron
import numpy as np
lattice = lat.SquareLattice(
L=(4,4),
axis1_boundary=lat.PBCBoundary,
axis2_boundary=lat.PBCBoundary,
twist=["1 Pi","1 Pi"]
)
params = {
"hamiltonian": {
"U" : 2.0,
"t" : 1.0
},
"lattice" : {
"L1" : 4,
"L2" : 4,
"boundary1" : "pbc",
"boundary2" : "pbc",
"twist" : ["1 Pi", "1 Pi"]
}
}
wfn, _ = free_electron(params, (8,8), lattice=lattice)
print(np.max(np.abs(wfn[1].imag)))
produces:
This is migrated from an issue by Ryan Levy. I updated the code snippet based on changes in afqmctools. I'm not 100% convinced that this is an issue - there isn't really a guarantee that the orbitals should be real even if a no twist is used. Keeping it for now anyway.
Due to imaginary noise in the Hamiltonian with a real twist, the returned orbitals are accidentally complex
MWE:
produces: