defining custom states

,

I am trying to play around with the S=3/2 example provided in the documentation by running DMRG on a simple S=3/2 Hamiltonian. Defining the Hamiltonian can be done by defining custom S=3/2 operators as detailed in the documentation. I am however unsure about how to define an initial product state MPS with a particular magnetization, which requires defining custom state types.

For example, I would like to be able to initialize an MPS by calling randomMPS(sites,states), where states is a vector of strings (e.g. ["-1/2","3/2",...] in this example). Does ITensor support the ability to define custom states in this way?

I was also trying an alternative approach, whereby I simply use the state types provided by the Qudit site type. In this case however I was not able to define appropriate S=3/2 operators. For example, if I naively do

ITensors.op(::OpName"Sz",::SiteType"Qudit") = [3/2 0 0 0; 0 1/2 0 0; 0 0 -1/2 0; 0 0 0 -3/2]

then I am unable to construct an MPO built from Sz operators acting on siteinds initialized from siteinds("Qudit",L;dim=4) (attempting to build the MPO throws the error MethodError: no method matching op(::OpName{:Sz}, ::SiteType{Qudit}, ::Int64)).

Probably I need to reference the dimension of the qudits in the definition of Sz, but I am not sure what the correct syntax to use here is.

Thanks for the help!

Yes, the states vector that randomMPS takes can be (and usually is) a vector of strings. For example, in this tutorial you can see that it is a vector of strings like ["Up","Dn","Up","Dn"] for the case of spin 1/2 used there.

For your custom S=3/2 site type, you can define the states that you want, following this code example (which right now only appears in the dev branch of the documentation). So you can define your states by strings and then pass those strings in your states vector.

It may be easier to just pass integers as states though too, which also works. If you pass 1 that corresponds to the first setting of the Index, and 2 to the second setting, etc.

Lastly, I’m not sure I understand the part of your question about the “Qudit” site type. If you are making and using sites with the site type of "S=3/2" then nothing about the "Qudit" site type will apply or work for a different site type. Or do you mean you are actually making indices with the “Qudit” site type?

Thanks Miles! Apologies for not seeing that earlier, I wasn’t aware that there was a dev version. For posterity’s sake, the syntax looks like e.g.

ITensors.state(::StateName"-3/2", ::SiteType"S=3/2") = [0, 0, 0, 1]

Good to know about passing integers though; that is indeed easier!

Re qudits: I was trying to define custom operators for the Qudit site type. For example, I was trying to naively do

ITensors.op(::OpName"Z",::SiteType"Qudit") = [1 0 0; 0 exp(2Ď€ * im/3) 0; 0 0 exp(-2Ď€ * im/3)]

and to then build an MPO defined on sites = siteinds("Qudit",L;dim=3) by taking ampo = OpSum() and doing

for i in 1:L 
     ampo += 1,"Z",i
end 
H = MPO(ampo,sites)

which throws the error mentioned in the previous post. Probably I need to include the dimension of qudits I am targeting somewhere in the definition of Z, but am not exactly sure where to do so.

I see - it’s a really good question about the “Qudit” site type. Your guess is right that you have to include the dimension – we need to figure out how to document that because it’s different from the other site types that way.

Here is the example of how to do it for your “Z” operator

ITensors.op(::OpName"Z",::SiteType"Qudit", d::Int)

Then of course you also need to define the operator matrix to be a d \times d matrix and put the appropriate entries. If that’s too much work and you only want to do the case of a certain d value, then you could always just put a line in the function that checks d is the right value and throws an error otherwise (just to prevent accidentally passing another value of d).

Please let me know if that doesn’t work. If you’d like to see more examples of how the “Qudit” operators included with ITensor are defined you can have a look here:
https://github.com/ITensor/ITensors.jl/blob/main/src/physics/site_types/qudit.jl

1 Like