-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoptimizesite.m
executable file
·66 lines (63 loc) · 2.64 KB
/
optimizesite.m
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
function [Aj,Vmat,results,para,op]=optimizesite(mps,Vmat,op,para,results,sitej)
optV=1;
while optV
if para.dk(sitej)>2 &¶.useVmat==1 %Only optizime Vmat{sitej} for the boson sites.
[Amat,V] = prepare_onesiteAmat(mps{sitej},para,sitej);
Blaststep = contracttensors(Vmat{sitej}, 2, 2, V, 2, 2);
[B,E] = minimizeE_onesiteVmat(op, Amat, Blaststep,para);
% if sitej>=3 && para.rescaling==1
% results.geoffset(sitej)=(results.geoffset(sitej-1)+results.leftge(sitej))*para.Lambda;
% E=(E+results.geoffset(sitej))./(para.Lambda.^(sitej-2));
% end
% %results.leftge(sitej)
% fprintf('\nE = %.10g\n', E);
[Vmat{sitej}, V, results] = prepare_onesiteVmat(B,para,results,sitej);
Amatlaststep = contracttensors(Amat, 3, 3, V, 2, 2);
else
Amatlaststep = mps{sitej}; optV=0;
end
[Aj, E] = minimizeE_onesiteA(op, Vmat{sitej}, Amatlaststep,para,sitej);
if para.loop>1 && para.dk(sitej)>2 && para.useshift==1 && sitej<=para.trustsite(end)
switch para.model
case 'SpinDoubleBoson'
[bp,bm,n] = bosonop(sqrt(para.dk(sitej)),para.shift(sitej),para.parity);
if para.parity=='n'
idm=eye(size(n));
bpx=kron(bp,idm);bmx=bpx';nx=kron(n,idm);
bpz=kron(idm,bp);bmz=bpz';nz=kron(idm,n);
else
[bpx,bmx,nx,bpz,bmz,nz]=paritykron(bp,para.bosonparity);
end
x=sqrt(2)/2*(bpx+bmx);
otherwise
[bp,bm,n] = bosonop(para.dk(sitej),para.shift(sitej),para.parity);
x=sqrt(2)/2*(bp+bm);
end
if para.useVmat==1
temp=contracttensors(x,2,2,Vmat{sitej},2,1);
temp=contracttensors(conj(Vmat{sitej}),2,1,temp,2,1);
else
temp=x;
end
temp=contracttensors(Aj,3,3,temp,2,2);
shift=real(contracttensors(temp,3,[1,2,3],conj(Aj),3,[1,2,3]));
para.relativeshift(sitej)=abs(shift-para.shift(sitej))/para.maxshift(sitej);
if para.relativeshift(sitej)>para.relativeshiftprecision
para.shift(sitej)=shift;%disp(shift)
op=update_sitej_h1h2(para,op,sitej);
mps{sitej}=Aj;
else
optV=0;
end
else
optV=0;
end
end
if sitej>=3 && para.rescaling==1
results.geoffset(sitej)=(results.geoffset(sitej-1)+results.leftge(sitej))*para.Lambda;
E=(E+results.geoffset(sitej))./(para.Lambda.^(sitej-2));
end
%results.leftge(sitej)
%fprintf('E = %.10g\n', E);
results.E=E;
end