Product state of rotated spins for SpinHalfFermionSite

How do I use this algorithm? What does that parameter do?
Post Reply
tanahy
Posts: 4
Joined: 17 Feb 2021, 15:24

Product state of rotated spins for SpinHalfFermionSite

Post by tanahy »

As instructed in MPS.from_product_state as well as in the original post I have tried to compose a state with all spins pointing towards Sx in the bloch sphere for the FermiHubbardChain model. However, this seems to be impossible due to an error that arises when I try to use the proposed notation for the spins using this model, which depends on SpinHalfFermionSite.

It works properly with SpinSite and SpinHalfSite, but not when SpinHalfFermionSite. My guess is that the difference is due to the absence of the conserve parameter, where it has been substitued with cons_N and cons_Sz. Here you have a bit of code to exemplify the error:

Code: Select all

rot_state    = np.array([1,1])
rotated_config = [rot_state/np.linalg.norm(rot_state) for i in range(L)]

site = tenpy.networks.site.SpinHalfSite(conserve=None)
site_Fermi = tenpy.networks.site.SpinHalfFermionSite(cons_N=None,cons_Sz=None)

psi = MPS.from_product_state([site]*L, rotated_config, bc=bc)
psi_Fermi = MPS.from_product_state([site_Fermi]*L, rotated_config, bc=bc)

Resulting in the following error:

Code: Select all

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-13-0557de387b23> in <module>
      6 
      7 psi = MPS.from_product_state([site]*L, rotated_config, bc=bc)
----> 8 psi_Fermi = MPS.from_product_state([site_Fermi]*L, rotated_config, bc=bc)

~/.local/lib/python3.9/site-packages/tenpy/networks/mps.py in from_product_state(cls, sites, p_state, bc, dtype, permute, form, chargeL)
    490             else:  # iter works
    491                 if len(p_st) != site.dim:
--> 492                     raise ValueError("p_state incompatible with local dim:" + repr(p_st))
    493                 B = np.array(p_st, dtype).reshape((site.dim, 1, 1))
    494             if perm:

ValueError: p_state incompatible with local dim:array([0.70710678, 0.70710678])

Is there any way to solve this issue? Any alternatives?

I have tried to build an MPO based on \(e^{-i Sy \frac{\pi}{2}}\) so that I can perform a rotation by applying it to the product state where all spins are up but I still don't know how to build such an MPO from one operator only. It would be great if there was a way to learn how to do this as it feels like a more universal solution than defining the rotation in local Hilbert space.

I have read the code on a_np_conserved.py but I can't wrap my head about how to build the MPO in this case. I'm fairly new to tensor networks so that is an important factor in my understanding of tenpy's syntax.

All the best,
Tana

tanahy
Posts: 4
Joined: 17 Feb 2021, 15:24

Re: Product state of rotated spins for SpinHalfFermionSite

Post by tanahy »

Ok, so I have found a workaround that I didn't thought before because I hadn't seen this method. The idea is to use MPS.apply_local_op to apply the rotation on each site such that, for example:

Code: Select all

Sy = model.lat.site(0).Sy
#Sy = site.Sy

Ry = npc.expm(-1j*np.pi/2*Sy)
#print(type(Ry))

[psi.apply_local_op(i,Ry) for i in range(L)]

Then we get the rotated state by changing the state per site. This works totally fine but the functionality of defining the state based on the superposition of states possible for other site models is still unavailable for SpinHalfFermionSite, so it would be great if someone could have a look at it or if by contrast I'm mistaken and there is a fundamental reason this is not possible.

All the best,
Tana

User avatar
Johannes
Site Admin
Posts: 413
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: Product state of rotated spins for SpinHalfFermionSite

Post by Johannes »

Hi Tana,
first of all, welcome to TeNPy, and sorry that I didn't reply earlier. I hope this still helps.

The issue which you ran into is quite simple: the SpinHalfFermionSite represents a 4-dimensional local Hilbert space (with states "empty", "spin-up", "spin-down", "both electrons"), whereas the SpinSite/SpinHalfSite only have a 2-dimensional Hilbert space.
Hence, building psi_Fermi will work if you just use the corresponding spin states:

Code: Select all

L = 10
ferm = tenpy.networks.site.SpinHalfFermionSite(None, None)
rot = np.zeros(ferm.dim)
rot[ferm.state_indices(['up', 'down'])] = 1./np.sqrt(2)
psi = tenpy.networks.mps.MPS.from_product_state([ferm]*L, [rot]*L)
psi.expectation_value('Sx')                                                                                                                                                          
# gives array([0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5])
If you would try to write an MPO for Ry, this would really just be a product of local rotations, so it is a product-MPO with bond dimension 1. There's no need to explicitly construct the MPO (and no good way to do it in TeNPy).

In general, these states are superpositions of different Sz sectors, so once you start thinking about Sz conservation, you should actually avoid them. (It's perfectly fine, however, if you have an Sz-breaking terms like Sx in your Hamiltonian.)
Post Reply