lattice2.f 17.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
      MODULE m_lattice
      use m_juDFT
!---------------------------------------------------------------------!
! eventually easy input of all 14 Bravais lattices in agreement with  !
! 'International Tables of Crystallography'                           !
! table 2.1.1, ( page13 in 3rd Ed. )                                  !
!---------------------------------------------------------------------!
      CONTAINS
      SUBROUTINE lattice2( 
     >                    buffer,xl_buffer,errfh,bfh,nline,
11
     <                    a1,a2,a3,aa,scale,mat,i_c,ios )
12 13 14 15 16 17 18 19 20

      USE m_constants
      IMPLICIT NONE

!==> Arguments
      INTEGER, INTENT (IN) :: errfh,bfh,nline
      INTEGER, INTENT (IN)                 :: xl_buffer
      CHARACTER(len=xl_buffer), INTENT(IN) :: buffer
      REAL,    INTENT (OUT) :: a1(3),a2(3),a3(3)
21 22
      REAL,    INTENT (OUT) :: aa                ! overall scaling constant
      REAL,    INTENT (OUT) :: scale(3),mat(3,3) ! for trigonal lattices
23
      INTEGER, INTENT (OUT) :: i_c,ios
24 25 26

!==> Local Variables
      CHARACTER(len=40) :: latsys
27
      REAL    :: a0,a_rho
28 29 30
      REAL    :: a,b,c
      REAL    :: alpha,beta,gamma
      REAL    :: c1(3),c2(3),c3(3)
31
      REAL    :: ar,br,cr,b1,b2,am(3,3)
32 33
      REAL    :: ca,cb,at
      INTEGER :: i,j,err,i1,i2
34
      LOGICAL :: noangles
35

36
      REAL, PARAMETER :: eps = 1.0e-7,
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
     &              sqrt2  =  1.4142135623730950,
     &              sqrt3  =  1.7320508075688773,
     &              sqrt32 =  0.86602540378444,
     &             msqrt32 = -0.86602540378444

      REAL :: lmat(3,3,8)
      DATA  lmat /  1.0,  0.0,  0.0,      ! 1: primitive     : P
     &              0.0,  1.0,  0.0,
     &              0.0,  0.0,  1.0,  
     +              0.0,  0.5,  0.5,      ! 2: face-centered : F
     &              0.5,  0.0,  0.5,
     &              0.5,  0.5,  0.0,
     +             -0.5,  0.5,  0.5,      ! 3: body-centered : I
     &              0.5, -0.5,  0.5,
     &              0.5,  0.5, -0.5,
52 53 54
     +            0.5, msqrt32, 0.0,      ! 4: hexagonal-P   : hP, hcp
     &            0.5,  sqrt32, 0.0,
     &            0.0,     0.0, 1.0,   
55 56 57 58 59 60 61 62 63 64
     +              0.0, -1.0,  1.0,      ! 5: hexagonal-R   : hR, trigonal
     &           sqrt32,  0.5,  1.0,
     &          msqrt32,  0.5,  1.0, 
     +              0.5, -0.5,  0.0,      ! 6: base-centered: S (C)
     &              0.5,  0.5,  0.0,
     &              0.0,  0.0,  1.0,
     +              0.5,  0.0, -0.5,      ! 7: base-centered: B
     &              0.0,  1.0,  0.0,
     &              0.5,  0.0,  0.5,
     +              1.0,  0.0,  0.0,      ! 8: base-centered: A
65 66
     &              0.0,  0.5,  0.5,
     &              0.0, -0.5,  0.5/
67 68

!===> namelists
69
      NAMELIST /lattice/ latsys,a0,a,b,c,alpha,beta,gamma
70 71 72 73 74

      noangles = .false.
      latsys = ' ' ; a0 = 0.0   
      a = 0.0      ; b = 0.0    ; c = 0.0 
      alpha = 0.0  ; beta = 0.0 ; gamma = 0.0   
75
      scale = 0.0  ; mat = 0.0
