types_force.f90 5.46 KB
Newer Older
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
!--------------------------------------------------------------------------------
! Copyright (c) 2018 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------

MODULE m_types_force

IMPLICIT NONE

PRIVATE

   TYPE t_force
      COMPLEX, ALLOCATABLE :: f_a12(:,:)
      COMPLEX, ALLOCATABLE :: f_a21(:,:)
      COMPLEX, ALLOCATABLE :: f_b4(:,:)
      COMPLEX, ALLOCATABLE :: f_b8(:,:)

      COMPLEX, ALLOCATABLE :: e1cof(:,:,:)
      COMPLEX, ALLOCATABLE :: e2cof(:,:,:)
      COMPLEX, ALLOCATABLE :: aveccof(:,:,:,:)
      COMPLEX, ALLOCATABLE :: bveccof(:,:,:,:)
      COMPLEX, ALLOCATABLE :: cveccof(:,:,:,:,:)

      COMPLEX, ALLOCATABLE :: acoflo(:,:,:,:)
      COMPLEX, ALLOCATABLE :: bcoflo(:,:,:,:)

      CONTAINS
         PROCEDURE,PASS :: init1 => force_init1
         PROCEDURE,PASS :: init2 => force_init2
         PROCEDURE      :: addContribsA21A12
   END TYPE t_force

PUBLIC t_force

CONTAINS

SUBROUTINE force_init1(thisForce,input,atoms)

   USE m_types_setup

   IMPLICIT NONE

   CLASS(t_force),     INTENT(INOUT) :: thisForce
   TYPE(t_input),      INTENT(IN)    :: input
   TYPE(t_atoms),      INTENT(IN)    :: atoms

   IF (input%l_f) THEN
      ALLOCATE (thisForce%f_a12(3,atoms%ntype))
      ALLOCATE (thisForce%f_a21(3,atoms%ntype))
      ALLOCATE (thisForce%f_b4(3,atoms%ntype))
      ALLOCATE (thisForce%f_b8(3,atoms%ntype))
   ELSE
      ALLOCATE (thisForce%f_a12(1,1))
      ALLOCATE (thisForce%f_a21(1,1))
      ALLOCATE (thisForce%f_b4(1,1))
      ALLOCATE (thisForce%f_b8(1,1))
   END IF

   thisForce%f_a12 = CMPLX(0.0,0.0)
   thisForce%f_a21 = CMPLX(0.0,0.0)
   thisForce%f_b4 = CMPLX(0.0,0.0)
   thisForce%f_b8 = CMPLX(0.0,0.0)

END SUBROUTINE force_init1

