Skip to content

A simple tutorial for beginners to get start with ITensor

Notifications You must be signed in to change notification settings

empter/mps-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Introduction

ITensor is a c++ library for implementing tensor network calculations easily and efficiently. The home page of ITensor. It's easy to use ITensor in MacOS and Linux including the Windows subsystem for linux (WSL). This tutorial is mainly focus on the WSL alone with Ubuntu 18.04LTS which can be installed in the Microsoft Store. An uptodate Windows 10 is needed.

Prepare Ubuntu

  1. Turn on wsl:
  • Right click on PowerShell and select Run as Administrator.

  • Paste the following code and hit return.

    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

  • Reboot system.

  1. Search Ubuntu in the Microsoft Store and install it.
  2. Launch bash by the new created shortcut and creat your user name and password.
  3. Go to wsltty repository download and install the lastest release version of wsltty. Use wsltty instead of default terminal for a better experience. If no shortcut created, creat it by hand.
  • Right click on the desktop, select New>Shortcut

  • Paste following code into the input box then Next

    %LOCALAPPDATA%\wsltty\bin\mintty.exe --wsl -o Locale=C -o Charset=UTF-8 /bin/wslbridge -C~ -t /bin/bash

  • Give this shortcut a name then Finish

  1. Change default PPA in Ubuntu: replace all the context in /etc/apt/sources.list with lines generated @mirrors.zju.edu.cn. open wsltty, run the following commands step by step:
  • sudo nano /etc/apt/sources.list
  • delete all contents
  • go to mirrors.zju.edu.cn, in 配置生成器 section, seletc Ubuntu>18.04 then generate configuration
  • paste lines generated by mirrors.zju.edu.cn (right click to paste)
  • CTRL+X to exit nano and type Y to save
  • sudo apt-get update
  • sudo apt-get install g++ make libopenblas-dev

Install ITensor

  • Download the tar.gz type file at ITensor home page. If the download path is D:\Downloads.

  • Move the downloaded file to your home directory

    cd ~/

    mv /mnt/d/Downloads/ITensor-*.tar.gz ~/

    tar -xvf ITensor-*.tar.gz

    mv ITensor-* ITensor

    cd ITensor

    path and file name can be autocompleted by hitting tab, the above commands includes * which is a random string, you should use tab to autocomplete it.

  • Modify make option file

    cp options.mk.sample options.mk

    nano options.mk

    comment the following two line (add #)

    PLATFORM=macos
    BLAS_LAPACK_LIBFLAGS=-framework Accelerate
    

    uncomment three line (delete #)

    #PLATFORM=openblas
    #BLAS_LAPACK_LIBFLAGS=-lpthread -L/usr/local/opt/openblas/lib -lopenblas
    #BLAS_LAPACK_INCLUDEFLAGS=-I/usr/local/opt/openblas/include -fpermissive -DHAVE_LAPACK_CONFIG_H -DLAPACK_COMPLEX_STRUCTURE
    

    change

    OPTIMIZATIONS=-O2 -DNDEBUG -Wall
    

    to

    OPTIMIZATIONS=-O3 -DNDEBUG -Wall
    

    CTRL+X Y return to save the modified file.

  • Compile ITensor

    make

    wait for compile process complete.

Learn&Use ITensor

Use

A simple DMRG code for a Ising chain can be found here. Download and unzip all three files (argv.txt, dmrgising.cc, and Makefile) to a place in Windows, e.g., D:\DMRG\

cd /mnt/d/DMRG

make

export OPENBLAS_NUM_THREADS=1 (set threads for openblas, 1 is most efficient in most cast for itensor)

./dmrgising argv.txt 100 0.6

./dmrgising is the program itself, argv.txt contains settings for dmrg, 100 is the chain length N, 0.6 is the the magnetic field strength hz.

When writting your own code in a file owncode.cc, always put Makefile with it in the same directory and change

APP=dmrgising

to

APP=owncode

then you can type

make

to compile your code into binary file and run it.

Learn

The folllowing tutorials should be learned step by step expect for the last one if you do not care about the implementations of ITensor.

  • Basic C++ grammar: take a look at this tutorial.
  • For a tensor fundamentals, see The ITensor Book.
  • The ITensor Tutorials gives intuitive sense for beginners.
  • Code Formulas is a great reference when you write your own code based on ITensor.
  • The details of ITensor library can be found here, it's useful when you decide to take a look at the source code of ITensor.

About

A simple tutorial for beginners to get start with ITensor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published