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