SUBROUTINE force_init2(thisForce,noccbd,input,atoms)

   USE m_types_setup

   IMPLICIT NONE

   CLASS(t_force),     INTENT(INOUT) :: thisForce
   TYPE(t_input),      INTENT(IN)    :: input
   TYPE(t_atoms),      INTENT(IN)    :: atoms
   INTEGER,            INTENT(IN)    :: noccbd

   IF (ALLOCATED(thisForce%e1cof)) DEALLOCATE(thisForce%e1cof)
   IF (ALLOCATED(thisForce%e2cof)) DEALLOCATE(thisForce%e2cof)
   IF (ALLOCATED(thisForce%acoflo)) DEALLOCATE(thisForce%acoflo)
   IF (ALLOCATED(thisForce%bcoflo)) DEALLOCATE(thisForce%bcoflo)
   IF (ALLOCATED(thisForce%aveccof)) DEALLOCATE(thisForce%aveccof)
   IF (ALLOCATED(thisForce%bveccof)) DEALLOCATE(thisForce%bveccof)
   IF (ALLOCATED(thisForce%cveccof)) DEALLOCATE(thisForce%cveccof)

   IF (input%l_f) THEN
      ALLOCATE (thisForce%e1cof(noccbd,0:atoms%lmaxd*(atoms%lmaxd+2),atoms%nat))
      ALLOCATE (thisForce%e2cof(noccbd,0:atoms%lmaxd*(atoms%lmaxd+2),atoms%nat))
      ALLOCATE (thisForce%acoflo(-atoms%llod:atoms%llod,noccbd,atoms%nlod,atoms%nat))
      ALLOCATE (thisForce%bcoflo(-atoms%llod:atoms%llod,noccbd,atoms%nlod,atoms%nat))
      ALLOCATE (thisForce%aveccof(3,noccbd,0:atoms%lmaxd*(atoms%lmaxd+2),atoms%nat))
      ALLOCATE (thisForce%bveccof(3,noccbd,0:atoms%lmaxd*(atoms%lmaxd+2),atoms%nat))
      ALLOCATE (thisForce%cveccof(3,-atoms%llod:atoms%llod,noccbd,atoms%nlod,atoms%nat))
   ELSE
      ALLOCATE (thisForce%e1cof(1,1,1))
      ALLOCATE (thisForce%e2cof(1,1,1))
      ALLOCATE (thisForce%acoflo(1,1,1,1))
      ALLOCATE (thisForce%bcoflo(1,1,1,1))
      ALLOCATE (thisForce%aveccof(1,1,1,1))
      ALLOCATE (thisForce%bveccof(1,1,1,1))
      ALLOCATE (thisForce%cveccof(1,1,1,1,1))
   END IF

   thisForce%e1cof = CMPLX(0.0,0.0)
   thisForce%e2cof = CMPLX(0.0,0.0)
   thisForce%acoflo = CMPLX(0.0,0.0)
   thisForce%bcoflo = CMPLX(0.0,0.0)
   thisForce%aveccof = CMPLX(0.0,0.0)
   thisForce%bveccof = CMPLX(0.0,0.0)
   thisForce%cveccof = CMPLX(0.0,0.0)

END SUBROUTINE force_init2

SUBROUTINE addContribsA21A12(thisForce,input,atoms,dimension,sym,cell,oneD,enpara,&
                             usdus,eigVecCoeffs,noccbd,ispin,eig,we,results)

   USE m_types_setup
   USE m_types_usdus
   USE m_types_enpara
120
   USE m_types_cdnval, ONLY: t_eigVecCoeffs
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
   USE m_types_misc
   USE m_forcea12
   USE m_forcea21

   IMPLICIT NONE

   CLASS(t_force),       INTENT(INOUT) :: thisForce
   TYPE(t_input),        INTENT(IN)    :: input
   TYPE(t_atoms),        INTENT(IN)    :: atoms
   TYPE(t_dimension),    INTENT(IN)    :: dimension
   TYPE(t_sym),          INTENT(IN)    :: sym
   TYPE(t_cell),         INTENT(IN)    :: cell
   TYPE(t_oneD),         INTENT(IN)    :: oneD
   TYPE(t_enpara),       INTENT(IN)    :: enpara
   TYPE(t_usdus),        INTENT(IN)    :: usdus
   TYPE(t_eigVecCoeffs), INTENT(IN)    :: eigVecCoeffs
   TYPE(t_results),      INTENT(INOUT) :: results

   INTEGER,              INTENT(IN)    :: noccbd
   INTEGER,              INTENT(IN)    :: ispin

   REAL,                 INTENT(IN)    :: eig(noccbd)
   REAL,                 INTENT(IN)    :: we(noccbd)

   IF (.NOT.input%l_useapw) THEN
      CALL force_a12(atoms,noccbd,sym,dimension,cell,oneD,&
                     we,ispin,noccbd,usdus,eigVecCoeffs,thisForce%acoflo,thisForce%bcoflo,&
                     thisForce%e1cof,thisForce%e2cof,thisForce%f_a12,results)
   END IF
   CALL force_a21(input,atoms,dimension,sym,oneD,cell,we,ispin,&
                  enpara%el0(0:,:,ispin),noccbd,eig,usdus,eigVecCoeffs,&
                  thisForce%aveccof,thisForce%bveccof,thisForce%cveccof,&
                  thisForce%f_a21,thisForce%f_b4,results)

END SUBROUTINE addContribsA21A12

END MODULE m_types_force