https://github.com/ultimatile/itensor_tutorial.jl
https://github.com/ultimatile/itensor_tutorial.jl
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ultimatile/itensor_tutorial.jl
- Owner: ultimatile
- License: mit
- Created: 2024-07-08T05:05:15.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-08-12T17:22:15.000Z (10 months ago)
- Last Synced: 2025-10-11T04:57:04.584Z (8 months ago)
- Language: Julia
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# itensor_tutorial
[](https://github.com/ultimatile/itensor_tutorial.jl/actions/workflows/CI.yml?query=branch%3Amain)
## target model: $S=1/2$ transverse field Ising chain
Hamiltonian:
$$
H=\sum_{i=1}^N\left(JS^z_i S^z_{i+1} + h S^x_i\right)
$$
When `periodic=true`, the periodic boundary condition is applied: $S^z_{N+1}=S^z_1$.
When `periodic=false`, the open boundary condition is applied; the maximum of the summation index $i$ changes as $N\to N-1$.
The default value is `periodic=true`.
## exact ground state energy for periodic boundary condition
$$
E = -\frac12\sum_{i=1}^{N}
\sqrt{\left(h-\frac{J}{2}\cos q_i\right)^2+\frac{J^2}{4}\sin^2q_i}
=-\frac12\sum_{i=1}^{N}\sqrt{h^2-hJ\cos q_i+\frac{J^2}{4}}
$$
Here, $q_i=\frac{2\pi}{N}(i-\frac12)$ if $N$ is even, and $q_i=\frac{2\pi}{N}i$ if $N$ is odd.
The periodic boundary condition is assumed.
## how to run
After executing Julia REPL, activate the environment and run the script:
```sh:
Pkg> activate .
using itensor_tutorial
main()
```
Alternatively, you can run the script directly with your Julia environment:
```sh:
julia src/itensor_tutorial.jl
```
## expected output
`J = -1.0`, `h = 0.5`, and `periodic = true` are used.
### $N=12$
```
Ground state energy (DMRG) = -3.830648787056722
Ground state energy (analytical) = -3.8306487877701936
Energy error = 7.134715040990613e-10
```
### $N=13$
```
Ground state energy (DMRG) = -4.148114903976182
Ground state energy (analytical) = -4.148114905279376
Energy error = 1.303193997159724e-9
```