-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm_configuration.f90
261 lines (210 loc) · 6.72 KB
/
m_configuration.f90
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
251
252
253
254
255
256
257
258
259
260
261
!----------------------------------------------------------------------
! MELQUIADES: Metropolis Monte Carlo Program !
!---------------------------------------------------------------------
!bop
!
! !Module: m_configuration
!
! !Description: This module contains a routine for
! the configurational energy calculation.
!\\
!\\
! !Interface:
!
module m_configuration
!
! !Uses:
use m_kind
use m_simtype
use m_boxtype
use m_precells
use m_zeros
use m_interaction
!
implicit none
!
! !Public member functions:
!
private
!
public :: r_configuration
!
! !Revision history:
! 06Aug 2015 Asdrubal Lozada
!
!eop
!----------------------------------------------------------------------
contains
!
!bop
!
! !Iroutine: r_configuration
!
! !Description: In this routine the configurational energy values
!are calculated by input the center of mass coordinates sequencially.
!\\
!\\
! !Interface:
!
subroutine r_configuration( edge, engconf, virconf, t, y, x, istate, iprint )
! return from this routine.
!
implicit none
!
! !Input parameters:
type(simulation), intent(inout) :: y
type(box), pointer :: x
type(temporary), intent(inout) :: t
real(rkind), dimension(:), intent(in) :: edge
real(rkind), intent(out) :: engconf, virconf
integer, intent(in) :: istate ! It's a flag for writting
logical :: iprint
!
! !Revision history:
! 06Aug 2015 Asdrubal Lozada
!
! !Remarks:
! The internal function cpu_time is called in order to measure
!the consumed time.
!
!eop
!--------------------------------------------------------
! Local variables
real(rkind), dimension(3) :: com
real(rkind) :: energy, virial, pressure
integer :: ids, jb, jb2
integer :: i, l, k, nk, m, n, iter, error
real(rkind) :: apv
!--------------------------------------------------------------
! Check time execution
real(rkind) :: start_time, stop_time
real(rkind) :: init_time, end_time
!---------------------------------------------------
ids = 0
jb = 0
jb2 = 0
iter = 0
engconf = 0.0_rkind ! Cofigurational energy
virconf = 0.0_rkind ! Virial
pressure = 0.0_rkind
if( iprint ) then
write(*,'(" Configurational Energy ")')
end if
if ( .not. y%m_solute ) then
call cpu_time(start_time)
do i = 1, y%m_mxmol-1
com(1) = x%m_cmass(1,i)
com(2) = x%m_cmass(2,i)
com(3) = x%m_cmass(3,i)
jb = i + 1
call r_interactions( com, edge, i, jb, ids, energy, virial, t, y, x )
engconf = engconf + energy
virconf = virconf + virial
pressure = y%m_dens * y%m_temper + virial/y%m_vol
end do ! i
call cpu_time(stop_time)
engconf = engconf !+ y%m_vlrc * y%m_voli
if ( iprint ) then
if(istate == 0 ) then
write(*,7000) engconf
!--------------------------------------------------------------------
write(*,*)"-------------------------------------------------------------------------------"
write(*,7100) virconf
write(*,7200) pressure
else
write(*,7001) engconf
!--------------------------------------------------------------------
write(*,*)"-------------------------------------------------------------------------------"
write(*,7101) virconf
end if
write(*,7002) stop_time - start_time
write(*,*)'-------------------------------------------------------------------'
end if ! iprint
!!* else
!!* call cpu_time(init_time)
!!* call cpu_time(start_time)
!!* do i = 1, y%m_mxmol-1
!!* logic = .false.
!!* do l = 1, y%m_iexcl
!!* if(x%m_idtype(i) == x%m_extype(l)) then
!!* logic = .true.
!!* exit
!!* end if ! id_type
!!* end do ! l
!!* if(.not.logic) then
!!* y%m_solute = .false.
!!* com(1) = x%m_cmass(1,i)
!!* com(2) = x%m_cmass(2,i)
!!* com(3) = x%m_cmass(3,i)
!!* jb = i + 1
!!* call r_interactions(com, edge, i, jb, ids, e1, t, y, x)
!!* y%m_enerne = y%m_enerne + e1(1)
!!* y%m_virial = y%m_virial + e1(2)
!!* end if ! logic
!!* end do ! i
!!* call cpu_time(stop_time)
!!* engconf1 = y%m_enerne
!!* if (istate == 0) then
!!* write(*,8000) engconf1
!!* else
!!* write(*,8001) engconf1
!!* end if
!!* write(*,8002) stop_time - start_time
!!* y%m_solute = .true.
!!* call cpu_time(start_time)
!!* do i = 1, y%m_mxmol-1
!!* logic2 = .false.
!!* do l = 1, y%m_iexcl
!!* if(x%m_idtype(i) == x%m_extype(l)) then
!!* logic2 = .true.
!!* exit
!!* end if ! id_type
!!* end do ! l
!!* if( logic2 ) then
!!* y%m_solute = .true.
!!* com(1) = x%m_cmass(1,i)
!!* com(2) = x%m_cmass(2,i)
!!* com(3) = x%m_cmass(3,i)
!!* jb2 = i + 1
!!* call r_interactions(com, edge, i, jb2, ids, e2, t, y, x)
!!* y%m_eneret = y%m_eneret + e2(1)
!!* y%m_virial = y%m_virial + e2(2)
!!* end if ! logic2
!!* end do !i
!!* call cpu_time(stop_time)
!!* call cpu_time(end_time)
!!* engconf2 = y%m_eneret
!!* if (istate == 0) then
!!* write(*,9000) engconf2
!!* else
!!* write(*,9001) engconf2
!!* end if
!!* write(*,9002) stop_time - start_time
!!* write(*,*)'------------------------------------------------------------------------'
!!* engconf = y%m_enerto ! Total configurational eniergy
!!* engconf = engconf1 + engconf2
!!* if (istate == 0) then
!!* write(*,1000) engconf
!!* else
!!* write(*,2000) engconf
!!* end if
!!* write(*,3000) end_time - init_time
!!* write(*,*)'------------------------------------------------------------------------'
end if ! Solute
7000 format(' Initial configurational energy : ',' Total',e20.10,' kcal/mol')
7001 format(' Final configurational energy : ',' Total',e20.10,' kcal/mol')
7002 format(' Time for configuration energy : ',e20.10,' seconds')
7100 format(' Initial configurational virial : ',e20.10)
7101 format(' Final configurational virial : ',' Total',e20.10,' kcal/mol')
7200 format(' Initial pressure : ',e20.10)
!!*8000 format(' Initial configuration energy. Non-excluded types : ',e20.10,' kcal/mol')
!!*8001 format(' Final configuration energy. Non-excluded types : ',e20.10,' kcal/mol')
!!*8002 format(' Time for configuration energy. Non-Excluded types: ',e20.10,' seconds')
!!*9000 format(' Initial configuration energy. Excluded types : ',e20.10,' kcal/mol')
!!*9001 format(' Final configuration energy. Excluded types : ',e20.10,' kcal/mol')
!!*9002 format(' Time for configuration energy. Excluded types : ',e20.10,' seconds')
!!*1000 format(' Total initial configurational energy : ',e20.10,' kcal/mol')
!!*2000 format(' Total final configurational energy : ',e20.10,' kcal/mol')
!!*3000 format(' Total time configurational energy : ',e20.10,' seconds')
end subroutine r_configuration
end module m_configuration