Statistiques
| Révision :

root / src / CheckPeriodicBound.f90 @ 3

Historique | Voir | Annoter | Télécharger (2,51 ko)

1
 SUBROUTINE CheckPeriodicBound
2
! This subroutine is only for periodic systems
3
! it checks that the atoms do not change their
4
! positions from one side to the other during the simulations.
5
! This would ruin the interpolation.
6

    
7

    
8
  Use Path_module
9
  Use Io_module
10

    
11
  IMPLICIT NONE
12

    
13

    
14
  INTEGER(KINT) :: IGeom, I,J,K
15
  REAL(KREAL), ALLOCATABLE :: GeomRef(:,:), GeomTmp(:,:) ! (3,Nat)
16

    
17
  REAL(KREAL) :: Latrloc(3,3),Bloc(3),Xt,Yt,Zt
18
  LOGICAL :: Debug
19

    
20
  INTERFACE
21
     function valid(string) result (isValid)
22
       CHARACTER(*), intent(in) :: string
23
       logical                  :: isValid
24
     END function VALID
25
  END INTERFACE
26

    
27
  debug=valid('checkperiodicbound')
28
if (debug) WRITE(*,*) "========================= Entering CheckPeriodicBound ==========="
29

    
30
  ALLOCATE(GeomRef(3,Nat), GeomTmp(3,Nat))
31

    
32
  V_direct=adjustl(Vasp_direct)
33
  Call upcase(V_direct)
34

    
35
! The test is easy in DIRECT space, so we will convert the geometries
36
! into this space. 
37
! We might optimize this as Read_geom converts geometries into NORMAL
38
! coordinates... so it might be that we are converting them back to direct here...
39

    
40
     Latrloc(1:3,1)=Lat_a
41
     Latrloc(1:3,2)=Lat_b
42
     Latrloc(1:3,3)=Lat_c
43
     Bloc=1.
44
     CALL Gaussj(Latrloc,3,3,Bloc,1,1)
45

    
46
 ! We put first geometry as the reference
47
     GeomRef=0.
48
     DO I=1,Nat
49
        DO K=1,3
50
           DO J=1,3
51
              GeomRef(K,I)=GeomRef(K,I)+XyzGeomI(1,J,I)*LatrLoc(K,J)
52
           END DO
53
        END DO
54
     END DO
55

    
56
  DO IGeom=2,NGeomI
57
     GeomTmp=0.
58
     DO I=1,Nat
59
        DO K=1,3
60
           DO J=1,3
61
              GeomTmp(K,I)=GeomTmp(K,I)+XyzGeomI(IGeom,J,I)*LatrLoc(K,J)
62
           END DO
63
           if (abs(GeomTmp(K,I)-GeomRef(K,I)).GE.BoxTol) THEN
64
              If (debug) & 
65
                  WRITE(*,'("Coord ",I1," has been changed for atom ",I5," by ",F4.0," ref:",F9.6," old:",F9.6," new:",F9.6)') &
66
                   K,I,Sign(1.d0,GeomRef(K,I)-GeomTmp(K,I)),& 
67
                   GeomRef(K,I),GeomTmp(K,I), &
68
                   GeomTmp(K,I)+Sign(1.d0,GeomRef(K,I)-GeomTmp(K,I))
69
              GeomTmp(K,I)=GeomTmp(K,I)+Sign(1.d0,GeomRef(K,I)-GeomTmp(K,I))
70
           END IF
71
        END DO
72
        Xt=GeomTmp(1,I)
73
        Yt=GeomTmp(2,I)
74
        Zt=GeomTmp(3,I)
75
        XyzGeomI(IGeom,1,I)=Xt*lat_a(1)+Yt*lat_b(1)+Zt*lat_c(1)
76
        XyzGeomI(IGeom,2,I)=Xt*lat_a(2)+Yt*lat_b(2)+Zt*lat_c(2)
77
        XyzGeomI(IGeom,3,I)=Xt*lat_a(3)+Yt*lat_b(3)+Zt*lat_c(3)
78
     END DO
79
  END DO
80

    
81
if (debug) WRITE(*,*) "========================= Exiting CheckPeriodicBound ==========="
82
END SUBROUTINE CheckPeriodicBound
83

    
84

    
85
 
86

    
87

    
88