how to construct a gate operator with onsite interaction term at TEBD

When i want to do a naive TEBD about bose-hubbard model, I get some obstacles when i’am trying to
make the local hj operator, the on-site term has some problem, how to construct the onsite term?

    for j in 1:(L - 1)
        s1 = sites[j]
        s2 = sites[j + 1]
        hj =
            0.5 * U * op("N", s1) * op("N", s1) + 
            - 0.5 * U * op("N", s1) + 
            V * op("N", s1) * op("N", s2) +
            -t * op("A", s1) * op("Adag", s2) +
            -t * op("Adag", s1) * op("A", s2)
        Gj = exp(-im * tau / 2 * hj)
        push!(gates, Gj)
    end

it has an error output :slight_smile:
ERROR: LoadError: syntax: “*(0.5, U, op(“N”, s1), op(“N”, s1))” is not a valid function argument name around d:\Source_Code\BaiduSyncdisk\julia\cold_atom\BHM\1d_BHM_TEBD.jl:72

It looks like you might be getting a Julia syntax error. Please check that U is defined, that your syntax is correct, and so on. You might want to try adding one term at a time to your expression to see which one is causing the issues, and also print out each thing such as U or op("N",s1) separately to make sure it has the type and behavior you expect.

thanks for your reply, I realize my aim by U/2 * op("N * N", s1) * op("I", s2), but there has anothter doubt,
when I save the data of MPS h5 data every time evolution steps, after about 300 steps, the file size madness grew to 1.0GB a MPS state, My system is sites = siteinds("Boson", 100; dim=3, conserve_qns=true), I want to ask is it normal?

That does seem a bit large. What is the bond dimension? Also are you adding more MPS to the same file? Or overwriting them and/or making new files each time?

thanks, my bond dimension for the initial wave function’s maxdim is about 250 , and it’s h5 file size is about 21MB. I have test my code for L = 10 system, I don’t see the crazy enlarge of MPS file, I don’t think I adding more MPS to the same file. this is my time loop code, is there something wrong?

for t in 0.0 : tau : t_total
        
        psi0 = apply(gates, psi0; cutoff)
        n = expect(psi0, "N"; sites=center)
        println("$t, $n")
        normalize!(psi0)
        f2 = h5open("./data/psi_t_$(round(t; digits = 4))_L_$(L)_J_$(round(J; digits = 4))_V_$(round(V; digits = 4)).h5","w")
            write(f2,"psi",psi0)
        close(f2)

        t ≈ t_total && break
    end

surely, I save the MPS data every time step by create a new file. The cutoff is set 1e-8.
I think the problem is might the gates operater’s dim is enlarge to a big value to make sure the cutoff 1e-8, and lead to the wave function enlarge, is this wright?

That’s good info, but I won’t be able to know what is causing the size to get larger. One thing you can do is borrow some of the techniques (like the idea of using the Base.summarysize function) from this code example:
https://itensor.github.io/ITensors.jl/dev/examples/DMRG.html#Monitoring-the-Memory-Usage-of-DMRG
to print out the size of your MPS just before you write it to the file. If the MPS is small but the file is large, then you’ll know something is going wrong with the file.

Otherwise you’ll have to try various things like that to debug it. I hope you find the issue!