Skip to content

[Py] Real twist produces complex orbitals #28

Description

@bkesk

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:

0.2500000003735068

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions