-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathswntstruct.f90
executable file
·1513 lines (1251 loc) · 46 KB
/
swntstruct.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
!*******************************************************************************
!*******************************************************************************
! Project : tubestruct.f90
!===============================================================================
! Purpose :
! Library to generate nanotube structures and related vector operations
!-------------------------------------------------------------------------------
! Authors :
! - ART Nugraha (nugraha@flex.phys.tohoku.ac.jp)
! - Daria Satco (dasha.shatco@gmail.com)
! Latest Vers. : 2018.09.30
!-------------------------------------------------------------------------------
! Reference(s) :
! Physical Properties of Carbon Nanotubes
! R. Saito, G. Dresselhaus, M. S. Dresselhaus (ICP, 1998)
!-------------------------------------------------------------------------------
! Contents :
! - FUNCTION NNatom(iatom,nn)
! - SUBROUTINE phij(n,m,iatom,ivec,nn,q,mu,phi)
! - SUBROUTINE phaseFactor(n,m,j1,j2,q,mu,phi)
! - SUBROUTINE rxyzVec(n,m,iatom,ivec,nn,Rxyz)
! - SUBROUTINE rxyzJ1J2Vec(n,m,iatom,j1,j2,Rxyz)
! - SUBROUTINE NNj1j2(iatom,ivec,nn,j1,j2)
! - SUBROUTINE tubetoXYZ(n,m,Vtube,Vxyz)
! - SUBROUTINE XYtoTube(n,m,Vin,Vout)
! - SUBROUTINE tauAjVecXY(ivec,nn,tau)
! - SUBROUTINE tauBjVecXY(ivec,nn,tau)
! - SUBROUTINE rhoVec(n,m,iatom,rho)
! - SUBROUTINE rho2Vec(n,m,iatom,ivec,rho)
! - SUBROUTINE tubeRadUnitVec(Vxyz,Ur)
! - SUBROUTINE r2xyzVec(n,m,iatom,ivec1,ivec2,Rxyz)
! - SUBROUTINE drVec(n,m,iatom,Dr)
! - SUBROUTINE dr2Vec(n,m,iatom,ivec,Dr)
! - SUBROUTINE dN2xyzVec(n,m,iatom,ivec1,ivec2,dN2xyz)
! - SUBROUTINE dNxyzVec(n,m,iatom,ivec,nn,dNxyz)
! - SUBROUTINE srmatrix(n,m,iatom,Sr)
! - SUBROUTINE sr2matrix(n,m,iatom,ivec,Sr)
! - SUBROUTINE sqmatrix(n,m,iatom,ivec,nn,q,mu,Sq)
! - SUBROUTINE sjmatrix(n,m,iatom,ivec,nn,Sj)
! - SUBROUTINE reducedCutLine
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!! Daria Satco added (autumn 2018) !!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! - SUBROUTINE getHexagonPosition(n,m,nhex,j1j2)
!*******************************************************************************
!*******************************************************************************
INTEGER FUNCTION NNatom(iatom,nn)
!===============================================================================
! label neighboring atoms
!===============================================================================
IMPLICIT NONE
INTEGER, INTENT(in) :: iatom, nn
IF(nn.EQ.0 .OR. nn.EQ.2) THEN
NNatom = iatom
ELSE
IF(iatom.EQ.1) NNatom = 2
IF(iatom.EQ.2) NNatom = 1
END IF
RETURN
END FUNCTION NNatom
!*******************************************************************************
!*******************************************************************************
SUBROUTINE phij(n,m,iatom,ivec,nn,q,mu,phi)
!===============================================================================
! Compute the phase factor phi = Q \cdot Rj (dimensionless), where
! Rj is the center of the two atom unit cell to which the neighbor atom
! at R(n)_(iatom,ivec,nn) belongs and Q is the 2D Q vector that satisfies
! translational and rotational boundary conditions
!-------------------------------------------------------------------------------
! Input :
! n,m chiral vector coordinates in (a1,a2)
! iatom specifies atom in two atom unit cell (1=A,2=B)
! ivec index for nearest neighbor vector in the shell
! nn neighbor index nn = 0,1,2,3,4
! q wavevector along tube axis (1/Angstroms)
! mu labels manifolds (0...N_hex-1)
! Output :
! phi dot product of Q and Rj (dimensionless)
!===============================================================================
IMPLICIT NONE
! input variables
INTEGER, INTENT(in) :: n, m, mu, iatom, ivec, nn
REAL(8), INTENT(in) :: q
! output variable
REAL(8), INTENT(out) :: phi
! working variables
INTEGER :: j1,j2
! near neighbor two atom unit cell indices j1 and j2
CALL NNj1j2(iatom,ivec,nn,j1,j2)
! dot product of Q and Rj (dimensionless)
CALL phaseFactor(n,m,j1,j2,q,mu,phi)
END SUBROUTINE phij
!*******************************************************************************
!*******************************************************************************
SUBROUTINE phaseFactor(n,m,j1,j2,q,mu,phi)
!===============================================================================
! Compute the phase factor phi = Q.Rj (dimensionless) where Rj is the
! center of the two atom unit cell in unrolled tube coordinates and Q
! is the 2D Q vector that satisfies translational and rotational
! boundary conditions
!-------------------------------------------------------------------------------
! Input :
! n,m chiral vector coordinates in (a1,a2)
! j1,j2 center of two atom unit cell in (a1,a2)
! q wavevector along tube axis (1/Angstroms)
! mu labels manifolds (0...N_hex-1)
! Output :
! phi dot product of Q and Rj (dimensionless)
!===============================================================================
IMPLICIT NONE
! input variables
INTEGER, INTENT(in) :: n,m,j1,j2,mu
REAL(8), INTENT(in) :: q
! output variable
REAL(8), INTENT(out) :: phi
! working variables and parameters
REAL(8), PARAMETER :: a = 2.49D0
REAL(8), PARAMETER :: pi = 3.14159265358979D0
REAL(8), PARAMETER :: sqrt3 = 1.73205080756888D0
REAL(8) :: rn, rm, qq, rmu, rj1, rj2
REAL(8) :: theta1, theta2, tau1, tau2, theta, tau
rn = DBLE(n)
rm = DBLE(m)
qq = DBLE(q)
rmu = DBLE(mu)
rj1 = DBLE(j1)
rj2 = DBLE(j2)
! screw operator rotations for basis vectors a1 and a2 (radians)
theta1 = (2.D0*rn + rm)*pi / (rn**2 + rn*rm + rm**2)
theta2 = (2.D0*rm + rn)*pi / (rn**2 + rn*rm + rm**2)
! screw operator translations for basis vectors a1 and a2 (Angstroms)
tau1 = a*sqrt3*rm / (2.D0 * DSQRT(rn**2 + rn*rm + rm**2))
tau2 = -a*sqrt3*rn / (2.D0 * DSQRT(rn**2 + rn*rm + rm**2))
! screw operator taking two atom unit cell at origin to near neighbor
theta = rj1*theta1 + rj2*theta2
tau = rj1*tau1 + rj2*tau2
! phase factor (dimensionless)
phi = rmu*theta + qq*tau
END SUBROUTINE phaseFactor
!*******************************************************************************
!*******************************************************************************
SUBROUTINE rxyzVec(n,m,iatom,ivec,nn,Rxyz)
!===============================================================================
! Compute the xyz coordinates for A and B atoms and their neighbors
! R(nn)_(iatom,ivec). If nn=0, return R_A or R_B.
!-------------------------------------------------------------------------------
! Input :
! n,m chiral vector coordinates in (a1,a2)
! iatom specifies atom in two atom unit cell (1=A,2=B)
! ivec index for nearest neighbor vector in the shell
! nn nearest neighbor index nn = 0,1,2,3,4
! Output :
! Rxyz(3) R(nn)_(iatom,ivec) in xyz coordinates (Angstroms)
!===============================================================================
IMPLICIT NONE
! input variables
INTEGER, INTENT(in) :: n, m, iatom, ivec, nn
! output variable
REAL(8), INTENT(out) :: Rxyz(3)
! working variables
REAL(8) :: tau0(2), tau(2), Rtube(2)
INTEGER :: ier, nnn, iiatom, iivec,ii
INTEGER, SAVE, DIMENSION(0:4) :: nvecs = (/ 1, 3, 6, 3, 6 /)
REAL(8), SAVE, DIMENSION(2,6, 0:4, 3) :: Rsave !(iatom,ivec,nn, 3)
INTEGER, SAVE :: nch = 0
INTEGER, SAVE :: mch = 0
! check input for errors
ier = 0
IF (iatom /= 1 .AND. iatom /= 2) THEN
ier = 1
WRITE (*,*) 'rxyzVec err: invalid iatom: ', iatom
END IF
IF (ier /= 0) STOP
! update Rxyz lookup table if (n,m) has changed
IF (n /= nch .OR. m /= mch) THEN
nch = n
mch = m
Rsave = 0.D0
DO iiatom = 1, 2
DO nnn = 0, 4
DO iivec = 1, nvecs(nnn)
! tube coordinates of A or B atom in two atom unit cell (Angstroms)
CALL tauAjVecXY(1,1,tau0)
IF (iiatom == 1) THEN
tau0 =-tau0/2.D0 !tauA = -tau(1)_(A1)/2 (graphene xy coord.)
ELSE
tau0 = tau0/2.D0 !tauB = tau(1)_(A1)/2
END IF
CALL XYtoTube(n,m,tau0,tau0)
! if nnn = 0, return xyz coordinates of A or B in two atom unit cell
IF (nnn == 0) THEN
Rtube = tau0
CALL tubetoXYZ(n,m,Rtube,Rxyz)
ELSE
! tube coordinates of neighbor atom (iatom,ivec,nn) (Angstroms)
IF (iiatom == 1) THEN
CALL tauAjVecXY(iivec,nnn,tau)
ELSE
CALL tauBjVecXY(iivec,nnn,tau)
END IF
CALL XYtoTube(n,m,tau,tau)
Rtube = tau0+tau
! go from tube to xyz coordinates (Angstroms)
CALL tubetoXYZ(n,m,Rtube,Rxyz)
END IF
! save Rxyz (Angstroms)
DO ii = 1,3
Rsave(iiatom,iivec,nnn,ii) = Rxyz(ii)
END DO
END DO
END DO
END DO
END IF
! return Rxyz using lookup table (Angstroms)
iivec = ivec
IF(nn == 0) iivec = 1
DO ii = 1,3
Rxyz(ii) = Rsave(iatom,iivec,nn,ii)
END DO
END SUBROUTINE rxyzVec
!*******************************************************************************
!*******************************************************************************
SUBROUTINE rxyzJ1J2Vec(n,m,iatom,j1,j2,Rxyz)
!===============================================================================
! compute xyz atomic position vector for an atom in the J = (j1,j2)
! hexagon in (n,m) nanotubes. The A and B atoms are iatom = 1 or 2.
! If iatom is otherwise, the center of the hexagon is returned.
!-------------------------------------------------------------------------------
! Input :
! n,m chiral vector coordinates in (a1,a2)
! iatom atom in the unit cell (1=A,2=B)
! j1,j2 center of two atom unit cell in a1 a2 basis
! Output :
! Rxyz(3) atomic position in tube xyz coordinates (Angstroms)
!===============================================================================
IMPLICIT NONE
! input variables
INTEGER, INTENT(in) :: n, m, iatom, j1, j2
! output variable
REAL(8), INTENT(out) :: Rxyz(3)
! working variables
REAL(8) :: a1(2), a2(2), tau(2), Rj(2)
REAL(8) :: rj1, rj2
!..center of hexagonal unit cell in graphene coordinates (Angstroms)
CALL unitVecXY(a1,a2)
rj1 = float(j1)
rj2 = float(j2)
Rj = rj1*a1 + rj2*a2
! offset in graphene coordinates to get atomic position (Angstroms)
CALL tauAjVecXY(1,1,tau)
IF (iatom == 1) THEN
Rj = Rj-tau/2.D0
END IF
IF(iatom == 2) THEN
Rj = Rj + tau/2.D0
END IF
! convert to xyz coordinates (Angstroms)
CALL XYtoTube(n,m,Rj,Rj)
CALL tubetoXYZ(n,m,Rj,Rxyz)
RETURN
END SUBROUTINE rxyzJ1J2Vec
!*******************************************************************************
!*******************************************************************************
SUBROUTINE NNj1j2(iatom,ivec,nn,j1,j2)
!===============================================================================
! for an atom in the two atom unit cell, find the two atom unit cell
! indices j1 and j2 that its neighbors belong to. The indices j1 and j2
! specify the center of the unit cell as R = j1*a1 + j2*a2.
!===============================================================================
! Input :
! iatom specifies atom in two atom unit cell (1=A,2=B)
! ivec index for nearest neighbor vector in the shell
! nn neighbor index nn = 0,1,2,3,4
! Output :
! j1,j2 center of two atom unit cell in (a1,a2)
!===============================================================================
IMPLICIT NONE
! input variables
INTEGER, INTENT(in) :: iatom, ivec, nn
! output variables
INTEGER, INTENT(out) :: j1, j2
! working variable
INTEGER :: ierr
! check input for errors
ierr = 0
IF (iatom /= 1 .AND. iatom /= 2) THEN
ierr = 1
WRITE (*,*) 'NNj1j2 err: invalid iatom: ', iatom
END IF
IF (nn < 0 .OR. nn > 4) THEN
ierr = 1
WRITE (*,*) 'NNj1j2 err: invalid nn: ', nn
END IF
IF (nn == 1 .AND. ivec > 3) THEN
ierr = 1
WRITE (*,*) 'NNj1j2 err: nn = 1 and ivec > 3'
END IF
IF (nn == 2 .AND. ivec > 6) THEN
ierr = 1
WRITE (*,*) 'NNj1j2 err: nn = 2 and ivec > 6'
END IF
IF (nn == 3 .AND. ivec > 3) THEN
ierr = 1
WRITE (*,*) 'NNj1j2 err: nn = 3 and ivec > 3'
END IF
IF (nn == 4 .AND. ivec > 6) THEN
ierr = 1
WRITE (*,*) 'NNj1j2 err: nn = 4 and ivec > 6'
END IF
IF (ierr.NE.0) STOP
! find j1 and j2 for an A atom (iatom = 1)
! onsite case
IF (nn == 0) THEN
j1 = 0
j2 = 0
END IF
! nearest neighghbor J1 J2 indices
IF (nn == 1) THEN
IF (ivec == 1) THEN
j1 = 0
j2 = 0
END IF
IF (ivec == 2) THEN
j1 = 0
j2 =-1
END IF
IF (ivec == 3) THEN
j1 =-1
j2 = 0
END IF
END IF
! second nearest neighbor J1 J2 indices
IF (nn == 2) THEN
IF (ivec == 1) THEN
j1 = 1
j2 = 0
END IF
IF (ivec == 2) THEN
j1 = 0
j2 = 1
END IF
IF (ivec == 3) THEN
j1 = 1
j2 =-1
END IF
IF (ivec == 4) THEN
j1 =-1
j2 = 1
END IF
IF (ivec == 5) THEN
j1 = 0
j2 =-1
END IF
IF (ivec == 6) THEN
j1 =-1
j2 = 0
END IF
END IF
! third nearest neighghbor J1 J2 indices
IF (nn == 3) THEN
IF (ivec == 1) THEN
j1 = -1
j2 = -1
END IF
IF (ivec == 2) THEN
j1 = 1
j2 =-1
END IF
IF (ivec == 3) THEN
j1 = -1
j2 = 1
END IF
END IF
! fourth nearest neighghbor J1 J2 indices
IF (nn == 4) THEN
IF (ivec == 1) THEN
j1 = 1
j2 = 0
END IF
IF (ivec == 2) THEN
j1 = 0
j2 = 1
END IF
IF (ivec == 3) THEN
j1 = 1
j2 =-2
END IF
IF (ivec == 4) THEN
j1 =-2
j2 = 1
END IF
IF (ivec == 5) THEN
j1 = 0
j2 =-2
END IF
IF (ivec == 6) THEN
j1 =-2
j2 = 0
END IF
END IF
! change sign of j1 and j2 if this is a B atom (iatom=2)
IF (iatom == 2) THEN
j1 = -j1
j2 = -j2
END IF
END SUBROUTINE NNj1j2
!*******************************************************************************
!*******************************************************************************
SUBROUTINE tubetoXYZ(n,m,Vtube,Vxyz)
!===============================================================================
! Convert 2D vector in tube coordinates to 3D xyz coordinates
!-------------------------------------------------------------------------------
! Input :
! n,m chiral vector coordinates in a1,a2 basis
! Vtube(2) 2D vector in tube coordinates (Angstroms)
! Output :
! Vxyz(3) 3D vector in xyz coordinates (Angstroms)
!===============================================================================
IMPLICIT NONE
! input variables
INTEGER, INTENT(in) :: n, m
REAL(8), INTENT(in) :: Vtube(2)
! output variable
REAL(8), INTENT(out) :: Vxyz(3)
! working variables
REAL(8), PARAMETER :: pi = 3.14159265358979D0
REAL(8) :: theta, tubeRadius, tubeDiam, chLength
tubeRadius = tubeDiam(n,m)/2.D0
theta = 2.D0 * pi * Vtube(1)/chLength(n,m)
Vxyz(1) = tubeRadius*DCOS(theta)
Vxyz(2) = tubeRadius*DSIN(theta)
Vxyz(3) = Vtube(2)
END SUBROUTINE tubetoXYZ
!*******************************************************************************
!*******************************************************************************
SUBROUTINE XYtoTube(n,m,Vin,Vout)
!===============================================================================
! Convert an xy vector to unrolled tube coordinates.
! In tube coordinates, x is taken parallel to the chiral vector (Ch)
! and y is parallel to the translation vector (T)
!-------------------------------------------------------------------------------
! Input :
! n,m chiral vector coordinates in a1,a2 basis
! Vin(2) vector in xy coordinates (A)
! Output :
! Vout(2) vector in tube coordinates (A)
!===============================================================================
IMPLICIT NONE
! input variables
INTEGER, INTENT(in) :: n, m
REAL(8), INTENT(in) :: Vin(2)
! output variable
REAL(8), INTENT(out) :: Vout(2)
! working variables
REAL(8) :: Ch(2), T(2)
REAL(8) :: Vtemp(2)
INTEGER :: it1,it2
REAL(8) :: rL,chLength
REAL(8) :: rT,trLength
CALL chVecXY(n,m,Ch)
CALL trVecXY(n,m,it1,it2,T)
rL = chLength(n,m)
rT = trLength(n,m)
Vtemp(1) = DOT_PRODUCT(Vin,Ch)
Vtemp(2) = DOT_PRODUCT(Vin, T)
Vtemp(1) = Vtemp(1)/rL
Vtemp(2) = Vtemp(2)/rT
Vout(1) = Vtemp(1)
Vout(2) = Vtemp(2)
END SUBROUTINE XYtoTube
!*******************************************************************************
!*******************************************************************************
SUBROUTINE tauAjVecXY(ivec,nn,tau)
!===============================================================================
! vectors from a graphene A atom to nearest neighbors up to the fourth
! nearest neighbor shell in graphene xy coordinates
!-------------------------------------------------------------------------------
! Input :
! ivec index for nearest neighbor vector in the shell
! nn nearest neighbor index nn = 1,2,3,4
! Output :
! tau(2) vector from A to nearest neighbor in xy coordinates (A)
!===============================================================================
IMPLICIT NONE
! input variables
INTEGER, INTENT(in) :: ivec, nn
! output variable
REAL(8), INTENT(out) :: tau(2)
! parameters
REAL(8), PARAMETER :: a = 2.49D0
REAL(8), PARAMETER :: sqrt3 = 1.73205080756888D0
! check input for errors
IF (nn <= 0 .OR. nn > 4) THEN
WRITE (*,*) 'tauAjVecXY err: invalid nn: ', nn
STOP
END IF
IF (nn == 1 .AND. ivec > 3) THEN
WRITE (*,*) 'nn = 1 and ivec > 3'
STOP
END IF
IF (nn == 2 .AND. ivec > 6) THEN
WRITE (*,*) 'nn = 2 and ivec > 6'
STOP
END IF
IF (nn == 3 .AND. ivec > 3) THEN
WRITE (*,*) 'nn = 3 and ivec > 3'
STOP
END IF
IF (nn == 4 .AND. ivec > 6) THEN
WRITE (*,*) 'nn = 4 and ivec > 6'
STOP
END IF
! nearest neighghbor vectors (A)
IF (nn == 1) THEN
IF (ivec == 1) THEN
tau(1) = a/sqrt3
tau(2) = 0.D0
RETURN
END IF
IF (ivec == 2) THEN
tau(1) =-a/(2.D0*sqrt3)
tau(2) = a/2.D0
RETURN
END IF
IF (ivec == 3) THEN
tau(1) =-a/(2.D0*sqrt3)
tau(2) =-a/2.D0
RETURN
END IF
WRITE (*,*) 'tauAjVecXY err: ivec,nn:', ivec, nn
STOP
END IF
! second nearest neighghbor vectors (A)
IF (nn == 2) THEN
IF (ivec == 1) THEN
tau(1) = a*sqrt3/2.
tau(2) = a/2.
RETURN
END IF
IF (ivec == 2) THEN
tau(1)= a*sqrt3/2.
tau(2)=-a/2.
RETURN
END IF
IF (ivec == 3) THEN
tau(1) = 0.D0
tau(2) = a
RETURN
END IF
IF (ivec == 4) THEN
tau(1) = 0.D0
tau(2) =-a
RETURN
END IF
IF (ivec == 5) THEN
tau(1) =-a*sqrt3/2.D0
tau(2) = a/2.D0
RETURN
END IF
IF (ivec == 6) THEN
tau(1) = -a*sqrt3/2.D0
tau(2) =-a/2.D0
RETURN
END IF
WRITE(*,*) 'tauAjVecXY err: ivec,nn:',ivec,nn
STOP
END IF
! third nearest neighghbor vectors (A)
IF (nn == 3) THEN
IF(ivec == 1) THEN
tau(1) = -2.D0*a/sqrt3
tau(2) = 0.D0
RETURN
END IF
IF (ivec == 2) THEN
tau(1) = a/sqrt3
tau(2) = a
RETURN
END IF
IF (ivec == 3) THEN
tau(1) = a/sqrt3
tau(2) =-a
RETURN
END IF
WRITE (*,*) 'tauAjVecXY err: ivec,nn:',ivec,nn
STOP
END IF
! fourth nearest neighghbor vectors (A)
IF (nn == 4) THEN
IF (ivec == 1) THEN
tau(1) = 5.*a/(2.D0*sqrt3)
tau(2) = a/2.D0
RETURN
END IF
IF (ivec == 2) THEN
tau(1) = 5.*a/(2.*sqrt3)
tau(2) =-a/2.
RETURN
END IF
IF (ivec == 3) THEN
tau(1) =-a/(2.D0*sqrt3)
tau(2) = 3.D0*a/2.D0
RETURN
END IF
IF (ivec == 4) THEN
tau(1) =-a/(2.D0*sqrt3)
tau(2) =-3.D0*a/2.D0
RETURN
END IF
IF (ivec == 5) THEN
tau(1) =-2.D0*a/sqrt3
tau(2) = a
RETURN
END IF
IF (ivec == 6) THEN
tau(1) = -2.D0*a/sqrt3
tau(2)=-a
RETURN
END IF
WRITE (*,*) 'tauAjVecXY err: ivec,nn:', ivec, nn
STOP
END IF
WRITE (*,*) 'tauAjVecXY err: never get here'
WRITE (*,*) 'ivec,nn:', ivec, nn
STOP
END SUBROUTINE tauAjVecXY
!*******************************************************************************
!*******************************************************************************
SUBROUTINE tauBjVecXY(ivec,nn,tau)
!===============================================================================
! vectors from a graphene B atom to nearest neighbors up to the fourth
! nearest neighbor shell in graphene xy coordinates.
!-------------------------------------------------------------------------------
! Input :
! ivec index for nearest neighbor vector in the shell
! nn nearest neighbor index nn = 1,2,3,4
! Output :
! tau(2) vector from B to nearest neighbor in xy coordinates (A)
!===============================================================================
IMPLICIT NONE
! input variables
INTEGER, INTENT(in) :: ivec, nn
! output
REAL(8), INTENT(out) :: tau(2)
CALL tauAjVecXY(ivec,nn,tau)
tau(1) = -tau(1)
tau(2) = -tau(2)
END SUBROUTINE tauBjVecXY
!*******************************************************************************
!*******************************************************************************
SUBROUTINE rhoVec(n,m,iatom,rho)
!===============================================================================
! out-of-surface unit xyz vector defined in Jiang et al for the
! A or B atom in an (n,m) carbon nanotube.
! Reference: J.-W, Jiang et al, PRB, 73, 235434 (2006).
!-------------------------------------------------------------------------------
! Input :
! n,m chiral vector coordinates in (a1,a2)
! iatom specifies atom in two atom unit cell (1=A,2=B)
! Output :
! rho(3) xyz coordinates of out-of-surface unit vector (none)
!=======================================================================
IMPLICIT NONE
! input variables
INTEGER, INTENT(in) :: n, m, iatom
! output variable
REAL(8), INTENT(out) :: rho(3)
! working variables
REAL(8) :: r0(3), r1(3)
INTEGER :: ier, nn, ivec
REAL(8) :: rnorm, vecLength
! check input for errors
ier = 0
IF (iatom /= 1 .AND. iatom /= 2) THEN
ier = 1
WRITE (*,*) 'rhoVec err: invalid iatom:', iatom
END IF
IF(ier /= 0) STOP
! z component of A or B atom position (Angstroms)
nn = 0
CALL rxyzVec(n,m,iatom,1,nn,r0)
r0(1) = 0.D0
r0(2) = 0.D0
! sum over ivec = 1..3
nn = 1
rho = 0.D0
DO ivec = 1, 3
CALL rxyzVec(n,m,iatom,ivec,nn,r1)
rho = rho + r1-r0
END DO
! unit rho vector (dimensionless)
rnorm = vecLength(3,rho)
rho = rho/rnorm
END SUBROUTINE rhoVec
!*******************************************************************************
!*******************************************************************************
SUBROUTINE rho2Vec(n,m,iatom,ivec,rho)
!===============================================================================
! out-of-surface unit xyz vector defined in Jiang et al for the three
! nearest neighbors of the A or B atom in an (n,m) carbon nanotube.
! Reference: J.-W, Jiang et al, PRB, 73, 235434 (2006).
!-------------------------------------------------------------------------------
! Input :
! n,m chiral vector coordinates in a1,a2 basis
! iatom specifies atom in two atom unit cell (1=A,2=B)
! ivec index for three nearest neighbors (ivec=1..3)
! Output :
! rho(3) xyz coordinates of out-of-surface unit vector (none)
!===============================================================================
IMPLICIT NONE
! input variables
INTEGER, INTENT(in) :: n, m, iatom, ivec
! output variable
REAL(8), INTENT(out) :: rho(3)
! working variables
REAL(8) :: r0(3), r1(3)
REAL(8) :: rnorm, vecLength ! function vecLength
INTEGER :: ier, nn, ivec1
! check input for errors
ier = 0
IF (iatom /= 1 .AND. iatom /= 2) THEN
ier = 1
WRITE (*,*) 'rho2Vec err: invalid iatom:', iatom
END IF
IF (ivec < 1 .OR. ivec > 3) THEN
ier = 1
WRITE (*,*) 'rho2Vec err: invalid ivec: ', ivec
END IF
IF (ier /= 0) STOP
! z component of R(1)_(iatom,ivec) position vector (Angstroms)
nn = 1
CALL rxyzVec(n,m,iatom,ivec,nn,r0)
r0(1) = 0.D0
r0(2) = 0.D0
! sum over ivec = 1..3
rho = 0.D0
DO ivec1 = 1, 3
CALL r2xyzVec(n,m,iatom,ivec,ivec1,r1)
rho = rho + (r1 - r0)
END DO
! unit rho vector (dimensionless)
rnorm = vecLength(3,rho)
rho = rho/rnorm
END SUBROUTINE rho2Vec
!*******************************************************************************
!*******************************************************************************
SUBROUTINE tubeRadUnitVec(Vxyz,Ur)
!===============================================================================
! unit outward radial vector in a carbon nanotube passing through Vxyz
!-------------------------------------------------------------------------------
! Input :
! Vxyz(3) position vector in xyz coordinates (Angstroms)
! Output :
! Ur(3) radial unit vector passing through Vxyz (dimensionless)
!===============================================================================
IMPLICIT NONE
! input variable
REAL(8), INTENT(in) :: Vxyz(3)
! output variable
REAL(8), INTENT(out) :: Ur(3)
! working variable
REAL(8) :: Vlength, pythagoras ! from libMath.f90
Vlength = pythagoras(Vxyz(1),Vxyz(2))
Ur(1) = Vxyz(1)/Vlength
Ur(2) = Vxyz(2)/Vlength
Ur(3) = 0.D0
END SUBROUTINE tubeRadUnitVec
!*******************************************************************************
!*******************************************************************************
SUBROUTINE r2xyzVec(n,m,iatom,ivec1,ivec2,Rxyz)
!===============================================================================
! Compute the xyz coordinates for R(1)_(iatom,ivec1,ivec2) which is the
! ivec2 nearest neighbor of the ivec1 nearest neighbor of atom A or B
!-------------------------------------------------------------------------------
! Input :
! n,m chiral vector coordinates in (a1,a2)
! iatom specifies atom in two atom unit cell (1=A,2=B)
! ivec1 index for nearest neighbor of R(1)_(iatom)
! ivec2 index for nearest neighbor of R(1)_(iatom,ivec1)
! Output :
! Rxyz(3) R(1)_(iatom,ivec1,ivec2) in xyz coordinates (Angstroms)
!===============================================================================
IMPLICIT NONE
! input variables
INTEGER, INTENT(in) :: n, m, iatom, ivec1, ivec2
! output variable
REAL(8), INTENT(out) :: Rxyz(3)
! working variables
REAL(8) :: tau0(2), tau1(2), tau2(2), Rtube(2)
INTEGER :: ier,nn
! check input for errors
ier = 0
IF (iatom /= 1 .AND. iatom /= 2) THEN
ier = 1
WRITE (*,*) 'r2xyzVec err: invalid iatom: ', iatom
END IF
IF (ivec1 < 1 .OR. ivec1 > 3) THEN
ier = 1
WRITE (*,*) 'r2xyzVec err: invalid ivec1: ', ivec1
END IF
IF (ivec2 < 1 .OR. ivec2 > 3) THEN
ier = 1
WRITE (*,*) 'r2xyzVec err: invalid ivec2: ', ivec2
END IF
IF (ier /= 0) STOP 'r2xyzVec unknown err'
! tube coordinates of A or B atom in two atom unit cell (Angstroms)
CALL tauAjVecXY(1,1,tau0)
IF (iatom == 1) THEN
tau0 =-tau0/2.D0 !tau_A = -tau(1)_(A1)/2 (graphene xy coordinates)
ELSE
tau0 = tau0/2.D0 !tau_B = tau(1)_(A1)/2
END IF
CALL XYtoTube(n,m,tau0,tau0)
! tube coordinates of pointer to neighbor of R_(iatom) (A)
nn = 1
IF(iatom == 1) THEN
CALL tauAjVecXY(ivec1,nn,tau1)
ELSE
CALL tauBjVecXY(ivec1,nn,tau1)
END IF
CALL XYtoTube(n,m,tau1,tau1)
! tube coordinates of pointer to neighbor of R_(iatomiivec1) (A)
nn = 1
IF (iatom == 2) THEN
CALL tauAjVecXY(ivec2,nn,tau2)