Questions Regarding Implementation of a 1D Lattice of Bosons

How do I use this algorithm? What does that parameter do?
Post Reply
dm_Physics
Posts: 7
Joined: 05 Dec 2021, 20:23

Questions Regarding Implementation of a 1D Lattice of Bosons

Post by dm_Physics »

Hello,

I have been reading the Overview section of the tenpy documentation. This can be found in the following link: https://tenpy.readthedocs.io/en/latest/ ... rview.html

Today I have looked at the SpinHalfSites sample code. After I have understood most of it, I adapted the code to implement a lattice of six spin-2 particles. The code and the output are provided below.

Input:

Code: Select all

# Let us play with SpinSite for spin S
# Step 1: Make the important imports
from tenpy.networks.site import SpinSite
from tenpy.networks.mps import MPS
from tenpy.networks.mpo import MPO

# Step 2: Create one spin S=2 object and check that we get the correct matrix Sz, Sp, Sm
spin2 = SpinSite(S=2, conserve='Sz')

print('The Sz matrix is')
print(spin2.Sz.to_ndarray())
print('The S+ matrix is')
print(spin2.Sp.to_ndarray())
print('The S- matrix is')
print(spin2.Sm.to_ndarray())

# Step 3: Create a 1D lattice of N = 6 spin 2 particles
N = 6
sites2 = [spin2] * N
print(sites2)

#Step 4: Create one state for the sites (i.e. one specific way the spins are "pointing" - here "up" = 4 and "down" = 0)
pstate2 = [0,1,2,3,4,2]
print(pstate2)

#Step 5: Create a MPS wave function
psi = MPS.from_product_state(sites2, pstate2, bc="finite")
print("<Sz> =", psi.expectation_value("Sz"))
# <Sz> = [ 0.5 -0.5  0.5 -0.5 0.5 -0.5]
print("<Sp_i Sm_j> =", psi.correlation_function("Sz", "Sz"), sep="\n")
# <Sp_i Sm_j> 
Output:

Code: Select all

The Sz matrix is
[[-2.  0.  0.  0.  0.]
 [ 0. -1.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.]
 [ 0.  0.  0.  1.  0.]
 [ 0.  0.  0.  0.  2.]]
The S+ matrix is
[[0.         0.         0.         0.         0.        ]
 [2.         0.         0.         0.         0.        ]
 [0.         2.44948974 0.         0.         0.        ]
 [0.         0.         2.44948974 0.         0.        ]
 [0.         0.         0.         2.         0.        ]]
The S- matrix is
[[0.         2.         0.         0.         0.        ]
 [0.         0.         2.44948974 0.         0.        ]
 [0.         0.         0.         2.44948974 0.        ]
 [0.         0.         0.         0.         2.        ]
 [0.         0.         0.         0.         0.        ]]
[SpinSite(S=2.0, 'Sz'), SpinSite(S=2.0, 'Sz'), SpinSite(S=2.0, 'Sz'), SpinSite(S=2.0, 'Sz'), SpinSite(S=2.0, 'Sz'), SpinSite(S=2.0, 'Sz')]
[0, 1, 2, 3, 4, 2]
<Sz> = [-2. -1.  0.  1.  2.  0.]
<Sp_i Sm_j> =
[[ 4.  2.  0. -2. -4.  0.]
 [ 2.  1.  0. -1. -2.  0.]
 [ 0.  0.  0.  0.  0.  0.]
 [-2. -1.  0.  1.  2.  0.]
 [-4. -2.  0.  2.  4.  0.]
 [ 0.  0.  0.  0.  0.  0.]]
Now, I am trying to implement a lattice of bosons using the class BosonSite. The documentation for this class can be found in the following link:
https://tenpy.github.io/reference/tenpy ... nSite.html

Here is the code that I ran:

Code: Select all

# Now let us try to implement a latice of bosons
# Step 1: Important Imports
from tenpy.networks.site import BosonSite
from tenpy.networks.mps import MPS
from tenpy.networks.mpo import MPO

#Step 2: Initialize one Boson site
boson = BosonSite(Nmax = 10, conserve ='N', filling=0.0)
print(boson.N.to_ndarray())
The output is the following:

Code: Select all

[[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  1.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  2.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  3.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  4.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  5.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  6.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  7.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  8.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  9.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0. 10.]]
Question 1: I understand that I created a boson site that can hold a maximum of 10 bosons, but what does the output mean?

Question 2: Suppose I want to create a lattice of 5 boson sites, each of which can hold at most 10 bosons, such that the total number of bosons in the entire lattice is fixed to be, let's say, 15. How would I do that?

Question 3: In the code for the spin-2 sites, I was able to create a variable called pstate2 that contained one specific set of spin orientations for the six spin-2 particles. This pstate2 was required to create the MPS wavefunction. Since I am trying to create an MPS state for my lattice of boson sites (so far there is only one site) how can I create a variable similar to pstate2? For instance, suppose I create a lattice of 5 boson sites with the properties mentioned in question 2. Then one possible state is as follows: site 1 = 6 bosons, site 2 = 4 bosons, site 3 = 0 bosons, site 4 = 4 bosons, site 5 = 1 boson. Would my pstate2 variable be [6,4,0,4,1] (I tried running it by creating an MPS state and no error message popped up, but I am not sure if I did it correctly)? If not, that how can I implement this initial state?

Question 4: In the spin-2 boson lattice example, after I was able to implement the MPS state, I was able to print out the expectation values of S_z? What expectation values can I print out for my lattice of boson sites?
User avatar
Johannes
Site Admin
Posts: 324
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: Questions Regarding Implementation of a 1D Lattice of Bosons

Post by Johannes »

Question 1: It's a dense matrix representation of the N (=particle number) operator. If you truncate to nmax=10, you have 11 local basis states |n>, where n=0,...,10 is the boson number. Hence, N is 11x11 matrix, with n on the diagonal.

Question 2/3/4: The cutoff nmax for the Site is the maximal boson number per site, which is often quite different from the total number of bosons: if the onsite boson interaction U limits the maximum occupation, you can have an infinite MPS/lattice with an infinite number of bosons, and say an average filling of 1 boson per site, but at most 2 or 3 bosons on a single site (up to a small truncation error).
Assuming you turn charge conservation on, the total number of bosons is fixed only once you choose an initial MPS state.
And yes, you can simply create the pstate2 accordingly. Note that in the example below, I used strings for the numbers, which are appropriate names for the onsite states of the tenpy.networks.site.BosonSite.
Check the documentation of the BosonSite compared to the tenpy.networks.site.SpinHalfSite to see what local basis states and onsite operators (like "Sz" or "N", respectively) they define.
Functions like the expectation_value can be given the names of the local onsite operators as arguments. Thus, the last line below prints the expectation values of the N operator, i.e. the local occupations, similarly to the Sz expectation value in the other example.

Code: Select all

from tenpy.networks.site import BosonSite
from tenpy.networks.mps import MPS

boson = BosonSite(Nmax = 10, conserve ='N')
pstate = ["6", "4", "0", "4", "1"]
psi = MPS.from_product_state([boson]*5, pstate, bc="finite")
print(psi.expectation_value("N"))
Post Reply