-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMPSAlgorithms_Class.fun
130 lines (99 loc) · 3.34 KB
/
MPSAlgorithms_Class.fun
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
!! Copyright 2010 Fernando M. Cucchietti
!
! This file is part of ForMPS
!
! ForMPS is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! ForMPS is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with ForMPS. If not, see <http://www.gnu.org/licenses/>.
test_suite MPSAlgorithms_Class
setup
!Set testing mode
MaxErrorAllowed=CriticalError
end setup
teardown
end teardown
test NormalizeUsingOverlap
type(MPS) :: anMPS
integer :: length=10,spin=2,bond=20
complex(8) :: overlap12
anMPS=new_MPS(length,spin,bond)
overlap12 = Overlap(anMPS,anMPS)
assert_false(abs(overlap12)**2.eq.1.0d0)
print *,'prevo overlap is ',overlap12
call Normalize(anMPS)
overlap12 = Overlap(anMPS,anMPS)
print *,'after overlap is ',overlap12
assert_equal_within(abs(overlap12)**2,1.0d0,1.0e-8)
spin= anMPS%Delete()
end test
test OverlapAlgorithm
type(MPS) :: anMPS
integer :: length=10,spin=2,bond=20
complex(8) :: overlap12
anMPS=new_MPS(length,spin,bond)
overlap12 = Overlap(anMPS,anMPS)
assert_false(abs(overlap12)**2.eq.1.0d0)
call anMPS%Canonize()
overlap12 = Overlap(anMPS,anMPS)
assert_equal_within(abs(overlap12)**2,1.0d0,1.0e-8)
spin= anMPS%Delete()
end test
test ApproximationAlgorithm
type(MPS) :: smallMPS,bigMPS
integer :: length=20,spin=2,bondBig=40,bondSmall=2,site
real(8) :: overlap12
type(MPSTensor) :: localTensor
bigMPS=new_MPS(length,spin,bondBig)
call bigMPS%Canonize()
smallMPS=Approximate(bigMPS,bondSmall,overlap12)
assert_equal_within(overlap12,1.0d0,1.0D-5)
print *,'Approximated overlap :',overlap12
print *,'Big bond:',bondBig
print *,'Small bond: ',smallMPS%GetMaxBond()
do site=1,smallMPS%GetSize()
localTensor=smallMPS.TensorAt.site
call localTensor%PrintDimensions('Dimensions of tensor')
print *,site
enddo
end test
test ApproximationWithoutCanonization
type(MPS) :: smallMPS,bigMPS
integer :: length=20,spin=2,bondBig=40,bondSmall=2,site
real(8) :: overlap12
type(MPSTensor) :: localTensor
bigMPS=new_MPS(length,spin,bondBig)
call Normalize(bigMPS)
smallMPS=Approximate(bigMPS,bondSmall,overlap12)
assert_equal_within(overlap12,1.0d0,1.0D-5)
print *,'Approximated overlap :',overlap12
print *,'Big bond:',bondBig
print *,'Small bond: ',smallMPS%GetMaxBond()
do site=1,smallMPS%GetSize()
localTensor=smallMPS.TensorAt.site
call localTensor%PrintDimensions('Dimensions of tensor')
print *,site
enddo
end test
test ApproximateLargeSpinMPS
type(MPS) :: smallMPS,bigMPS
integer :: length=20,spin=20,bondBig=20,bondSmall=2,site
real(8) :: overlap12
type(MPSTensor) :: localTensor
bigMPS=new_MPS(length,spin,bondBig)
call Normalize(bigMPS)
smallMPS=Approximate(bigMPS,bondSmall,overlap12)
assert_equal_within(overlap12,1.0d0,1.0D-5)
print *,'Approximated overlap :',overlap12
print *,'Big bond:',bondBig
print *,'Small bond: ',smallMPS%GetMaxBond()
end test
end test_suite