76
 
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
      READ (bfh,lattice,err=911,end=911,iostat=ios)
      
      IF ( abs(a0) < eps ) a0 = 1.0
      IF ( abs(a)  < eps ) a  = 1.0
      IF ( abs(b)  < eps ) b  = a
      IF ( abs(c)  < eps ) c  = a
      IF ( abs(alpha)  < eps ) alpha  = 90.0
      IF ( abs(beta)   < eps ) beta   = 90.0
      IF ( abs(gamma)  < eps ) gamma  = 90.0

      IF ( alpha > pi_const ) THEN     ! deg
        ar = alpha * pi_const / 180.0 
        br = beta  * pi_const / 180.0 
        cr = gamma * pi_const / 180.0 
      ELSE                       ! radians
        ar = alpha
        br = beta
        cr = gamma
      ENDIF

97 98 99 100
      scale(1) = a
      scale(2) = b
      scale(3) = c

101 102 103 104 105 106 107 108
      latsys = ADJUSTL(latsys)

!===>  1: cubic-P          (cP) sc

      IF ( latsys =='cubic-P'.OR.latsys =='cP'.OR.latsys =='sc'.OR.
     &     latsys =='simple-cubic' ) THEN

        noangles=.true.
109
        i_c = 1
110 111 112 113
        a1 = lmat(:,1,i_c) * scale(:)
        a2 = lmat(:,2,i_c) * scale(:)
        a3 = lmat(:,3,i_c) * scale(:)
        scale = 1.0
114 115 116 117 118 119 120 121 122 123

        IF ( a.NE.b .OR. a.NE.c ) err = 11
        IF ( ar.NE.br .OR. ar.NE.cr .OR. ar.NE.(pi_const/2.0) ) err = 12

!===>  2: cubic-F          (cF) fcc

      ELSEIF ( latsys =='cubic-F'.OR.latsys =='cF'.OR.latsys =='fcc'.OR.
     &         latsys =='face-centered-cubic' ) THEN

        noangles=.true.
124
        i_c = 2
125 126 127 128
        a1 = lmat(:,1,i_c) * scale(:)
        a2 = lmat(:,2,i_c) * scale(:)
        a3 = lmat(:,3,i_c) * scale(:)
        scale = 1.0
129 130 131 132 133 134 135 136 137

        IF ( a.NE.b .OR. a.NE.c ) err = 21

!===>  3: cubic-I          (cI) bcc

      ELSEIF ( latsys =='cubic-I'.OR.latsys =='cI'.OR.latsys =='bcc'.OR.
     &         latsys =='body-centered-cubic' ) THEN

        noangles=.true.
138
        i_c = 3
139 140 141 142
        a1 = lmat(:,1,i_c) * scale(:)
        a2 = lmat(:,2,i_c) * scale(:)
        a3 = lmat(:,3,i_c) * scale(:)
        scale = 1.0
143 144 145 146 147 148 149 150 151

        IF ( a.NE.b .OR. a.NE.c ) err = 31

!===>  4: hexagonal-P      (hP) hcp

      ELSEIF ( latsys =='hexagonal-P'.OR.latsys =='hP'.OR.latsys =='hcp'
     &                               .OR.latsys =='hexagonal' ) THEN

        noangles=.true.
152
        i_c = 4
153 154 155 156
        a1 = lmat(:,1,i_c) * scale(:)
        a2 = lmat(:,2,i_c) * scale(:)
        a3 = lmat(:,3,i_c) * scale(:)
        scale = 1.0
157 158 159 160 161 162 163 164

        IF ( a.NE.b ) err = 41

!===>  4.1 : hexagonal-P   60 degrees variant

      ELSEIF ( latsys =='hdp' ) THEN

        noangles=.true.
165
        i_c = 4
166 167 168 169
        a1 =  lmat((/2,1,3/),1,i_c) * scale(:)
        a2 = -lmat((/2,1,3/),2,i_c) * scale(:)
        a3 = lmat(:,3,i_c) * scale(:)
        scale = 1.0
170
        i_c = 9
171 172 173 174 175 176 177 178 179 180

        IF ( a.NE.b ) err = 41

!===>  5.1: hexagonal-R      (hR) trigonal,( rhombohedral )

      ELSEIF ( latsys =='hexagonal-R'.OR.latsys =='hR'.OR.latsys =='r'.
     &      OR.latsys =='R'.OR.latsys =='rhombohedral'.OR.
     &         latsys =='rho'.OR.latsys =='trigonal' ) THEN

        noangles=.false.
