Statistiques
| Révision :

root / src / CalcCnct.f90 @ 3

Historique | Voir | Annoter | Télécharger (3,67 ko)

1
!================================================================
2
! Calculation of the connectivity.
3
!
4
! Input:
5
! Na: (INTEGER) Number of atoms in the system
6
! Atome: (INTEGER) Number of mass of the atoms.
7
!                  Needed to find their covalent raii.
8
!  x(Nat), y(nat), z(nat) : (REAL) Cartesian coordinates of the system.
9
!  LIAISONS: (INTEGER Na,0:NMaxL) Array containing the connectivity.
10
!            That is Liaisons(i,:) contains the atoms linked to i.
11
!            Liaisons(i,0) contains the number of atoms linked to i.
12
! r_cov(0:Max_Z) (REAL) Covalent radii
13
! Fact (REAL) Factor used to determined if two atoms are linked :
14
!            i and j are linked if (dist(i,j)*fact <= rcov(i)+rcov(j)
15
!
16
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
17
! Taken from Path_Module
18
! NMaxL (INTEGER): Maximum number of bonds for one atome
19
! Max_Z (INTEGER): Last atom for which I have the atomic of mass and covalent radii.
20
! Nom(Nat) (STRING): Name of the atoms.
21
! Prog (SCHARS): Name of the program used to calculate energies and gradients
22
!
23
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24
! v1.0 (c) PFL
25
! v1.1 (c) PFL 11.2007
26
! A test has been added for periodic system, ie the linked test
27
! is done between i in the central cell, and j in all surrounding cells.
28
!
29
!================================================================
30

    
31
SUBROUTINE CalcCnct(na,atome,x,y,z,LIAISONS,r_cov,fact)
32

    
33
  use Path_module, only : NMaxL, max_Z,Nom,Prog, KINT, KREAL
34

    
35
  integer(KINT) :: na, atome(Na)
36
  real(KREAL) ::  x(Na),y(Na),z(Na),fact
37
  real(KREAL) :: vx,vy,vz,dist
38
  REAL(KREAL) :: r_cov(0:Max_Z)
39
  INTEGER(KINT) :: LIAISONS(Na,0:NMaxL),Nbli,Nblj
40

    
41
  ! For periodic systems
42
  INTEGER(KINT) :: Ka,Kb,Kc
43
  LOGICAL   :: Bound
44

    
45
  ! Internals
46
  logical(KREAL) ::debug
47

    
48
  INTERFACE
49
     function valid(string) result (isValid)
50
       CHARACTER(*), intent(in) :: string
51
       logical                  :: isValid
52
     END function VALID
53
  END INTERFACE
54

    
55
  debug=valid('calccnct')
56
  if (debug) WRITE(*,*) "======================= Entering CalcCnct ======================="
57

    
58
  DO i=1,na
59
     Liaisons(i,0)=0
60
  END DO
61

    
62
  if (debug) THEN
63
     WRITE(*,*) 'CalcCnct'
64
     DO iat=1,na
65
        i=atome(iat)
66
        WRITE(*,*) Nom(I),I,r_cov(i),r_cov(i)*fact
67
     END DO
68
  END IF
69

    
70
  IF (PROG/="VASP") THEN
71
     DO i=1,na
72
        NbLi=LIAISONS(i,0)
73
        DO j=i+1,na
74
           CALL vecteur(j,i,x,y,z,vx,vy,vz,dist)
75
           dist=dist/fact
76
           distth=(r_cov(atome(i))+r_cov(atome(j)))/100.
77
!           if (debug) WRITE(*,*) atome(i),atome(j),dist,distth
78
           if (dist.le.distth) THEN
79
              NbLi=NbLi+1
80
              LIAISONS(i,NbLi)=j;
81
              NBlj=LIAISONS(j,0)+1
82
              LIAISONS(j,Nblj)=i;
83
              LIAISONS(j,0)=Nblj
84
           END IF
85
        END DO
86
        LIAISONS(i,0)=Nbli
87
     END DO
88
  ELSE
89
     DO i=1,na
90
        NbLi=LIAISONS(i,0)
91
        DO j=i+1,na
92
           Bound=.FALSE.
93
           DO ka=-1,1
94
              DO Kb=-1,1
95
                 DO Kc=-1,1
96
                    CALL VectorPer(j,i,ka,kb,kc,x,y,z,vx,vy,vz,dist)
97
                    dist=dist/fact
98
                    distth=(r_cov(atome(i))+r_cov(atome(j)))/100.
99
!                    if (debug) WRITE(*,*) atome(i),atome(j),dist,distth
100
                    if (dist.le.distth) Bound=.TRUE.
101
                 END DO
102
              END DO
103
           END DO
104
           IF (Bound) THEN
105
              if (debug) WRITE(*,*) "Adding a bond between:",i,j
106
              NbLi=NbLi+1
107
              LIAISONS(i,NbLi)=j;
108
              NBlj=LIAISONS(j,0)+1
109
              LIAISONS(j,Nblj)=i;
110
              LIAISONS(j,0)=Nblj
111
           END IF
112
        END DO
113
        LIAISONS(i,0)=Nbli
114
     END DO
115
  END IF
116
  if (debug) WRITE(*,*) "======================= CalcCnct  over ======================="
117
END SUBROUTINE CalcCnct