I am trying to calculate excited states of spinful fermi hubbard model by using DMRG. I need to add magnetic field \sum{}h_{i}(n_{i,\uparrow} - n_{i,\downarrow})/2. The values of magnetic field should be random at each site. Any idea how to implement this?
Our OpSum system allows you to add terms such as h n_{i \uparrow} by doing:
os = OpSum()
...
os .+= h,"Nup",i
You can put this kind of summation into a for loop over i to sum over different sites. Then if you want the h values to be random, I would suggest making the random values inside an array named h then accessing them as h[i].
Thank you for your reply! It was useful.
Is it possible to do this with AutoMPO() ? For example:
ampo = AutoMPO()
...
for i = 1:N
ampo .+= h, "Nup", i
end
for i = 1:N
ampo .+= -h, "Ndn", i
end
Is this a same with which was written above? But I am afraid it does not work. How to add term -Ndn?
For some reason I can not use OpSum(). Getting following error:
UndefVarError: OpSum not defined in Main. What can be reason for this error?
Yes, so OpSum is the new name for AutoMPO. We have updated all of the code examples and documentation to use OpSum but I suppose there are still examples on the forum using the older name.
I’m not sure the reason for that error, unfortunately. Are you putting using ITensors in your code? That should bring OpSum into your set of imported type names. If the error persists, could you show a minimal example to reproduce that error?