181 182 183 184
        i_c = 5
        a1 = lmat(:,1,i_c)
        a2 = lmat(:,2,i_c)
        a3 = lmat(:,3,i_c)
185
        
186
        IF ( a.NE.b ) err = 51
187
        IF ( b.NE.c ) err = 51
188 189 190
        IF ( alpha.EQ.0.0  .OR. 
     &       alpha.NE.beta .OR. alpha.NE.gamma ) err = 52

191
        at = sqrt( 2.0 / 3.0 * ( 1 - cos(ar) ) )
192
        am(:,1) = a1 ; am(:,2) = a2 ; am(:,3) = a3
193 194 195
        am(1,:) = at * am(1,:)
        am(2,:) = at * am(2,:)
        am(3,:) = cos(asin(at)) * am(3,:)
196 197
        a1 = am(:,1)*a ; a2 = am(:,2)*b ; a3 = am(:,3)*c
        scale = 1.0
198

199 200
        CALL angles( am )
 
201 202 203 204 205 206 207
!===>  5.2: hexagonal-R      (hR) trigonal,( rhombohedral )

      ELSEIF (latsys =='hexagonal-R2'.OR.latsys =='hR2'.OR.latsys =='r2'
     &    .OR.latsys =='R2'.OR.latsys =='rhombohedral2'.OR.
     &        latsys =='trigonal2' ) THEN

        noangles=.false.
208
        i_c = 5
209 210 211
        a1 = lmat(:,1,i_c)
        a2 = lmat(:,2,i_c)
        a3 = lmat(:,3,i_c)
212

213 214 215
        IF ( a.NE.b ) err = 53
        IF ( alpha.NE.90 ) err = 54
        IF ( alpha.NE.beta .OR. gamma.NE.120 ) err = 54
216

217 218 219
        mat(:,1) = a*lmat(:,1,4) ! to transfer atom
        mat(:,2) = a*lmat(:,2,4) ! positions hex -> trig
        mat(:,3) = c*lmat(:,3,4) ! in struct_inp.f
220

221 222 223 224
! transform hex -> rho
        a_rho = sqrt( 3*a*a + c*c)/3.0
        ar = acos( 1. - 9./(6.+2*(c/a)**2) )
        at = sqrt( 2.0 / 3.0 * ( 1 - cos(ar) ) )
225

226 227 228 229 230 231 232 233 234 235 236 237
        a = a_rho * at
        b = a_rho * at
        c = a_rho * cos( asin(at) )

        am(:,1) = a1 ; am(:,2) = a2 ; am(:,3) = a3
        am(1,:) = a*am(1,:)
        am(2,:) = b*am(2,:)
        am(3,:) = c*am(3,:)
        a1 = am(:,1) ; a2 = am(:,2) ; a3 = am(:,3)
        scale = 1.0

        CALL angles( am )
238 239 240 241 242 243 244

!===>  6: tetragonal-P     (tP) st

      ELSEIF ( latsys =='tetragonal-P'.OR.latsys =='st'.OR.latsys =='tP'
     &     .OR.latsys =='simple-tetragonal' ) THEN

        noangles=.true.
245
        i_c = 1
246 247 248 249
        a1 = lmat(:,1,i_c) * scale(:)
        a2 = lmat(:,2,i_c) * scale(:)
        a3 = lmat(:,3,i_c) * scale(:)
        scale = 1.0
250 251 252 253 254 255 256 257 258 259
          
        IF ( a.NE.b ) err = 61
        IF ( ar.NE.br .OR. ar.NE.cr .OR. ar.NE.(pi_const/2.0)  ) err= 62

!===>  7: tetragonal-I     (tI) bct

      ELSEIF (latsys =='tetragonal-I'.OR.latsys =='tI'.OR.latsys =='bct'
     &    .OR.latsys =='body-centered-tetragonal' ) THEN

        noangles=.true.
260
        i_c = 3
261 262 263 264
        a1 = lmat(:,1,i_c) * scale(:)
        a2 = lmat(:,2,i_c) * scale(:)
        a3 = lmat(:,3,i_c) * scale(:)
        scale = 1.0
265 266 267 268 269 270 271 272 273
          
        IF ( a.NE.b ) err = 61

