-
Notifications
You must be signed in to change notification settings - Fork 13
/
example_groundstate_energy.py
96 lines (81 loc) · 3.2 KB
/
example_groundstate_energy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# -*- coding: utf-8 -*-
'''
Example script how to use the functions get_hamiltonian_sparse(...)
in the files:
- hamiltonian_tfi.py
- hamiltonian_hb_staggered.py
- hamiltonian_hb_xxz.py
:author: Alexander Wietek
:email: alexander.wietek@uibk.ac.at
:year: 2018
'''
from __future__ import absolute_import, division, print_function
import numpy as np
import scipy as sp
from scipy import sparse
from scipy import linalg
from scipy.sparse import linalg
import hamiltonian_tfi as tfi
import hamiltonian_hb_staggered as stag
import hamiltonian_hb_xxz as xxz
# Parameters for diagonalization
full_diagonalization = False
n_lowest_eigenvalues = 1
'''
Computation of the ground state energy of the transverse field Ising
model
'''
# Parameters for TFI model
L=12 # length of chain, keep it smaller than ~16, :-)
J=1 # strength of Ising interaction
hx=0.5 # strangth of transverse field
rows, cols, data = tfi.get_hamiltonian_sparse(L, J, hx)
hamiltonian = sp.sparse.csr_matrix((data, (rows, cols)))
if full_diagonalization:
eigs = sp.linalg.eigh(hamiltonian.todense(), eigvals_only=True)
else:
eigs = sp.sparse.linalg.eigsh(hamiltonian, k=n_lowest_eigenvalues,
which='SA', return_eigenvectors=False,
maxiter=1000)
print("Ground state energy of TFI model at J =", J, ", hx =",
hx, ":", min(eigs))
'''
Computation of the ground state energy of the Heisenberg model
in a staggered magnetic field
'''
# Parameters for Heisenberg model
L=12 # length of chain, keep it smaller than ~16, :-)
J=1 # strength of Heisenberg interaction
hs=0.5 # strangth of staggered magnetic field
sz=0 # magnetization, (number of up-spins = L//2 + sz)
rows, cols, data = stag.get_hamiltonian_sparse(L, J, hs, sz)
hamiltonian = sp.sparse.csr_matrix((data, (rows, cols)))
if full_diagonalization:
eigs = sp.linalg.eigh(hamiltonian.todense(), eigvals_only=True)
else:
eigs = sp.sparse.linalg.eigsh(hamiltonian, k=n_lowest_eigenvalues,
which='SA', return_eigenvectors=False,
maxiter=1000)
print("Ground state energy of Heisenberg model with staggered field at J =",
J, ", hs =", hs, ", Sz =", sz, ":", min(eigs))
'''
Computation of the ground state energy of the Heisenberg XXZ model
'''
# Parameters for Heisenberg model
L=16 # length of chain, keep it smaller than ~16, :-)
J=1 # strength of Heisenberg interaction
delta=0 # strength of XY anisotropy
sz=0 # magnetization, (number of up-spins = L//2 + sz)
k=1 # momentum quantum number
#(in integer units, acutal momentum 2*pi/L*k
rows, cols, data = xxz.get_hamiltonian_sparse(L, J, delta, sz, k)
hamiltonian = sp.sparse.csr_matrix((data, (rows, cols)))
if full_diagonalization:
eigs = sp.linalg.eigh(hamiltonian.todense(), eigvals_only=True)
else:
eigs = sp.sparse.linalg.eigsh(hamiltonian, k=n_lowest_eigenvalues,
which='SA', return_eigenvectors=False,
maxiter=1000)
print("Ground state energy of Heisenberg model with staggered field at J =",
J, ", delta =", delta, ", Sz =", sz, ", k = ", k, ":", min(eigs))
print("Run successful")