-
Notifications
You must be signed in to change notification settings - Fork 1
/
kpsym.F
3073 lines (2997 loc) · 142 KB
/
kpsym.F
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
!--------------------------------------------------------------------------------------------------!
! CP2K: A general program to perform molecular dynamics simulations !
! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
! !
! SPDX-License-Identifier: GPL-2.0-or-later !
!--------------------------------------------------------------------------------------------------!
! **************************************************************************************************
!> \brief K-points and crystal symmetry routines based on
! K290 code:
! Written on September 12th, 1979.
! IBM-retouched on October 27th, 1980.
! Generation of special points modified on 26-May-82 by ohn.
! Retouched on January 8th, 1997
! Integration in CPMD-FEMD Program by Thierry Deutsch
! ==--------------------------------------------------------------==
! Playing with special points and creation of 'CRYSTALLOGRAPHIC'
! File for band structure calculations.
! Generation of special points in k-space for an arbitrary lattice,
! Following the method Monkhorst,Pack, Phys. Rev. B13 (1976) 5188
! Modified by Macdonald, Phys. Rev. B18 (1978) 5897
! Modified also by Ole Holm Nielsen ("SYMMETRIZATION")
! ==--------------------------------------------------------------==
! (GROUP1, PGL1, ATFTM1, ROT1 FROM THE
! "COMPUTER PHYSICS COMMUNICATIONS" PACKAGE "ACMI" - (1971,1974)
! Worlton-Warren).
! **************************************************************************************************
MODULE kpsym
USE kinds, ONLY: dp
USE mathlib, ONLY: invmat
USE string_utilities, ONLY: xstring
#include "./base/base_uses.f90"
IMPLICIT NONE
PRIVATE
PUBLIC :: K290s, GROUP1s
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'kpsym'
! **************************************************************************************************
CONTAINS
! **************************************************************************************************
!> \brief ...
!> \param iout ...
!> \param nat ...
!> \param nkpoint ...
!> \param nsp ...
!> \param iq1 ...
!> \param iq2 ...
!> \param iq3 ...
!> \param istriz ...
!> \param a1 ...
!> \param a2 ...
!> \param a3 ...
!> \param alat ...
!> \param strain ...
!> \param xkapa ...
!> \param rx ...
!> \param tvec ...
!> \param ty ...
!> \param isc ...
!> \param f0 ...
!> \param ntvec ...
!> \param wvk0 ...
!> \param wvkl ...
!> \param lwght ...
!> \param lrot ...
!> \param nhash ...
!> \param includ ...
!> \param list ...
!> \param rlist ...
!> \param delta ...
! **************************************************************************************************
SUBROUTINE k290s(iout, nat, nkpoint, nsp, iq1, iq2, iq3, istriz, &
a1, a2, a3, alat, strain, xkapa, rx, tvec, &
ty, isc, f0, ntvec, wvk0, wvkl, lwght, lrot, &
nhash, includ, list, rlist, delta)
! ==================================================================
! WRITTEN ON SEPTEMBER 12TH, 1979.
! IBM-RETOUCHED ON OCTOBER 27TH, 1980.
! Tsukuba-retouched on March 19th, 2008.
! GENERATION OF SPECIAL POINTS MODIFIED ON 26-MAY-82 BY OHN.
! RETOUCHED ON JANUARY 8TH, 1997
! INTEGRATION IN CPMD-FEMD PROGRAM BY THIERRY DEUTSCH
! ==--------------------------------------------------------------==
! PLAYING WITH SPECIAL POINTS AND CREATION OF 'CRYSTALLOGRAPHIC'
! FILE FOR BAND STRUCTURE CALCULATIONS.
! GENERATION OF SPECIAL POINTS IN K-SPACE FOR AN ARBITRARY LATTICE,
! FOLLOWING THE METHOD MONKHORST,PACK, PHYS. REV. B13 (1976) 5188
! MODIFIED BY MACDONALD, PHYS. REV. B18 (1978) 5897
! MODIFIED ALSO BY OLE HOLM NIELSEN ("SYMMETRIZATION")
! ==--------------------------------------------------------------==
! TESTING THEIR EFFICIENCY AND PREPARATION OF THE
! "STRUCTURAL" FILE FOR RUNNING THE
! SELF-CONSISTENT BAND STRUCTURE PROGRAMS.
! IN THE CASES WHERE THE POINT GROUP OF THE CRYSTAL DOES NOT
! CONTAIN INVERSION, THE LATTER IS ARTIFICIALLY ADDED, IN ORDER
! TO MAKE USE OF THE HERMITICITY OF THE HAMILTONIAN
! ==--------------------------------------------------------------==
! == INPUT: ==
! == IOUT LOGIC FILE NUMBER ==
! == NAT NUMBER OF ATOMS ==
! == NKPOINT MAXIMAL NUMBER OF K POINTS ==
! == NSP NUMBER OF SPECIES ==
! == IQ1,IQ2,IQ3 THE MONKHORST-PACK MESH PARAMETERS ==
! == ISTRIZ SWITCH FOR SYMMETRIZATION ==
! == A1(3),A2(3),A3(3) LATTICE VECTORS ==
! == ALAT LATTICE CONSTANT ==
! == STRAIN(3,3) STRAIN APPLIED TO LATTICE IN ORDER ==
! == TO HAVE K POINTS WITH SYMMETRY OF STRAINED LATTICE ==
! == XKAPA(3,NAT) ATOMS COORDINATES ==
! == TY(NAT) TYPES OF ATOMS ==
! == WVK0(3) SHIFT FOR K POINTS MESh (MACDONALD ARTICLE) ==
! == NHASH SIZE OF THE HASH TABLES (LIST) ==
! == DELTA REQUIRED ACCURACY (1.e-6_dp IS A GOOD VALUE) ==
! == K-VECTOR < DELTA IS CONSIDERED ZERO ==
! == OUTPUT: ==
! == RX(3,NAT) SCRATCH ARRAY USED BY GROUP1 ROUTINE ==
! == TVEC(1:3,1:NTVEC) TRANSLATION VECTORS (SEE NTVEC) ==
! == ISC(NAT) SCRATCH ARRAY USED BY GROUP1 ROUTINE ==
! == F0(49,NAT) ATOM TRANSFORMATION TABLE ==
! == IF NTVEC/=1 THE 49TH GIVES INEQUIVALENT ATOMS ==
! == NTVEC NUMBER OF TRANSLATION VECTORS (IF NOT PRIMITIVE CELL)==
! == WVKL(3,NKPOINT) SPECIAL KPOINTS GENERATED ==
! == LWGHT(NKPOINT) WEIGHT FOR EACH K POINT ==
! == LROT(48,NKPOINT) SYMMETRY OPERATION FOR EACH K POINTS ==
! == INCLUD(NKPOINT) SCRATCH ARRAY USED BY SPPT2 ==
! == LIST(NKPOINT+NHASH) HASH TABLE USED BY SPPT2 ==
! == RLIST(3,NKPOINT) SCRATCH ARRAY USED BY SPPT2 ==
! ==--------------------------------------------------------------==
! SUBROUTINES NEEDED:
! SPPT2, GROUP1, PGL1, ATFTM1, ROT1, STRUCT,
! BZRDUC, INBZ, MESH, BZDEFI
! (GROUP1, PGL1, ATFTM1, ROT1 FROM THE
! "COMPUTER PHYSICS COMMUNICATIONS" PACKAGE "ACMI" - (1971,1974)
! WORLTON-WARREN).
! ==================================================================
INTEGER :: iout, nat, nkpoint, nsp, iq1, iq2, iq3, &
istriz
REAL(KIND=dp) :: a1(3), a2(3), a3(3), alat, strain(6), &
xkapa(3, nat), rx(3, nat), tvec(3, nat)
INTEGER :: ty(nat), isc(nat), f0(49, nat), ntvec
REAL(KIND=dp) :: wvk0(3), wvkl(3, nkpoint)
INTEGER :: lwght(nkpoint), lrot(48, nkpoint), &
nhash, includ(nkpoint), &
list(nkpoint + nhash)
REAL(KIND=dp) :: rlist(3, nkpoint), delta
CHARACTER(len=10), DIMENSION(48), PARAMETER :: rname_cubic = (/' 1 ', ' 2[ 10 0] ', &
' 2[ 01 0] ', ' 2[ 00 1] ', ' 3[-1-1-1]', ' 3[ 11-1] ', ' 3[-11 1] ', ' 3[ 1-11] ', &
' 3[ 11 1] ', ' 3[-11-1] ', ' 3[-1-11] ', ' 3[ 1-1-1]', ' 2[-11 0] ', ' 4[ 00 1] ', &
' 4[ 00-1] ', ' 2[ 11 0] ', ' 2[ 0-11] ', ' 2[ 01 1] ', ' 4[ 10 0] ', ' 4[-10 0] ', &
' 2[-10 1] ', ' 4[ 0-10] ', ' 2[ 10 1] ', ' 4[ 01 0] ', '-1 ', '-2[ 10 0] ', &
'-2[ 01 0] ', '-2[ 00 1] ', '-3[-1-1-1]', '-3[ 11-1] ', '-3[-11 1] ', '-3[ 1-11] ', &
'-3[ 11 1] ', '-3[-11-1] ', '-3[-1-11] ', '-3[ 1-1-1]', '-2[-11 0] ', '-4[ 00 1] ', &
'-4[ 00-1] ', '-2[ 11 0] ', '-2[ 0-11] ', '-2[ 01 1] ', '-4[ 10 0] ', '-4[-10 0] ', &
'-2[-10 1] ', '-4[ 0-10] ', '-2[ 10 1] ', '-4[ 01 0] '/)
CHARACTER(len=11), DIMENSION(24), PARAMETER :: rname_hexai = (/' 1 ', ' 6[ 00 1] ', &
' 3[ 00 1] ', ' 2[ 00 1] ', ' 3[ 00 -1] ', ' 6[ 00 -1] ', ' 2[ 01 0] ', ' 2[-11 0] ', &
' 2[ 10 0] ', ' 2[ 21 0] ', ' 2[ 11 0] ', ' 2[ 12 0] ', '-1 ', '-6[ 00 1] ', &
'-3[ 00 1] ', '-2[ 00 1] ', '-3[ 00 -1] ', '-6[ 00 -1] ', '-2[ 01 0] ', '-2[-11 0] ', &
'-2[ 10 0] ', '-2[ 21 0] ', '-2[ 11 0] ', '-2[ 12 0] '/)
CHARACTER(len=12), DIMENSION(7), PARAMETER :: icst = (/'TRICLINIC ', 'MONOCLINIC ', &
'ORTHORHOMBIC', 'TETRAGONAL ', 'CUBIC ', 'TRIGONAL ', 'HEXAGONAL '/)
INTEGER :: i, ib(48), ib0(48), ihc, ihc0, ihg, ihg0, indpg, indpg0, invadd, istrin, iswght, &
isy, isy0, itype, j, k, l, li, li0, lmax, n, nc, nc0, ntot, ntvec0
INTEGER, DIMENSION(49, 1) :: f00
REAL(KIND=dp) :: a01(3), a02(3), a03(3), b01(3), b02(3), b03(3), b1(3), b2(3), b3(3), &
dtotstr, origin(3), origin0(3), proj1, proj2, proj3, r(3, 3, 48), r0(3, 3, 48), totstr, &
tvec0(3, 1), volum, vv0(3)
REAL(KIND=dp), DIMENSION(3, 1) :: x0
REAL(KIND=dp), DIMENSION(3, 48) :: v, v0
f00 = 0
x0 = 0._dp
v = 0._dp
v0 = 0._dp
! ==--------------------------------------------------------------==
! READ IN LATTICE STRUCTURE
! ==--------------------------------------------------------------==
DO i = 1, 3
a01(i) = a1(i)/alat
a02(i) = a2(i)/alat
a03(i) = a3(i)/alat
END DO
WRITE (iout, '(" KPSYM| NUMBER OF ATOMS (STRUCT):",I6)') nat
IF (iout > 0) &
WRITE (iout, '(" KPSYM|",10X,"K TYPE",14X,"X(K)")')
itype = 0
DO i = 1, nat
! Assign an atomic type (for internal purposes)
IF (i .NE. 1) THEN
DO j = 1, (i - 1)
IF (ty(j) .EQ. ty(i)) THEN
! Type located
GOTO 178
END IF
END DO
! New type
END IF
itype = itype + 1
IF (itype .GT. nsp) THEN
IF (iout > 0) &
WRITE (iout, '(A,I4,")")') &
' KPSYM| NUMBER OF ATOMIC TYPES EXCEEDS DIMENSION (NSP=)', &
nsp
IF (iout > 0) &
WRITE (iout, '(" KPSYM| THE ARRAY TY IS:",/,9(1X,10I7,/))') &
(ty(j), j=1, nat)
CALL stopgm('K290', 'FATAL ERROR')
END IF
178 CONTINUE
IF (iout > 0) &
WRITE (iout, '(" KPSYM|",6X,I5,I6,3F10.5)') &
i, ty(i), (xkapa(j, i), j=1, 3)
END DO
! ==--------------------------------------------------------------==
! IS THE STRAIN SIGNIFICANT ?
! ==--------------------------------------------------------------==
dtotstr = delta*delta
totstr = 0._dp
istrin = 0
DO i = 1, 6
totstr = totstr + ABS(strain(i))
END DO
IF (totstr .GT. dtotstr) istrin = 1
! ==--------------------------------------------------------------==
! Volume of the cell.
volum = a1(1)*a2(2)*a3(3) + a2(1)*a3(2)*a1(3) + &
a3(1)*a1(2)*a2(3) - a1(3)*a2(2)*a3(1) - &
A2(3)*A3(2)*A1(1) - A3(3)*A1(2)*A2(1)
volum = ABS(volum)
b1(1) = (a2(2)*a3(3) - a2(3)*a3(2))/volum
b1(2) = (a2(3)*a3(1) - a2(1)*a3(3))/volum
b1(3) = (a2(1)*a3(2) - a2(2)*a3(1))/volum
b2(1) = (a3(2)*a1(3) - a3(3)*a1(2))/volum
b2(2) = (a3(3)*a1(1) - a3(1)*a1(3))/volum
b2(3) = (a3(1)*a1(2) - a3(2)*a1(1))/volum
b3(1) = (a1(2)*a2(3) - a1(3)*a2(2))/volum
b3(2) = (a1(3)*a2(1) - a1(1)*a2(3))/volum
b3(3) = (a1(1)*a2(2) - a1(2)*a2(1))/volum
! ==--------------------------------------------------------------==
DO i = 1, 3
b01(i) = b1(i)*alat
b02(i) = b2(i)*alat
b03(i) = b3(i)*alat
END DO
! ==--------------------------------------------------------------==
! == GROUP-THEORY ANALYSIS OF LATTICE ==
! ==--------------------------------------------------------------==
CALL group1s(iout, a1, a2, a3, nat, ty, xkapa, b1, b2, b3, &
ihg, ihc, isy, li, nc, indpg, ib, ntvec, &
v, f0, r, tvec, origin, rx, isc, delta)
! ==--------------------------------------------------------------==
DO n = nc + 1, 48
ib(n) = 0
END DO
! ==--------------------------------------------------------------==
invadd = 0
IF (li .EQ. 0) THEN
IF (iout > 0) &
WRITE (iout, '(A,/,A,/,A)') &
' KPSYM| ALTHOUGH THE POINT GROUP OF THE CRYSTAL DOES NOT', &
' KPSYM| CONTAIN INVERSION, THE SPECIAL POINT GENERATION ALGORITHM', &
' KPSYM| WILL CONSIDER IT AS A SYMMETRY OPERATION'
invadd = 1
END IF
! ==--------------------------------------------------------------==
! == CRYSTALLOGRAPHIC DATA ==
! ==--------------------------------------------------------------==
IF (iout > 0) THEN
WRITE (iout, '(/," KPSYM| CRYSTALLOGRAPHIC DATA:")')
WRITE (iout, '(4X,"A1",3F10.5,10X,"B1",3F10.5)') a1, b1
WRITE (iout, '(4X,"A2",3F10.5,10X,"B2",3F10.5)') a2, b2
WRITE (iout, '(4X,"A3",3F10.5,10X,"B3",3F10.5)') a3, b3
END IF
! ==--------------------------------------------------------------==
! == GROUP-THEORETICAL INFORMATION ==
! ==--------------------------------------------------------------==
IF (iout > 0) &
WRITE (iout, '(/," KPSYM| GROUP-THEORETICAL INFORMATION:")')
! IHG .... Point group of the primitive lattice, holohedral
IF (iout > 0) &
WRITE (iout, &
'(" KPSYM| POINT GROUP OF THE PRIMITIVE LATTICE: ",A," SYSTEM")') &
icst(ihg)
! IHC .... Code distinguishing between hexagonal and cubic groups
! ISY .... Code indicating whether the space group is symmorphic
IF (isy .EQ. 0) THEN
IF (iout > 0) &
WRITE (iout, '(" KPSYM|",4X,"NONSYMMORPHIC GROUP")')
ELSEIF (isy .EQ. 1) THEN
IF (iout > 0) &
WRITE (iout, '(" KPSYM|",4X,"SYMMORPHIC GROUP")')
ELSEIF (isy .EQ. -1) THEN
IF (iout > 0) &
WRITE (iout, '(" KPSYM|",4X,"SYMMORPHIC GROUP WITH NON-STANDARD ORIGIN")')
ELSEIF (isy .EQ. -2) THEN
IF (iout > 0) &
WRITE (iout, '(" KPSYM|",4X,"NONSYMMORPHIC GROUP???")')
END IF
! LI ..... Inversions symmetry
IF (li .EQ. 0) THEN
IF (iout > 0) &
WRITE (iout, '(" KPSYM|",4X,"NO INVERSION SYMMETRY")')
ELSEIF (li .GT. 0) THEN
IF (iout > 0) &
WRITE (iout, '(" KPSYM|",4X,"INVERSION SYMMETRY")')
END IF
! NC ..... Total number of elements in the point group
IF (iout > 0) &
WRITE (iout, &
'(" KPSYM|",4X,"TOTAL NUMBER OF ELEMENTS IN THE POINT GROUP:",I3)') nc
IF (iout > 0) &
WRITE (iout, '(" KPSYM|",4X,"TO SUM UP: (",I1,5I3,")")') &
ihg, ihc, isy, li, nc, indpg
! IB ..... List of the rotations constituting the point group
IF (iout > 0) &
WRITE (iout, '(/," KPSYM|",4X,"LIST OF THE ROTATIONS:")')
IF (iout > 0) &
WRITE (iout, '(7X,12I4)') (ib(i), i=1, nc)
! V ...... Nonprimitive translations (for nonsymmorphic groups)
IF (isy .LE. 0) THEN
IF (iout > 0) &
WRITE (iout, '(/," KPSYM|",4X,"NONPRIMITIVE TRANSLATIONS:")')
IF (iout > 0) &
WRITE (iout, '(A,A)') &
' ROT V IN THE BASIS A1, A2, A3 ', &
'V IN CARTESIAN COORDINATES'
! Cartesian components of nonprimitive translation.
DO i = 1, nc
DO j = 1, 3
vv0(j) = v(1, i)*a1(j) + v(2, i)*a2(j) + v(3, i)*a3(j)
END DO
IF (iout > 0) &
WRITE (iout, '(1X,I3,3F10.5,3X,3F10.5)') &
ib(i), (v(j, i), j=1, 3), vv0
END DO
END IF
! F0 ..... The function defined in Maradudin, Ipatova by
! eq. (3.2.12): atom transformation table.
IF (iout > 0) &
WRITE (iout, &
'(/," KPSYM|",4X,"ATOM TRANSFORMATION TABLE (MARADUDIN,VOSKO):")')
IF (iout > 0) &
WRITE (iout, '(5(4X,"R AT->AT"))')
IF (iout > 0) &
WRITE (iout, '(I5," [Identity]")') 1
DO k = 2, nc
DO j = 1, nat
IF (iout > 0) &
WRITE (iout, '(I5,2I4)', advance="no") ib(k), j, f0(k, j)
IF ((MOD(j, 5) .EQ. 0) .AND. iout > 0) &
WRITE (iout, *)
END DO
IF ((MOD(j - 1, 5) .NE. 0) .AND. iout > 0) &
WRITE (iout, *)
END DO
! R ...... List of the 3 x 3 rotation matrices
IF (iout > 0) &
WRITE (iout, '(/," KPSYM|",4X,"LIST OF THE 3 X 3 ROTATION MATRICES:")')
IF (ihc .EQ. 0) THEN
DO k = 1, nc
IF (iout > 0) &
WRITE (iout, &
'(4X,I3," (",I2,": ",A11,")",2(3F14.6,/,25X),3F14.6)') &
k, ib(k), rname_hexai(ib(k)), ((r(i, j, ib(k)), j=1, 3), i=1, 3)
END DO
ELSE
DO k = 1, nc
IF (iout > 0) &
WRITE (iout, &
'(4X,I3," (",I2,": ",A10,") ",2(3F14.6,/,25X),3F14.6)') &
k, ib(k), rname_cubic(ib(k)), ((r(i, j, ib(k)), j=1, 3), i=1, 3)
END DO
END IF
! ==--------------------------------------------------------------==
! GENERATE THE BRAVAIS LATTICE
! ==--------------------------------------------------------------==
CALL group1s(iout, a01, a02, a03, 1, ty, x0, b01, b02, b03, &
ihg0, ihc0, isy0, li0, nc0, indpg0, ib0, ntvec0, &
v0, f00, r0, tvec0, origin0, rx, isc, delta)
! ==--------------------------------------------------------------==
! It is assumed that the same 'type' of symmetry operations
! (cubic/hexagonal) will apply to the crystal as well as the Bravais
! lattice.
! ==--------------------------------------------------------------==
IF (iout > 0) &
WRITE (iout, '(/,1X,19("*"),A,25("*"))') &
' GENERATION OF SPECIAL POINTS '
! Parameter Q of Monkhorst and Pack, generalized for 3 axes B1,2,3
IF (iout > 0) &
WRITE (iout, '(A,/,1X,3I5)') &
' KPSYM| MONKHORST-PACK PARAMETERS (GENERALIZED) IQ1,IQ2,IQ3:', &
iq1, iq2, iq3
! WVK0 is the shift of the whole mesh (see Macdonald)
IF (iout > 0) &
WRITE (iout, '(A,/,1X,3F10.5)') &
' KPSYM| CONSTANT VECTOR SHIFT (MACDONALD) OF THIS MESH:', wvk0
IF (iabs(iq1) + iabs(iq2) + iabs(iq3) .EQ. 0) GOTO 710
IF (ABS(istriz) .NE. 1) THEN
IF (iout > 0) &
WRITE (iout, '(" KPSYM| INVALID SWITCH FOR SYMMETRIZATION",I10)') istriz
IF (iout > 0) &
WRITE (iout, '(" KPSYM| INVALID SWITCH FOR SYMMETRIZATION",I10)') istriz
CALL stopgm('K290', 'ISTRIZ WRONG ARGUMENT')
END IF
IF (iout > 0) &
WRITE (iout, '(" KPSYM| SYMMETRIZATION SWITCH: ",I3)', advance="no") istriz
IF (istriz .EQ. 1) THEN
IF (iout > 0) &
WRITE (iout, '(" (SYMMETRIZATION OF MONKHORST-PACK MESH)")')
ELSE
IF (iout > 0) &
WRITE (iout, '(" (NO SYMMETRIZATION OF MONKHORST-PACK MESH)")')
END IF
! Set to 0.
DO i = 1, nkpoint
lwght(i) = 0
END DO
! ==--------------------------------------------------------------==
! == Generation of the points (they are not multiplied ==
! == by 2*Pi because B1,2,3 were not,either) ==
! ==--------------------------------------------------------------==
IF (nc .GT. nc0) THEN
! Due to non-use of primitive cell, the crystal has more
! rotations than Bravais lattice.
! We use only the rotations for Bravais lattices
IF (ntvec .EQ. 1) THEN
IF (iout > 0) &
WRITE (iout, *) ' KPSYM| NUMBER OF ROTATIONS FOR BRAVAIS LATTICE', nc0
IF (iout > 0) &
WRITE (iout, *) ' KPSYM| NUMBER OF ROTATIONS FOR CRYSTAL LATTICE', nc
IF (iout > 0) &
WRITE (iout, *) ' KPSYM| NO DUPLICATION FOUND'
CALL stopgm('ERROR', &
'SOMETHING IS WRONG IN GROUP DETERMINATION')
END IF
nc = nc0
DO i = 1, nc0
ib(i) = ib0(i)
END DO
IF (iout > 0) &
WRITE (iout, '(/,1X,20("! "),"WARNING",20("!"))')
IF (iout > 0) &
WRITE (iout, '(A)') &
' KPSYM| THE CRYSTAL HAS MORE SYMMETRY THAN THE BRAVAIS LATTICE'
IF (iout > 0) &
WRITE (iout, '(A)') &
' KPSYM| BECAUSE THIS IS NOT A PRIMITIVE CELL'
IF (iout > 0) &
WRITE (iout, '(A)') &
' KPSYM| USE ONLY SYMMETRY FROM BRAVAIS LATTICE'
IF (iout > 0) &
WRITE (iout, '(1X,20("! "),"WARNING",20("!"),/)')
END IF
CALL sppt2(iout, iq1, iq2, iq3, wvk0, nkpoint, &
a01, a02, a03, b01, b02, b03, &
invadd, nc, ib, r, ntot, wvkl, lwght, lrot, nc0, ib0, istriz, &
nhash, includ, list, rlist, delta)
! ==--------------------------------------------------------------==
! == Check on error signals ==
! ==--------------------------------------------------------------==
IF (iout > 0) &
WRITE (iout, '(/," KPSYM|",1X,I5," SPECIAL POINTS GENERATED")') ntot
IF (ntot .EQ. 0) THEN
GOTO 710
ELSE IF (ntot .LT. 0) THEN
IF (iout > 0) &
WRITE (iout, '(A,I5,/,A,/,A)') ' KPSYM| DIMENSION NKPOINT =', nkpoint, &
' KPSYM| INSUFFICIENT FOR ACCOMMODATING ALL THE SPECIAL POINTS', &
' KPSYM| WHAT FOLLOWS IS AN INCOMPLETE LIST'
ntot = iabs(ntot)
END IF
! Before using the list WVKL as wave vectors, they have to be
! multiplied by 2*Pi
! The list of weights LWGHT is not normalized
iswght = 0
DO i = 1, ntot
iswght = iswght + lwght(i)
END DO
IF (iout > 0) &
WRITE (iout, '(8X,A,T33,A,4X,A)') &
'WAVEVECTOR K', 'WEIGHT', 'UNFOLDING ROTATIONS'
! Set near-zeroes equal to zero:
DO l = 1, ntot
DO i = 1, 3
IF (ABS(wvkl(i, l)) .LT. delta) wvkl(i, l) = 0._dp
END DO
IF (istrin .NE. 0) THEN
! Express special points in (unstrained) basis.
proj1 = 0._dp
proj2 = 0._dp
proj3 = 0._dp
DO i = 1, 3
proj1 = proj1 + wvkl(i, l)*a01(i)
proj2 = proj2 + wvkl(i, l)*a02(i)
proj3 = proj3 + wvkl(i, l)*a03(i)
END DO
DO i = 1, 3
wvkl(i, l) = proj1*b1(i) + proj2*b2(i) + proj3*b3(i)
END DO
END IF
lmax = lwght(l)
IF (iout > 0) &
WRITE (iout, fmt='(1X,I5,3F8.4,I8,T42,12I3)') &
l, (wvkl(i, l), i=1, 3), lwght(l), (lrot(i, l), i=1, MIN(lmax, 12))
DO j = 13, lmax, 12
IF (iout > 0) &
WRITE (iout, fmt='(T42,12I3)') &
(lrot(i, l), i=j, MIN(lmax, j - 1 + 12))
END DO
END DO
IF (iout > 0) &
WRITE (iout, '(24X,"TOTAL:",I8)') iswght
! ==--------------------------------------------------------------==
710 CONTINUE
! ==--------------------------------------------------------------==
RETURN
END SUBROUTINE k290s
! **************************************************************************************************
! **************************************************************************************************
!> \brief ...
!> \param iout ...
!> \param a1 ...
!> \param a2 ...
!> \param a3 ...
!> \param nat ...
!> \param ty ...
!> \param x ...
!> \param b1 ...
!> \param b2 ...
!> \param b3 ...
!> \param ihg ...
!> \param ihc ...
!> \param isy ...
!> \param li ...
!> \param nc ...
!> \param indpg ...
!> \param ib ...
!> \param ntvec ...
!> \param v ...
!> \param f0 ...
!> \param r ...
!> \param tvec ...
!> \param origin ...
!> \param rx ...
!> \param isc ...
!> \param delta ...
! **************************************************************************************************
SUBROUTINE group1s(iout, a1, a2, a3, nat, ty, x, b1, b2, b3, &
ihg, ihc, isy, li, nc, indpg, ib, ntvec, &
v, f0, r, tvec, origin, rx, isc, delta)
! ==--------------------------------------------------------------==
! == WRITTEN ON SEPTEMBER 10TH - FROM THE ACMI COMPLEX ==
! == (WORLTON AND WARREN, COMPUT.PHYS.COMMUN. 8,71-84 (1974)) ==
! == (AND 3,88-117 (1972)) ==
! == BASIC CRYSTALLOGRAPHIC INFORMATION ==
! == ABOUT A GIVEN CRYSTAL STRUCTURE. ==
! == SUBROUTINES NEEDED: PGL1,ATFTM1,ROT1,RLV3 ==
! ==--------------------------------------------------------------==
! == INPUT DATA: ==
! == IOUT ... NUMBER OF THE OUTPUT UNIT FOR ON-LINE PRINTING ==
! == OF VARIOUS MESSAGES ==
! == IF IOUT.LE.0 NO MESSAGE ==
! == A1,A2,A3 .. ELEMENTARY TRANSLATIONS OF THE LATTICE, IN SOME ==
! == UNIT OF LENGTH ==
! == NAT .... NUMBER OF ATOMS IN THE UNIT CELL ==
! == ALL THE DIMENSIONS ARE SET FOR NAT .LE. 20 ==
! == TY ..... INTEGERS DISTINGUISHING BETWEEN THE ATOMS OF ==
! == DIFFERENT TYPE. TY(I) IS THE TYPE OF THE I-TH ATOM ==
! == OF THE BASIS ==
! == X ...... CARTESIAN COORDINATES OF THE NAT ATOMS OF THE BASIS ==
! == DELTA... REQUIRED ACCURACY (1.e-6_dp IS A GOOD VALUE) ==
! ==--------------------------------------------------------------==
! == OUTPUT DATA: ==
! == B1,B2,B3 .. RECIPROCAL LATTICE VECTORS, NOT MULTIPLIED BY ==
! == ANY 2PI, IN UNITS RECIPROCAL TO THOSE OF A1,A2,A3 ==
! == IHG .... POINT GROUP OF THE PRIMITIVE LATTICE, HOLOHEDRAL ==
! == GROUP NUMBER: ==
! == IHG=1 STANDS FOR TRICLINIC SYSTEM ==
! == IHG=2 STANDS FOR MONOCLINIC SYSTEM ==
! == IHG=3 STANDS FOR ORTHORHOMBIC SYSTEM ==
! == IHG=4 STANDS FOR TETRAGONAL SYSTEM ==
! == IHG=5 STANDS FOR CUBIC SYSTEM ==
! == IHG=6 STANDS FOR TRIGONAL SYSTEM ==
! == IHG=7 STANDS FOR HEXAGONAL SYSTEM ==
! == IHC .... CODE DISTINGUISHING BETWEEN HEXAGONAL AND CUBIC ==
! == GROUPS ==
! == IHC=0 STANDS FOR HEXAGONAL GROUPS ==
! == IHC=1 STANDS FOR CUBIC GROUPS ==
! == ISY .... CODE INDICATING WHETHER THE SPACE GROUP IS ==
! == SYMMORPHIC OR NONSYMMORPHIC ==
! == ISY= 0 NONSYMMORPHIC GROUP ==
! == ISY= 1 SYMMORPHIC GROUP ==
! == ISY=-1 SYMMORPHIC GROUP WITH NON-STANDARD ORIGIN ==
! == ISY=-2 UNDETERMINED (NORMALLY NEVER) ==
! == THE GROUP IS CONSIDERED SYMMORPHIC IF FOR EACH ==
! == OPERATION OF THE POINT GROUP THE SUM OF THE 3 ==
! == COMPONENTS OF ABS(V(N)) (NONPRIMITIVE TRANSLATION, ==
! == SEE BELOW) IS LT. 0.0001 ==
! == ORIGIN STANDARD ORIGIN IF SYMMORPHIC (CRYSTAL COORDINATES) ==
! == LI ..... CODE INDICATING WHETHER THE POINT GROUP ==
! == OF THE CRYSTAL CONTAINS INVERSION OR NOT ==
! == (OPERATIONS 13 OR 25 IN RESPECTIVELY HEXAGONAL ==
! == OR CUBIC GROUPS). ==
! == LI=0 MEANS: DOES NOT CONTAIN INVERSION ==
! == LI.GT.0 MEANS: THERE IS INVERSION IN THE POINT ==
! == GROUP OF THE CRYSTAL ==
! == NC ..... TOTAL NUMBER OF ELEMENTS IN THE POINT GROUP OF THE ==
! == CRYSTAL ==
! == INDPG .. POINT GROUP INDEX (DETERMINED IF SYMMORPHIC GROUP) ==
! == IB ..... LIST OF THE ROTATIONS CONSTITUTING THE POINT GROUP ==
! == OF THE CRYSTAL. THE NUMBERING IS THAT DEFINED IN ==
! == WORLTON AND WARREN, I.E. THE ONE MATERIALIZED IN THE==
! == ARRAY R (SEE BELOW) ==
! == ONLY THE FIRST NC ELEMENTS OF THE ARRAY IB ARE ==
! == MEANINGFUL ==
! == NTVEC .. NUMBER OF TRANSLATIONAL VECTORS ==
! == ASSOCIATED WITH IDENTITY OPERATOR I.E. ==
! == GIVES THE NUMBER OF IDENTICAL PRIMITIVE CELLS ==
! == V ...... NONPRIMITIVE TRANSLATIONS (IN THE CASE OF NONSYMMOR-==
! == PHIC GROUPS). V(I,N) IS THE I-TH COMPONENT ==
! == OF THE TRANSLATION CONNECTED WITH THE N-TH ELEMENT ==
! == OF THE POINT GROUP (I.E. WITH THE ROTATION ==
! == NUMBER IB(N) ). ==
! == ATTENTION: V(I) ARE NOT CARTESIAN COMPONENTS, ==
! == THEY REFER TO THE SYSTEM A1,A2,A3. ==
! == F0 ..... THE FUNCTION DEFINED IN MARADUDIN, IPATOVA BY ==
! == EQ. (3.2.12): ATOM TRANSFORMATION TABLE. ==
! == THE ELEMENT F0(N,KAPA) MEANS THAT THE N-TH ==
! == OPERATION OF THE SPACE GROUP (I.E. OPERATION NUMBER ==
! == IB(N), TOGETHER WITH AN EVENTUAL NONPRIMITIVE ==
! == TRANSLATION V(N)) TRANSFERS THE ATOM KAPA INTO THE ==
! == ATOM F0(N,KAPA). ==
! == THE 49TH LINE GIVES EQUIVALENT ATOMS FOR ==
! == FRACTIONAl TRANSLATIONS ASSOCIATED WITH IDENTITY ==
! == R ...... LIST OF THE 3 X 3 ROTATION MATRICES ==
! == (XYZ REPRESENTATION OF THE O(H) OR D(6)H GROUPS) ==
! == ALL 48 OR 24 MATRICES ARE LISTED. ==
! == FOLLOW NOTATION OF WORLTON-WARREN(1972) ==
! == TVEC .. LIST OF NTVEC TRANSLATIONAL VECTORS ==
! == ASSOCIATED WITH IDENTITY OPERATOR ==
! == TVEC(1:3,1) = \(0,0,0\) ==
! == (CRYSTAL COORDINATES) ==
! == RX ..... SCRATCH ARRAY ==
! == ISC .... SCRATCH ARRAY ==
! ==--------------------------------------------------------------==
! == PRINTED OUTPUT: ==
! == PROGRAM PRINTS THE TYPE OF THE LATTICE (IHG, IN WORDS), ==
! == LISTS THE OPERATIONS OF THE POINT GROUP OF THE ==
! == CRYSTAL, INDICATES WHETHER THE SPACE GROUP IS SYMMORPHIC OR ==
! == NONSYMMORPHIC AND WHETHER THE POINT GROUP OF THE CRYSTAL ==
! == CONTAINS INVERSION. ==
! ==--------------------------------------------------------------==
INTEGER :: iout
REAL(dp) :: a1(3), a2(3), a3(3)
INTEGER :: nat, ty(nat)
REAL(dp) :: x(3, nat), b1(3), b2(3), b3(3)
INTEGER :: ihg, ihc, isy, li, nc, indpg, ib(48), &
ntvec
REAL(dp) :: v(3, 48)
INTEGER :: f0(49, nat)
REAL(dp) :: r(3, 3, 48), tvec(3, nat), origin(3), &
rx(3, nat)
INTEGER :: isc(nat)
REAL(dp) :: delta
INTEGER :: i, ncprim
REAL(dp) :: a(3, 3), ai(3, 3), ap(3, 3), api(3, 3)
DO i = 1, 3
a(i, 1) = a1(i)
a(i, 2) = a2(i)
a(i, 3) = a3(i)
END DO
! ==--------------------------------------------------------------==
! == A(I,J) IS THE I-TH CARTESIAN COMPONENT OF THE J-TH PRIMITIVE ==
! == TRANSLATION VECTOR OF THE DIRECT LATTICE ==
! == TY(I) IS AN INTEGER DISTINGUISHING ATOMS OF DIFFERENT TYPE, ==
! == I.E., DIFFERENT ATOMIC SPECIES ==
! == X(J,I) IS THE J-TH CARTESIAN COMPONENT OF THE POSITION ==
! == VECTOR FOR THE I-TH ATOM IN THE UNIT CELL. ==
! ==--------------------------------------------------------------==
! ==DETERMINE PRIMITIVE LATTICE VECTORS FOR THE RECIPROCAL LATTICE==
! ==--------------------------------------------------------------==
CALL calbrec(a, ai)
DO i = 1, 3
b1(i) = ai(1, i)
b2(i) = ai(2, i)
b3(i) = ai(3, i)
END DO
! ==--------------------------------------------------------------==
! Determination of the translation vectors associated with
! the Identity matrix i.e. if the cell is duplicated
! Give also the ``primitive lattice''
CALL primlatt(a, ai, ap, api, nat, ty, x, ntvec, tvec, f0, isc, delta)
! ==--------------------------------------------------------------==
! Determination of the holohedral group (and crystal system)
CALL pgl1(ap, api, ihc, nc, ib, ihg, r, delta)
IF (ntvec .GT. 1) THEN
! All rotations found by PGL1 have axes in x, y or z cart. axis
! So we have too check if we do not loose symmetry
ncprim = nc
! The hexagonal system is found if the z axis is the sixfold axis
CALL pgl1(a, ai, ihc, nc, ib, ihg, r, delta)
IF (ncprim .GT. nc) THEN
! More symmetry with
CALL pgl1(ap, api, ihc, nc, ib, ihg, r, delta)
END IF
END IF
! Determination of the space group
CALL atftm1(iout, r, v, x, f0, origin, ib, ty, nat, ihg, ihc, rx, &
nc, indpg, ntvec, a, ai, li, isy, isc, delta)
IF (iout .GT. 0) THEN
IF (li .GT. 0) THEN
IF (iout > 0) &
WRITE (iout, '(1X,A)') &
'KPSYM| THE POINT GROUP OF THE CRYSTAL CONTAINS THE INVERSION'
END IF
IF (iout > 0) &
WRITE (iout, *)
END IF
END SUBROUTINE group1s
! **************************************************************************************************
!> \brief ...
!> \param a ...
!> \param ai ...
! **************************************************************************************************
SUBROUTINE calbrec(a, ai)
! ==--------------------------------------------------------------==
! == CALCULATE RECIPROCAL VECTOR BASIS (AI(1:3,1:3)) ==
! == INPUT: ==
! == A(3,3) A(I,J) IS THE I-TH CARTESIAN COMPONENT ==
! == OF THE J-TH PRIMITIVE TRANSLATION VECTOR OF ==
! == THE DIRECT LATTICE ==
! == OUTPUT: ==
! == AI(3,3) RECIPROCAL VECTOR BASIS ==
! ==--------------------------------------------------------------==
REAL(dp) :: a(3, 3), ai(3, 3)
INTEGER :: i, il, iu, j, jl, ju
REAL(dp) :: det
det = a(1, 1)*a(2, 2)*a(3, 3) + a(2, 1)*a(1, 3)*a(3, 2) + &
a(3, 1)*a(1, 2)*a(2, 3) - a(1, 1)*a(2, 3)*a(3, 2) - &
A(2, 1)*A(1, 2)*A(3, 3) - A(3, 1)*A(1, 3)*A(2, 2)
det = 1._dp/det
DO i = 1, 3
il = 1
iu = 3
IF (i .EQ. 1) il = 2
IF (i .EQ. 3) iu = 2
DO j = 1, 3
jl = 1
ju = 3
IF (j .EQ. 1) jl = 2
IF (j .EQ. 3) ju = 2
ai(j, i) = (-1._dp)**(i + j)*det* &
(A(IL, JL)*A(IU, JU) - A(IL, JU)*A(IU, JL))
END DO
END DO
! ==--------------------------------------------------------------==
RETURN
END SUBROUTINE calbrec
! ==================================================================
! **************************************************************************************************
!> \brief ...
!> \param a ...
!> \param ai ...
!> \param ap ...
!> \param api ...
!> \param nat ...
!> \param ty ...
!> \param x ...
!> \param ntvec ...
!> \param tvec ...
!> \param f0 ...
!> \param isc ...
!> \param delta ...
! **************************************************************************************************
SUBROUTINE primlatt(a, ai, ap, api, nat, ty, x, ntvec, tvec, f0, isc, delta)
! ==--------------------------------------------------------------==
! == DETERMINATION OF THE TRANSLATION VECTORS ASSOCIATED WITH ==
! == THE IDENTITY SYMMETRY I.E. IF THE CELL IS DUPLICATED ==
! == GIVE ALSO THE PRIMITIVE DIRECT AND RECIPROCAL LATTICE VECTOR ==
! ==--------------------------------------------------------------==
! == INPUT: ==
! == A(3,3) A(I,J) IS THE I-TH CARTESIAN COMPONENT ==
! == OF THE J-TH TRANSLATION VECTOR OF ==
! == THE DIRECT LATTICE ==
! == AI(3,3) RECIPROCAL VECTOR BASIS (CARTESIAN) ==
! == NAT NUMBER OF ATOMS ==
! == TY(NAT) TYPE OF ATOMS ==
! == X(3,NAT) ATOMIC COORDINATES IN CARTESIAN COORDINATES ==
! == DELTA REQUIRED ACCURACY (1.e-6_dp IS A GOOD VALUE) ==
! == OUTPUT: ==
! == AP(3,3) COMPONENTS OF THE PRIMITIVE TRANSLATION VECTORS ==
! == API(3,3) PRIMITIVE RECIPROCAL BASIS VECTORS ==
! == BOTH BAISI ARE IN CARTESIAN COORDINATES ==
! == NTVEC NUMBER OF TRANSLATION VECTORS (FRACTIONNAL) ==
! == TVEC(3,NTVEC) COMPONENTS OF TRANSLATIONAL VECTORS ==
! == (CRYSTAL COORDINATES) ==
! == F0(49,NAT) GIVES INEQUIVALENT ATOM FOR EACH ATOM ==
! == THE 49-TH LINE ==
! == ISC(NAT) SCRATCH ARRAY ==
! ==--------------------------------------------------------------==
REAL(dp) :: a(3, 3), ai(3, 3), ap(3, 3), api(3, 3)
INTEGER :: nat, ty(nat)
REAL(dp) :: x(3, nat)
INTEGER :: ntvec
REAL(dp) :: tvec(3, nat)
INTEGER :: f0(49, nat), isc(nat)
REAL(dp) :: delta
INTEGER :: i, il, iv, j, k2
LOGICAL :: oksym
REAL(dp) :: vr(3), xb(3)
! Variables
! ==--------------------------------------------------------------==
! First we check if there exist fractional translational vectors
! associated with Identity operation i.e.
! if the cell is duplicated or not.
ntvec = 1
tvec(1, 1) = 0._dp
tvec(2, 1) = 0._dp
tvec(3, 1) = 0._dp
DO i = 1, nat
f0(49, i) = i
END DO
DO k2 = 2, nat
IF (ty(1) .NE. ty(k2)) GOTO 100
DO i = 1, 3
xb(i) = x(i, k2) - x(i, 1)
END DO
! A fractional translation vector VR is defined.
CALL rlv3(ai, xb, vr, il, delta)
CALL checkrlv3(1, nat, ty, x, x, vr, f0, ai, isc, .TRUE., oksym, delta)
IF (oksym) THEN
! A fractional translational vector is found
ntvec = ntvec + 1
! F0(49,1:NAT) gives number of equivalent atoms
! and has atom indexes of inequivalent atoms (for translation)
DO i = 1, nat
IF (f0(49, i) .GT. f0(1, i)) f0(49, i) = f0(1, i)
END DO
DO i = 1, 3
tvec(i, ntvec) = vr(i)
END DO
END IF
100 CONTINUE
END DO
! ==-------------------------------------------------------------==
DO i = 1, 3
ap(1, i) = a(1, i)
ap(2, i) = a(2, i)
ap(3, i) = a(3, i)
api(1, i) = ai(1, i)
api(2, i) = ai(2, i)
api(3, i) = ai(3, i)
END DO
IF (ntvec .EQ. 1) THEN
! The current cell is definitely a primitive one
! Copy A and AI to AP and API
ELSE
! We are looking for the primitive lattice vector basis set
! AP is our current lattice vector basis
DO iv = 2, ntvec
! TVEC in cartesian coordinates
DO i = 1, 3
xb(i) = tvec(1, iv)*a(i, 1) &
+ TVEC(2, IV)*A(I, 2) &
+ TVEC(3, IV)*A(I, 3)
END DO
! We calculare TVEC in AP basis
CALL rlv3(api, xb, vr, il, delta)
DO i = 1, 3
IF (ABS(vr(i)) .GT. delta) THEN
il = NINT(1._dp/ABS(vr(i)))
IF (il .GT. 1) THEN
! We replace AP(1:3,I) by TVEC(1:3,IV)
DO j = 1, 3
ap(j, i) = xb(j)
END DO
! Calculate new API
CALL calbrec(ap, api)
GOTO 200 ! EXIT
END IF
END IF
END DO
200 CONTINUE
END DO
END IF
! ==--------------------------------------------------------------==
RETURN
END SUBROUTINE primlatt
! ==================================================================
! **************************************************************************************************
!> \brief ...
!> \param a ...
!> \param ai ...
!> \param ihc ...
!> \param nc ...
!> \param ib ...
!> \param ihg ...
!> \param r ...
!> \param delta ...
! **************************************************************************************************
SUBROUTINE pgl1(a, ai, ihc, nc, ib, ihg, r, delta)
! ==--------------------------------------------------------------==
! == WRITTEN ON SEPTEMBER 11TH, 1979 - FROM ACMI COMPLEX ==
! == AUXILIARY SUBROUTINE TO GROUP1 ==
! == SUBROUTINE PGL DETERMINES THE POINT GROUP OF THE LATTICE ==
! == AND THE CRYSTAL SYSTEM. ==
! == SUBROUTINES NEEDED: ROT1, RLV3 ==
! ==--------------------------------------------------------------==
! == WARNING: FOR THE HEXAGONAL SYSTEM, THE 3RD AXIS SUPPOSE ==
! == TO BE THE SIX-FOLD AXIS ==
! ==--------------------------------------------------------------==
! == INPUT: ==
! == A ..... DIRECT LATTICE VECTORS ==
! == AI .... RECIPROCAL LATTICE VECTORS ==
! == DELTA.. REQUIRED ACCURACY (1.e-6_dp IS A GOOD VALUE) ==
! ==--------------------------------------------------------------==
! == OUTPUT: ==
! == IHC .... CODE DISTINGUISHING BETWEEN HEXAGONAL AND CUBIC ==
! == GROUPS ==
! == IHC=0 STANDS FOR HEXAGONAL GROUPS ==
! == IHC=1 STANDS FOR CUBIC GROUPS ==
! == NC .... NUMBER OF ROTATIONS IN THE POINT GROUP ==
! == IB .... SET OF ROTATION ==
! == IHG .... POINT GROUP OF THE PRIMITIVE LATTICE, HOLOHEDRAL ==
! == GROUP NUMBER: ==
! == IHG=1 STANDS FOR TRICLINIC SYSTEM ==
! == IHG=2 STANDS FOR MONOCLINIC SYSTEM ==
! == IHG=3 STANDS FOR ORTHORHOMBIC SYSTEM ==
! == IHG=4 STANDS FOR TETRAGONAL SYSTEM ==
! == IHG=5 STANDS FOR CUBIC SYSTEM ==
! == IHG=6 STANDS FOR TRIGONAL SYSTEM ==
! == IHG=7 STANDS FOR HEXAGONAL SYSTEM ==
! == R ...... LIST OF THE 3 X 3 ROTATION MATRICES ==
! == (XYZ REPRESENTATION OF THE O(H) OR D(6)H GROUPS) ==
! == ALL 48 OR 24 MATRICES ARE LISTED. ==
! == FOLLOW NOTATION OF WORLTON-WARREN(1972) ==
! ==--------------------------------------------------------------==
REAL(dp) :: a(3, 3), ai(3, 3)
INTEGER :: ihc, nc, ib(48), ihg
REAL(dp) :: r(3, 3, 48), delta
INTEGER :: i, j, k, lx, n, nr
REAL(dp) :: tr, vr(3), xa(3)
DO ihc = 0, 1
! IHC is 0 for hexagonal groups and 1 for cubic groups.
IF (ihc .EQ. 0) THEN
nr = 24
ELSE
nr = 48
END IF
nc = 0
! Constructs rotation operations.
CALL rot1(ihc, r)
DO n = 1, nr
ib(n) = 0
! Rotate the A1,2,3 vectors by rotation No. N
DO k = 1, 3
DO i = 1, 3
xa(i) = 0._dp
DO j = 1, 3
xa(i) = xa(i) + r(i, j, n)*a(j, k)
END DO
END DO
CALL rlv3(ai, xa, vr, lx, delta)
tr = 0._dp
DO i = 1, 3
tr = tr + ABS(vr(i))
END DO
! If VR.ne.0, then XA cannot be a multiple of a lattice vector
IF (tr .GT. delta) GOTO 140
END DO
nc = nc + 1
ib(nc) = n
140 CONTINUE
END DO
! ==------------------------------------------------------------==
! IHG stands for holohedral group number.
IF (ihc .EQ. 0) THEN
! Hexagonal group:
IF (nc .EQ. 12) ihg = 6