!===>  8: orthorhombic-P   (oP) 

      ELSEIF ( latsys =='orthorhombic-P'.OR.latsys =='oP'.OR.
     &         latsys =='simple-orthorhombic' ) THEN

        noangles=.true.
274
        i_c = 1
275 276 277 278
        a1 = lmat(:,1,i_c) * scale(:)
        a2 = lmat(:,2,i_c) * scale(:)
        a3 = lmat(:,3,i_c) * scale(:)
        scale = 1.0
279 280 281 282 283 284 285 286
          
!===>  9: orthorhombic-F   (oF) 

      ELSEIF ( latsys =='orthorhombic-F'.OR.latsys =='oF'.OR.
     &         latsys =='orF'.OR.
     &         latsys =='face-centered-orthorhombic' ) THEN

        noangles=.true.
287
        i_c = 2
288 289 290 291
        a1 = lmat(:,1,i_c) * scale(:)
        a2 = lmat(:,2,i_c) * scale(:)
        a3 = lmat(:,3,i_c) * scale(:)
        scale = 1.0
292 293 294 295 296 297 298 299
          
!===> 10: orthorhombic-I   (oI) 

      ELSEIF ( latsys =='orthorhombic-I'.OR.latsys =='oI'.OR.
     &         latsys =='orI'.OR.
     &         latsys =='body-centered-orthorhombic' ) THEN

        noangles=.true.
300
        i_c = 3
301 302 303 304
        a1 = lmat(:,1,i_c) * scale(:)
        a2 = lmat(:,2,i_c) * scale(:)
        a3 = lmat(:,3,i_c) * scale(:)
        scale = 1.0
305 306 307 308 309 310 311 312
          
!===> 11: orthorhombic-S   (oS) (oC) 

      ELSEIF ( latsys =='orthorhombic-S'.OR.latsys =='orthorhombic-C'.or
     &        .latsys =='oS'.OR.latsys =='oC'.OR.latsys =='orC'.OR.
     &         latsys =='base-centered-orthorhombic' ) THEN

        noangles=.true.
313
        i_c = 6
314 315 316 317
        a1 = lmat(:,1,i_c) * scale(:)
        a2 = lmat(:,2,i_c) * scale(:)
        a3 = lmat(:,3,i_c) * scale(:)
        scale = 1.0
318 319 320 321 322 323 324 325
          
!===> 11a: orthorhombic-A   (oA)

      ELSEIF ( latsys =='orthorhombic-A'.OR.latsys =='oA'.OR
     &        .latsys =='orA'.OR.
     &         latsys =='base-centered-orthorhombic2' ) THEN

        noangles=.true.
326
        i_c = 8
327 328 329 330
        a1 = lmat(:,1,i_c) * scale(:)
        a2 = lmat(:,2,i_c) * scale(:)
        a3 = lmat(:,3,i_c) * scale(:)
        scale = 1.0
331 332 333 334 335 336 337 338

!===> 11b: orthorhombic-B   (oB)

      ELSEIF ( latsys =='orthorhombic-B'.OR.latsys =='oB'.OR
     &        .latsys =='orB'.OR.
     &         latsys =='base-centered-orthorhombic3' ) THEN

        noangles=.true.
339
        i_c = 7
340 341 342 343
        a1 = lmat(:,1,i_c) * scale(:)
        a2 = lmat(:,2,i_c) * scale(:)
        a3 = lmat(:,3,i_c) * scale(:)
        scale = 1.0
344 345 346 347 348 349 350

!===> 12: monoclinic-P     (mP) 
      ELSEIF ( latsys =='monoclinic-P'.OR.latsys =='mP'.OR
     &        .latsys =='moP'.OR.
     &         latsys =='simple-monoclinic' ) THEN

        noangles=.false.
351 352
        i_c = 1

353 354 355 356 357 358 359 360 361
        IF ( (abs(alpha-90.0)<eps).AND.(abs(beta-90.0)<eps) ) THEN
           IF ( ABS(gamma - 90.0) <eps )  CALL juDFT_error
     +          ("no monoclinic angle!",calledby ="lattice2")
        ELSE 
           CALL juDFT_error
     +          ("lattice2: Please take gamma as monoclinic angle!"
     +          ,calledby ="lattice2")
        ENDIF  
        CALL brvmat ( alpha, beta, gamma, am )
