Statistiques
| Révision :

root / src / CalcCnct.f90 @ 2

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

1 1 pfleura2
!================================================================
2 1 pfleura2
! Calculation of the connectivity.
3 1 pfleura2
!
4 1 pfleura2
! Input:
5 1 pfleura2
! Na: (INTEGER) Number of atoms in the system
6 1 pfleura2
! Atome: (INTEGER) Number of mass of the atoms.
7 1 pfleura2
!                  Needed to find their covalent raii.
8 1 pfleura2
!  x(Nat), y(nat), z(nat) : (REAL) Cartesian coordinates of the system.
9 1 pfleura2
!  LIAISONS: (INTEGER Na,0:NMaxL) Array containing the connectivity.
10 1 pfleura2
!            That is Liaisons(i,:) contains the atoms linked to i.
11 1 pfleura2
!            Liaisons(i,0) contains the number of atoms linked to i.
12 1 pfleura2
! r_cov(0:Max_Z) (REAL) Covalent radii
13 1 pfleura2
! Fact (REAL) Factor used to determined if two atoms are linked :
14 1 pfleura2
!            i and j are linked if (dist(i,j)*fact <= rcov(i)+rcov(j)
15 1 pfleura2
!
16 1 pfleura2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
17 1 pfleura2
! Taken from Path_Module
18 1 pfleura2
! NMaxL (INTEGER): Maximum number of bonds for one atome
19 1 pfleura2
! Max_Z (INTEGER): Last atom for which I have the atomic of mass and covalent radii.
20 1 pfleura2
! Nom(Nat) (STRING): Name of the atoms.
21 1 pfleura2
! Prog (SCHARS): Name of the program used to calculate energies and gradients
22 1 pfleura2
!
23 1 pfleura2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24 1 pfleura2
! v1.0 (c) PFL
25 1 pfleura2
! v1.1 (c) PFL 11.2007
26 1 pfleura2
! A test has been added for periodic system, ie the linked test
27 1 pfleura2
! is done between i in the central cell, and j in all surrounding cells.
28 1 pfleura2
!
29 1 pfleura2
!================================================================
30 1 pfleura2
31 1 pfleura2
SUBROUTINE CalcCnct(na,atome,x,y,z,LIAISONS,r_cov,fact)
32 1 pfleura2
33 1 pfleura2
  use Path_module, only : NMaxL, max_Z,Nom,Prog, KINT, KREAL
34 1 pfleura2
35 2 pfleura2
  integer(KINT) :: na, atome(Na)
36 1 pfleura2
  real(KREAL) ::  x(Na),y(Na),z(Na),fact
37 1 pfleura2
  real(KREAL) :: vx,vy,vz,dist
38 1 pfleura2
  REAL(KREAL) :: r_cov(0:Max_Z)
39 1 pfleura2
  INTEGER(KINT) :: LIAISONS(Na,0:NMaxL),Nbli,Nblj
40 1 pfleura2
41 1 pfleura2
  ! For periodic systems
42 1 pfleura2
  INTEGER(KINT) :: Ka,Kb,Kc
43 1 pfleura2
  LOGICAL   :: Bound
44 1 pfleura2
45 1 pfleura2
  ! Internals
46 1 pfleura2
  logical(KREAL) ::debug
47 1 pfleura2
48 1 pfleura2
  INTERFACE
49 1 pfleura2
     function valid(string) result (isValid)
50 1 pfleura2
       CHARACTER(*), intent(in) :: string
51 1 pfleura2
       logical                  :: isValid
52 1 pfleura2
     END function VALID
53 1 pfleura2
  END INTERFACE
54 1 pfleura2
55 1 pfleura2
  debug=valid('calccnct')
56 1 pfleura2
  if (debug) WRITE(*,*) "======================= Entering CalcCnct ======================="
57 1 pfleura2
58 1 pfleura2
  DO i=1,na
59 1 pfleura2
     Liaisons(i,0)=0
60 1 pfleura2
  END DO
61 1 pfleura2
62 1 pfleura2
  if (debug) THEN
63 1 pfleura2
     WRITE(*,*) 'CalcCnct'
64 1 pfleura2
     DO iat=1,na
65 1 pfleura2
        i=atome(iat)
66 1 pfleura2
        WRITE(*,*) Nom(I),I,r_cov(i),r_cov(i)*fact
67 1 pfleura2
     END DO
68 1 pfleura2
  END IF
69 1 pfleura2
70 1 pfleura2
  IF (PROG/="VASP") THEN
71 1 pfleura2
     DO i=1,na
72 1 pfleura2
        NbLi=LIAISONS(i,0)
73 1 pfleura2
        DO j=i+1,na
74 1 pfleura2
           CALL vecteur(j,i,x,y,z,vx,vy,vz,dist)
75 1 pfleura2
           dist=dist/fact
76 1 pfleura2
           distth=(r_cov(atome(i))+r_cov(atome(j)))/100.
77 1 pfleura2
!           if (debug) WRITE(*,*) atome(i),atome(j),dist,distth
78 1 pfleura2
           if (dist.le.distth) THEN
79 1 pfleura2
              NbLi=NbLi+1
80 1 pfleura2
              LIAISONS(i,NbLi)=j;
81 1 pfleura2
              NBlj=LIAISONS(j,0)+1
82 1 pfleura2
              LIAISONS(j,Nblj)=i;
83 1 pfleura2
              LIAISONS(j,0)=Nblj
84 1 pfleura2
           END IF
85 1 pfleura2
        END DO
86 1 pfleura2
        LIAISONS(i,0)=Nbli
87 1 pfleura2
     END DO
88 1 pfleura2
  ELSE
89 1 pfleura2
     DO i=1,na
90 1 pfleura2
        NbLi=LIAISONS(i,0)
91 1 pfleura2
        DO j=i+1,na
92 1 pfleura2
           Bound=.FALSE.
93 1 pfleura2
           DO ka=-1,1
94 1 pfleura2
              DO Kb=-1,1
95 1 pfleura2
                 DO Kc=-1,1
96 1 pfleura2
                    CALL VectorPer(j,i,ka,kb,kc,x,y,z,vx,vy,vz,dist)
97 1 pfleura2
                    dist=dist/fact
98 1 pfleura2
                    distth=(r_cov(atome(i))+r_cov(atome(j)))/100.
99 1 pfleura2
!                    if (debug) WRITE(*,*) atome(i),atome(j),dist,distth
100 1 pfleura2
                    if (dist.le.distth) Bound=.TRUE.
101 1 pfleura2
                 END DO
102 1 pfleura2
              END DO
103 1 pfleura2
           END DO
104 1 pfleura2
           IF (Bound) THEN
105 1 pfleura2
              if (debug) WRITE(*,*) "Adding a bond between:",i,j
106 1 pfleura2
              NbLi=NbLi+1
107 1 pfleura2
              LIAISONS(i,NbLi)=j;
108 1 pfleura2
              NBlj=LIAISONS(j,0)+1
109 1 pfleura2
              LIAISONS(j,Nblj)=i;
110 1 pfleura2
              LIAISONS(j,0)=Nblj
111 1 pfleura2
           END IF
112 1 pfleura2
        END DO
113 1 pfleura2
        LIAISONS(i,0)=Nbli
114 1 pfleura2
     END DO
115 1 pfleura2
  END IF
116 1 pfleura2
  if (debug) WRITE(*,*) "======================= CalcCnct  over ======================="
117 1 pfleura2
END SUBROUTINE CalcCnct