-
Notifications
You must be signed in to change notification settings - Fork 0
/
scratchpad.m
8810 lines (8222 loc) · 375 KB
/
scratchpad.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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%% Path where to save figures
path = pwd;
saveto = '..\Presentations\20140206 - Summary\';
%saveto = '..\..\Presentations\20140520 - MLSBM\20140525-CoupFunc\';
wantSave = 0;
%% Plot Vmat contributions for different Sites i (normalized)
i=2;
plot(abs((Vmat{1,i}(:,:))))
title(['k = ',num2str(i),', max SV = ',num2str(results.Vmat_sv{1,i}(1,1))])
ylabel('Contribution to OBB')
xlabel('$d_k$')
if wantSave
export_fig(sprintf('%sVmatNormalized%s-%u',saveto,para.filename(1:13),i),'-transparent','-png','-eps')
end
%% Plot Vmat contributions for different Sites i (SV-weighted)
i = 5;
plot(real(Vmat{1,i}*diag(results.Vmat_sv{1,i})))
title(['k = ',num2str(i),', max SV = ',num2str(results.Vmat_sv{1,i}(1,1))])
ylabel('Contribution to OBB')
xlabel('$d_k$')
%print(gcf, [saveto,'VmatScaled',num2str(i),'.eps'],'-deps')
if wantSave
export_fig(sprintf('%sVmatScaled%s-%u',saveto,para.filename(1:13),i),'-transparent','-png','-eps')
end
%% Plot Sum over Vmat
i = 2;
a=sum(abs((Vmat{1,i}*diag(results.Vmat_sv{1,i}))),2);
plot(sum(abs(real(Vmat{1,i}*diag(results.Vmat_sv{1,i}))),2))
set(gca,'YScale','log')
title(['k = ',num2str(i),', max SV = ',num2str(results.Vmat_sv{1,i}(1,1))])
ylabel('Contribution to OBB')
xlabel('$d_k$')
%print(gcf, [saveto,'VmatScaled',num2str(i),'.eps'],'-deps')
if wantSave
export_fig(sprintf('%sVmatScaled%s-%u',saveto,para.filename(1:13),i),'-transparent','-png','-eps')
end
%% Plot Sum over Vtens
i = 2;
for j = 1:para.nChains
a(1:size(Vmat{i}{j},1),j) = sum(abs((Vmat{i}{j}*diag(results.Vmat_sv{j,i}))),2)'./para.d_opt(j,i);
end
plot(a);
set(gca,'YScale','log')
title(['k = ',num2str(i)])
ylabel('Contribution to OBB')
xlabel('$d_k$')
%print(gcf, [saveto,'VmatScaled',num2str(i),'.eps'],'-deps')
if wantSave
export_fig(sprintf('%sVmatScaled%s-%u',saveto,para.filename(1:13),i),'-transparent','-png','-eps')
end
%% Plot Sum over Vmat in 3D
plotMat = [];
mc = 1; % choose the chain!
rotate3d off
zeroVals = -50; % value of zeros for padding and -inf replacement
for i = 2:length(Vmat)
if size(Vmat{1,i}{mc},2) < size(results.Vmat_sv{mc,i},1)
a = log10(sum(abs((Vmat{1,i}{mc}*diag(results.Vmat_sv{mc,i}(1:size(Vmat{1,i}{mc},2),:)))),2));
else
a = log10(sum(abs((Vmat{1,i}{mc}(:,1:size(results.Vmat_sv{mc,i},1))*diag(results.Vmat_sv{mc,i}))),2));
end
a(a==-inf)=zeroVals;
dim = max(length(a),size(plotMat,1));
if length(a)< dim
a = padarray(a,dim-length(a),zeroVals,'pre');
elseif size(plotMat,1) < dim
plotMat = padarray(plotMat,dim-size(plotMat,1),zeroVals,'pre');
end
plotMat = [plotMat,a];
end
surf(plotMat)
title(['k = ',num2str(i),', max SV = ',num2str(results.Vmat_sv{mc,i}(1,1))])
ylabel('$d_k$')
xlabel('Site $k$')
set(gca,'View',[9.5 40]);
formatPlot(1)
rotate3d on
axis tight
shading interp
%% Plot Results
f1=figure(1);
for i = 2:1:size(results.D,2)
if isempty(results.D{i})
results.D{i} = results.D{i-1};
end
if isempty(results.d_opt{i})
results.d_opt{i} = results.d_opt{i-1};
end
if isempty(results.dk{i})
results.dk{i} = results.dk{i-1};
end
end
for i = 2:1:size(results.shift,2)
if isempty(results.shift{i})
results.shift{i} = results.shift{i-1};
end
end
subplot(2,2,1);
plot(real(results.nx));
title('$$<n_x(k)>$$');
subplot(2,2,2);
plot(para.trustsite);
title('Trustsite')
% 3D-version elucidating change:
if para.useshift
subplot(2,2,3);
surf(cell2mat(results.shift'))
set(gca,'View',[-25 10]);
shading interp
title('Bosonic shift');
end
subplot(2,2,4);
surf(cell2mat(results.d_opt'));
shading interp
set(gca,'View',[0 90]);
title('OBB dim')
% 2D-version showing final
% subplot(2,2,3);
% plot(results.shift{end});
% title('Bosonic shift');
% subplot(2,2,4);
% plot(results.d_opt{end});
% title('OBB dim')
% text(-80,-30,sprintf(para.filename(1:38)))
if wantSave
export_fig(sprintf('%sResultsSummary%s',saveto,para.filename(1:13)),'-transparent','-png','-painters')
end
%% Plot d_opt, D adjustments
% fill cell arrays
for i = 2:1:size(results.D,2)
if isempty(results.D{i})
results.D{i} = results.D{i-1};
end
if isempty(results.d_opt{i})
results.d_opt{i} = results.d_opt{i-1};
end
if isempty(results.dk{i})
results.dk{i} = results.dk{i-1};
end
end
f2 = figure(2);
subplot(1,3,1);
surf(cell2mat(results.D'))
set(gca,'View',[0 90]);
shading interp
title('Change in bond dimension D')
subplot(1,3,2);
surf(cell2mat(results.d_opt'))
set(gca,'View',[0 90]);
shading interp
title('Change in $d_{opt}$')
subplot(1,3,3);
surf(cell2mat(results.dk'))
set(gca,'View',[0 90]);
shading interp
title('Change in $d_{k}$')
rotate3d on
%set(gcf, 'Position', get(0,'Screensize')); % Maximize figure, to make caption readable
%export_fig(['png/',para.folder,'-D-dopt.png'],'-transparent',f2)
if wantSave
export_fig(sprintf('%sChangeOfdoptDdk%s',saveto,para.filename(1:13)),'-transparent','-png')
end
%% Plot shift adjustment history of results.shift
saveto = '..\Presentations\20140206 - Summary\';
% fill cell array
for i = 2:1:size(results.shift,2)
if isempty(results.shift{i})
results.shift{i} = results.shift{i-1};
end
end
f3 = figure(3);
%subplot(1,2,1);
%surf(cell2mat(results.D'))
%shading interp
%title('Change in bond dimension D')
%subplot(1,2,2);
surf(cell2mat(results.shift'))
set(gca,'View',[-25 10]);
shading interp
title('Change of shift $\delta_k$')
xlabel('site k')
ylabel('sweep')
zlabel('$\delta_k$')
%set(gcf, 'Position', get(0,'Screensize')); % Maximize figure, to make caption readable
if wantSave
export_fig(sprintf('%sChangeOfShift%s',saveto,para.filename(1:13)),'-transparent','-png')
end
%% Simulate shifting procedure
dim = 200; [bp,bm,n]=bosonop(dim,0,'n');
v1 = zeros(dim,1); v1(2:4) = 1/sqrt(3);
% 1. iteration
x = (bp+bm)./sqrt(2);
shift1 = v1'*x*v1;
[bp1n,bm1n,n1n]=bosonop(dim,shift1,'n');
bm1t = expm((bp-bm).*shift1./sqrt(2))'*bm*expm((bp-bm).*shift1./sqrt(2));
v1n = expm((bp-bm).*shift1./sqrt(2))'*v1;
% 2. iteration
x1n = (bp1n+bm1n)./sqrt(2);
shift2 = v1n'*x1n*v1n;
[bp2n,bm2n,n2n]=bosonop(dim,shift2,'n');
v2n = expm((bm1n-bp1n).*shift2./sqrt(2))*v1n;
plot([v1,v1n,v2n])
%% Try to analyse Differential Shift
diffShift = cell(1);
diffShift{1} = zeros(1,para.L);
diffShift{2} = zeros(1,para.L);
for i = 2:1:size(results.shift,2)
if isempty(results.shift{i})
results.shift{i} = results.shift{i-1};
end
if i~=2
diffShift{i} = results.shift{i}-results.shift{i-1};
end
end
f3 = figure(3);
%subplot(1,2,1);
%surf(cell2mat(results.D'))
%shading interp
%title('Change in bond dimension D')
%subplot(1,2,2);
surf(abs(cell2mat(diffShift')))
%set(gca,'View',[-25 10]);
set(gca,'View',[0 80]);
shading interp
title('Differential shift $\Delta (\delta_k)$')
xlabel('site k')
ylabel('sweep')
zlabel('$\delta_k$')
%set(gcf, 'Position', get(0,'Screensize')); % Maximize figure, to make caption readable
if wantSave
export_fig(sprintf('%sDifferentialShift%s',saveto,para.filename(1:13)),'-transparent','-png')
end
%% plot results.Vmat_svLog
f4 = figure(4);
surf(cell2mat(results.Vmat_svLog'))
shading interp
title('Maximum SV of V')
xlabel('site k')
ylabel('sweep')
zlabel('SV')
set(gca,'View',[0 90]); %top
%set(gca,'View',[90 0]); %side
% set(gcf, 'Position', get(0,'Screensize')); % Maximize figure, to make caption readable
rotate3d on
if wantSave
export_fig(sprintf('%sChangeOfVmatSV%s',saveto,para.filename(1:13)),'-transparent','-png')
end
%% Plot results.Amat_sv - logPlot
figure;
svCell = results.Amat_sv;
maxN = max(cellfun(@(x) length(x),svCell));
pTemp = zeros(maxN,length(svCell));
for ii = 1:length(svCell)
pTemp(1:length(svCell{ii}),ii) = svCell{ii};
end
surf(log10(pTemp));
% shading interp;
axis tight; rotate3d on;
set(gca,'View',[0,0]);
%% plotting first rows of uneven cell arrays
cellfun(@(x) x(1,1), results.Vmat_sv(2:end))
%% try to calculate Shift analytically:
t = para.chain{1}.t; e = para.chain{1}.epsilon;
A = gallery('tridiag',t(2:end-1),e(1:end),t(2:end-1)); %creates tridiag for system A.(shiftVec) = (-t1*sigmaZ, 0,0,0,0,...)
B = zeros(para.L-1,1);
B(1) = -t(1)*1;%(results.spin.sz); % -t1*sigmaZ
shift = A\B.*sqrt(2);
%% Plot my Shift versus VMPS Shift
colors={[0 0 1];[0 1 0];[1 0 0];[1 1 0];[1 0 1];[0 1 1];[0 0 0]};
hold all
pl(1) = plot([0;shift]);
set(pl(1), 'Marker', 'none','Color',colors{1}); % blue my
pl(2) = plot(para.shift);
set(pl(2), 'Marker', 'none','Color',colors{2}); % green VMPS
if wantSave
export_fig(sprintf('%sAnalyticShift%s',saveto,para.filename(1:13)),'-transparent','-png','-eps')
end
%% Plot < n > of chain
figure(1); hold on;
results.nx = real(getObservable({'bath1correlators','n'}, mps,Vmat,para));
pl = plot(real(results.nx));
%set(gca,'YScale','log');
xlabel('Site k')
ylabel('$<n_{k,VMPS}>$')
% set(gca,'yscale','log')
formatPlot(1)
if wantSave
export_fig(sprintf('%s%s-Occupation',saveto,para.filename(1:13)),'-transparent','-png','-pdf','-painters')
end
%% Plot < x > of chain
figure(1); hold on;
results.xx = real(getObservable({'bath1correlators','x'}, mps,Vmat,para));
pl = plot(real(results.xx));
%set(gca,'YScale','log');
xlabel('Site k')
ylabel('$<x_{k,VMPS}>$')
% set(gca,'yscale','log')
formatPlot(1)
if wantSave
export_fig(sprintf('%s%s-Occupation',saveto,para.filename(1:13)),'-transparent','-png','-pdf','-painters')
end
%% Plot Chain epsilon-t
f = figure(3)
f.Name = 'Chain hopping and site energies';
subplot(1,2,1); hold all
% pl = plot(cell2mat(cellfun(@(x) x.t, para.chain, 'UniformOutput',false)));
cellfun(@(x) plot(x.t), para.chain, 'UniformOutput',false);
% set(gca,'YScale','log');
xlabel('Site k')
ylabel('$t_k$')
axis tight
legend(strsplit(sprintf('%d,', 1:length(para.chain)),','))
subplot(1,2,2); hold all;
cellfun(@(x) plot(x.epsilon), para.chain, 'UniformOutput',false);
% set(gca,'YScale','log');
xlabel('Site k')
ylabel('$\epsilon_k$')
%% Plot RC coupling over energy
% to estimate reorg. Energy
f = figure(4);
f.Name = 'RC reorganisation energies';
subplot(1,2,1);
pl = plot(cellfun(@(x) x.t(1)/x.epsilon(1), para.chain));
xlabel('Chain k');
ylabel('$\lambda/\omega$');
subplot(1,2,2);
pl = plot(cellfun(@(x) x.t(1)^2/4/x.epsilon(1), para.chain));
xlabel('Chain k');
ylabel('$\lambda^2/4\omega$');
% formatPlot(2)
%% Plot relative deviation from calculated < n >
% Much more important as here the Wavefunction corrects also for different shift.
nx = [0 (shift.*shift./2)'];
figure(1)
plot((nx-real(results.nx))./nx,'LineStyle','none','Marker','*');
%set(gca,'YScale','log');
%title('Relative Deviation of $<n_k>$');
xlabel('Site k');
ylabel('$\frac{<n_k>-<n_{k,VMPS}>}{<n_k>}$')
formatPlot(1)
if wantSave
export_fig(sprintf('%s%s-RelativeDeviationN',saveto,para.filename(1:13)),'-transparent','-png','-pdf','-painters')
end
%% Plot relative deviation of shift
relShift = ((shift-para.shift(2:end)')./shift);
figure(1)
pl(1) = plot([0; relShift],'LineStyle','none','Marker','*');
set(gca,'YScale','log');
%title('Relative deviation of shift from calculation')
xlabel('Site k')
ylabel('$\frac{\delta_k-\delta_{k,VMPS}}{\delta_k}$')
formatPlot(1)
if wantSave
export_fig(sprintf('%sRelativeDeviationShift%s',saveto,para.filename(1:13)),'-transparent','-png','-pdf','-painters')
end
%% Plot ShiftUp vs ShiftDown
figure(5);
wantSave=0;
hold on
plot(results.bosonshift.x,'b')
plot(results.bosonshiftPerSpin.xUp,'r')
plot(results.bosonshiftPerSpin.xDown,'g')
title('Bosonic Shift vs Up or Down')
xlabel('site k')
ylabel('$\delta_k$')
legend('$x$','$x_\uparrow$','$x_\downarrow$');
ylim=get(gca,'YLim');
text(3,ylim(2)*2/3,...
['$x-(x_{\uparrow} +x_\downarrow) = $', sprintf('%.4g; \n', norm(results.bosonshift.x-results.bosonshiftPerSpin.xUp-results.bosonshiftPerSpin.xDown)),...
'$|x|-|x_{\uparrow}|-|x_{\downarrow}| = $',sprintf('%.4g; ', norm(abs(results.bosonshift.x)-abs(results.bosonshiftPerSpin.xUp)-abs(results.bosonshiftPerSpin.xDown)))]);
formatPlot(5)
if wantSave
export_fig(sprintf('%s%s-SBM-subOhmic-a0036622-shiftUpvsDown',saveto,para.filename(1:13)),'-transparent','-png','-painters')
end
%% Plot s-alpha relation
figure(5)
x = 0:0.01:1;
y = 0.005;
z = y.^(x./(1-x));
plot(x,z);
PlotData(:,PlotData(:,7)==0.001)
%% For PPC MLSBM:
%% Plot Energy convergence
figure(2);
plot(cell2mat(results.EvaluesLog)-min(cell2mat(results.EvaluesLog)));
% disp(sprintf('%.15e',results.E))
set(gca,'YScale','log');
% try
% title(sprintf('$E_0 = %.10g, \\Lambda = %.2g, z = %.2g$',results.E, para.Lambda, para.z));catch end
xlabel('Site$\cdot$Loop');
ylabel('$E-E_0$');
formatPlot(2)
yLim = get(gca,'YLim');
for i = 1:para.loop
% line([para.L*i para.L*i],yLim,'LineWidth',1,'Color','black');
end
if wantSave
export_fig(sprintf('%s%s-MLSBM-Econvergence-Lambda%.2gz%.2gp16',saveto,para.filename(1:13),para.Lambda,para.z),'-transparent','-png','-painters')
end
%% Plot Energy Error convergence
figure(3);
plot(results.Eerror);
set(gca,'YScale','log');
xlabel('Sweep');
ylabel('E error');
formatPlot(3);
%% Get System-Bath coupling
figure(2);
plot(real(diag(op.h2term{1,1,1})./para.t(1)));
xlabel('Site k');
ylabel('$\hat\eta$');
formatPlot(2);
%% Plot System Wavefunction
figure(3);
plot(diag(calReducedDensity(mps,Vmat,para,1)))
if para.MLSB_staticDisorder
hold all
plot(para.MLSB_disDiag/500); % /500 scales to see both
end
%%
%% Plot Flowdiagram
loop = para.loop;
plot(results.flowdiag{1,loop});
%% Plot the CoupDiscr dataPoints
figure(1); clf; hold all;
pl = {};
for ii = 1:length(para.chain)
pl{ii} = stem(para.chain{ii}.dataPoints(:,1),para.chain{ii}.dataPoints(:,2))
end
%% Get the RC parameters in cm^-1
x = res(1);
[cellfun(@(x) x.epsilon(1), x.para.chain);cellfun(@(x) x.t(1), x.para.chain)]./1.23984e-4
%% For TDVP analysis:
%% TDVP (1) SBM: Plot evolution of the spin
figure(11);clf;
hold all
sphereon = true;
if sphereon
sphere
daspect([1 1 1])
alpha(0.2)
set(get(gca,'children'),'linestyle',':')
end
col = parula(size(tresults.spin.sx,1));
scatter3(tresults.spin.sx,tresults.spin.sy,tresults.spin.sz,20,col,'filled');
plot3(tresults.spin.sx,tresults.spin.sy,tresults.spin.sz);
set(gca,'xlim',[-1,1]);
set(gca,'ylim',[-1,1]);
set(gca,'zlim',[-1,1]);
set(gca,'view',[-29,16]);
rotate3d on
%% TDVP (2) SBM: Plot <sz> / Visibility / Coherence
figure(20); hold all;
% tresults = res{3}.tresults; % for res-extraction
% plotOpt = {'LineWidth',1.5};
% plotOpt = {'black','LineWidth',1};
plotOpt = {};
if isfield(tresults,'t')
t=tresults.t; % for the new convention when extracting in intervals >= rev42
else
t=para.tdvp.t; % for the old files
end
% n = find(tresults.n(:,3),1,'last');
n = find(t,1,'last');
plot(t(1:n), tresults.spin.sx(1:n), plotOpt{:});
plot(t(1:n), tresults.spin.sy(1:n), plotOpt{:});
plot(t(1:n), tresults.spin.sz(1:n), plotOpt{:});
plot(t(1:n), tresults.spin.visibility(1:n), plotOpt{:});
set(gca,'ylim',[-1,1]);
% set(gca,'xscale','log');
xlabel('t');
ylabel('$\left<\sigma_z\right>$');
l=legend('$\left< \sigma_x \right>$','$\left< \sigma_y \right>$','$\left< \sigma_z \right>$');
% l=legend('$\left< \sigma_x \right>$','$\left< \sigma_y \right>$','$\left| D(t) \right|$');
l.Interpreter = 'latex';
%% TDVP (2.1) SBM: Plot spin for adiabatic RDM:
figure(21); clf; hold all;
n = size(tresults.rho,1);
rho = squeeze(tresults.rho(:,:,:,3)); % 1: full rdm; 2: RDM of dominant state
% s2 = arrayfun(@(x) trace(squeeze(tresults.rho(x,:,:,1))*rho(x,:,:)),1:n); % SV^2 corresponding to the bond state
s2 = diag(reshape(tresults.rho(:,:,:,1),n,[])*reshape(tresults.rho(:,:,:,2),n,[])'); % achieves the same
rho = reshape(rho,n,[]); % reshape into t x 4
[sigmaX,sigmaY,sigmaZ] = spinop('Z');
sigmaX = reshape(sigmaX.',[],1);
sigmaY = reshape(sigmaY.',[],1);
sigmaZ = reshape(sigmaZ.',[],1);
plot(tresults.t,rho*sigmaX);
plot(tresults.t,rho*sigmaY);
plot(tresults.t,real(rho*sigmaZ));
set(gca,'ylim',[-1,1]);
%% TDVP (2) SBM: Plot Bloch length
figure(2); hold all;
plot(para.tdvp.t(1:length(tresults.spin.sz)), sqrt(tresults.spin.sz.^2+tresults.spin.sx.^2+tresults.spin.sy.^2));
plot(para.tdvp.t, tresults.spin.visibility);
set(gca,'ylim',[0,1]);
% set(gca,'xscale','log');
xlabel('t');
ylabel('$\sqrt{<s_x>^2+<s_y>^2+<s_z>^2}$');
legend('Bloch length','Visibility');
%% TDVP (2.3) RDM analysis separate plots
plotOpt = {'-fsev'};
f = figure(1); clf; hold all;
x.plot('rhoii',plotOpt{:});
formatPlot(f,'twocolumn-single')
grid on;
f = figure(2); clf; hold all;
x.plot('rhoij-imag',plotOpt{:});
formatPlot(f,'twocolumn-single')
grid on;
f = figure(3); clf; hold all;
x.plot('rhoij-real',plotOpt{:});
formatPlot(f,'twocolumn-single')
grid on;
%% TDVP (2.3) RDM analysis DPMES joint plots
plotOpt = {'-fsev'};
x(2).plot('rho-dpmes',plotOpt{:});
f = gcf; f.Name = 'Rho of DPMES Overview';
formatPlot(f,'twocolumn-single');
% diff(rhoii) overlay: select upper plot first!
% plot(x.t(1:x.lastIdx-1)*0.658,-25*diff(real(x.rho(1:x.lastIdx,1,1))),'-.','Color',[0.5,0.5,0.5],'LineWidth',1.5); % for LE+
%% TDVP Get TreeMPS vNE across all ER-node
% open a full .mat file and deserialise treeMPS
TDVPData.printSvNETreeMPS(treeMPS)
%% TDVP (3) Environment Plots
%% TDVP (3.1): Plot <n> CHAIN
mode = 0; % 0: lin, 1: log
f=figure(312); clf; f.Name = 'Chain Occupation';
% x = res{9,1}; tresults = x.tresults; para = x.para;
x = res(9); tresults = x.tresults; para = x.para;
mc = 1; % choose chain for display!
if str2double(para.tdvp.version(2:end)) < 50
tresults.n = tresults.nx;
end
n = tresults.n(:,:,mc);
l = find(tresults.n(:,3),1,'last');
if isfield(tresults,'t')
t=tresults.t; % for the new convention when extracting in intervals >= rev42
else
t=para.tdvp.t; % for the old files
end
if mode
surf(1:size(n,2),t(1:l),log10(abs(n(1:l,:))));
% surf(1:size(n,2),t(1:l),log10(abs(real(n(1:l,:))-ones(l,1)*real(n(1,:))))); % subtract intitial population
zlabel('$\log_{10}\left<n_k\right>$');
else
surf(1:size(n,2),t(1:l),real(n(1:l,:)));
% surf(1:size(n,2),t(1:l),real(n(1:l,:))-ones(l,1)*real(n(1,:))); % subtract initial population
zlabel('$\left<n_k\right>$');
end
ax = gca;
cb = colorbar;cb.Title.Interpreter = 'latex';
cb.Title.String = ax.ZLabel.String;
xlabel('Site $k$');
ylabel('Time $\omega_c t$');
% set(gca,'yscale','log');se
% set(gca,'View',[0 42]);
set(gca,'View',[0 90]);
shading interp
rotate3d on
axis tight
if mode
% ax.ZLim = [-30, max(max(ax.Children.ZData))];
% ax.ZLim = [-6, 0];
else
% ax.ZLim = [0.1,1].*10^-26;
end
ax.CLim = ax.ZLim;
% ax.YLim = [0,100];
%% TDVP (3.1): 2D Plot <n> CHAIN - L x t - TDVPData
mode = 0; % 0: lin, 1: log
f=figure(313); clf; f.Name = 'Chain Occupation';
del = findobj(f,'Type','hgjavacomponent'); del.delete; % get rid of old sliders
hold all;
% x = res(35);
if mode
h = x.plotSld2D('chain-n','-log');
else
h = x.plotSld2D('chain-n','-fsev');
end
%% TDVP (3.1): 1D Plot <n> Chain coherence - TDVPData
f=figure(315); f.Name = ''; clf; hold all; ax = gca;
% x = res(6);
pl = x.plotSld1D('chain-n-c-t','-fsev',f);
leg = legend('$A_{1,1}$','$A_{1,2}$','$A_{2}$','$B_{1}$','$B_{2,1}$','$B_{2,2}$','$B_{2,3}$');
ylabel('$|TT\rangle\langle LE^+|\hat n_k$');
grid on
axis tight
formatPlot(f,'twocolumn-single')
%% TDVP (3.1): 1D Plot <n> Chain DFT - norm dist - TDVPData
f=figure(315); f.Name = ''; clf; hold all; ax = gca;
x = res(4);
h = x.plotSld1DFT('chain-n','-cmev','-norm','-dist','-smoothres',f);
set(h.sld{2},'Value',20); % start with 20 zero padding
leg = legend('$A_{1,1}$','$A_{1,2}$','$A_{2}$','$B_{1}$','$B_{2,1}$','$B_{2,2}$','$B_{2,3}$');
ylabel('$|FT (n_2)|$');
grid on
axis tight
[h.ax.XLim] = deal([0,2000]);
formatPlot(f,'twocolumn-single')
%% TDVP (3.1): 1D Plot <n> Chain DFT - dist - TDVPData
f=figure(316); f.Name = ''; clf; hold all; ax = gca;
% x = res(4);
h = x.plotSld1DFT('chain-n','-cmev','-dist','-smoothres',f);
set(h.sld{2},'Value',20); % start with 20 zero padding
set(h.pl,{'Displayname'},{'$A_{1,1}$','$A_{1,2}$','$A_{2}$','$B_{1}$','$B_{2,1}$','$B_{2,2}$','$B_{2,3}$'}')
arrayfun(@(x) legend(x,'show'),h.ax);
arrayfun(@(x) grid(x,'on'),h.ax);
ylabel('$|FT (n_{RC})|$');
[h.ax.XLim] = deal([0,2000]);
formatPlot(f,'twocolumn-single')
drawnow; h.controlPanel.delete;
%% TDVP (3.1): 1D Plot <n> Chain DFT - dist - TDVPData
f=figure(316); f.Name = ''; clf; hold all; ax = gca;
x = res(1);
h = x.plot('chain-n-rc-ft','-cmev','-resetColorOrder','-norm','-dist',f)
% set(h.pl,{'Displayname'},{'$A_{1,1}$','$A_{1,2}$','$A_{2}$','$B_{1}$','$B_{2,1}$','$B_{2,2}$','$B_{2,3}$'}')
set(h.pl,{'Displayname'},{'$A_{2}$','$A_{1,1}$','$A_{1,2}$','$B_{1,1}$','$B_{1,2}$','$B_{2,2}$','$B_{2,3}$'}'); %for DPMES-Tree3
arrayfun(@(x) legend(x,'show'),h.ax);
arrayfun(@(x) grid(x,'on'),h.ax);
ylabel('$|FT (n_{RC})|$');
[h.ax.XLim] = deal([0,2000]);
formatPlot(f,'twocolumn-single')
drawnow;
%% TDVP (3.1): 1D Plot <n> RC - diabatic all chains, grid - TDVPData
% x = y(end);
h = x.plot('chain-n-d-rc','-fsev');
h.f.Units = 'pixels'; h.f.Position = get(0,'ScreenSize'); h.f.Name = 'Diabatic Occupation RC';
chainlbl = {'$A_{1,1}$','$A_{1,2}$','$A_{2}$','$B_{1}$','$B_{2,1}$','$B_{2,2}$','$B_{2,3}$'};
popName = {'TT','LE$^+$','LE$^-$','CT$^+$','CT$^-$'};
for ii = 1:length(chainlbl)
text(h.f.Children(ii),0.9,0.9,chainlbl{end-ii+1},'sc');
text(h.f.Children(ii),0.8,0.85,sprintf('$\\langle n \\rangle_{max} \\approx %g$',h.f.Children(ii).YLim(end)),'sc');
end
ax = [h.f.Children]; [ax.XLim] = deal([0,199]); %[ax.YLim] = deal([-0.07,0.3]);
legend(popName{:});
ax(end).Visible = 'off';
t = title(x.folder); t.Units = 'norm'; t.Position = [0.5,-0.13,0];
%% TDVP (3.1): 1D Plot <n> RC - adiabatic all chains, grid - TDVPData
% x = y(1);
h = x.plot('chain-n-a-rc','-fsev');
h.f.Units = 'pixels'; h.f.Position = get(0,'ScreenSize'); h.f.Name = 'Adiabatic Occupation RC';
chainlbl = {'$A_{1,1}$','$A_{1,2}$','$A_{2}$','$B_{1}$','$B_{2,1}$','$B_{2,2}$','$B_{2,3}$'};
for ii = 1:length(chainlbl)
text(h.f.Children(ii),0.9,0.9,chainlbl{end-ii+1},'sc');
text(h.f.Children(ii),0.8,0.85,sprintf('$\\langle n \\rangle_{max} \\approx %g$',h.f.Children(ii).YLim(end)),'sc');
end
ax = [h.f.Children]; [ax.XLim] = deal([0,199]); %[ax.YLim] = deal([-0.07,0.3]);
legend toggle;
ax(end).Visible = 'off';
t = title(x.folder); t.Units = 'norm'; t.Position = [0.5,-0.13,0];
%% TDVP (3.1): 1D Plot <n> RC - adiabatic & diabatic, grid - TDVPData
h = x.plot('chain-n-a-rc','-fsev','-xlim',[0,200],'-rowheight',10,'-rowwidth',40);
h.f.OuterPosition = [0 0.05 1 0.95];
h.f.Name = 'Bond State Occupation RC';
chainlbl = x.chainLabel;
for ii = 1:length(chainlbl)
text(h.ax(ii),0.9,0.9,chainlbl{ii},'sc');
text(h.ax(ii),0.05,0.95,sprintf('$\\langle n \\rangle \\in [%g,%g]$',h.ax(ii).YLim(1),h.ax(ii).YLim(2)),'sc');
end
ax = h.ax; %[ax.YLim] = deal([-0.07,0.3]);
legend toggle;
t = title(x.folder);t.Units = 'normalized'; t.Position = [0.5,-0.13,0];
isLine = arrayfun(@(x) isa(x,'matlab.graphics.chart.primitive.Line'), h.pl);
[h.pl(isLine).LineStyle] = deal(':');
[h.pl(isLine).LineWidth] = deal(2);
cpStates = [1,2]; % copy States TT and LE+ for now!
h2 = x.plot('chain-n-d-rc','-fsev','-xlim',[0,200]);
h2.f.Visible = 'off';
pl = reshape(h2.pl,[],size(h2.pl,3));
for ii = 1:length(ax)
copyobj(pl(ii,cpStates),ax(ii));
end
close(h2.f);
%% TDVP (3.1): 2D Plot <n> RC tFFT
nc = 2;
f = figure(310+nc+4); clf;f.Name = sprintf('Chain %d',nc);
x = res(1);
h.m = x.lastIdx; h.tTocm = 0.658/4.135/8065.73; % convert from simulation timescale to cm
h.data = real(squeeze(real(x.occC(1:h.m,2,nc)))); % t x L x nChain
h.data = TDVPData.movAvgRes(h.data,350/x.dt);
h.tdata = x.t;
h.Fs = 1/x.dt;
h.nwind = 1024*6;
%spectrogram(x ,window ,Nolap,NFFT/F,h.Fs,'yaxis','reassigned','power','MinThreshold',-40);
[h.S,h.F,h.T,h.P] = spectrogram(h.data,kaiser(h.nwind,5),h.nwind-2,[0:1600]*h.tTocm,h.Fs,'yaxis','reassigned','power','MinThreshold',-50); % only calculate for specified points!
% spectrogram(h.data,kaiser(1024,5),1000,0:0.0001:0.04,h.Fs,'yaxis','reassigned','power','MinThreshold',-40); % only calculate for specified points!
% spectrogram(h.data,kaiser(1024,5),1000,(h.m*7),h.Fs,'yaxis','reassigned','power','MinThreshold',-40); % to zero padding across entire range!
% ax=gca; ax.Children.YData = ax.Children.YData/0.658*4.135*8065.73*1e-3; ylim([0,2000]);
% surf(h.T,h.F,10*log10(abs(h.P).^2))
surf(h.T*0.658,h.F,mag2db(h.P))
axis tight; shading interp; view([0,90]);
ylabel('$E/cm^{-1}$');xlabel('$t/fs$');
ax=gca; ax.Children.YData = ax.Children.YData/h.tTocm; ylim([0,1600]); xlim([0,960]);
%% TDVP (3.1): 2D Plot <n> RC WSST
% Wavelet Synchrosqueezed Transform
% not optimal, since needs better scale resolution! padding is not controllable!
nc = 3; fwind = 1;
popName = {'$A_{1,1}$','$A_{1,2}$','$A_{2}$','$B_{1}$','$B_{2,1}$','$B_{2,2}$','$B_{2,3}$'};
for nc = [1:7]
% for fwind = [1,2,4,6,8]
f = figure(300+nc*10+fwind); clf;f.Name = sprintf('Chain WSST - %s',popName{nc});
x = res(1);
h.m = x.lastIdx; h.tTocm = 0.658/4.135/8065.73; % convert from simulation timescale to cm
h.data = real(squeeze(real(x.occC(1:h.m,2,nc)))); % t x L x nChain
h.data = TDVPData.movAvgRes(h.data,760/x.dt);
h.tdata = x.t*h.tTocm; h.dt = x.dt*h.tTocm;
h.f0 = 6/(2*pi); % 5 for bump, 6 for morl
% h.scales = helperCWTTimeFreqVector(30,1600,h.f0,h.dt,128)/h.dt; % (fmin, fmax, f0, dt, nVoices), returns s*dt and not pure scale
h.scales = fliplr(h.f0/h.dt./(30:1600));
[h.sst,h.f]=mywsst(double(h.data),1/h.dt,'VoicesPerOctave',128,'amor'); ylim([0,1.6]);
% [h.sst,h.f] = mywsst(double(h.data),1/h.dt,'scales',h.scales,'amor'); h.f = fliplr(h.f0./h.scales./h.dt);% does not work! frequencies are stretched
% [h.sst,h.f] = sswt(double(h.data),1/h.dt,'fmin',50,'fmax',1600,'plot','amp');
%
h.sstDB = mag2db(abs(h.sst)/max(max(abs(h.sst))));
h.sstDB(h.sstDB<-90) = -inf;
surf(x.t*0.658,h.f,h.sstDB);
% surf(x.t*0.658,Freq,abs(h.sst));
axis tight; shading interp; view([0,90]); ylim([0,10000]);xlim([0,987]);
ylabel('$E/cm^{-1}$');xlabel('$t/fs$');
title(sprintf('Chain WSST - %s',popName{nc}));
export_fig(sprintf('img/%d',get(gcf,'Number')),'-transparent','-png','-m3');
close(f);
% end
end
%% TDVP (3.1): 2D Plot rhoii tFFT
pop = 1; fwind = 3;
popName = {'TT','LE$^+$','LE$^-$','CT$^+$','CT$^-$'};
for pop = 1:5
for fwind = [1,2,4,6,8]
f = figure(300+pop*10+fwind); clf;f.Name = sprintf('Population STFT - %s',popName{pop});
x = res(1);
h.m = x.lastIdx; h.tTocm = 0.658/4.135/8065.73; % convert from simulation timescale to cm
h.data = abs(x.getData('rhoii')); h.data = h.data(:,pop); % t x L x nChain
h.data = TDVPData.movAvgRes(h.data,350/x.dt);
h.tdata = x.t;
h.Fs = 1/x.dt;
h.nwind = 1024*fwind;
%spectrogram(x ,window ,Nolap,NFFT/F,h.Fs,'yaxis','reassigned','power','MinThreshold',-40);
[h.S,h.F,h.T,h.P] = spectrogram(h.data,kaiser(h.nwind,5),h.nwind-2,[0:1600]*h.tTocm,h.Fs,'yaxis','reassigned','power','MinThreshold',-50); % only calculate for specified points!
% spectrogram(h.data,kaiser(1024,5),1000,0:0.0001:0.04,h.Fs,'yaxis','reassigned','power','MinThreshold',-40); % only calculate for specified points!
% spectrogram(h.data,kaiser(1024,5),1000,(h.m*7),h.Fs,'yaxis','reassigned','power','MinThreshold',-40); % to zero padding across entire range!
% ax=gca; ax.Children.YData = ax.Children.YData/0.658*4.135*8065.73*1e-3; ylim([0,2000]);
% surf(h.T,h.F,10*log10(abs(h.P).^2))
surf(h.T*0.658,h.F,mag2db(h.P))
axis tight; shading interp; view([0,90]);
ylabel('$E/cm^{-1}$');xlabel('$t/fs$');
title(sprintf('Population STFT - %s - Nwind %d',popName{pop}, h.nwind));
ax=gca; ax.Children.YData = ax.Children.YData/h.tTocm; ylim([0,1600]); xlim([0,960]);
% export_fig(sprintf('img/%d',get(gcf,'Number')),'-transparent','-png','-m3');
close(f);
end
end
%% TDVP (3.1): 2D Plot rhoii CWTft
% not optimal since needs reassignment!
pop = 3; fwind = 2;
popName = {'TT','LE$^+$','LE$^-$','CT$^+$','CT$^-$'};
for pop = 1:5
% for fwind = [1,2,4,6,8]
f = figure(400+pop*10+fwind); clf;f.Name = sprintf('Population CWTft - %s',popName{pop});
% x = res(1);
h.m = x.lastIdx; h.tTocm = 0.658/4.135/8065.73; % convert from simulation timescale to cm
h.data = abs(x.getData('rhoii')); h.data = h.data(:,pop); % t x L x nChain
h.data = TDVPData.movAvgRes(h.data,760/x.dt);
h.tdata = x.t*h.tTocm; h.dt = x.dt*h.tTocm;
h.s0 = 2*h.dt;
h.f0 = 5/(2*pi); % 5 for bump, 6 for morl
h.scales = helperCWTTimeFreqVector(30,1600,h.f0,h.dt,128); % (fmin, fmax, f0, dt, nVoices)
% h.scales = fliplr(h.f0/h.dt./(30:1600));
h.cwtdata = cwtft({h.data,h.dt},'wavelet','bump','scales',h.scales,'padmode','symw');
helperCWTTimeFreqPlot((h.cwtdata.cfs),h.tdata/h.tTocm*0.658,h.cwtdata.frequencies,...
'surf',sprintf('Population CWTFT - %s',popName{pop}),'$t/fs$','$E/cm^{-1}$')
% export_fig(sprintf('img/%d',get(gcf,'Number')),'-transparent','-png','-m3');
% close(f);
end
%% TDVP (3.1): 2D Plot rhoii WSST
% Wavelet Synchrosqueezed Transform
% not optimal, since needs better scale resolution! padding is not controllable!
pop = 3; fwind = 1;
popName = {'TT','LE$^+$','LE$^-$','CT$^+$','CT$^-$'};
for pop = 1
% for fwind = [1,2,4,6,8]
f = figure(300+pop*10+fwind); clf;f.Name = sprintf('Population WSST - %s',popName{pop});
% x = res(1);
h.m = x.lastIdx; h.tTocm = 0.658/4.135/8065.73; % convert from simulation timescale to cm
h.data = abs(x.getData('rhoii')); h.data = h.data(:,pop); % t x L x nChain
h.data = TDVPData.movAvgRes(h.data,760/x.dt);
h.tdata = x.t*h.tTocm; h.dt = max(diff(x.t))*h.tTocm;
h.f0 = 6/(2*pi); % 5 for bump, 6 for morl
% h.scales = helperCWTTimeFreqVector(30,1600,h.f0,h.dt,128)/h.dt; % (fmin, fmax, f0, dt, nVoices), returns s*dt and not pure scale
% h.scales = fliplr(h.f0/h.dt./(30:1600));
% [h.sst,h.f]=mywsst(double(h.data),1/h.dt,'VoicesPerOctave',128,'amor'); %ylim([0,1.6]);
% [h.sst,h.f] = mywsst(double(h.data),1/h.dt,'scales',h.scales,'amor'); h.f = fliplr(h.f0./h.scales./h.dt);% does not work! frequencies are stretched
[h.sst,h.f,h.wopt,h.wt,h.wtf,h.ifr] = sswt(double(h.data),1/h.dt,'fmin',50,'fmax',1600,'plot','amp++-wr','Padding',0,'nv',256,'Wavelet','Morlet');
% separate plot, if needed
h.sstDB = mag2db(abs(h.sst)/max(max(abs(h.sst))));
h.sstDB(h.sstDB<-90) = -inf;
f = figure(300+pop*10+fwind);
surf(x.t(1:h.m)*0.658,h.f,h.sstDB); shading interp, view([0,90]), axis tight
% surf(x.t*0.658,Freq,abs(h.sst));
end
%%
for pop = 1:5
figure(300+pop*10+fwind);
axis tight; shading interp; view([0,90]); ylim([0,1600]);xlim([0,987]);
ylabel('$E/cm^{-1}$');xlabel('$t/fs$');
title(sprintf('Population WSST - %s',popName{pop}));
export_fig(sprintf('img/%d',get(gcf,'Number')),'-transparent','-png','-m3');
% close(f);
% end
end
%% TDVP (3.1): 2D Plot rhoij-imag CWTft
% not optimal since needs reassignment!
pop = 4; fwind = 2;
popName = {'TT','LE$^+$','LE$^-$','CT$^+$','CT$^-$'};
% for pop = 1:5
% for fwind = [1,2,4,6,8]
f = figure(400+pop*10+fwind); clf;%f.Name = sprintf('Coherence CWTft - %s',popName{pop});
% x = res(1);
h.m = x.lastIdx; h.tTocm = 0.658/4.135/8065.73; % convert from simulation timescale to cm
out = x.getData('rhoij'); h.data = imag(out{1}(:,pop)); % out: { t x coherences, state numbers}
h.data = TDVPData.movAvgRes(h.data,760/x.dt);
h.tdata = x.t(1:x.lastIdx)*h.tTocm; h.dt = x.dt*h.tTocm;
h.s0 = 2*h.dt;
h.f0 = 5/(2*pi); % 5 for bump, 6 for morl
h.scales = helperCWTTimeFreqVector(30,8000,h.f0,h.dt,128); % (fmin, fmax, f0, dt, nVoices)
% h.scales = fliplr(h.f0/h.dt./(30:1600));
h.cwtdata = cwtft({h.data,h.dt},'wavelet','bump','scales',h.scales,'padmode','symw');
helperCWTTimeFreqPlot((h.cwtdata.cfs),h.tdata/h.tTocm*0.658,h.cwtdata.frequencies,...
'surf',sprintf('Coherence CWTFT - %s-%s',popName{out{2}(1,pop)},popName{out{2}(2,pop)}),'$t/fs$','$E/cm^{-1}$')
% export_fig(sprintf('img/%d',get(gcf,'Number')),'-transparent','-png','-m3');
% close(f);
% end
%% TDVP (3.1) Wavelet Coherence between states and <n> RC
x = res(1);
h.m = x.lastIdx; h.tTocm = 0.658/4.135/8065.73; h.dt = max(diff(x.t))*h.tTocm;
h.tdata = x.t(1:h.m);
h.Odata = real(squeeze(real(x.occC(1:h.m,2,:)))); h.Odata = TDVPData.movAvgRes(h.Odata,760/x.dt);
h.pdata = abs(x.getData('rhoii')); h.pdata = TDVPData.movAvgRes(h.pdata,760/x.dt);
%% state-RC coherences
popName = {'TT','LE$^+$','LE$^-$','CT$^+$','CT$^-$'}; chainName = {'$A_{1,1}$','$A_{1,2}$','$A_{2}$','$B_{1}$','$B_{2,1}$','$B_{2,2}$','$B_{2,3}$'};
[~,m] = size(h.pdata); [~,n] = size(h.Odata);
hPl = TDVPData.plotGrid(m,n); hPl.f.Units = 'pixels';
hPl.f.Position = [1,1,1920,1080]; hPl.f.Name = 'Wavelet Coherence state-RC';
for kk = 1:m*n
[ii,jj] = ind2sub([m,n],kk);
axes(hPl.ax(kk));
wcoherence(h.pdata(:,ii),h.Odata(:,jj),1/h.dt,'VoicesPerOctave',32,'PhaseDisplayThreshold',0.5,'NumScalesToSmooth',10);
hPl.ax(kk).YLim(end) = 4; % 2^4 = 16 kcm^-1
hPl.ax(kk).YTick = hPl.ax(kk).YLim(1):(hPl.ax(kk).YLim(end)-1);
title('');
if ii < m
xlabel('');
hPl.ax(kk).XTickLabel = '';
if ii == 1
title(chainName{jj});
end
else
hPl.ax(kk).XTickLabel = strsplit(sprintf('%d ',round(hPl.ax(kk).XTick*10^-3/h.tTocm*0.658)));
xlabel('$t/fs$');
end
if jj > 1
ylabel('');
hPl.ax(kk).YTickLabel = '';
if jj == n
hPl.ax(kk).YAxisLocation = 'right';
ylabel(popName{ii});
end
else
ylabel('$E/(10^3 cm^{-1})$');
end
colorbar off
drawnow
end
%% inter-state coherences
[m,n] = size(h.pdata);
hPl = TDVPData.plotGrid(n-1,n-1); hPl.f.Units = 'pixels';
hPl.f.Position = [1,1,1920,1080]; hPl.f.Name = 'Wavelet Coherence inter-state';
hPl.ax = reshape(hPl.ax,n-1,n-1);
for kk = 1:n*n
[ii,jj] = ind2sub([n,n],kk);
if ii >= jj
if all([ii,jj-1] > 0) && ii < n
hPl.ax(ii,jj-1).Visible = 'off';
end
continue;
end
axes(hPl.ax(ii,jj-1));
wcoherence(h.pdata(:,ii),h.pdata(:,jj),1/h.dt,'VoicesPerOctave',32,'PhaseDisplayThreshold',0.5,'NumScalesToSmooth',10);
hPl.ax(ii,jj-1).YLim(end) = 4; % 2^4 = 16 kcm^-1
hPl.ax(ii,jj-1).YTick = hPl.ax(ii,jj-1).YLim(1):(hPl.ax(ii,jj-1).YLim(end)-1);
title('');
if ii < n
if ii == 1
title(popName{jj});
end
xlabel('');
hPl.ax(ii,jj-1).XTickLabel = '';
end
if jj > 2
if jj ~= ii+1
ylabel('');
hPl.ax(ii,jj-1).YTickLabel = '';
end
if jj == n
hPl.ax(ii,jj-1).YAxisLocation = 'right';
ylabel(popName{ii});
end
end
if ii == jj-1 && ii ~= n-1
ylabel('$E/(10^3 cm^{-1})$');
hPl.ax(ii,jj-1).XTickLabel = strsplit(sprintf('%d ',round(hPl.ax(ii,jj-1).XTick*10^-3/h.tTocm*0.658)));
xlabel('$t/fs$');
end
if ii == n-1
hPl.ax(ii,jj-1).YTickLabel = '';
hPl.ax(ii,jj-1).XTickLabel = strsplit(sprintf('%d ',round(hPl.ax(ii,jj-1).XTick*10^-3/h.tTocm*0.658)));
xlabel('$t/fs$');
end
colorbar off
drawnow
end
%% TDVP (3.2): Plot <n> STAR
mode = 0; % 0: lin, 1: log
f=figure(320); clf; f.Name = 'Star Occupation';
l = find(tresults.star.t,1,'last');
mc = 2;
n = tresults.star.n(:,:,mc);
if numel(tresults.star.omega) == length(tresults.star.omega)
omega = tresults.star.omega;
else
omega = tresults.star.omega(:,mc);
end
if mode
surf(omega,tresults.star.t(1:l),log10(n(1:l,:)));
% surf(tresults.star.omega,tresults.star.t(1:n),log10(tresults.star.n(1:n,:))-log10(ones(n,1)*tresults.star.n(1,:)));
zlabel('$\log_{10}\left<n_k\right>$');
else
surf(omega,tresults.star.t(1:l),n(1:l,:));
zlabel('$\left<n_k\right>$');
end
cb = colorbar;cb.Title.Interpreter = 'latex';
cb.Title.String = get(get(gca,'zlabel'),'String');
xlabel('Mode $\omega_k / \omega_c$');
ylabel('Time $\omega_c t$');
% set(gca,'yscale','log'); % log in sites
% set(gca,'View',[0 42]);
set(gca,'View',[0 90]);
shading interp
rotate3d on
axis tight
if mode
% set(gca,'zlim',[-3,1]);
% set(gca,'clim',get(gca,'zlim'));
end