Can itensor implement z2 parity in ising model

As a beginner, I have a very naive question here. I’m thinking of a simple transverse field ising model ,and trying to eccode the z2 parity in itensor, but fail. If it can be achieved, can you provide a simple 1D example that can be learned.
I am looking forward to getting your views or suggestions on this issue. Thank you for your answer, thanks for itensor team.

According to itensor.jl’s tutorial, I have tried to write an ising model with h=1, J=1, using z2 parity.

using MKL
using LinearAlgebra
using ITensors
using ITensors.HDF5
using Plots

ITensors.disable_threaded_blocksparse()
ITensors.Strided.set_num_threads(1)
BLAS.set_num_threads(8)

@show Threads.nthreads()
@show Sys.CPU_THREADS
@show ITensors.blas_get_num_threads()
@show ITensors.Strided.get_num_threads()
@show ITensors.using_threaded_blocksparse()
@show BLAS.get_config()
println()

@time let
  N = 64
  
  println("Begin calculation TFI=",N)
  
  # ground state
  sites = siteinds("S=1/2",N; conserve_szparity=true)

  ampo = OpSum()
  for j = 1:N-1
      ampo .+=  -4.0,"Sx",j,"Sx",j+1
      ampo .+=  -2.0,"Sz",j
  end
  ampo .+=  -2.0,"Sz",N
  
  H = MPO(ampo,sites)
  
  state = [isodd(n) ? "Up" : "Dn" for n=1:N]
  psi0 = productMPS(sites,state)
  
  sweeps = Sweeps(20) # number of sweeps is 20
  maxdim!(sweeps,10,20,100,100,200) # gradually increase states kept
  cutoff!(sweeps,1E-14) # desired truncation error
  
  energy,psi = dmrg(H,psi0,sweeps)
  
  println(" Transverse field = ",energy/N)

My first question is, whether the above code with z2 parity can speed up the operation compared to the non-QN conserving ising model code?

My second question is, in the answer to Multi-thread julia ITensor - ITensor Support Q&A it says: for z2 parity , if the blocks are large enough , it may be better to use BLAS/LAPACK multithreading instead of block sparse multithreading. I wonder if my code above applies both BLAS/LAPACK multithreading and z2 parity correctly?

Hi kevinh,
Yes your code looks correct for what you’re trying to do, and I’m glad you figured out about the conserve_szparity keyword.

  • At a glance, yes it looks like your code is doing the right thing to enable BLAS multithreading and to disable ITensor block-sparse multithreading (which is a good idea if you are using BLAS multithreading). But the most important thing is to test your code on some medium-sized systems with different multithreading settings to see if you can observe a benefit to using it, since the benefits of multithreading (and different kinds of multithreading) depend sensitively and in non-obvious ways on details like the typical block size in the tensors, number of blocks, etc. which are hard to predict.

  • To verify that the conserve_szparity setting is working properly, print out the first few sites to check that they carry Z_2 parity quantum numbers: @show sites[1] etc.

1 Like