source: opesol.f@ bd2278d

Last change on this file since bd2278d was bd2278d, checked in by baerbaer <baerbaer@…>, 16 years ago

Reformatting comments and continuation marks.

Fortran 90 and higher use ! to mark comments no matter where they are in the
code. The only valid continuation marker is &.
I also added the SMMP.kdevelop.filelist to the repository to make it easier
to use kdevelop.

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/smmp/trunk@12 26dc1dd8-5c4e-0410-9ffe-d298b4865968

  • Property mode set to 100644
File size: 7.3 KB
Line 
1! **************************************************************
2!
3! This file contains the subroutines: opesol,gdtsol
4!
5! Copyright 2003-2005 Frank Eisenmenger, U.H.E. Hansmann,
6! Shura Hayryan, Chin-Ku
7! Copyright 2007 Frank Eisenmenger, U.H.E. Hansmann,
8! Jan H. Meinke, Sandipan Mohanty
9!
10! **************************************************************
11
12 subroutine opesol(nml)
13
14! ......................................................................
15! PURPOSE: derivatives of solvatation energy vs. internal variables for
16! molecule 'nml'
17!
18! NB: if the unit axis for an internal variable coincides with a
19! global axis (i.e. for torsion or bond length variation round
20! or along 'xrfax', respectively, and bd. angle var. round
21! 'zrfax'): VdW & 14 interaction partners of moving set atoms
22! should be used for calculation, instead of the mov. sets,
23! with opposite sign.
24!
25! Example: By the the way the molecule-fixed system is set up,
26! changes in Phi_1 affect atomic positions BEFORE the
27! N-C^alpha bond relatively to the space-fixed system,
28! not the moving set of Phi_1.
29!
30! CALLS: esolan, gdtsol
31! ......................................................................
32
33 include 'INCL.H'
34
35 dimension xfat(mxat),yfat(mxat),zfat(mxat),
36 & xfrat(mxat),yfrat(mxat),zfrat(mxat),
37
38 & xfvr(mxvr),yfvr(mxvr),zfvr(mxvr),
39 & xfrvr(mxvr),yfrvr(mxvr),zfrvr(mxvr)
40
41 logical lnb
42
43
44 ntlvr=nvrml(nml)
45 if (ntlvr.eq.0) then
46 write (*,'(a,i4)')
47 & ' opesol> No variables defined in molecule #',nml
48 return
49 endif
50
51 ix2=ixrfpt(2,nml) ! as indicator for situation noted above
52
53 ifivr=ivrml1(nml) ! 1st var. &
54 ilavr=ifivr+ntlvr-1 ! last var. of 'nml'
55
56 do i=ifivr,ilavr ! variables of 'nml'
57 gdeysl(i)=0.d0
58 xfvr(i)=0.d0
59 yfvr(i)=0.d0
60 zfvr(i)=0.d0
61 xfrvr(i)=0.d0
62 yfrvr(i)=0.d0
63 zfrvr(i)=0.d0
64 enddo
65
66 eysl = esolan(nml)
67
68! -------------------------------------------------- f & g for atoms
69
70 do i=iatrs1(irsml1(nml)),iatrs2(irsml2(nml))
71
72 dx = -gradan(i,1) ! f = - sigma * dA(r)/dr ( calc. in esolan() )
73 dy = -gradan(i,2)
74 dz = -gradan(i,3)
75
76 xfat(i) = dx
77 yfat(i) = dy
78 zfat(i) = dz
79
80 xi = xat(i)
81 yi = yat(i)
82 zi = zat(i)
83
84 xfrat(i) = dy*zi-dz*yi ! g = f x r
85 yfrat(i) = dz*xi-dx*zi !
86 zfrat(i) = dx*yi-dy*xi !
87
88 enddo
89
90 i1s=imsml1(nml)+nmsml(nml) ! last mov. set of 'nml' + 1
91 i1a=iadml1(nml)+nadml(nml) ! last added var. of 'nml' + 1
92
93 do io=ilavr,ifivr,-1 ! ______ loop over vars in desc. order
94
95 lnb = .false. ! = true, if situation noted above takes place
96
97 iv=iorvr(io) ! index,
98 it=ityvr(iv) ! type,
99 ia=iatvr(iv) ! primary mov. atom,
100 ib=iowat(ia) ! "base" of current var.
101
102 xb=xat(ib)
103 yb=yat(ib)
104 zb=zat(ib)
105
106 if (it.eq.3) then ! torsion
107
108 ex=xtoat(ib)
109 ey=ytoat(ib)
110 ez=ztoat(ib)
111
112 if (ib.eq.ix2) lnb = .true.
113
114 elseif (it.eq.2) then ! b.angle
115
116 ex=xbaat(ia)
117 ey=ybaat(ia)
118 ez=zbaat(ia)
119
120 if (ib.eq.ix2) lnb = .true.
121
122 elseif (it.eq.1) then ! b.length
123
124 ex=xtoat(ia)
125 ey=ytoat(ia)
126 ez=ztoat(ia)
127
128 if (ia.eq.ix2) lnb = .true.
129
130 endif
131
132 xfiv=0.d0
133 yfiv=0.d0
134 zfiv=0.d0
135 xfriv=0.d0
136 yfriv=0.d0
137 zfriv=0.d0
138
139 if (.not.lnb) then
140
141 i2s=i1s-1 ! last m.s &
142 i1s=imsvr1(iv) ! 1st m.s for var. index 'iv'
143
144 do ims=i1s,i2s ! __ loop over moving sets
145
146 i1=latms1(ims) ! 1st &
147 i2=latms2(ims) ! last mov. atom in mov. set 'ims'
148
149 do i=i1,i2 ! __ loop over atoms i ===================
150
151 xfiv = xfiv + xfat(i) ! f
152 yfiv = yfiv + yfat(i) !
153 zfiv = zfiv + zfat(i) !
154
155 xfriv = xfriv + xfrat(i) ! g
156 yfriv = yfriv + yfrat(i) !
157 zfriv = zfriv + zfrat(i) !
158
159 enddo ! ... atoms i
160 enddo ! ... m.s.
161
162 i2a=i1a-1 ! last &
163 i1a=iadvr1(iv) ! 1st 'added' var. for 'iv'
164
165 do iad=i1a,i2a ! loop over add. var.
166
167 lad=ladvr(iad)
168
169 xfiv = xfiv + xfvr(lad)
170 yfiv = yfiv + yfvr(lad)
171 zfiv = zfiv + zfvr(lad)
172 xfriv = xfriv + xfrvr(lad)
173 yfriv = yfriv + yfrvr(lad)
174 zfriv = zfriv + zfrvr(lad)
175
176 enddo
177
178 else
179
180 do ivw=ivwat1(ia),ivwat2(ia) ! vdW-domains of 'ia'
181 do j=lvwat1(ivw),lvwat2(ivw) ! .. their atoms
182
183 xfiv = xfiv - xfat(j)
184 yfiv = yfiv - yfat(j)
185 zfiv = zfiv - zfat(j)
186
187 xfriv = xfriv - xfrat(j)
188 yfriv = yfriv - yfrat(j)
189 zfriv = zfriv - zfrat(j)
190
191 enddo
192 enddo
193
194 do i14=i14at1(ia),i14at2(ia) ! 1-4 partn. of 'ia'
195 j=l14at(i14)
196
197 xfiv = xfiv - xfat(j)
198 yfiv = yfiv - yfat(j)
199 zfiv = zfiv - zfat(j)
200
201 xfriv = xfriv - xfrat(j)
202 yfriv = yfriv - yfrat(j)
203 zfriv = zfriv - zfrat(j)
204
205 enddo
206
207 endif
208
209 xfvr(iv) = xfiv
210 yfvr(iv) = yfiv
211 zfvr(iv) = zfiv
212 xfrvr(iv) = xfriv
213 yfrvr(iv) = yfriv
214 zfrvr(iv) = zfriv
215
216 if (it.eq.3.or.it.eq.2) then ! torsion,b.angle
217
218 gdeysl(iv)= (ey*zb-ez*yb)*xfiv+(ez*xb-ex*zb)*yfiv+
219 & (ex*yb-ey*xb)*zfiv
220 & +ex*xfriv+ey*yfriv+ez*zfriv
221
222 elseif (it.eq.1) then ! b.length
223
224 gdeysl(iv)= -(ex*xfiv+ey*yfiv+ez*zfiv)
225
226 endif
227
228 if (tesgrd) call gdtsol(nml,iv)
229
230 enddo ! ... variables in desc. order
231
232 return
233 end
234! *****************************
235 subroutine gdtsol(nml,iv)
236
237! .....................................................................
238! PURPOSE: calculate partial derivative of solvation energy for molecule
239! 'nml' vs. variable 'iv' NUMERICALLY and compare with
240! its value obtained analytically
241!
242! CALLS: setvar, esolan
243! .....................................................................
244
245 include 'INCL.H'
246
247 parameter (del=1.d-6)
248
249 dimension vlvrx(mxvr)
250
251
252! ____________________________ get & save values of variables
253 do i=1,ivrml1(ntlml)+nvrml(ntlml)-1
254 it=ityvr(i) ! type
255 if (it.eq.3) then ! torsion
256 vlvrx(i)=toat(iatvr(i))
257 elseif (it.eq.2) then ! b.angle
258 vlvrx(i)=baat(iatvr(i))
259 elseif (it.eq.1) then ! b.length
260 vlvrx(i)=blat(iatvr(i))
261 endif
262 enddo
263
264 ovr=vlvrx(iv)
265
266 vlvrx(iv)=ovr+del ! change variable 'iv' by 'del'
267 call setvar(nml,vlvrx)
268
269 eynw=esolan(nml)
270 gda=gdeysl(iv)
271 gdn=(eynw-eysl)/del ! numerical derivative
272
273 write (*,'(1x,2a,2(e12.6,a))') nmvr(iv),': ',gda,' (',
274 & abs(gda-gdn),')'
275
276! _________________________ restore vars
277 vlvrx(iv)=ovr
278
279 call setvar(nml,vlvrx)
280
281 return
282 end
283
Note: See TracBrowser for help on using the repository browser.