-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlandau_level.f90
executable file
·1946 lines (1634 loc) · 64.7 KB
/
landau_level.f90
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
!> calculate landau levels in 3D system in special k line
!> fix B field
!> the magnetic field is in the a1 a2 plane
!> B= (B cos\theta, B sin\theta, 0)
!>Periodic Landau gauge by Guan Yifei. contact: guan.yifei@outlook.com
!> construct on Dec 8 2015
!> By QuanSheng Wu at ETH Zurich Honggerberg
! Copyright (c) 2010 QuanSheng Wu. All rights reserved.
!
!> At present, only \theta=0 is well tested
!include "sparse.f90"
subroutine landau_level_k
use para
implicit none
!> magnetic supercell size, perpendicular to the magnetic field, Ndimq= Nq*Num_wann
integer :: Nq, Ndimq
integer :: ik, i, j, ib, ierr, iq, ig
!> lowest and highest band index to be calculated
integer :: il, iu
!> mdimq= iu-il+1, number of LLs to be calculated
integer :: mdimq
real(dp) :: B0, B0Tesla, B0Tesla_quantumflux_magsupcell
real(dp) :: time_start, time_end, time_start0
real(dp) :: theta
real(dp) :: emin, emax
! wave vector
real(dp) :: k3(3)
!> dim= Ndimq, knv3
real(dp), allocatable :: W(:)
real(dp), allocatable :: W_full(:)
real(dp), allocatable :: eigv(:, :)
real(dp), allocatable :: eigv_mpi(:, :)
complex(dp), allocatable :: psi(:)
!> print the weight for the Selected_WannierOrbitals
real(dp), allocatable :: dos_selected(:, :, :)
real(dp), allocatable :: dos_selected_mpi(:, :, :)
real(dp), allocatable :: dos_l_selected(:, :, :)
real(dp), allocatable :: dos_l_selected_mpi(:, :, :)
real(dp), allocatable :: dos_r_selected(:, :, :)
real(dp), allocatable :: dos_r_selected_mpi(:, :, :)
!> dim= Ndimq*Ndimq
complex(dp), allocatable :: eigvec(:, :)
complex(dp), allocatable :: ham_landau(:, :)
Nq= Magq
Ndimq= Num_wann* Nq
il= Numoccupied*Nq- 2000
iu= Numoccupied*Nq+ 2000
il=1
iu=Ndimq
if (il< 1) il= 1
if (iu> Ndimq) iu= Ndimq
mdimq= iu-il+1
if (cpuid==0) then
write(stdout, '(a,i8)')' >> The magnetic-supercell size is ', Nq
write(stdout, '(a,i8)')' >> The dimension of magnetic-supercell is ', Ndimq
write(stdout, '(a,i8,a,i8)')' >> calculated LLs from il', il, ' to', iu, ' bands'
write(stdout, '(a,i8,a,i8)')' >> in total, there are ', mdimq, ' bands'
endif
allocate( ham_landau(Ndimq, Ndimq))
allocate( W( mdimq))
allocate( W_full( Ndimq))
allocate( eigv( mdimq, nk3_band))
allocate( eigv_mpi( mdimq, nk3_band))
allocate( eigvec( Ndimq, mdimq))
allocate( psi(Ndimq))
allocate( dos_selected (mdimq, nk3_band, NumberofSelectedOrbitals_groups))
allocate( dos_selected_mpi (mdimq, nk3_band, NumberofSelectedOrbitals_groups))
if (landau_chern_calc) then
allocate( dos_l_selected (mdimq, nk3_band, NumberofSelectedOrbitals_groups))
allocate( dos_l_selected_mpi (mdimq, nk3_band, NumberofSelectedOrbitals_groups))
allocate( dos_r_selected (mdimq, nk3_band, NumberofSelectedOrbitals_groups))
allocate( dos_r_selected_mpi (mdimq, nk3_band, NumberofSelectedOrbitals_groups))
dos_l_selected= 0d0
dos_l_selected_mpi= 0d0
dos_r_selected= 0d0
dos_r_selected_mpi= 0d0
endif
dos_selected= 0d0
dos_selected_mpi= 0d0
eigv_mpi = 0d0
eigv = 0d0
eigvec = 0d0
ham_landau = 0d0
!> deal with the magnetic field parallel with R1' direction which
!> is the same as the first vector in SURFACE card.
!> the flux in the unit cell not the magnetic supercell
theta=0d0
B0= 2d0*pi/dble(Nq)*Magp
Bx= B0* dcos(theta)
By= B0* dsin(theta)
!> transform it into Tesla
!> B=2*pi*\phi_0/S0, where \phi_0 is the quantum flux, S0 is the projected area
!> \phi_0 = h/2e h=6.62607004*1E-34, e= 1.6*1E-19
!> B0Tesla_quantumflux_magsupcell is the magnetic field that makes the flux through the magnetic
!> supercell to be one quantum flux
B0Tesla_quantumflux_magsupcell= 6.62607004*1E-34/1.6021766208*1E19/MagneticSuperProjectedArea*1E20
B0Tesla= 6.62607004*1E-34/1.6021766208*1E19/MagneticSuperProjectedArea*1E20*Magp
if (cpuid==0) then
write(stdout, '(a, 2E18.8)')' Magnetic field B in Tesla that makes the flux through '
write(stdout, '(a, 2E18.8)')' the magnetic supercell to be one quantum flux : ', B0Tesla_quantumflux_magsupcell
write(stdout, '(a, 2E18.8)')' Magnetic field B in Tesla that fits to Magp : ', B0Tesla
write(stdout, '(a, 2f18.8)')' Magnetic field Bx, By= ', Bx, By
endif
!> calculate the landau levels along special k line
k3= 0
time_start= 0d0
time_start0= 0d0
call now(time_start0)
time_start= time_start0
time_end = time_start0
do ik=1+ cpuid, nk3_band, num_cpu
if (cpuid.eq.0) &
write(stdout, '(2a, i9, " /", i10, a, f10.1, "s", a, f10.1, "s")') &
'In LandauLevel_kband ', ' ik/NK ', ik, nk3_band, &
' time elapsed: ', time_end-time_start0, &
' time left: ', ((nk3_band-ik)/num_cpu)*(time_end-time_start)
call now(time_start)
k3= k3points(:, ik)
call ham_3Dlandau(Ndimq, Nq, k3, ham_landau)
ham_landau= ham_landau/eV2Hartree
!> diagonalization by call zheev in lapack
!W_full= 0d0
if (mdimq<2000) then
if (LandauLevel_wavefunction_calc) then
call eigensystem_c( 'V', 'U', Ndimq ,ham_landau, W_full)
eigv(:, ik)= W_full(il:iu)
eigvec(1:Ndimq, 1:mdimq)= ham_landau(1:Ndimq, 1:mdimq)
else
call eigensystem_c( 'N', 'U', Ndimq ,ham_landau, W_full)
eigv(:, ik)= W_full(il:iu)
eigvec(1:Ndimq, 1:mdimq)= 0d0
endif
else
W= 0d0
if (LandauLevel_wavefunction_calc) then
call zheevx_pack('V', 'U', Ndimq, il, iu, ham_landau, W, eigvec)
else
call zheevx_pack('N', 'U', Ndimq, il, iu, ham_landau, W, eigvec)
endif
eigv(:, ik)= W
endif
!> calculate the weight on the selected orbitals
do ib= 1, mdimq
psi(:)= eigvec(:, ib) !> the eigenvector of ib'th band
do ig=1, NumberofSelectedOrbitals_groups
do iq=1, Nq
do i= 1, NumberofSelectedOrbitals(ig)
j= Num_wann*(iq-1)+ Selected_WannierOrbitals(ig)%iarray(i)
dos_selected(ib, ik, ig)= dos_selected(ib, ik, ig)+ abs(psi(j))**2
enddo ! sweep the selected orbitals
enddo ! iq sweep the magnetic supercell
if (landau_chern_calc) then
do iq=1, 2 ! edge states
if (iq>Nq) cycle
do i= 1, NumberofSelectedOrbitals(ig)
j= Num_wann*(iq-1)+ Selected_WannierOrbitals(ig)%iarray(i)
dos_l_selected(ib, ik, ig)= dos_l_selected(ib, ik, ig)+ abs(psi(j))**2
enddo ! sweep the selected orbitals
enddo ! iq sweep the magnetic supercell
do iq=Nq-1, Nq ! edge states
if (iq<1) cycle
do i= 1, NumberofSelectedOrbitals(ig)
j= Num_wann*(iq-1)+ Selected_WannierOrbitals(ig)%iarray(i)
dos_r_selected(ib, ik, ig)= dos_r_selected(ib, ik, ig)+ abs(psi(j))**2
enddo ! sweep the selected orbitals
enddo ! iq sweep the magnetic supercell
endif
enddo ! ig
enddo ! ib sweep the eigenvalue
call now(time_end)
enddo !ik
#if defined (MPI)
call mpi_allreduce(eigv, eigv_mpi, size(eigv), &
mpi_dp, mpi_sum, mpi_cmw, ierr)
call mpi_allreduce(dos_selected, dos_selected_mpi,size(dos_selected),&
mpi_dp,mpi_sum,mpi_cmw,ierr)
if (landau_chern_calc) then
call mpi_allreduce(dos_l_selected, dos_l_selected_mpi,size(dos_l_selected),&
mpi_dp,mpi_sum,mpi_cmw,ierr)
call mpi_allreduce(dos_r_selected, dos_r_selected_mpi,size(dos_r_selected),&
mpi_dp,mpi_sum,mpi_cmw,ierr)
endif
#else
eigv_mpi= eigv
dos_selected_mpi= dos_selected
if (landau_chern_calc) then
dos_l_selected_mpi= dos_l_selected
dos_r_selected_mpi= dos_r_selected
endif
#endif
!> minimum and maximum value of energy bands
emin= minval(eigv_mpi)*1.05-maxval(eigv_mpi)*0.05
emax= -minval(eigv_mpi)*0.05+maxval(eigv_mpi)*1.05
outfileindex= outfileindex+ 1
if (cpuid.eq.0) then
open(unit=outfileindex, file='landaulevel_k.dat')
if (LandauLevel_wavefunction_calc) then
write(outfileindex, '("#", a14, f16.8)')'Magnetic field in Tesla: ', B0Tesla
if (landau_chern_calc) then
write(outfileindex, '("#", a14, a15, 2a16)')'k ', ' Eig of LL', ' left side', ' right side'
else
write(outfileindex, '("#", a14, a15, a)')'k ', ' Eig of LL', ' Weight on the selected orbitals'
endif
do j=1, mdimq
do i=1, nk3_band
if (landau_chern_calc) then
write(outfileindex,'(20f16.8)')k3len_mag(i)*Angstrom2atomic, eigv_mpi(j, i), &
(dos_l_selected_mpi(j, i, ig), dos_r_selected_mpi(j, i, ig), &
ig=1, NumberofSelectedOrbitals_groups)
else
write(outfileindex,'(20f16.8)')k3len_mag(i)*Angstrom2atomic, eigv_mpi(j, i), &
(dos_selected_mpi(j, i, ig), ig=1, NumberofSelectedOrbitals_groups)
endif
enddo
write(outfileindex , *)' '
enddo
else
write(outfileindex, '("#", a14, f16.8)')'Magnetic field in Tesla: ', B0Tesla
write(outfileindex, '("#", a14, a15, a)')'k ', ' Eig of LL', ' Weight on the selected orbitals'
do j=1, mdimq
do i=1, nk3_band
write(outfileindex,'(20f16.8)')k3len_mag(i)*Angstrom2atomic, eigv_mpi(j, i)
enddo
write(outfileindex , *)' '
enddo
endif
close(outfileindex)
write(stdout,*) 'Calculate landau level done'
endif
outfileindex= outfileindex+ 1
if (cpuid==0) then
open(unit=outfileindex, file='landaulevel_k.gnu')
write(outfileindex, '(a)')"set encoding iso_8859_1"
write(outfileindex, '(a)')'#set terminal postscript enhanced color'
write(outfileindex, '(a)')"#set output 'landaulevel_k.eps'"
write(outfileindex, '(3a)')'#set terminal pngcairo truecolor enhanced', &
' font ",60" size 1920, 1680'
write(outfileindex, '(3a)')'set terminal png truecolor enhanced', &
' font ",60" size 1920, 1680'
write(outfileindex, '(a)')"set output 'landaulevel_k.png'"
write(outfileindex, '(a)')'unset key'
write(outfileindex, '(a)')'set pointsize 0.8'
write(outfileindex, '(a)')'set border lw 3 '
write(outfileindex, '(a)')'#set xtics font ",36"'
write(outfileindex, '(a)')'#set ytics font ",36"'
write(outfileindex, '(a)')'#set xlabel font ",36"'
write(outfileindex, '(a)')'set ylabel "Energy (eV)"'
write(outfileindex, '(a, f10.5, a)')'set xrange [0: ', maxval(k3len_mag*Angstrom2atomic), ']'
write(outfileindex, '(a, i6, a, i6, a)')'set title "Landau level with p/q=', magp, "/", Nq, '"'
write(outfileindex, '(a)')'#set xtics offset 0, -1'
write(outfileindex, '(a)')'#set ylabel offset -1, 0 '
write(outfileindex, '(a)')'rgb(r,g,b) = int(r)*65536 + int(g)*256 + int(b)'
write(outfileindex, 202, advance="no") (k3line_name(i), k3line_mag_stop(i)*Angstrom2atomic, i=1, nk3lines)
write(outfileindex, 203)k3line_name(nk3lines+1), k3line_mag_stop(nk3lines+1)*Angstrom2atomic
write(outfileindex, '(a, f10.5, a, f10.5, a)')'set yrange [', emin, ':', emax, ']'
do i=1, nk3lines-1
write(outfileindex, 204)k3line_mag_stop(i+1)*Angstrom2atomic, emin, &
k3line_mag_stop(i+1)*Angstrom2atomic, emax
enddo
202 format('set xtics (',:20('"',A3,'" ',F10.5,','))
203 format(A3,'" ',F10.5,')')
204 format('set arrow from ',F10.5,',',F10.5,' to ',F10.5,',',F10.5, ' nohead')
if (LandauLevel_wavefunction_calc) then
if (landau_chern_calc) then
write(outfileindex,'(2a)') 'set palette defined ( -1 "blue", ', &
'0 "grey", 1 "red" )'
write(outfileindex, '(2a)')"plot 'landaulevel_k.dat' u 1:2:($4-$3)", &
"w p pt 7 ps 2 lc palette"
else
write(outfileindex, '(2a)')"plot 'landaulevel_k.dat' u 1:2:(rgb(255,255-255*$3, 3)) ", &
" w p pt 7 ps 2 lc rgb variable"
endif
else
write(outfileindex, '(2a)')"plot 'landaulevel_k.dat' u 1:2", &
"w p pt 7 ps 2"
endif
close(outfileindex)
endif
deallocate( ham_landau)
deallocate( W)
deallocate( W_full)
deallocate( eigv)
deallocate( eigv_mpi)
deallocate( eigvec)
return
end subroutine landau_level_k
!> calculate landau levels in 3D system in kplane
!> fix B field
!> the magnetic field is in the a1 a2 plane
!> B= (B cos\theta, B sin\theta, 0)
!> Periodic Landau gauge by Guan Yifei. contact: guan.yifei@outlook.com
!> construct on Dec 8 2015
!> By QuanSheng Wu at ETH Zurich Honggerberg
!> License : GPL V3
!>
!include "sparse.f90"
subroutine landau_level_kplane
use para
implicit none
!> magnetic supercell size, perpendicular to the magnetic field, Ndimq= Nq*Num_wann
integer :: Nq, Ndimq
integer :: ik, i, j, ib, ierr, iq, ig
!> lowest and highest band index to be calculated
integer :: il, iu
!> mdimq= iu-il+1, number of LLs to be calculated
integer :: mdimq
integer :: nkx, nky
real(dp) :: B0, B0Tesla, B0Tesla_quantumflux_magsupcell
real(dp) :: time_start, time_end, time_start0
real(dp) :: theta
real(dp) :: emin, emax
! wave vector
real(dp) :: k3(3)
real(dp), allocatable :: kxy(:,:), kxy_shape(:,:), kxy_plane(:,:)
!> dim= Ndimq, knv3
real(dp), allocatable :: W(:)
real(dp), allocatable :: W_full(:)
real(dp), allocatable :: eigv(:, :)
real(dp), allocatable :: eigv_mpi(:, :)
complex(dp), allocatable :: psi(:)
!> print the weight for the Selected_WannierOrbitals
real(dp), allocatable :: dos_selected(:, :, :)
real(dp), allocatable :: dos_selected_mpi(:, :, :)
!> dim= Ndimq*Ndimq
complex(dp), allocatable :: eigvec(:, :)
complex(dp), allocatable :: ham_landau(:, :)
Nq= Magq
Ndimq= Num_wann* Nq
nkx= Nk
nky= Nk
if (cpuid==0) then
write(stdout, '(a,i8)')' >> The magnetic-supercell size is ', Nq
write(stdout, '(a,i8)')' >> The dimension of magnetic-supercell is ', Ndimq
write(stdout, '(a,1000i5)')' >> calculated LLs for selected bands', Selected_band_index(:)
write(stdout, '(a,i8,a,i8)')' >> in total, there are ', NumberofSelectedBands, ' bands'
endif
allocate( ham_landau(Ndimq, Ndimq))
allocate( W( NumberofSelectedBands))
allocate( W_full( Ndimq))
allocate( eigv( NumberofSelectedBands, nkx*nky))
allocate( eigv_mpi( NumberofSelectedBands, nkx*nky))
allocate( eigvec( Ndimq, NumberofSelectedBands))
allocate( psi(Ndimq))
allocate( dos_selected (NumberofSelectedBands, nkx*nky, NumberofSelectedOrbitals_groups))
allocate( dos_selected_mpi (NumberofSelectedBands, nkx*nky, NumberofSelectedOrbitals_groups))
dos_selected= 0d0
dos_selected_mpi= 0d0
eigv_mpi = 0d0
eigv = 0d0
eigvec = 0d0
ham_landau = 0d0
!> deal with the magnetic field
!> first transform the Bx By into B*Cos\theta, B*Sin\theta
if (abs(By)<1e-8) then
if (Bx<0) then
theta= pi
else
theta= 0d0
endif
elseif (By>0) then
theta = atan(Bx/By)
else
theta = atan(Bx/By)+ pi
endif
!> The flux in the supercell should be 2*pi
!> the flux in the unit cell not the magnetic supercell
theta=0d0
B0= 2d0*pi/dble(Nq)*Magp
Bx= B0* dcos(theta)
By= B0* dsin(theta)
!> transform it into Tesla
!> B=2*pi*\phi_0/S0, where \phi_0 is the quantum flux, S0 is the projected area
!> \phi_0 = h/2e h=6.62607004*1E-34, e= 1.6*1E-19
!> B0Tesla_quantumflux_magsupcell is the magnetic field that makes the flux through the magnetic
!> supercell to be one quantum flux
B0Tesla_quantumflux_magsupcell= 6.62607004*1E-34/1.6021766208*1E19/MagneticSuperProjectedArea*1E20
B0Tesla= 6.62607004*1E-34/1.6021766208*1E19/MagneticSuperProjectedArea*1E20*Magp
if (cpuid==0) then
write(stdout, '(a, 2E18.8)')' Magnetic field B in Tesla that makes the flux through '
write(stdout, '(a, 2E18.8)')' the magnetic supercell to be one quantum flux : ', B0Tesla_quantumflux_magsupcell
write(stdout, '(a, 2E18.8)')' Magnetic field B in Tesla that fits to Magp : ', B0Tesla
write(stdout, '(a, 2f18.8)')' Magnetic field Bx, By= ', Bx, By
endif
!> set k slice
allocate( kxy(3, nkx*nky))
allocate( kxy_shape(3, nkx*nky))
allocate( kxy_plane(3, nkx*nky))
kxy=0d0
kxy_shape=0d0
kxy_plane=0d0
ik =0
do i= 1, nkx
do j= 1, nky
ik =ik +1
kxy(:, ik)= K3D_start+ K3D_vec1*(i-1)/dble(nkx-1)+ K3D_vec2*(j-1)/dble(nky-1) &
-(K3D_vec1+K3D_vec2)/2d0
kxy_shape(:, ik)= kxy(1, ik)* Kua_mag+ kxy(2, ik)* Kub_mag+ kxy(3, ik)* Kuc_mag
call rotate_k3_to_kplane_mag(kxy_shape(:, ik), kxy_plane(:, ik))
enddo
enddo
!> calculate the landau levels along special k line
k3= 0
time_start= 0d0
time_start0= 0d0
call now(time_start0)
time_start= time_start0
time_end = time_start0
do ik=1+ cpuid, nkx*nky, num_cpu
if (cpuid.eq.0) &
write(stdout, '(2a, i9, " /", i10, a, f10.1, "s", a, f10.1, "s")') &
'In LandauLevel_k_dos_Lanczos ', ' ik/NK ', ik, Nkx*nky, &
' time elapsed: ', time_end-time_start0, &
' time left: ', ((nkx*nky-ik)/num_cpu)*(time_end-time_start)
call now(time_start)
k3= kxy(:, ik)
call ham_3Dlandau(Ndimq, Nq, k3, ham_landau)
ham_landau= ham_landau/eV2Hartree
!> diagonalization by call zheev in lapack
!W_full= 0d0
if (Ndimq<2000) then
if (LandauLevel_wavefunction_calc) then
call eigensystem_c( 'V', 'U', Ndimq ,ham_landau, W_full)
do ib=1, NumberofSelectedBands
eigv(ib, ik)= W_full(Selected_band_index(ib))
eigvec(1:Ndimq, ib)= ham_landau(1:Ndimq, Selected_band_index(ib))
enddo
else
call eigensystem_c( 'N', 'U', Ndimq ,ham_landau, W_full)
do ib=1, NumberofSelectedBands
eigv(ib, ik)= W_full(Selected_band_index(ib))
eigvec(1:Ndimq, ib)= 0d0
enddo
endif
else
do i =1, NumberofSelectedBands
il= Selected_band_index(i)
iu= Selected_band_index(i)
W= 0d0
if (LandauLevel_wavefunction_calc) then
call zheevx_pack('V', 'U', Ndimq, il, iu, ham_landau, W(1), eigvec(:, i))
else
call zheevx_pack('N', 'U', Ndimq, il, iu, ham_landau, W(1), eigvec(:, i))
endif
eigv(i, ik)= W(1)
enddo
endif
if (LandauLevel_wavefunction_calc) then
!> calculate the weight on the selected orbitals
do ib= 1, NumberofSelectedBands
psi(:)= eigvec(:, ib) !> the eigenvector of ib'th band
do ig=1, NumberofSelectedOrbitals_groups
do iq=1, Nq
do i= 1, NumberofSelectedOrbitals(i)
j= Num_wann*(iq-1)+ Selected_WannierOrbitals(ig)%iarray(i)
dos_selected(ib, ik, ig)= dos_selected(ib, ik, ig)+ abs(psi(j))**2
enddo ! sweep the selected orbitals
enddo ! iq sweep the magnetic supercell
enddo ! ig
enddo ! ib sweep the eigenvalue
endif
call now(time_end)
enddo !ik
#if defined (MPI)
call mpi_allreduce(eigv, eigv_mpi, size(eigv), &
mpi_dp, mpi_sum, mpi_cmw, ierr)
call mpi_allreduce(dos_selected, dos_selected_mpi,size(dos_selected),&
mpi_dp,mpi_sum,mpi_cmw,ierr)
#else
eigv_mpi= eigv
dos_selected_mpi= dos_selected
#endif
!> minimum and maximum value of energy bands
emin= minval(eigv_mpi)-0.5d0
emax= maxval(eigv_mpi)+0.5d0
!> write out the data in gnuplot format
outfileindex= outfileindex+ 1
if (cpuid==0)then
open(unit=outfileindex, file='landaulevel_kplane.dat')
write(outfileindex, "(6a19, ' E', i17, 1000i19 )")'# kx', 'ky', 'kz', 'k1', 'k2', 'k3', &
Selected_band_index(:)
do ik=1, nkx*nky
write(outfileindex, '(10000f19.9)')kxy_shape(:, ik)*Angstrom2atomic, &
kxy_plane(:, ik)*Angstrom2atomic, eigv_mpi(:, ik)
if (mod(ik, nk2)==0) write(outfileindex, *)' '
enddo
close(outfileindex)
endif
outfileindex= outfileindex+ 1
if (cpuid==0)then
open(unit=outfileindex, file='landaulevel_kplane-matlab.txt')
write(outfileindex, "(6a19, ' E', i17, 1000i19 )")'% kx', 'ky', 'kz', 'k1', 'k2', 'k3', &
Selected_band_index(:)
do ik=1, nkx*nky
write(outfileindex, '(10000f19.9)')kxy_shape(:, ik)*Angstrom2atomic, &
kxy_plane(:, ik)*Angstrom2atomic, eigv_mpi(:, ik)
enddo
close(outfileindex)
endif
!> write out a script that can be used for gnuplot
outfileindex= outfileindex+ 1
if (cpuid==0)then
open(unit=outfileindex, file='landaulevel_kplane.gnu')
write(outfileindex, '(a)')"set encoding iso_8859_1"
write(outfileindex, '(a)')'#set terminal postscript enhanced color'
write(outfileindex, '(a)')"#set output 'bulkek_plane.eps'"
write(outfileindex, '(3a)')'set terminal png truecolor enhanced', &
' size 1920, 1680 font ",36"'
write(outfileindex, '(a)')"set output 'landaulevel_kplane.png'"
write(outfileindex, '(a)')'set palette rgbformulae 33,13,10'
write(outfileindex, '(a)')'unset key'
write(outfileindex, '(a)')'set pm3d'
write(outfileindex, '(a)')'set origin 0.2, 0'
write(outfileindex, '(a)')'set size 0.8, 1'
write(outfileindex, '(a)')'set border lw 3'
write(outfileindex, '(a)')'#set xtics font ",24"'
write(outfileindex, '(a)')'#set ytics font ",24"'
write(outfileindex, '(a)')'set size ratio -1'
write(outfileindex, '(a)')'set xtics'
write(outfileindex, '(a)')'set ytics'
write(outfileindex, '(a)')'set view 80,60'
write(outfileindex, '(a)')'set xlabel "k_1"'
write(outfileindex, '(a)')'set ylabel "k_2"'
write(outfileindex, '(a)')'set zlabel "Energy (eV)" rotate by 90'
write(outfileindex, '(a)')'unset colorbox'
write(outfileindex, '(a)')'set autoscale fix'
write(outfileindex, '(a)')'set pm3d interpolate 4,4'
write(outfileindex, '(2a)')"splot 'landaulevel_kplane.dat' u 4:5:7 w pm3d, \"
write(outfileindex, '(2a)')" 'landaulevel_kplane.dat' u 4:5:8 w pm3d"
close(outfileindex)
endif ! cpuid
deallocate( ham_landau)
deallocate( W)
deallocate( W_full)
deallocate( eigv)
deallocate( eigv_mpi)
deallocate( eigvec)
return
end subroutine landau_level_kplane
!> calculate landau levels in 3D system for different B
!> fix k point, usually Gamma point
subroutine landau_level_B
use para
implicit none
!> magnetic supercell size, perpendicular to the magnetic field
!> Ndimq= Nq* Num_wann
integer :: Nq, Ndimq
integer :: Nmag
integer :: ib, i, j, ie, ierr, iq, ig
real(dp) :: B0, B0Tesla, B0Tesla_quantumflux_magsupcell
real(dp) :: time_start, time_end, time_start0
! wave vector
real(dp) :: k3(3)
!> dim= Ndimq, knv3
real(dp), allocatable :: mag(:), mag_Tesla(:)
real(dp), allocatable :: W(:)
real(dp), allocatable :: eigv(:, :)
real(dp), allocatable :: eigv_mpi(:, :)
real(dp), allocatable :: eigv_mpi2(:, :)
!> wave function
complex(dp), allocatable :: psi(:)
!> print the weight for the Selected_WannierOrbitals
real(dp), allocatable :: dos_selected(:, :, :)
real(dp), allocatable :: dos_selected_mpi(:, :, :)
!> dim= Ndimq*Ndimq
complex(dp), allocatable :: ham_landau(:, :)
Nq= nslab
Nmag= Magp_max-Magp_min-1
if (Nmag<=0) Nmag=Magp
Ndimq= Num_wann* Nq
allocate( ham_landau(Ndimq, Ndimq))
allocate( W( Ndimq))
allocate( eigv( Ndimq, Nmag+1))
allocate( eigv_mpi( Ndimq, Nmag+1))
allocate( eigv_mpi2( Ndimq, Nmag+1))
allocate( mag(Nmag+1), mag_Tesla(Nmag+1))
allocate( psi(Ndimq))
allocate( dos_selected (Ndimq, Nmag+ 1, NumberofSelectedOrbitals_groups))
allocate( dos_selected_mpi (Ndimq, Nmag+ 1, NumberofSelectedOrbitals_groups))
dos_selected= 0d0
dos_selected_mpi= 0d0
mag= 0d0
eigv_mpi= 0d0
eigv = 0d0
ham_landau= 0d0
!> deal with the magnetic field
!> first transform the Bx By into B*Cos\theta, B*Sin\theta
!~ if (abs(By)<1e-8) then
!~ if (Bx<0) then
!~ theta= pi
!~ else
!~ theta= 0d0
!~ endif
!~ elseif (By>0) then
!~ theta = atan(Bx/By)
!~ else
!~ theta = atan(Bx/By)+ pi
!~ endif
!> The flux in the supercell should be the integer of 2*pi
! if (dis1< 1e-9) stop 'something wrong with the atom position'
B0=2d0*pi/(Nq)
B0=abs(B0)
!> transform it into Tesla
!> B=2*pi*\phi_0/S0, where \phi_0 is the quantum flux, S0 is the projected area
!> \phi_0 = h/2e h=6.62607004*1E-34, e= 1.6*1E-19
!> B0Tesla_quantumflux_magsupcell is the magnetic field that makes the flux through the magnetic
!> supercell to be one quantum flux
B0Tesla_quantumflux_magsupcell= 6.62607004*1E-34/1.6021766208*1E19/MagneticSuperProjectedArea*1E20
B0Tesla= 6.62607004*1E-34/1.6021766208*1E19/MagneticSuperProjectedArea*1E20*Magp
if (cpuid==0) then
write(stdout, '(a, 2E18.8)')' Magnetic field B in Tesla that makes the flux through '
write(stdout, '(a, 2E18.8)')' the magnetic supercell to be one quantum flux : ', B0Tesla_quantumflux_magsupcell
write(stdout, '(a, 2E18.8)')' Magnetic field B in Tesla that fits to Magp : ', B0Tesla
write(stdout, '(a, 2f18.8)')' Magnetic field Bx, By= ', Bx, By
endif
k3=Single_KPOINT_3D_DIRECT
if (cpuid==0) then
write(stdout, *) k3
endif
!> calculate the landau levels along special k line
eigv_mpi2=0
do ib=1, Nmag+1
mag(ib)= B0* (ib+Magp_min-1)
mag_Tesla(ib)= B0Tesla_quantumflux_magsupcell* (ib-1)
enddo
time_start= 0d0
time_start0= 0d0
call now(time_start0)
time_start= time_start0
time_end = time_start0
do ib=1+ cpuid, Nmag+1, num_cpu
!Bx= mag(ib)* Cos(theta)
!By= mag(ib)* Sin(theta)
Bx= -mag(ib)
By=0d0
if (cpuid.eq.0) &
write(stdout, '(2a, i9, " /", i10, a, f10.1, "s", a, f10.1, "s")') &
'In LandauLevel_B ', ' ib/Nmag ', ib, Nmag+1, &
' time elapsed: ', time_end-time_start0, &
' time left: ', ((Nmag-ib)/num_cpu)*(time_end-time_start)
call now(time_start)
call ham_3Dlandau(Ndimq, Nq, k3, ham_landau)
ham_landau= ham_landau/eV2Hartree
!> diagonalization by call zheev in lapack
W= 0d0
if (LandauLevel_wavefunction_calc) then
call eigensystem_c( 'V', 'U', Ndimq ,ham_landau, W)
!> calculate the weight on the selected orbitals
do ie= 1, Ndimq
psi(:)= ham_landau(:, ie) !> the eigenvector of ib'th band
do ig=1, NumberofSelectedOrbitals_groups
do iq=1, Nq
do i= 1, NumberofSelectedOrbitals(i)
j= Num_wann*(iq-1)+ Selected_WannierOrbitals(ig)%iarray(i)
dos_selected(ie, ib, ig)= dos_selected(ie, ib, ig)+ abs(psi(j))**2
enddo ! sweep the selected orbitals
enddo ! iq sweep the magnetic supercell
enddo ! ig
enddo ! ib sweep the eigenvalue
else
call eigensystem_c( 'N', 'U', Ndimq ,ham_landau, W)
endif
eigv(:, ib)= W
call now(time_end)
enddo !ib
#if defined (MPI)
call mpi_allreduce(eigv,eigv_mpi,size(eigv),&
mpi_dp,mpi_sum,mpi_cmw,ierr)
call mpi_allreduce(dos_selected, dos_selected_mpi,size(dos_selected),&
mpi_dp,mpi_sum,mpi_cmw,ierr)
#else
eigv_mpi= eigv
dos_selected_mpi= dos_selected
#endif
outfileindex= outfileindex+ 1
if (cpuid.eq.0) then
open(unit=outfileindex, file='landaulevel_B.dat')
if (LandauLevel_wavefunction_calc) then
write(outfileindex, '("#", a, 3f12.6, a)')'k points in fractional coordinates (', k3, ')'
write(outfileindex, '("#", a14, 2a15, a)')'Phi per cell', 'B (Tesla)', ' Eig of LL', ' Weight on the selected orbitals'
do j=1, Ndimq
do ib=1, Nmag+1
write(outfileindex, '(30f19.8)')mag(ib)/2d0/pi, mag_Tesla(ib), eigv_mpi(j, ib), &
(dos_selected_mpi(j, ib, ig), ig=1, NumberofSelectedOrbitals_groups)
enddo
write(outfileindex , *)' '
enddo
else
write(outfileindex, '("#", a, 3f12.6, a)')'k points in fractional coordinates (', k3, ')'
write(outfileindex, '("#", a14, 2a15)')'Phi per cell', 'B (Tesla)', ' Eig of LL'
do j=1, Ndimq
do ib=1, Nmag+1
write(outfileindex, '(30f19.8)')mag(ib)/2d0/pi, mag_Tesla(ib), eigv_mpi(j, ib)
enddo
write(outfileindex , *)' '
enddo
endif
close(outfileindex)
write(stdout,*) 'calculate landau level done'
endif
outfileindex= outfileindex+ 1
if (cpuid==0) then
open(unit=outfileindex, file='landaulevel_B.gnu')
write(outfileindex, '(a)')"set encoding iso_8859_1"
write(outfileindex, '(a)')'#set terminal postscript enhanced color'
write(outfileindex, '(a)')"#set output 'landaulevel_B.eps'"
write(outfileindex, '(3a)')'#set terminal pngcairo truecolor enhanced', &
' font ",60" size 1920, 1680'
write(outfileindex, '(3a)')'set terminal png truecolor enhanced', &
' font ",60" size 1920, 1680'
write(outfileindex, '(a)')"set output 'landaulevel_B.png'"
write(outfileindex, '(a)')'unset key'
write(outfileindex, '(a)')'set pointsize 0.8'
write(outfileindex, '(a)')'set border lw 3 '
write(outfileindex, '(a)')'#set xtics font ",36"'
write(outfileindex, '(a)')'#set ytics font ",36"'
write(outfileindex, '(a)')'#set xlabel font ",36"'
write(outfileindex, '(a)')'set xlabel "Phi per cell"'
write(outfileindex,*) '#set xlabel "{/Symbol F}/{/Symbol F}_0"'
write(outfileindex, '(a)')'set ylabel "Energy (eV)"'
write(outfileindex, '(a, i6,a)')'set title "Hofstadter butterfly with Nq=', Nq, '" font ",40"'
write(outfileindex, '(a)')'#set xtics offset 0, -1'
write(outfileindex, '(a)')'#set ylabel offset -1, 0 '
write(outfileindex, '(a)')'rgb(r,g,b) = int(r)*65536 + int(g)*256 + int(b)'
if (LandauLevel_wavefunction_calc) then
write(outfileindex, '(2a)')"plot 'landaulevel_B.dat' u 1:3:(rgb(255,255-255*$4, 4)) ", &
"w p pt 7 ps 1 lc rgb variable"
else
write(outfileindex, '(2a)')"plot 'landaulevel_B.dat' u 1:3", &
" w p pt 7 ps 1"
endif
close(outfileindex)
endif
#if defined (MPI)
call mpi_barrier(mpi_cmw, ierr)
#endif
deallocate( ham_landau)
deallocate( W)
deallocate( eigv)
deallocate( eigv_mpi)
deallocate( eigv_mpi2)
deallocate( mag)
return
end subroutine landau_level_B
subroutine landau_sf
use para
implicit none
!> magnetic supercell size, perpendicular to the magnetic field, Ndimq= Nq*Num_wann
integer :: Nq, Ndimq
integer :: ik, i, j, ib, ierr, iq, ig
!> lowest and highest band index to be calculated
integer :: il, iu
!> mdimq= iu-il+1, number of LLs to be calculated
integer :: mdimq
real(dp) :: B0, B0Tesla, B0Tesla_quantumflux_magsupcell
real(dp) :: time_start, time_end, time_start0
real(dp) :: theta
real(dp) :: emin, emax
! wave vector
real(dp) :: k3(3)
!> dim= Ndimq, knv3
real(dp), allocatable :: W(:)
real(dp), allocatable :: W_full(:)
real(dp), allocatable :: eigv(:, :)
real(dp), allocatable :: eigv_mpi(:, :)
complex(dp), allocatable :: psi(:)
!> print the weight for the Selected_WannierOrbitals
real(dp), allocatable :: dos_selected(:, :, :)
real(dp), allocatable :: dos_selected_mpi(:, :, :)
!> dim= Ndimq*Ndimq
complex(dp), allocatable :: eigvec(:, :)
complex(dp), allocatable :: ham_landau(:, :)
Nq= Magq
Ndimq= Num_wann* Nq
il= Numoccupied*Nq- 2000
iu= Numoccupied*Nq+ 2000
il=1
iu=Ndimq
if (il< 1) il= 1
if (iu> Ndimq) iu= Ndimq
mdimq= iu-il+1
if (cpuid==0) then
write(stdout, '(a,i8)')' >> The magnetic-supercell size is ', Nq
write(stdout, '(a,i8)')' >> The dimension of magnetic-supercell is ', Ndimq
write(stdout, '(a,i8,a,i8)')' >> calculated LLs from il', il, ' to', iu, ' bands'
write(stdout, '(a,i8,a,i8)')' >> in total, there are ', mdimq, ' bands'
endif
allocate( ham_landau(Ndimq, Ndimq))
allocate( W( mdimq))
allocate( W_full( Ndimq))
allocate( eigv( mdimq, knv2))
allocate( eigv_mpi( mdimq, knv2))
allocate( eigvec( Ndimq, mdimq))
allocate( psi(Ndimq))
allocate( dos_selected (mdimq, knv2, NumberofSelectedOrbitals_groups))
allocate( dos_selected_mpi (mdimq, knv2, NumberofSelectedOrbitals_groups))
dos_selected= 0d0
dos_selected_mpi= 0d0
eigv_mpi = 0d0
eigv = 0d0
eigvec = 0d0
ham_landau = 0d0
!> deal with the magnetic field
!> first transform the Bx By into B*Cos\theta, B*Sin\theta
if (abs(By)<1e-8) then
if (Bx<0) then
theta= pi
else
theta= 0d0
endif
elseif (By>0) then
theta = atan(Bx/By)
else
theta = atan(Bx/By)+ pi
endif
!> The flux in the supercell should be 2*pi
! if (dis1< 1e-9) stop 'something wrong with the atom position'
!> the flux in the unit cell not the magnetic supercell
B0= 2d0*pi/dble(Nq)*Magp
Bx= B0* dcos(theta)
By= B0* dsin(theta)
!> transform it into Tesla
!> B=2*pi*\phi_0/S0, where \phi_0 is the quantum flux, S0 is the projected area
!> \phi_0 = h/2e h=6.62607004*1E-34, e= 1.6*1E-19
!> B0Tesla_quantumflux_magsupcell is the magnetic field that makes the flux through the magnetic
!> supercell to be one quantum flux
B0Tesla_quantumflux_magsupcell= 6.62607004*1E-34/1.6021766208*1E19/MagneticSuperProjectedArea*1E20
B0Tesla= 6.62607004*1E-34/1.6021766208*1E19/MagneticSuperProjectedArea*1E20*Magp
if (cpuid==0) then
write(stdout, '(a, 2E18.8)')' Magnetic field B in Tesla that makes the flux through '
write(stdout, '(a, 2E18.8)')' the magnetic supercell to be one quantum flux : ', B0Tesla_quantumflux_magsupcell
write(stdout, '(a, 2E18.8)')' Magnetic field B in Tesla that fits to Magp : ', B0Tesla
write(stdout, '(a, 2f18.8)')' Magnetic field Bx, By= ', Bx, By
endif
!> calculate the landau levels along special k line
k3= 0
time_start= 0d0
time_start0= 0d0
call now(time_start0)
time_start= time_start0
time_end = time_start0
do ik=1+cpuid,knv2,num_cpu
if (cpuid.eq.0) &
write(stdout, '(2a, i9, " /", i10, a, f10.1, "s", a, f10.1, "s")') &
'In LandauLevel_k_dos_Lanczos ', ' ik/NK ', ik, knv2, &
' time elapsed: ', time_end-time_start0, &
' time left: ', ((knv2-ik)/num_cpu)*(time_end-time_start)
call now(time_start)