-
Notifications
You must be signed in to change notification settings - Fork 1
/
gle_system_types.F
250 lines (217 loc) · 9.4 KB
/
gle_system_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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
!--------------------------------------------------------------------------------------------------!
! 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 !
!--------------------------------------------------------------------------------------------------!
! **************************************************************************************************
!> \brief
!> \par History
!> \author MI 07.2009
! **************************************************************************************************
MODULE gle_system_types
USE bibliography, ONLY: Ceriotti2009,&
Ceriotti2009b,&
cite_reference
USE extended_system_types, ONLY: create_map_info_type,&
map_info_type,&
release_map_info_type
USE input_section_types, ONLY: section_vals_type,&
section_vals_val_get
USE kinds, ONLY: dp
USE parallel_rng_types, ONLY: GAUSSIAN,&
next_rng_seed,&
rng_stream_type
USE string_utilities, ONLY: compress
#include "./base/base_uses.f90"
IMPLICIT NONE
PRIVATE
PUBLIC :: gle_dealloc, &
gle_init, gle_thermo_create, &
gle_type
!
TYPE gle_thermo_type
INTEGER :: degrees_of_freedom = -1
REAL(KIND=dp) :: nkt = 0.0_dp, kin_energy = 0.0_dp, thermostat_energy = 0.0_dp
REAL(KIND=dp), DIMENSION(:), POINTER :: s => NULL()
TYPE(rng_stream_type) :: gaussian_rng_stream = rng_stream_type()
END TYPE gle_thermo_type
! **************************************************************************************************
TYPE gle_type
INTEGER :: ndim = -1
INTEGER :: glob_num_gle = -1, loc_num_gle = -1, region = -1
INTEGER, DIMENSION(:), POINTER :: mal => NULL()
REAL(dp) :: temp = 0.0_dp, dt = 0.0_dp, dt_fact = 0.0_dp
REAL(dp), POINTER :: gle_s(:, :) => NULL(), gle_t(:, :) => NULL()
REAL(dp), POINTER :: a_mat(:, :) => NULL(), c_mat(:, :) => NULL()
TYPE(gle_thermo_type), POINTER :: nvt(:) => NULL()
TYPE(map_info_type), POINTER :: map_info => NULL()
END TYPE gle_type
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'gle_system_types'
CONTAINS
! **************************************************************************************************
!> \brief ...
!> \param gle ...
!> \param dt ...
!> \param temp ...
!> \param section ...
!> \param
! **************************************************************************************************
SUBROUTINE gle_init(gle, dt, temp, section)
TYPE(gle_type), POINTER :: gle
REAL(dp), INTENT(IN) :: dt, temp
TYPE(section_vals_type), POINTER :: section
INTEGER :: i, ir, j, k, n_rep
REAL(dp), DIMENSION(:), POINTER :: list
REAL(KIND=dp) :: a_scale
NULLIFY (gle%nvt)
NULLIFY (gle%gle_s)
NULLIFY (gle%gle_t)
NULLIFY (gle%map_info)
gle%loc_num_gle = 0
gle%glob_num_gle = 0
gle%temp = temp
gle%dt = dt*0.5_dp
CALL cite_reference(Ceriotti2009)
CALL cite_reference(Ceriotti2009b)
CALL section_vals_val_get(section, "NDIM", i_val=gle%ndim)
CALL section_vals_val_get(section, "A_SCALE", r_val=a_scale)
ALLOCATE (gle%a_mat(gle%ndim, gle%ndim))
ALLOCATE (gle%c_mat(gle%ndim, gle%ndim))
ALLOCATE (gle%gle_s(gle%ndim, gle%ndim))
ALLOCATE (gle%gle_t(gle%ndim, gle%ndim))
CALL section_vals_val_get(section, "A_LIST", n_rep_val=n_rep)
j = 1
k = 1
DO ir = 1, n_rep
NULLIFY (list)
CALL section_vals_val_get(section, "A_LIST", &
i_rep_val=ir, r_vals=list)
IF (ASSOCIATED(list)) THEN
DO i = 1, SIZE(list)
IF (j > gle%ndim) THEN
CPABORT("GLE: Too many elements in A_LIST")
END IF
gle%a_mat(j, k) = list(i)
k = k + 1
IF (k > gle%ndim) THEN
k = 1
j = j + 1
END IF
END DO
END IF
END DO ! ir
IF (j < gle%ndim + 1) THEN
CPABORT("GLE: Too few elements in A_LIST")
END IF
gle%a_mat = gle%a_mat*a_scale
CALL section_vals_val_get(section, "C_LIST", n_rep_val=n_rep)
IF (n_rep > 0) THEN
j = 1
k = 1
DO ir = 1, n_rep
NULLIFY (list)
CALL section_vals_val_get(section, "C_LIST", &
i_rep_val=ir, r_vals=list)
IF (ASSOCIATED(list)) THEN
DO i = 1, SIZE(list)
IF (j > gle%ndim) THEN
CPABORT("GLE: Too many elements in C_LIST")
END IF
gle%c_mat(j, k) = list(i)
k = k + 1
IF (k > gle%ndim) THEN
k = 1
j = j + 1
END IF
END DO
END IF
END DO ! ir
IF (j < gle%ndim + 1) THEN
CPABORT("GLE: Too few elements in C_LIST")
END IF
ELSE
gle%c_mat = 0.0_dp
DO i = 1, gle%ndim
gle%c_mat(i, i) = gle%temp
END DO
END IF
CALL create_map_info_type(gle%map_info)
END SUBROUTINE gle_init
! **************************************************************************************************
!> \brief ...
!> \param gle ...
!> \param mal_size ...
!> \param
! **************************************************************************************************
SUBROUTINE gle_thermo_create(gle, mal_size)
TYPE(gle_type), POINTER :: gle
INTEGER, INTENT(IN) :: mal_size
CHARACTER(LEN=40) :: name
INTEGER :: i, ithermo, my_index
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :) :: seed
REAL(KIND=dp), DIMENSION(3, 2) :: initial_seed, my_seed
CPASSERT(ASSOCIATED(gle))
CPASSERT(.NOT. ASSOCIATED(gle%nvt))
ALLOCATE (gle%nvt(gle%loc_num_gle))
DO i = 1, gle%loc_num_gle
NULLIFY (gle%nvt(i)%s)
ALLOCATE (gle%nvt(i)%s(gle%ndim))
gle%nvt(i)%kin_energy = 0.0_dp
gle%nvt(i)%thermostat_energy = 0.0_dp
END DO
ALLOCATE (gle%mal(mal_size))
gle%mal(:) = 0
! Initialize the gaussian stream random number
initial_seed = next_rng_seed()
ALLOCATE (seed(3, 2, gle%glob_num_gle))
seed(:, :, 1) = initial_seed
DO ithermo = 2, gle%glob_num_gle
seed(:, :, ithermo) = next_rng_seed(seed(:, :, ithermo - 1))
END DO
! Update initial seed
initial_seed = next_rng_seed(seed(:, :, gle%glob_num_gle))
DO ithermo = 1, gle%loc_num_gle
my_index = gle%map_info%index(ithermo)
my_seed = seed(:, :, my_index)
WRITE (UNIT=name, FMT="(A,I8)") "Wiener process for Thermostat #", my_index
CALL compress(name)
gle%nvt(ithermo)%gaussian_rng_stream = rng_stream_type( &
name=name, distribution_type=GAUSSIAN, extended_precision=.TRUE., seed=my_seed)
END DO
DEALLOCATE (seed)
END SUBROUTINE gle_thermo_create
! **************************************************************************************************
!> \brief Deallocate type for GLE thermostat
!> \param gle ...
! **************************************************************************************************
SUBROUTINE gle_dealloc(gle)
TYPE(gle_type), POINTER :: gle
INTEGER :: i
IF (ASSOCIATED(gle)) THEN
IF (ASSOCIATED(gle%a_mat)) THEN
DEALLOCATE (gle%a_mat)
END IF
IF (ASSOCIATED(gle%c_mat)) THEN
DEALLOCATE (gle%c_mat)
END IF
IF (ASSOCIATED(gle%gle_t)) THEN
DEALLOCATE (gle%gle_t)
END IF
IF (ASSOCIATED(gle%gle_s)) THEN
DEALLOCATE (gle%gle_s)
END IF
IF (ASSOCIATED(gle%nvt)) THEN
DO i = 1, SIZE(gle%nvt)
DEALLOCATE (gle%nvt(i)%s)
END DO
DEALLOCATE (gle%nvt)
END IF
IF (ASSOCIATED(gle%mal)) THEN
DEALLOCATE (gle%mal)
END IF
CALL release_map_info_type(gle%map_info)
DEALLOCATE (gle)
END IF
END SUBROUTINE gle_dealloc
END MODULE gle_system_types