362 363 364 365 366
        a1 = a*am(:,1)
        a2 = b*am(:,2)
        a3 = c*am(:,3) 
        scale = 1.0

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
        CALL angles( am )

!===> 13: monoclinic-C (mC) 
      ELSEIF ( latsys =='monoclinic-C'.OR.latsys =='mC'.OR
     &        .latsys =='moC'.OR.
     &         latsys =='centered-monoclinic' ) THEN

         CALL juDFT_error
     +    ("Monoclinic setup",hint
     +        ="Please use gamma as monoclinic angle"//
     +        " and center on A or B !",calledby ="lattice2")

!===> 13a monoclinic-A (mA)
      ELSEIF ( latsys =='monoclinic-A'.OR.latsys =='mA'.OR
     &        .latsys =='moA'.OR.
     &         latsys =='centered-monoclinic2' ) THEN

        noangles=.false.
        IF ( (abs(alpha-90.0)<eps).AND.(abs(beta-90.0)<eps) ) THEN
           IF ( abs(gamma - 90.0) <eps )  CALL juDFT_error
     +          ("no monoclinic angle!",calledby ="lattice2")
        ELSE
           CALL juDFT_error("Please take gamma as monoclinic angle!"
     +          ,calledby ="lattice2")
        ENDIF
        CALL brvmat ( alpha, beta, gamma, am )
393 394 395 396 397
        am(:,1) = a * am(:,1)
        am(:,2) = b * am(:,2)
        am(:,3) = c * am(:,3)
        i_c = 8
        am = matmul ( am, lmat(:,:,i_c) )
398 399 400 401
        a1 = am(:,1)
        a2 = am(:,2)
        a3 = am(:,3)
        CALL angles( am )
402
        scale = 1.0 
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417

!===> 13b monoclinic-B (mB)
      ELSEIF ( latsys =='monoclinic-B'.OR.latsys =='mB'.OR
     &        .latsys =='moB'.OR.
     &         latsys =='centered-monoclinic3' ) THEN

        noangles=.false.
        IF ( (abs(alpha-90.0)<eps).AND.(abs(beta-90.0)<eps) ) THEN
           IF ( ABS(gamma - 90.0) <eps )  CALL juDFT_error
     +          ("no monoclinic angle!",calledby ="lattice2")
        ELSE
           CALL juDFT_error("Please take gamma as monoclinic angle!"
     +          ,calledby ="lattice2")
        ENDIF
        CALL brvmat ( alpha, beta, gamma, am )
418 419 420 421 422
        am(:,1) = a * am(:,1)
        am(:,2) = b * am(:,2)
        am(:,3) = c * am(:,3)
        i_c = 7
        am = matmul ( am, lmat(:,:,i_c) )
423 424 425 426
        a1 = am(:,1)
        a2 = am(:,2)
        a3 = am(:,3)
        CALL angles( am )
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
        scale = 1.0 

!===> 13c monoclinic-I (mI)
      ELSEIF ( latsys =='monoclinic-I'.OR.latsys =='mI'.OR
     &        .latsys =='moI' ) THEN

        noangles=.false.
        IF ( (abs(alpha-90.0)<eps).AND.(abs(beta-90.0)<eps) ) THEN
           IF ( ABS(gamma - 90.0) <eps )  CALL juDFT_error
     +          ("no monoclinic angle!",calledby ="lattice2")
        ELSE
           CALL juDFT_error("Please take gamma as monoclinic angle!"
     +          ,calledby ="lattice2")
        ENDIF
        CALL brvmat ( alpha, beta, gamma, am )
        am(:,1) = a * am(:,1)
        am(:,2) = b * am(:,2)
        am(:,3) = c * am(:,3)
        i_c = 3
        am = matmul ( am, lmat(:,:,i_c) )
        a1 = am(:,1)
        a2 = am(:,2)
        a3 = am(:,3)
        CALL angles( am )
        scale = 1.0 
452 453 454 455 456 457 458

!===> 14: triclinic        (aP) 

      ELSEIF ( latsys =='aP' .OR. latsys =='triclinic' .OR.
     &         latsys =='tcl' )  THEN

        noangles=.false.
