Quantum-Many-Body / QuantumLattices.jl

Julia package for the construction of quantum lattice systems.
https://quantum-many-body.github.io/QuantumLattices.jl
Other
108 stars 9 forks source link

Does this package support non-uniform Onsite energy term? #30

Open hz-xiaxz opened 1 month ago

hz-xiaxz commented 1 month ago

Hello, thanks for your robust and elegant package!

I'm using this package to perform benchmark of Anderson-Hubbard Model (ref). It is simply a Hubbard model with random onsite energy for each site.

I read the source code and find that an array input for the Onsite function will cause the assertion error: AssertionError: Term error: only real values are allowed. Complex values always have the positive directions, therefore, they must be specified by the amplitude function.

I wonder if it is possible to support non-uniform Onsite energy assignment according to the id's of lattice sites?

hz-xiaxz commented 1 month ago

After learning from the document, I found this feature is well-supported by the TermAmplitude parameter. So I hacked to add my onsite disorder term $ \sumi \sum{\sigma} \omegai c^\dagger{i,\sigma} c_{i, \sigma} $ to the Fermi-Hubbard model

    # define the terms, i.e. the nearest-neighbor hopping and the Hubbard interaction
    t_term = Hopping(:t, -t, 1)
    U_term = Hubbard(:U, U)

    #########################

    function disorder(bond::Bond)
        coordinate = bond.points[1].rcoordinate
        onsite = omega_reshape[Int(coordinate[1])+1, Int(coordinate[2])+1]
        return onsite
    end

    ω_up = Term{:Onsite}(:ωup, 1.0, 0, Coupling(Index(:, FID{:f}(:, 1 // 2, 2)), Index(:, FID{:f}(:, 1 // 2, 1))), true; amplitude=disorder, ismodulatable=true)

    ω_down = Term{:Onsite}(:ωdown, 1.0, 0, Coupling(Index(:, FID{:f}(:, -1 // 2, 2)), Index(:, FID{:f}(:, -1 // 2, 1))), true; amplitude=disorder, ismodulatable=true)

    ###########################

    # define the exact diagonalization algorithm for the Fermi Hubbard model
    ed = ED(lattice, hilbert, (t_term, U_term, ω_up, ω_down), quantumnumber)

I wonder if I got all things right? Thanks for your assistance!