-
Notifications
You must be signed in to change notification settings - Fork 1
/
hartree_local_types.F
196 lines (143 loc) · 7.26 KB
/
hartree_local_types.F
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
120
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
!--------------------------------------------------------------------------------------------------!
! CP2K: A general program to perform molecular dynamics simulations !
! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
! !
! SPDX-License-Identifier: GPL-2.0-or-later !
!--------------------------------------------------------------------------------------------------!
! **************************************************************************************************
MODULE hartree_local_types
USE kinds, ONLY: dp
USE qs_rho_atom_types, ONLY: rho_atom_coeff
#include "./base/base_uses.f90"
IMPLICIT NONE
PRIVATE
! *** Global parameters (only in this module)
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'hartree_local_types'
! *** Define the ecoul_1center_type ***
! **************************************************************************************************
TYPE ecoul_1center_type
TYPE(rho_atom_coeff), POINTER :: Vh1_h => NULL(), Vh1_s => NULL()
REAL(dp) :: ecoul_1_h = 0.0_dp, &
ecoul_1_s = 0.0_dp, &
ecoul_1_z = 0.0_dp, &
ecoul_1_0 = 0.0_dp
END TYPE ecoul_1center_type
! **************************************************************************************************
TYPE hartree_local_type
TYPE(ecoul_1center_type), &
DIMENSION(:), POINTER :: ecoul_1c => NULL()
END TYPE hartree_local_type
! *** Public subroutines ***
PUBLIC :: allocate_ecoul_1center, &
get_hartree_local, hartree_local_create, &
hartree_local_release, set_ecoul_1c, &
set_hartree_local
! *** Public data types ***
PUBLIC :: ecoul_1center_type, hartree_local_type
CONTAINS
! **************************************************************************************************
!> \brief ...
!> \param ecoul_1c ...
!> \param natom ...
! **************************************************************************************************
SUBROUTINE allocate_ecoul_1center(ecoul_1c, natom)
TYPE(ecoul_1center_type), DIMENSION(:), POINTER :: ecoul_1c
INTEGER, INTENT(IN) :: natom
INTEGER :: iat
IF (ASSOCIATED(ecoul_1c)) THEN
CALL deallocate_ecoul_1center(ecoul_1c)
END IF
ALLOCATE (ecoul_1c(natom))
DO iat = 1, natom
ALLOCATE (ecoul_1c(iat)%Vh1_h)
NULLIFY (ecoul_1c(iat)%Vh1_h%r_coef)
ALLOCATE (ecoul_1c(iat)%Vh1_s)
NULLIFY (ecoul_1c(iat)%Vh1_s%r_coef)
END DO
END SUBROUTINE allocate_ecoul_1center
! **************************************************************************************************
!> \brief ...
!> \param ecoul_1c ...
! **************************************************************************************************
SUBROUTINE deallocate_ecoul_1center(ecoul_1c)
TYPE(ecoul_1center_type), DIMENSION(:), POINTER :: ecoul_1c
INTEGER :: iat, natom
natom = SIZE(ecoul_1c, 1)
DO iat = 1, natom
IF (ASSOCIATED(ecoul_1c(iat)%Vh1_h%r_coef)) THEN
DEALLOCATE (ecoul_1c(iat)%Vh1_h%r_coef)
END IF
DEALLOCATE (ecoul_1c(iat)%Vh1_h)
IF (ASSOCIATED(ecoul_1c(iat)%Vh1_s%r_coef)) THEN
DEALLOCATE (ecoul_1c(iat)%Vh1_s%r_coef)
END IF
DEALLOCATE (ecoul_1c(iat)%Vh1_s)
END DO
DEALLOCATE (ecoul_1c)
END SUBROUTINE deallocate_ecoul_1center
! **************************************************************************************************
!> \brief ...
!> \param hartree_local ...
!> \param ecoul_1c ...
! **************************************************************************************************
SUBROUTINE get_hartree_local(hartree_local, ecoul_1c)
TYPE(hartree_local_type), POINTER :: hartree_local
TYPE(ecoul_1center_type), DIMENSION(:), OPTIONAL, &
POINTER :: ecoul_1c
IF (PRESENT(ecoul_1c)) ecoul_1c => hartree_local%ecoul_1c
END SUBROUTINE get_hartree_local
! **************************************************************************************************
!> \brief ...
!> \param hartree_local ...
! **************************************************************************************************
SUBROUTINE hartree_local_create(hartree_local)
TYPE(hartree_local_type), POINTER :: hartree_local
ALLOCATE (hartree_local)
NULLIFY (hartree_local%ecoul_1c)
END SUBROUTINE hartree_local_create
! **************************************************************************************************
!> \brief ...
!> \param hartree_local ...
! **************************************************************************************************
SUBROUTINE hartree_local_release(hartree_local)
TYPE(hartree_local_type), POINTER :: hartree_local
IF (ASSOCIATED(hartree_local)) THEN
IF (ASSOCIATED(hartree_local%ecoul_1c)) THEN
CALL deallocate_ecoul_1center(hartree_local%ecoul_1c)
END IF
DEALLOCATE (hartree_local)
END IF
END SUBROUTINE hartree_local_release
! **************************************************************************************************
!> \brief ...
!> \param ecoul_1c ...
!> \param iatom ...
!> \param ecoul_1_h ...
!> \param ecoul_1_s ...
!> \param ecoul_1_z ...
!> \param ecoul_1_0 ...
! **************************************************************************************************
SUBROUTINE set_ecoul_1c(ecoul_1c, iatom, ecoul_1_h, ecoul_1_s, ecoul_1_z, ecoul_1_0)
TYPE(ecoul_1center_type), DIMENSION(:), POINTER :: ecoul_1c
INTEGER, INTENT(IN), OPTIONAL :: iatom
REAL(dp), INTENT(IN), OPTIONAL :: ecoul_1_h, ecoul_1_s, ecoul_1_z, &
ecoul_1_0
IF (PRESENT(iatom)) THEN
IF (PRESENT(ecoul_1_h)) ecoul_1c(iatom)%ecoul_1_h = ecoul_1_h
IF (PRESENT(ecoul_1_s)) ecoul_1c(iatom)%ecoul_1_s = ecoul_1_s
IF (PRESENT(ecoul_1_0)) ecoul_1c(iatom)%ecoul_1_0 = ecoul_1_0
IF (PRESENT(ecoul_1_z)) ecoul_1c(iatom)%ecoul_1_z = ecoul_1_z
END IF
END SUBROUTINE set_ecoul_1c
! **************************************************************************************************
!> \brief ...
!> \param hartree_local ...
!> \param ecoul_1c ...
! **************************************************************************************************
SUBROUTINE set_hartree_local(hartree_local, ecoul_1c)
TYPE(hartree_local_type), POINTER :: hartree_local
TYPE(ecoul_1center_type), DIMENSION(:), OPTIONAL, &
POINTER :: ecoul_1c
IF (PRESENT(ecoul_1c)) hartree_local%ecoul_1c => ecoul_1c
END SUBROUTINE set_hartree_local
END MODULE hartree_local_types