459
        i_c = 1
460
        CALL brvmat ( alpha, beta, gamma, am )
461 462 463
        a1 = a*am(:,1)
        a2 = b*am(:,2)
        a3 = c*am(:,3)
464
        CALL angles( am )
465
        scale = 1.0
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488
          
      ELSE
          WRITE (errfh,*)
          WRITE (errfh,*) '*** unknown lattice system latsys=',latsys,
     &                    'in line',nline,'.'
          WRITE (errfh,*) 
     &    '***  No reason for panic, it is probably because'
          WRITE (errfh,*) 
     & '***  subroutine lattice2 in struct_input.f is unfinished. ***'
        ios = 1
        RETURN
      ENDIF

      IF ( noangles .AND.
     &    ( abs(alpha - 90.0 ) > eps .OR.
     &      abs(beta  - 90.0 ) > eps .OR.
     &      abs(gamma - 90.0 ) > eps )    ) THEN
        WRITE (errfh,*)
        WRITE (errfh,*) 'ERROR in &lattice ... /. ',
     & 'For the given lattice system all angles should be 90deg.'
        WRITE (errfh,*)
      ENDIF

489
      IF (abs(scale(1)) < eps) THEN
490 491
        CALL juDFT_error("Illegal program section reached!"
     +          ,calledby ="lattice2")
492 493 494 495
        scale(1) = a
        scale(2) = b
        scale(3) = c
      ENDIF
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
      aa = a0

 911  CONTINUE

      RETURN
      END SUBROUTINE lattice2
!
!**********************************************************************!
!
      SUBROUTINE angles( am )
!----------------------------------------------------------------------!
!     given an bravais matrix (am), calculate length of basis vectors  !
!     and angles beween them ; write results to standard output        !
!----------------------------------------------------------------------!

      USE m_constants
      IMPLICIT NONE

      REAL, INTENT(IN) :: am(3,3)

      REAL     ca,al(3)
      INTEGER  i,j,i1,i2

      al = 0.0
      DO j = 1, 3
        DO i = 1, 3
          al(j) = al(j) + am(i,j)*am(i,j)
        ENDDO
        al(j) = sqrt(al(j))
      ENDDO

      DO j = 1, 3
        WRITE (6,'("vector ",i1," : ",3f9.5,5x," length : ",f9.5)') 
     &                                              j,am(:,j),al(j)
      ENDDO

      DO i1 = 1, 2 
        DO i2 = i1+1, 3
          ca = 0.0
          DO i = 1, 3
            ca = ca + am(i,i1)*am(i,i2)
          ENDDO
          ca  = ca/(al(i1)*al(i2))
          ca = acos(ca)*180/pi_const
    
          WRITE (6,'("angle between vectors (",i1,",",i1,") =",f9.5)') 
     &                                                        i1,i2,ca
        ENDDO
      ENDDO

      END SUBROUTINE angles
!
!**********************************************************************!
!
      SUBROUTINE brvmat ( alpha, beta, gamma, am )
!----------------------------------------------------------------------!
!     given the angles alpha, beta and gamma, set up an matrix 'am'    !
!     with 3 unit vectors and these angles between them. The first     !
!     unit vector poins in (1,0,0) direction                gb`05      !
!----------------------------------------------------------------------!

      USE m_constants
      IMPLICIT NONE

      REAL, INTENT (IN)  :: alpha, beta, gamma
      REAL, INTENT (OUT) :: am(3,3)

      REAL ca,cb,cg,sg,c1,c2

      ca = cos(alpha*pi_const/180); cb = cos(beta*pi_const/180)
      cg = cos(gamma*pi_const/180); sg = sin(gamma*pi_const/180)
      c1 = (ca - cg*cb ) / sg
      c2 = sqrt( 1 - cb**2 - c1**2 ) 

570
      am(1,1) = 1.0 ; am(2,1) = 0.0 ; am(3,1) = 0.0
571
      am(1,2) = cg  ; am(2,2) = sg  ; am(3,2) = 0.0
572
      am(1,3) = cb  ; am(2,3) = c1  ; am(3,3) = c2
573 574 575 576

      END SUBROUTINE brvmat

      END MODULE m_lattice