-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadinput.f90
executable file
·5000 lines (4340 loc) · 189 KB
/
readinput.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
subroutine readinput
! Read in the control paramters from wt.in,
! and set default values if not specified in the wt.in
!
! Constructed on 4/22/2010 by QS.Wu
use wmpi
use para
implicit none
character*12 :: fname='wt.in'
character*25 :: char_temp
character*256 :: inline
logical :: exists, lfound
real(dp) :: cell_volume, cell_volume2
integer :: i, j, ia, ik, iq, io, it, idummy, ig, NN, stat, istart, iend
integer :: NumberOfspinorbitals, NumberOfspinorbitals_unfold
integer, allocatable :: iarray_temp(:)
real(dp) :: t1, temp
real(dp) :: pos(3), k1(3), k2(3), k(3), kstart(3), kend(3)
real(dp) :: R1(3), R2(3), R3(3), Rt(3), Rt2(3)
real(dp), external :: norm, angle
real(dp), allocatable :: mass_temp(:)
real(dp), allocatable :: Born_Charge_temp(:, :, :)
inquire(file=fname,exist=exists)
if (exists)then
if(cpuid==0)write(stdout,*) ' '
if(cpuid==0)write(stdout,*) '>>>Read some paramters from wt.in'
open(unit=1001,file=fname,status='old')
else
if(cpuid==0)write(stdout,*)'file' ,fname, 'dosnot exist'
stop
endif
!===============================================================================================================!
! TB_FILE namelist
!===============================================================================================================!
Particle='electron'
Package= 'VASP'
KPorTB = 'TB'
Is_HrFile= .TRUE.
Is_Sparse_Hr= .FALSE.
Is_Sparse = .FALSE.
Orthogonal_Basis = .TRUE.
read(1001, TB_FILE, iostat= stat)
if (stat/=0) then
Hrfile='wannier90_hr.dat'
Particle='electron'
inquire(file='wannier90_hr.dat',exist=exists)
backspace(1001)
read(1001,fmt='(A)') inline
write(*,'(A)') &
'>>> ERROR : Invalid line in namelist TB_FILE : '//trim(inline)
if (.not.exists) stop "ERROR>> TB_FIlE namelist should be given or wannier90_hr.dat should exist"
endif
if(cpuid==0)write(stdout,'(1x, a, a6, a)')"You are using : ", KPorTB, " model"
Is_Sparse_Hr= (Is_Sparse_Hr.or.Is_Sparse)
if(cpuid==0) then
if(Is_HrFile) then
write(stdout,'(1x, a)')"Tight-binding Hamiltonian FROM: Hr File"
write(stdout,'(1x, a, L2)')"Is_Sparse_Hr= ", Is_Sparse_Hr
if(Is_Sparse_Hr) write(stdout,'(1x, a)')"Tight-binding Hamiltonian FROM: Sparse Hr File"
else
write(stdout,'(1x, a)')"Tight-binding Hamiltonian FROM: fitting"
end if
end if
if(cpuid==0)write(stdout,'(1x, a, a25)')"Tight-binding Hamiltonian filename : ",Hrfile
if(cpuid==0)write(stdout,'(1x, a, a25)')"System of particle: ", Particle
if(cpuid==0)write(stdout,'(1x, a, a25)')"Tight-binding Hamiltonian obtained from package : ",Package
if (index(Particle, 'electron')==0 .and. index(Particle, 'phonon')==0 &
.and. index(Particle, 'photon')==0) then
write(stdout, *)' ERROR: Particle shoule equal either "electron"' , &
'"phonon", or "photon"'
stop
endif
!===============================================================================================================!
!> CONTROL namelist
!===============================================================================================================!
BulkBand_calc = .FALSE.
BulkBand_line_calc = .FALSE.
BulkBand_unfold_line_calc = .FALSE.
Landaulevel_unfold_line_calc = .FALSE.
BulkBand_unfold_plane_calc = .FALSE.
QPI_unfold_plane_calc = .FALSE.
BulkFatBand_calc = .FALSE.
BulkBand_plane_calc = .FALSE.
BulkBand_cube_calc = .FALSE.
BulkFS_calc = .FALSE.
BulkFS_Plane_calc = .FALSE.
BulkFS_plane_stack_calc = .FALSE.
BulkGap_cube_calc = .FALSE.
BulkGap_plane_calc = .FALSE.
SlabBand_calc = .FALSE.
SlabBandWaveFunc_calc = .FALSE.
WireBand_calc = .FALSE.
SlabSS_calc = .FALSE.
SlabArc_calc = .FALSE.
SlabQPI_calc = .FALSE.
SlabQPI_kpath_calc = .FALSE.
SlabQPI_kplane_calc = .FALSE.
SlabSpintexture_calc = .FALSE.
BulkSpintexture_calc = .FALSE.
wanniercenter_calc = .FALSE.
Z2_3D_calc = .FALSE.
Chern_3D_calc = .FALSE.
WeylChirality_calc = .FALSE.
NLChirality_calc = .FALSE.
BerryPhase_calc = .FALSE.
BerryCurvature_calc = .FALSE.
BerryCurvature_EF_calc = .FALSE.
BerryCurvature_plane_selectedbands_calc = .FALSE.
BerryCurvature_Cube_calc = .FALSE.
BerryCurvature_slab_calc = .FALSE.
Berrycurvature_kpath_EF_calc = .FALSE.
BerryCurvature_kpath_Occupied_calc = .FALSE.
MirrorChern_calc = .FALSE.
Dos_calc = .FALSE.
JDos_calc = .FALSE.
EffectiveMass_calc = .FALSE.
FindNodes_calc = .FALSE.
LOTO_correction = .FALSE.
Boltz_OHE_calc = .FALSE.
Boltz_Berry_correction= .FALSE.
AHC_calc = .FALSE.
SHC_calc = .FALSE.
Hof_Butt_calc = .FALSE.
LandauLevel_k_calc = .FALSE.
LandauLevel_B_calc = .FALSE.
LandauLevel_wavefunction_calc = .FALSE.
OrbitalTexture_calc = .FALSE.
OrbitalTexture_3D_calc = .FALSE.
Fit_kp_calc = .FALSE.
DMFT_MAG_calc = .FALSE. ! not finished yet
Symmetry_Import_calc = .FALSE.
LanczosSeqDOS_calc = .FALSE.
LandauLevel_kplane_calc = .FALSE.
LandauLevel_k_dos_calc = .FALSE.
LandauLevel_B_dos_calc = .FALSE.
Translate_to_WS_calc = .FALSE.
FermiLevel_calc = .FALSE.
ANE_calc = .FALSE.
w3d_nested_calc =.false.
valley_projection_calc =.false.
ChargeDensity_selected_bands_calc= .FALSE.
ChargeDensity_selected_energies_calc= .FALSE.
read(1001, CONTROL, iostat=stat)
SlabQPI_kplane_calc= SlabQPI_kplane_calc.or.SlabQPI_calc
if (stat/=0) then
write(*, *)"ERROR: namelist CONTROL should be set"
write(*, *)"You should set one of these functions to be T."
write(*, *)"And please make sure that the spelling are correct."
write(*, *)"BulkBand_calc, BulkBand_plane_calc, BulkFS_calc"
write(*, *)"BulkBand_line_calc, BulkBand_cube_calc"
write(*, *)"Landaulevel_unfold_line_calc, "
write(*, *)"BulkBand_unfold_line_calc, "
write(*, *)"BulkBand_unfold_plane_calc, "
write(*, *)"QPI_unfold_plane_calc, "
write(*, *)"BulkFatBand_calc, "
write(*, *)"BulkGap_cube_calc,BulkGap_plane_calc"
write(*, *)"SlabBand_calc,SlabBandWaveFunc_calc"
write(*, *)"WireBand_calc,SlabSS_calc,SlabArc_calc "
write(*, *)"SlabQPI_calc"
write(*, *)"SlabQPI_kpath_calc"
write(*, *)"SlabQPI_kplane_calc"
write(*, *)"SlabSpintexture,wanniercenter_calc"
write(*, *)"BerryPhase_calc,BerryCurvature_calc, BerryCurvature_EF_calc"
write(*, *)"Berrycurvature_kpath_EF_calc, BerryCurvature_kpath_Occupied_calc"
write(*, *)"BerryCurvature_slab_calc, BerryCurvature_Cube_calc"
write(*, *)"Dos_calc, JDos_calc, FindNodes_calc"
write(*, *)"BulkFS_plane_calc"
write(*, *)"BulkFS_plane_stack_calc"
write(*, *)"Z2_3D_calc"
write(*, *)"Chern_3D_calc"
write(*, *)"MirrorChern_calc"
write(*, *)"WeylChirality_calc"
write(*, *)"NLChirality_calc"
write(*, *)"LOTO_correction"
write(*, *)"AHC_calc"
write(*, *)"SHC_calc"
write(*, *)"Hof_Butt_calc"
write(*, *)"Boltz_OHE_calc"
write(*, *)"Boltz_Berry_correction"
write(*, *)"DMFT_MAG_calc"
write(*, *)"Fit_kp_calc"
write(*, *)"OrbitalTexture_calc"
write(*, *)"OrbitalTexture_3D_calc"
write(*, *)"LandauLevel_wavefunction_calc"
write(*, *)"LandauLevel_k_calc"
write(*, *)"LandauLevel_kplane_calc"
write(*, *)"LandauLevel_B_calc"
write(*, *)"Hof_Butt_calc"
write(*, *)"LandauLevel_k_dos_calc"
write(*, *)"LandauLevel_B_dos_calc"
write(*, *)"Translate_to_WS_calc"
write(*, *)"FermiLevel_calc"
write(*, *)"ANE_calc"
write(*, *)"valley_projection_calc"
write(*, *)"ChargeDensity_selected_energies_calc"
write(*, *)"ChargeDensity_selected_bands_calc"
write(*, *)"The default Vaule is F"
backspace(1001)
read(1001,fmt='(A)') inline
write(*,'(A)') &
'>>> ERROR : Invalid line in namelist CONTROL : '//trim(inline)
stop
endif
!> In order to be compatiable with the old version, we keep the bulkband_calc.
BulkBand_line_calc= BulkBand_line_calc.or.BulkBand_calc
BulkBand_unfold_line_calc= BulkBand_unfold_line_calc.or.Landaulevel_unfold_line_calc
if (MirrorChern_calc) Symmetry_Import_calc = .true.
!> control parameters
if (cpuid==0) then
write(stdout, *) " "
write(stdout, *) ">>>Control parameters: "
write(stdout, *) "BulkBand_line_calc : ", BulkBand_line_calc
write(stdout, *) "BulkBand_plane_calc : ", BulkBand_plane_calc
write(stdout, *) "Landaulevel_unfold_line_calc : ", Landaulevel_unfold_line_calc
write(stdout, *) "BulkBand_unfold_line_calc : ", BulkBand_unfold_line_calc
write(stdout, *) "BulkBand_unfold_plane_calc : ", BulkBand_unfold_plane_calc
write(stdout, *) "QPI_unfold_plane_calc : ", QPI_unfold_plane_calc
write(stdout, *) "BulkFatBand_calc : ", BulkFatBand_calc
write(stdout, *) "BulkBand_cube_calc : ", BulkBand_cube_calc
write(stdout, *) "BulkFS_calc : ", BulkFS_calc
write(stdout, *) "BulkFS_Plane_calc : ", BulkFS_Plane_calc
write(stdout, *) "BulkFS_plane_stack_calc : ", BulkFS_plane_stack_calc
write(stdout, *) "BulkGap_cube_calc : ", BulkGap_cube_calc
write(stdout, *) "BulkGap_plane_calc : ", BulkGap_plane_calc
write(stdout, *) "SlabBand_calc : ", SlabBand_calc
write(stdout, *) "SlabBandWaveFunc_calc : ", SlabBandWaveFunc_calc
write(stdout, *) "SlabSS_calc : ", SlabSS_calc
write(stdout, *) "SlabArc_calc : ", SlabArc_calc
write(stdout, *) "SlabSpintexture_calc : ", SlabSpintexture_calc
write(stdout, *) "wanniercenter_calc : ", wanniercenter_calc
write(stdout, *) "BerryPhase_calc : ", BerryPhase_calc
write(stdout, *) "BerryCurvature_calc : ", BerryCurvature_calc
write(stdout, *) "BerryCurvature_EF_calc : ", BerryCurvature_EF_calc
write(stdout, *) "BerryCurvature_kpath_EF_calc : ", BerryCurvature_kpath_EF_calc
write(stdout, *) "BerryCurvature_kpath_Occupied_calc: ", BerryCurvature_kpath_Occupied_calc
write(stdout, *) "BerryCurvature_Cube_calc : ", BerryCurvature_Cube_calc
write(stdout, *) "BerryCurvature_slab_calc : ", BerryCurvature_slab_calc
write(stdout, *) "Dos_calc : ", DOS_calc
write(stdout, *) "Z2_3D_calc : ", Z2_3D_calc
write(stdout, *) "WeylChirality_calc : ", WeylChirality_calc
write(stdout, *) "NLChirality_calc : ", NLChirality_calc
write(stdout, *) "Chern_3D_calc : ", Chern_3D_calc
write(stdout, *) "MirrorChern_calc : ", MirrorChern_calc
write(stdout, *) "JDos_calc : ", JDOS_calc
write(stdout, *) "FindNodes_calc : ", FindNodes_calc
write(stdout, *) "EffectiveMass_calc : ", EffectiveMass_calc
write(stdout, *) "AHC_calc : ", AHC_calc
write(stdout, *) "SHC_calc : ", SHC_calc
write(stdout, *) "Boltz_OHE_calc : ", Boltz_OHE_calc
write(stdout, *) "Boltz_Berry_correction : ", Boltz_Berry_correction
write(stdout, *) "LOTO_correction : ", LOTO_correction
write(stdout, *) "OrbitalTexture_calc : ", OrbitalTexture_calc
write(stdout, *) "OrbitalTexture_3D_calc : ", OrbitalTexture_3D_calc
write(stdout, *) "LandauLevel_k_calc : ", LandauLevel_k_calc
write(stdout, *) "LandauLevel_B_calc : ", LandauLevel_B_calc
write(stdout, *) "LandauLevel_wavefunction_calc : ", LandauLevel_wavefunction_calc
write(stdout, *) "Fit_kp_calc : ", Fit_kp_calc
write(stdout, *) "DMFT_MAG_calc : ", DMFT_MAG_calc
write(stdout, *) "Translate_to_WS_calc : ", Translate_to_WS_calc
write(stdout, *) "LandauLevel_kplane_calc : ", LandauLevel_kplane_calc
write(stdout, *) "LandauLevel_k_dos_calc : ", LandauLevel_k_dos_calc
write(stdout, *) "LandauLevel_B_dos_calc : ", LandauLevel_B_dos_calc
write(stdout, *) "FermiLevel_calc : ", FermiLevel_calc
write(stdout, *) "ANE_calc : ", ANE_calc
write(stdout, *) "Symmetry_Import_calc : ", Symmetry_Import_calc
write(stdout, *) "ChargeDensity_selected_bands_calc : ", ChargeDensity_selected_bands_calc
write(stdout, *) "ChargeDensity_selected_energies_calc : ", ChargeDensity_selected_energies_calc
write(stdout, *) "valley_projection_calc : " , valley_projection_calc
endif
!===============================================================================================================!
!> SYSTEM namelist
!===============================================================================================================!
!> set system parameters by default
Nslab= 10
Nslab1= 1
Nslab2= 1
Numoccupied = 0
Ntotch = 0
SOC = 0
SOC_in = 0
E_FERMI = 0d0
!> By default magnetic field is zero
Bx = 0d0
By = 0d0
Bz = 0d0
Bmagnitude = 0d0
Btheta = -99999d0
Bphi = -99999d0
surf_onsite = 0d0
!> By default, we don't add zeeman field
Add_Zeeman_Field = .FALSE.
!> by default, g-factor is 2
Effective_gfactor = 2d0
Zeeman_energy_in_eV = 0d0
!> by default, Electric_field_in_eVpA=0
Electric_field_in_eVpA= 0d0
Symmetrical_Electric_field_in_eVpA= 0d0
Inner_symmetrical_Electric_Field= .False.
!> by default we don't set the center atom
center_atom_for_electric_field = -1
!> by default, Vacuum_thickness_in_Angstrom= 20 Angstrom
Vacuum_thickness_in_Angstrom = 20d0
!> read system parameters from file
read(1001, SYSTEM, iostat=stat)
if (stat/=0) then
write(*, *)"ERROR: namelist SYSTEM is wrong and should be set correctly"
backspace(1001)
read(1001,fmt='(A)') inline
write(*,'(A)') &
'>>> ERROR : Invalid line in namelist SYSTEM : '//trim(inline)
stop
endif
SOC_in=SOC
if (SOC == -1) then
write(*, *)"ERROR: you should set SOC in namelist SYSTEM correctly"
stop
endif
if (Numoccupied == 0) then
if (Z2_3D_calc.or.Chern_3D_calc.or.BulkFS_calc &
.or.BulkGap_plane_calc.or.WannierCenter_calc.or.&
BerryPhase_calc.or.BerryCurvature_EF_calc.or.BerryCurvature_calc.or.&
BerryCurvature_plane_selectedbands_calc.or.BerryCurvature_slab_calc.or.&
MirrorChern_calc.or.WeylChirality_calc.or.NLChirality_calc.or.&
FindNodes_calc) then
write(*, *)"ERROR: you should set Numoccupied in namelist SYSTEM correctly"
stop
else
Numoccupied = 1
endif
endif
if (abs(Ntotch) <eps3) then
if (SOC>0) then
Ntotch = Numoccupied
else
Ntotch = Numoccupied*2
endif
endif
if (.not.Add_Zeeman_Field) then
Zeeman_energy_in_eV = 0d0
Effective_gfactor = 0d0
endif
if (cpuid==0) then
write(stdout, *) " "
write(stdout, *) ">>>System parameters: "
write(stdout, '(1x, a, i6 )')"NumSlabs :", Nslab
write(stdout, '(1x, a, i6)')"Nslab1 for ribbon :", Nslab1
write(stdout, '(1x, a, i6)')"Nslab2 for ribbon :", Nslab2
write(stdout, '(1x, a, i6)')"Number of Occupied bands:", NumOccupied
write(stdout, '(1x, a, f12.6)')"Number of total electrons:", Ntotch
write(stdout, '(1x, a, i6)')"With SOC or not in Hrfile:", SOC
write(stdout, '(1x, a, 3f16.6)')"Fermi energy (eV) :", E_FERMI
write(stdout, '(1x, a, 3f16.6)')"surf_onsite (eV): ", surf_onsite
write(stdout, '(1x, a, L)')"Add_Zeeman_Field: ", Add_Zeeman_Field
write(stdout, '(1x, a, 3f16.6)')"Zeeman_energy_in_eV (eV): ", Zeeman_energy_in_eV
write(stdout, '(1x, a, 3f16.6)')"Electric_field_in_eVpA (eV/Angstrom): ", Electric_field_in_eVpA
write(stdout, '(1x, a, 3f16.6)')"Symmetrical_Electric_field_in_eVpA (eV/Angstrom): ", Symmetrical_Electric_field_in_eVpA
write(stdout, '(1x, a, L)')"Inner_symmetrical_Electric_Field: ", Inner_symmetrical_Electric_Field
write(stdout, '(1x, a, i6 )')"ijmax :", ijmax
endif
if (cpuid==0) then
write(stdout, *) " "
write(stdout, "(1x,a)") "**Notes**: There are two ways to specify magnetic field."
write(stdout, "(1x,a)") "1. specify Bmagnitude, Btheta, Bphi"
write(stdout, "(1x,a)") "2. specify Bx, By, Bz"
write(stdout, "(1x,a)") "Bmagnitude, Bx, By, Bz are real numbers in unit of Tesla. and Bx, By, Bz "
write(stdout, "(1x,a)") "are in the cartesian coordinates. Btheta is the angle with z axial "
write(stdout, "(1x,a)") " and Bphi is the angle with respect to x axial in the x-y plane"
write(stdout, "(1x,a)") " Btheta is in [0, 180], Bphi is in [0, 360)."
write(stdout, "(1x,a)") "If you specify both of them together, we will choose the first one."
write(stdout, "(1x,a)") "If choose the first one, but not specify Btheta, Bphi, then "
write(stdout, "(1x,a)") "by default we set Btheta=0, Bphi=0 which means B is along z direction."
endif
!> check if Bmagnitude is specified in the input.dat/wt.in
if (abs(Bmagnitude)>eps6 .and. (abs(Bx)+abs(By)+abs(Bz))>eps6) then
if (cpuid==0) then
write(stdout, *) " "
write(stdout, *) " Warning: You specify Bmagnitude and Bx, By, Bz at the same time "
write(stdout, *) " in the SYSTEM namelist in the wt.in/input.dat."
write(stdout, *) " However, we will only take Bmagnitude and Btheta, Bphi but discard Bx,By,Bz. "
write(stdout, *) " Bx,By,Bz will be calculated as Bx=Bmagnitude*sin(Btheta*pi/180)*cos(bphi/180*pi). "
write(stdout, *) " By=Bmagnitude*sin(Btheta*pi/180)*sin(bphi/180*pi), "
write(stdout, *) " Bz=cos(btheta/180*pi). "
endif
endif
if (abs(Bmagnitude)<eps6 .and. (abs(Bx)+abs(By)+abs(Bz))<eps6) then
if (cpuid==0) then
write(stdout, *) " "
write(stdout, *) " Warning: You didn't specify the magnitude of magnetic field."
write(stdout, *) " "
endif
endif
if (abs(Bmagnitude)>eps6) then
if (abs(Btheta+99999d0)<eps6) then
Btheta=0d0
endif
if (abs(Bphi+99999d0)<eps6) then
Bphi=0d0
endif
Bx=Bmagnitude*sin(Btheta/180d0*pi)*cos(Bphi/180d0*pi)
By=Bmagnitude*sin(Btheta/180d0*pi)*sin(Bphi/180d0*pi)
Bz=Bmagnitude*cos(Btheta/180d0*pi)
Bdirection(1)=Bx/Bmagnitude
Bdirection(2)=By/Bmagnitude
Bdirection(3)=Bz/Bmagnitude
if (cpuid==0)then
write(stdout, '(1x, a, f16.6)')">>You specified the magnitude of magnetic field, "
write(stdout, '(1x, a, f16.6)')"So we will take this option but discard the setting of Bx, By, Bz"
write(stdout, '(1x, a, f16.6)')"Bmagnitude (in Tesla) :", Bmagnitude
write(stdout, '(1x, a, 3f16.6)')"Btheta, Bphi :", Btheta, Bphi
write(stdout, '(1x, a, 3f16.6)')"Bx, By, Bz (in Tesla) :", Bx, By, Bz
write(stdout, '(1x, a, 3f16.6)')"B direction cosines :", Bdirection
endif
else
if (abs(Bx)+abs(By)+abs(Bz)>eps6) then
if (cpuid==0)then
write(stdout, '(1x, a, f16.6)')">>You did not specified the magnitude of magnetic field, "
write(stdout, '(1x, a, f16.6)')" but set Bx, By, Bz. So we will set the magnetic direction"
write(stdout, '(1x, a, f16.6)')" from Bx, By, Bz but discard the settings of Btheta, Bphi."
endif
Bmagnitude= sqrt(Bx*Bx+By*By+Bz*Bz) !> in Tesla
Bdirection(1)=Bx/Bmagnitude
Bdirection(2)=By/Bmagnitude
Bdirection(3)=Bz/Bmagnitude
Btheta= acos(Bdirection(3))*180d0/pi
if (abs(Bx)+abs(By)<eps6) then
Bphi=0d0
else
Bphi= atan2(Bdirection(2),Bdirection(1))*180d0/pi
endif
else
if (cpuid==0)then
write(stdout, '(1x, a, f16.6)')">>You did not specified the magnitude of magnetic field, "
write(stdout, '(1x, a, f16.6)')" and also didn't set Bx, By, Bz. So we will set the magnetic direction"
write(stdout, '(1x, a, f16.6)')" from the settings of Btheta, Bphi."
write(stdout, '(1x, a, f16.6)')" If you even didn't set Btheta, Bphi, we will take the default value, "
write(stdout, '(1x, a, f16.6)')" Btheta=0, Bphi=0 which means B is along z direction"
endif
if (abs(Btheta+99999d0)<eps6) then
Btheta=0d0
if (cpuid==0)then
write(stdout, '(1x, a, f16.6)')">>You didn't set Btheta, and we set it to 0."
endif
else
if (cpuid==0)then
write(stdout, '(1x, a, f16.6)')">>You set Btheta, and we will take it."
endif
endif
if (abs(Bphi+99999d0)<eps6) then
Bphi=0d0
if (cpuid==0)then
write(stdout, '(1x, a, f16.6)')">>You didn't set Bphi, and we set it to 0."
endif
else
if (cpuid==0)then
write(stdout, '(1x, a, f16.6)')">>You set Bphi, and we will take it."
endif
endif
Bdirection(1)=sin(Btheta/180d0*pi)*cos(Bphi/180d0*pi)
Bdirection(2)=sin(Btheta/180d0*pi)*sin(Bphi/180d0*pi)
Bdirection(3)=cos(Btheta/180d0*pi)
Bmagnitude= 1d0
Bx=Bmagnitude*sin(Btheta/180d0*pi)*cos(Bphi/180d0*pi)
By=Bmagnitude*sin(Btheta/180d0*pi)*sin(Bphi/180d0*pi)
Bz=Bmagnitude*cos(Btheta/180d0*pi)
endif
if (cpuid==0)then
write(stdout, '(1x, a, f16.6)')"Bmagnitude (in Tesla) :", Bmagnitude
write(stdout, '(1x, a, 3f16.6)')"Btheta, Bphi :", Btheta, Bphi
write(stdout, '(1x, a, 3f16.6)')"Bx, By, Bz (in Tesla) :", Bx, By, Bz
write(stdout, '(1x, a, 3f16.6)')"B direction cosines :", Bdirection
endif
endif
!> change the unit of magnetic field from Tesla to atomic unit
!> 1 atomic unit = hbar/(e*a0^2) Tesla
!> 1 Tesla= (e*a0^2)/hbar a.u.
Bmagnitude= Bmagnitude*Echarge*bohr_radius**2/hbar
Bx=Bmagnitude*sin(Btheta/180d0*pi)*cos(Bphi/180d0*pi)
By=Bmagnitude*sin(Btheta/180d0*pi)*sin(Bphi/180d0*pi)
Bz=Bmagnitude*cos(Btheta/180d0*pi)
!===============================================================================================================!
!> PARAMETERS namelist
!===============================================================================================================!
!> set up parameters for calculation
E_arc = 0.0d0
Eta_Arc= 0.001d0
EF_broadening= 0.05d0
OmegaNum = 100
OmegaNum_unfold = 0
OmegaMin = -1d0
OmegaMax = 1d0
Nk1 = 10
Nk2 = 10
Nk3 = 1
NP = 2
Gap_threshold= 0.01d0
Tmin = 100. ! in Kelvin
Tmax = 100. ! in Kelvin
NumT= 1
NBTau = 1
BTauNum = 1
Nslice_BTau_Max = 5000
BTauMax = 0d0
Rcut = 999999d0
Magp= 1
Magq= 0
Magp_min=0
Magp_max=0
wcc_calc_tol= 0.08
wcc_neighbour_tol= 0.3
NumLCZVecs=400
NumRandomConfs=1
NumSelectedEigenVals=0
Beta= 100
Relaxation_Time_Tau= 1d0 ! in ps
topsurface_atom_index= 0
!> by default, we only project on atoms for a given wave function
projection_weight_mode = "NORMAL"
read(1001, PARAMETERS, iostat= stat)
if (Magp<1) Magp= 0
if (Magp_max<1) Magp_max= Magp
if (Magq==0) Magq= Nslab
if (Is_Sparse_Hr) then
if (OmegaNum_unfold==0) OmegaNum_unfold= 4*OmegaNum
else
if (OmegaNum_unfold==0) OmegaNum_unfold= 200
endif
if (stat>0) then
backspace(1001)
read(1001,fmt='(A)') inline
write(*,'(A)') &
'>>> ERROR : Invalid line in namelist PARAMETERS : '//trim(inline)
endif
NBTau= max(NBTau, BTauNum)
projection_weight_mode= upper(projection_weight_mode)
if (cpuid==0) then
write(stdout, *) " "
write(stdout, *) ">>>calculation parameters : "
write(stdout, '(1x, a, f16.5)')'E_arc : ', E_arc
write(stdout, '(1x, a, f16.5)')'Eta_arc : ', Eta_arc
write(stdout, '(1x, a, f16.5)')'symprec : ', symprec
write(stdout, '(1x, a, f16.5)')'EF_broadening : ', EF_broadening
write(stdout, '(1x, a, f16.5)')'Gap_threshold', Gap_threshold
write(stdout, '(1x, a, f16.5)')'OmegaMin : ', OmegaMin
write(stdout, '(1x, a, f16.5)')'OmegaMax : ', OmegaMax
write(stdout, '(1x, a, i6 )')'OmegaNum : ', OmegaNum
write(stdout, '(1x, a, i6 )')'OmegaNum_unfold : ', OmegaNum_unfold
write(stdout, '(1x, a, i6 )')'Nk1 : ', Nk1
write(stdout, '(1x, a, i6 )')'Nk2 : ', Nk2
write(stdout, '(1x, a, i6 )')'Nk3 : ', Nk3
write(stdout, '(1x, a, i6 )')'NP number of principle layers : ', Np
write(stdout, '(1x, a, f16.5)')'Tmin(Kelvin) : ', Tmin
write(stdout, '(1x, a, f16.5)')'Tmax(Kelvin) : ', Tmax
write(stdout, '(1x, a, i6 )')'NumT : ', NumT
write(stdout, '(1x, a, i6 )')'NBTau : ', NBTau
write(stdout, '(1x, a, f16.5)')'Beta : ', Beta
write(stdout, '(1x, a, i6 )')'Nslice_BTau_Max : ', Nslice_BTau_Max
write(stdout, '(1x, a, f16.5)')'BTauMax(Tesla.ps)', BTauMax
write(stdout, '(1x, a, f16.5)')'Relaxation_Time_Tau (ps)', Relaxation_Time_Tau
write(stdout, '(1x, a, f16.5)')'Rcut', Rcut
write(stdout, '(1x, a, i16 )')'Magp', Magp
write(stdout, '(1x, a, i16 )')'Magp_min', Magp_min
write(stdout, '(1x, a, i16 )')'Magp_max', Magp_max
write(stdout, '(1x, a, f16.5)')'wcc_calc_tol', wcc_calc_tol
write(stdout, '(1x, a, f16.5)')'wcc_neighbour_tol', wcc_neighbour_tol
write(stdout, '(1x, a, i6 )')'NumLCZVecs', NumLCZVecs
write(stdout, '(1x, a, i6 )')'NumSelectedEigenVals', NumSelectedEigenVals
write(stdout, '(1x, a, i6 )')'NumRandomConfs:', NumRandomConfs
write(stdout, '(1x, a, a )')'Projection weight mode:', projection_weight_mode
write(stdout, '(1x, a, i8 )')'The size of magnetic supercell is Magq= :', Magq
endif
!> changed to atomic units
E_arc= E_arc*eV2Hartree
Eta_Arc = Eta_Arc*eV2Hartree
OmegaMin= OmegaMin*eV2Hartree
OmegaMax= OmegaMax*eV2Hartree
Gap_threshold= Gap_threshold*eV2Hartree
Rcut= Rcut*Ang2Bohr
!> change the unit of relaxtion time from ps to atomic unit
Relaxation_Time_Tau= Relaxation_Time_Tau*1E-12/Time_atomic
!> change the unit of B*Tau from T*ps to atomic unit
BTauMax= BTauMax/Magneticfluxdensity_atomic*Relaxation_Time_Tau
!>
allocate(Omega_array(OmegaNum))
if (OmegaNum==1) then
Omega_array(1)= OmegaMin
else
do i=1, OmegaNum
Omega_array(i)= OmegaMin+ (OmegaMax-OmegaMin)* (i-1d0)/dble(OmegaNum-1)
enddo ! i
endif
!===============================================================================================================!
!> LATTICE card
!===============================================================================================================!
NK = Nk1
!> Read the cell information include the lattice and atom's position
rewind(1001)
lfound = .false.
do while (.true.)
read(1001, *, end= 100)inline
inline= upper(inline)
if (trim(adjustl(inline))=='LATTICE') then
lfound= .true.
if (cpuid==0) write(stdout, *)' '
if (cpuid==0) write(stdout, *)'We found LATTICE card'
exit
endif
enddo
100 continue
if (lfound) then
read(1001, *)inline ! The unit of lattice vector
inline= upper(inline)
AngOrBohr=trim(adjustl(inline))
read(1001, *)Origin_cell%Rua
read(1001, *)Origin_cell%Rub
read(1001, *)Origin_cell%Ruc
else
stop 'ERROR: please set lattice information'
endif
if (index(AngOrBohr, 'ANG')>0) then
!> the input unit is Angstrom
Origin_cell%Rua= Origin_cell%Rua*Angstrom2atomic
Origin_cell%Rub= Origin_cell%Rub*Angstrom2atomic
Origin_cell%Ruc= Origin_cell%Ruc*Angstrom2atomic
endif
Origin_cell%lattice(:, 1)= Origin_cell%Rua
Origin_cell%lattice(:, 2)= Origin_cell%Rub
Origin_cell%lattice(:, 3)= Origin_cell%Ruc
!> cell parameters
Origin_cell%cell_parameters(1)= norm(Origin_cell%Rua)
Origin_cell%cell_parameters(2)= norm(Origin_cell%Rub)
Origin_cell%cell_parameters(3)= norm(Origin_cell%Ruc)
Origin_cell%cell_parameters(4)= angle(Origin_cell%Rub, Origin_cell%Ruc)
Origin_cell%cell_parameters(5)= angle(Origin_cell%Rua, Origin_cell%Ruc)
Origin_cell%cell_parameters(6)= angle(Origin_cell%Rua, Origin_cell%Rub)
!> transform lattice from direct space to reciprocal space
Origin_cell%Kua= 0d0
Origin_cell%Kub= 0d0
Origin_cell%Kuc= 0d0
call get_volume(Origin_cell%Rua, Origin_cell%Rub, Origin_cell%Ruc, Origin_cell%CellVolume)
Origin_cell%ReciprocalCellVolume= (2d0*pi)**3/Origin_cell%CellVolume
call get_reciprocal_lattice(Origin_cell%Rua, Origin_cell%Rub, Origin_cell%Ruc, &
Origin_cell%Kua, Origin_cell%Kub, Origin_cell%Kuc)
Origin_cell%reciprocal_lattice(:, 1)= Origin_cell%Kua
Origin_cell%reciprocal_lattice(:, 2)= Origin_cell%Kub
Origin_cell%reciprocal_lattice(:, 3)= Origin_cell%Kuc
!> cell parameters
Origin_cell%reciprocal_cell_parameters(1)= norm(Origin_cell%Kua)
Origin_cell%reciprocal_cell_parameters(2)= norm(Origin_cell%Kub)
Origin_cell%reciprocal_cell_parameters(3)= norm(Origin_cell%Kuc)
Origin_cell%reciprocal_cell_parameters(4)= angle(Origin_cell%Kub, Origin_cell%Kuc)
Origin_cell%reciprocal_cell_parameters(5)= angle(Origin_cell%Kua, Origin_cell%Kuc)
Origin_cell%reciprocal_cell_parameters(6)= angle(Origin_cell%Kua, Origin_cell%Kub)
if(cpuid==0)write(stdout, '(a)') '>> lattice information (Angstrom)'
if(cpuid==0)write(stdout, '(6a12)')" a", " b", " c", 'alpha', 'beta', 'gamma'
if(cpuid==0)write(stdout, '(6f12.6)')Origin_cell%cell_parameters/Angstrom2atomic
if(cpuid==0)write(stdout, '(a)')" Three Lattice vectors of the unfolded cell: "
if(cpuid==0)write(stdout, '(3f12.6)')Origin_cell%Rua/Angstrom2atomic
if(cpuid==0)write(stdout, '(3f12.6)')Origin_cell%Rub/Angstrom2atomic
if(cpuid==0)write(stdout, '(3f12.6)')Origin_cell%Ruc/Angstrom2atomic
if(cpuid==0)write(stdout, '(a)') '>> Reciprocal lattice information (1/Angstrom)'
if(cpuid==0)write(stdout, '(6a12)')" a", " b", " c", 'alpha', 'beta', 'gamma'
if(cpuid==0)write(stdout, '(6f12.6)')Origin_cell%reciprocal_cell_parameters*Angstrom2atomic
if(cpuid==0)write(stdout, '(a)')" Three reciprocal lattice vectors of the primitive cell: "
if(cpuid==0)write(stdout, '(3f12.6)')Origin_cell%Kua*Angstrom2atomic
if(cpuid==0)write(stdout, '(3f12.6)')Origin_cell%Kub*Angstrom2atomic
if(cpuid==0)write(stdout, '(3f12.6)')Origin_cell%Kuc*Angstrom2atomic
!===============================================================================================================!
!> ATOM_POSITIONS card
!===============================================================================================================!
!> Read atom positions information
rewind(1001)
lfound = .false.
do while (.true.)
read(1001, *, end= 101)inline
inline=upper(inline)
if (trim(adjustl(inline))=='ATOM_POSITIONS') then
lfound= .true.
if (cpuid==0) write(stdout, *)' '
if (cpuid==0) write(stdout, *)'We found ATOM_POSITIONS card'
exit
endif
enddo
101 continue
if (lfound) then
read(1001, *)Origin_cell%Num_atoms ! total number of atoms
if(cpuid==0)write(stdout, '(a, i5)')'Origin_cell%Num_atoms', Origin_cell%Num_atoms
allocate(Origin_cell%atom_name(Origin_cell%Num_atoms))
allocate(Origin_cell%Atom_position_cart(3, Origin_cell%Num_atoms))
allocate(Origin_cell%Atom_position_direct(3, Origin_cell%Num_atoms))
allocate(Atom_position_cart_newcell(3, Origin_cell%Num_atoms))
allocate(Atom_position_direct_newcell(3, Origin_cell%Num_atoms))
allocate(Origin_cell%Atom_magnetic_moment(3, Origin_cell%Num_atoms))
Origin_cell%Atom_magnetic_moment= 0d0
read(1001, *)inline ! The unit of lattice vector
DirectOrCart= trim(adjustl(inline))
!> check whether we have the magnetic moment in the POSITION card
do i=1, Origin_cell%Num_atoms
read(1001, *, err=132) Origin_cell%atom_name(i), Origin_cell%Atom_position_cart(:, i), Origin_cell%Atom_magnetic_moment(:, i)
if(cpuid==0)write(stdout, '(a4,3f12.6)')Origin_cell%atom_name(i), Origin_cell%Atom_position_cart(:, i)
if (index(DirectOrCart, "D")>0)then
pos= Origin_cell%Atom_position_cart(:, i)
Origin_cell%Atom_position_cart(:, i)= pos(1)*Origin_cell%Rua+ pos(2)*Origin_cell%Rub+ pos(3)*Origin_cell%Ruc
else
if (index(AngOrBohr, 'ANG')>0) then
Origin_cell%Atom_position_cart(:, i)= Origin_cell%Atom_position_cart(:, i)*Angstrom2atomic
endif
endif
enddo
go to 133
132 continue
!> if the code comes to here, it means there is no atom's magnetic moment in the POSITION card
if (cpuid==0) write(stdout, *) ' '
if (cpuid==0) write(stdout, *) &
"Warning: You didn't specify the atom magnetic moment in the ATOMIC_POSITION card", &
" Or the format is wrong. ", &
"So we set all the Atom-magnetic-moments to zero."
Origin_cell%Atom_magnetic_moment= 0d0
rewind(1001)
do while (.true.)
read(1001, *)inline
inline=upper(inline)
if (trim(adjustl(inline))=='ATOM_POSITIONS') then
exit
endif
enddo
!> skip two lines
read(1001, *)
read(1001, *)
do i=1, Origin_cell%Num_atoms
read(1001, *, err=134) Origin_cell%atom_name(i), Origin_cell%Atom_position_cart(:, i)
!> Origin_cell%Atom_position_cart is in the cartesian coordinate.
if (index(DirectOrCart, "D")>0)then
pos= Origin_cell%Atom_position_cart(:, i)
Origin_cell%Atom_position_cart(:, i)= pos(1)*Origin_cell%Rua+ pos(2)*Origin_cell%Rub+ pos(3)*Origin_cell%Ruc
else
if (index(AngOrBohr, 'ANG')>0) then
Origin_cell%Atom_position_cart(:, i)= Origin_cell%Atom_position_cart(:, i)*Angstrom2atomic
endif
endif
enddo
go to 133
134 continue
write(*, *)"ERROR happens in the ATOMIC_POSITION card"
write(*, *)"This is a free format card, between lines there should be any comments"
write(*, *)"The number in the second line should be the same as the number of lines of the atom positions."
stop "ERROR: please set ATOMIC_POSITION card correctly, see manual on www.wanniertools.com"
133 continue
do ia=1, Origin_cell%Num_atoms
call cart_direct_real(Origin_cell%Atom_position_cart(:, ia), &
Origin_cell%Atom_position_direct(:, ia), Origin_cell%lattice)
enddo
if(cpuid==0)write(stdout,'(a)')' '
if(cpuid==0)write(stdout,'(a)')'>> Atom position and magnetic moment of Original lattice'
if(cpuid==0)write(stdout,'(13X, 2a36, a24)')' Catesian(Ang)', 'Fractional(Direct)', 'Magnetic moment'
if(cpuid==0)write(stdout,'(a)')'------------------------------------------------------------------------------------------------------------------'
if(cpuid==0)write(stdout,'(a6, 2X, a10, 6a12, 3a8)')'index', 'Atom Name ', ' x', ' y', ' z', 'a', 'b', 'c', 'Mx', 'My', 'Mz'
if(cpuid==0)write(stdout,'(a)')'------------------------------------------------------------------------------------------------------------------'
do i=1, Origin_cell%Num_atoms
if(cpuid==0)write(stdout, '(i6,2X, a10,6f12.6,3f8.3)')i, Origin_cell%atom_name(i), &
Origin_cell%Atom_position_cart(:, i)/Angstrom2atomic, Origin_cell%Atom_position_direct(:,i), Origin_cell%Atom_magnetic_moment(:, i)
enddo
else
stop "ERROR: please set atom's positions information correctly"
endif
!> setup atom type
if (allocated(iarray_temp))deallocate(iarray_temp)
allocate(iarray_temp(Origin_cell%Num_atoms))
iarray_temp= 1
do ia=1, Origin_cell%Num_atoms
char_temp= Origin_cell%atom_name(ia)
do i=ia+1, Origin_cell%Num_atoms
if (char_temp==Origin_cell%atom_name(i).and.iarray_temp(i)/=0)then
iarray_temp(i)=0
endif
enddo
enddo
Origin_cell%Num_atom_type= sum(iarray_temp)
allocate(Origin_cell%Name_of_atomtype(Origin_cell%Num_atom_type))
allocate(Origin_cell%Num_atoms_eachtype(Origin_cell%Num_atom_type))
allocate(Origin_cell%itype_atom(Origin_cell%Num_atoms))
it = 0
do ia=1, Origin_cell%Num_atoms
if (iarray_temp(ia)/=0) then
it= it+ 1
Origin_cell%Name_of_atomtype(it)= Origin_cell%atom_name(ia)
endif
enddo
!> find the type of atoms and label them
do ia=1, Origin_cell%Num_atoms
do i=1, Origin_cell%Num_atom_type
if (Origin_cell%atom_name(ia)==Origin_cell%Name_of_atomtype(i))then
Origin_cell%itype_atom(ia)= i
endif
enddo
enddo
do i=1, Origin_cell%Num_atom_type
it = 0
do ia=1, Origin_cell%Num_atoms
if (Origin_cell%atom_name(ia)==Origin_cell%Name_of_atomtype(i))then
it = it+ 1
endif
enddo
Origin_cell%Num_atoms_eachtype(i)= it
enddo
!===============================================================================================================!
!> PROJECTORS card
!===============================================================================================================!
!> Read projectors information
rewind(1001)
lfound = .false.
do while (.true.)
read(1001, *, end= 102)inline
inline=upper(inline)
if (trim(adjustl(inline))=='PROJECTORS'.or.&
trim(adjustl(inline))=='PROJECTOR') then
lfound= .true.
if (cpuid==0) write(stdout, *)' '
if (cpuid==0) write(stdout, *)'We found PROJECTORS card'
exit
endif
enddo
102 continue
if (lfound) then
allocate(Origin_cell%nprojs(Origin_cell%Num_atoms))
Origin_cell%nprojs= 0
read(1001, *)Origin_cell%nprojs
if(cpuid==0)write(stdout, '(a)')' >>Number of projectors per atoms:'
if(cpuid==0)write(stdout, '(10i6)')Origin_cell%nprojs
Origin_cell%max_projs= maxval(Origin_cell%nprojs)
allocate(Origin_cell%proj_name(Origin_cell%max_projs, Origin_cell%Num_atoms))
Origin_cell%proj_name= ' '
do i=1, Origin_cell%Num_atoms
read(1001, *)char_temp, Origin_cell%proj_name(1:Origin_cell%nprojs(i), i)
if(cpuid==0)write(stdout, '(40a8)') &
char_temp, Origin_cell%proj_name(1:Origin_cell%nprojs(i), i)
!> change the projector name to upper case
do j=1, Origin_cell%nprojs(i)
Origin_cell%proj_name(j, i)= upper(Origin_cell%proj_name(j, i))
enddo
enddo
else
stop "ERROR: please set projectors for Wannier functions information"
endif
!> set up orbitals_start
allocate(orbitals_start(Origin_cell%Num_atoms))
orbitals_start= 1
do i=1, Origin_cell%Num_atoms-1
orbitals_start(i+1)= orbitals_start(i)+ Origin_cell%nprojs(i)
enddo
!> orbital index order
allocate(index_start(Origin_cell%Num_atoms))
allocate(index_end (Origin_cell%Num_atoms))
index_start= 0
index_end= 0
index_start(1)= 1
index_end(1)= Origin_cell%nprojs(1)
do i=2, Origin_cell%Num_atoms
index_start(i)= index_start(i-1)+ Origin_cell%nprojs(i-1)
index_end(i)= index_end(i-1)+ Origin_cell%nprojs(i)
enddo
!> read Wannier centres
NumberOfspinorbitals= sum(Origin_cell%nprojs)
if (SOC>0.or.Add_Zeeman_Field) NumberOfspinorbitals= 2*NumberOfspinorbitals
Origin_cell%NumberOfspinorbitals= NumberOfspinorbitals
allocate(Origin_cell%spinorbital_to_atom_index(NumberOfspinorbitals))
allocate(Origin_cell%spinorbital_to_projector_index(NumberOfspinorbitals))
allocate(Origin_cell%wannier_centers_cart(3, NumberOfspinorbitals))
allocate(Origin_cell%wannier_centers_direct(3, NumberOfspinorbitals))
Origin_cell%wannier_centers_direct= 0d0
Origin_cell%wannier_centers_cart= 0d0
!> default wannier centers
i= 0
do ia= 1, Origin_cell%Num_atoms
do j= 1, Origin_cell%nprojs(ia)
i= i+ 1
Origin_cell%spinorbital_to_atom_index(i)= ia
Origin_cell%spinorbital_to_projector_index(i)= j
Origin_cell%wannier_centers_cart(:, i)= Origin_cell%Atom_position_cart(:, ia)
call cart_direct_real(Origin_cell%wannier_centers_cart(:, i), &
Origin_cell%wannier_centers_direct(:, i), &
Origin_cell%lattice)
if (SOC>0.or.Add_Zeeman_Field) then
Origin_cell%spinorbital_to_atom_index(i+NumberOfspinorbitals/2)= ia
Origin_cell%spinorbital_to_projector_index(i+NumberOfspinorbitals/2)= j
Origin_cell%wannier_centers_cart(:, i+NumberOfspinorbitals/2)= Origin_cell%Atom_position_cart(:, ia)
call cart_direct_real(Origin_cell%wannier_centers_cart(:, i+NumberOfspinorbitals/2), &
Origin_cell%wannier_centers_direct(:, i+NumberOfspinorbitals/2), &
Origin_cell%lattice)
endif
enddo ! j
enddo ! ia