2 c--------------------------------------------------------------
3 c This subroutine converts the energy derivatives from internal
4 c coordinates to cartesian coordinates
5 c-------------------------------------------------------------
6 implicit real*8 (a-h,o-z)
10 include 'COMMON.DERIV'
12 include 'COMMON.LOCAL'
13 include 'COMMON.INTERACT'
15 include 'COMMON.IOUNITS'
16 include 'COMMON.SCCOR'
17 include 'COMMON.CONTROL'
19 C print *,"wchodze22",ialph(2,1)
20 if (nres.lt.3) go to 18
22 gcart(j,1)=gcart(j,1)+gloc(1,icg)*dphi(j,1,4)
23 & +gloc(nres-2,icg)*dtheta(j,1,3)
24 if(itype(2).ne.10) then
25 gcart(j,1)=gcart(j,1)+gloc(ialph(2,1),icg)*dalpha(j,1,2)+
26 & gloc(ialph(2,1)+nside,icg)*domega(j,1,2)
29 C print *,"wchodze22",ialph(2,1)
30 c Calculating the remainder of dE/ddc2
32 gcart(j,2)=gcart(j,2)+gloc(1,icg)*dphi(j,2,4)+
33 & gloc(nres-2,icg)*dtheta(j,2,3)+gloc(nres-1,icg)*dtheta(j,1,4)
34 if(itype(2).ne.10) then
35 gcart(j,2)=gcart(j,2)+gloc(ialph(2,1),icg)*dalpha(j,2,2)+
36 & gloc(ialph(2,1)+nside,icg)*domega(j,2,2)
38 if(itype(3).ne.10) then
39 gcart(j,2)=gcart(j,2)+gloc(ialph(3,1),icg)*dalpha(j,1,3)+
40 & gloc(ialph(3,1)+nside,icg)*domega(j,1,3)
43 gcart(j,2)=gcart(j,2)+gloc(2,icg)*dphi(j,1,5)
46 C print *,"wchodze22",ialph(2,1)
47 c If there are only five residues
50 gcart(j,3)=gcart(j,3)+gloc(1,icg)*dphi(j,3,4)+gloc(2,icg)*
51 & dphi(j,2,5)+gloc(nres-1,icg)*dtheta(j,2,4)+gloc(nres,icg)*
53 if(itype(3).ne.10) then
54 gcart(j,3)=gcart(j,3)+gloc(ialph(3,1),icg)*
55 & dalpha(j,2,3)+gloc(ialph(3,1)+nside,icg)*domega(j,2,3)
57 if(itype(4).ne.10) then
58 gcart(j,3)=gcart(j,3)+gloc(ialph(4,1),icg)*
59 & dalpha(j,1,4)+gloc(ialph(4,1)+nside,icg)*domega(j,1,4)
63 c If there are more than five residues
65 C print *,"wchodze22",ialph(2,1)
67 C print *,i,ialph(i,1)+nside
69 gcart(j,i)=gcart(j,i)+gloc(i-2,icg)*dphi(j,3,i+1)
70 & +gloc(i-1,icg)*dphi(j,2,i+2)+
71 & gloc(i,icg)*dphi(j,1,i+3)+gloc(nres+i-4,icg)*dtheta(j,2,i+1)+
72 & gloc(nres+i-3,icg)*dtheta(j,1,i+2)
73 if((itype(i).ne.10).and.(itype(i).ne.ntyp1)) then
74 gcart(j,i)=gcart(j,i)+gloc(ialph(i,1),icg)*dalpha(j,2,i)+
75 & gloc(ialph(i,1)+nside,icg)*domega(j,2,i)
77 if((itype(i+1).ne.10).and.(itype(i+1).ne.ntyp1)) then
78 gcart(j,i)=gcart(j,i)+gloc(ialph(i+1,1),icg)*dalpha(j,1,i+1)
79 & +gloc(ialph(i+1,1)+nside,icg)*domega(j,1,i+1)
84 c write (iout,*) "gcart 2"
86 c write (iout,*) i,(gcart(j,i),j=1,3)
88 C print *,"wchodze22",ialph(2,1)
93 gcart(j,nres-2)=gcart(j,nres-2)+gloc(nres-4,icg)*
94 & dphi(j,3,nres-1)+gloc(nres-3,icg)*dphi(j,2,nres)
95 & +gloc(2*nres-6,icg)*
96 & dtheta(j,2,nres-1)+gloc(2*nres-5,icg)*dtheta(j,1,nres)
97 if(itype(nres-2).ne.10) then
98 gcart(j,nres-2)=gcart(j,nres-2)+gloc(ialph(nres-2,1),icg)*
99 & dalpha(j,2,nres-2)+gloc(ialph(nres-2,1)+nside,icg)*
102 if(itype(nres-1).ne.10) then
103 gcart(j,nres-2)=gcart(j,nres-2)+gloc(ialph(nres-1,1),icg)*
104 & dalpha(j,1,nres-1)+gloc(ialph(nres-1,1)+nside,icg)*
109 c Settind dE/ddnres-1
111 gcart(j,nres-1)=gcart(j,nres-1)+gloc(nres-3,icg)*dphi(j,3,nres)+
112 & gloc(2*nres-5,icg)*dtheta(j,2,nres)
113 if(itype(nres-1).ne.10) then
114 gcart(j,nres-1)=gcart(j,nres-1)+gloc(ialph(nres-1,1),icg)*
115 & dalpha(j,2,nres-1)+gloc(ialph(nres-1,1)+nside,icg)*
119 c The side-chain vector derivatives
121 if(itype(i).ne.10 .and. itype(i).ne.ntyp1) then
123 gxcart(j,i)=gxcart(j,i)+gloc(ialph(i,1),icg)*dalpha(j,3,i)
124 & +gloc(ialph(i,1)+nside,icg)*domega(j,3,i)
128 c write (iout,*) "gcart 3"
130 c write (iout,*) i,(gcart(j,i),j=1,3)
132 c----------------------------------------------------------------------
133 C INTERTYP=1 SC...Ca...Ca...Ca
134 C INTERTYP=2 Ca...Ca...Ca...SC
135 C INTERTYP=3 SC...Ca...Ca...SC
136 c calculating dE/ddc1
140 c write (iout,*) "poczotkoawy",i,gloc_sc(1,i,icg)
142 C print *,"tu dochodze??"
143 if (nres.lt.2) return
144 if ((nres.lt.3).and.(itype(1).eq.10)) return
145 if ((itype(1).ne.10).and.(itype(1).ne.ntyp1)) then
147 cc Derviative was calculated for oposite vector of side chain therefore
148 c there is "-" sign before gloc_sc
149 gxcart(j,1)=gxcart(j,1)-gloc_sc(1,0,icg)*
151 gcart(j,1)=gcart(j,1)+gloc_sc(1,0,icg)*
153 if ((itype(2).ne.10).and.(itype(2).ne.ntyp1)) then
154 gxcart(j,1)= gxcart(j,1)
155 & -gloc_sc(3,0,icg)*dtauangle(j,3,1,3)
156 gcart(j,1)=gcart(j,1)+gloc_sc(3,0,icg)*
161 if ((nres.ge.3).and.(itype(3).ne.10).and.(itype(3).ne.ntyp1))
164 gcart(j,1)=gcart(j,1)+gloc_sc(2,1,icg)*dtauangle(j,2,1,4)
167 c As potetnial DO NOT depend on omicron anlge their derivative is
169 c & +gloc_sc(intertyp,nres-2,icg)*dtheta(j,1,3)
171 c Calculating the remainder of dE/ddc2
173 if((itype(2).ne.10).and.(itype(2).ne.ntyp1)) then
174 if (itype(1).ne.10) gxcart(j,2)=gxcart(j,2)+
175 & gloc_sc(3,0,icg)*dtauangle(j,3,3,3)
176 if ((itype(3).ne.10).and.(nres.ge.3).and.(itype(3).ne.ntyp1))
178 gxcart(j,2)=gxcart(j,2)-gloc_sc(3,1,icg)*dtauangle(j,3,1,4)
179 cc the - above is due to different vector direction
180 gcart(j,2)=gcart(j,2)+gloc_sc(3,1,icg)*dtauangle(j,3,2,4)
183 gxcart(j,2)=gxcart(j,2)-gloc_sc(1,1,icg)*dtauangle(j,1,1,4)
184 cc the - above is due to different vector direction
185 gcart(j,2)=gcart(j,2)+gloc_sc(1,1,icg)*dtauangle(j,1,2,4)
186 c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,2,4),"gcart"
187 c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,1,4),"gx"
190 if ((itype(1).ne.10).and.(itype(1).ne.ntyp1)) then
191 gcart(j,2)=gcart(j,2)+gloc_sc(1,0,icg)*dtauangle(j,1,3,3)
192 c write(iout,*) gloc_sc(1,0,icg),dtauangle(j,1,3,3)
194 if ((itype(3).ne.10).and.(nres.ge.3)) then
195 gcart(j,2)=gcart(j,2)+gloc_sc(2,1,icg)*dtauangle(j,2,2,4)
196 c write(iout,*) gloc_sc(2,1,icg),dtauangle(j,2,2,4)
198 if ((itype(4).ne.10).and.(nres.ge.4)) then
199 gcart(j,2)=gcart(j,2)+gloc_sc(2,2,icg)*dtauangle(j,2,1,5)
200 c write(iout,*) gloc_sc(2,2,icg),dtauangle(j,2,1,5)
203 c write(iout,*) gcart(j,2),itype(2),itype(1),itype(3), "gcart2"
205 c If there are more than five residues
209 c write(iout,*) "before", gcart(j,i)
210 if ((itype(i).ne.10).and.(itype(i).ne.ntyp1)) then
211 gxcart(j,i)=gxcart(j,i)+gloc_sc(2,i-2,icg)
212 & *dtauangle(j,2,3,i+1)
213 & -gloc_sc(1,i-1,icg)*dtauangle(j,1,1,i+2)
214 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-1,icg)
215 & *dtauangle(j,1,2,i+2)
216 c write(iout,*) "new",j,i,
217 c & gcart(j,i),gloc_sc(1,i-1,icg),dtauangle(j,1,2,i+2)
218 if (itype(i-1).ne.10) then
219 gxcart(j,i)=gxcart(j,i)+gloc_sc(3,i-2,icg)
220 &*dtauangle(j,3,3,i+1)
222 if (itype(i+1).ne.10) then
223 gxcart(j,i)=gxcart(j,i)-gloc_sc(3,i-1,icg)
224 &*dtauangle(j,3,1,i+2)
225 gcart(j,i)=gcart(j,i)+gloc_sc(3,i-1,icg)
226 &*dtauangle(j,3,2,i+2)
229 if (itype(i-1).ne.10) then
230 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-2,icg)*
231 & dtauangle(j,1,3,i+1)
233 if (itype(i+1).ne.10) then
234 gcart(j,i)=gcart(j,i)+gloc_sc(2,i-1,icg)*
235 & dtauangle(j,2,2,i+2)
236 c write(iout,*) "numer",i,gloc_sc(2,i-1,icg),
237 c & dtauangle(j,2,2,i+2)
239 if (itype(i+2).ne.10) then
240 gcart(j,i)=gcart(j,i)+gloc_sc(2,i,icg)*
241 & dtauangle(j,2,1,i+3)
246 c Setting dE/ddnres-1
249 if ((itype(nres-1).ne.10).and.(itype(nres-1).ne.ntyp1)) then
250 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(2,nres-3,icg)
251 & *dtauangle(j,2,3,nres)
252 c write (iout,*) "gxcart(nres-1)", gloc_sc(2,nres-3,icg),
253 c & dtauangle(j,2,3,nres), gxcart(j,nres-1)
254 if (itype(nres-2).ne.10) then
255 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(3,nres-3,icg)
256 & *dtauangle(j,3,3,nres)
258 if ((itype(nres).ne.10).and.(itype(nres).ne.ntyp1)) then
259 gxcart(j,nres-1)=gxcart(j,nres-1)-gloc_sc(3,nres-2,icg)
260 & *dtauangle(j,3,1,nres+1)
261 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(3,nres-2,icg)
262 & *dtauangle(j,3,2,nres+1)
265 if ((itype(nres-2).ne.10).and.(itype(nres-2).ne.ntyp1)) then
266 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(1,nres-3,icg)*
267 & dtauangle(j,1,3,nres)
269 if ((itype(nres).ne.10).and.(itype(nres).ne.ntyp1)) then
270 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(2,nres-2,icg)*
271 & dtauangle(j,2,2,nres+1)
272 c write (iout,*) "gcart(nres-1)", gloc_sc(2,nres-2,icg),
273 c & dtauangle(j,2,2,nres+1), itype(nres-1),itype(nres)
278 if ((nres.ge.3).and.(itype(nres).ne.10).and.
279 & (itype(nres).ne.ntyp1))then
281 gxcart(j,nres)=gxcart(j,nres)+gloc_sc(3,nres-2,icg)
282 & *dtauangle(j,3,3,nres+1)+gloc_sc(2,nres-2,icg)
283 & *dtauangle(j,2,3,nres+1)
286 c write (iout,*) "gcart 4"
288 c write (iout,*) i,(gcart(j,i),j=1,3)
290 c The side-chain vector derivatives
291 C if (SELFGUIDE.gt.0) then
293 C gcart(j,afmbeg)=gcart(j,afmbeg)+gcart(j,afmend)
294 C gcart(j,afmbeg)=0.0d0
295 C gcart(j,afmend)=0.0d0