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'
18 if (nres.lt.3) goto 18
21 c write (iout,*) "przed tosyjnymi",i,intertyp,gcart(intertyp,i)
22 c &,gloc_sc(1,i,icg),gloc(i,icg)
26 gcart(j,1)=gcart(j,1)+gloc(1,icg)*dphi(j,1,4)
27 & +gloc(nres-2,icg)*dtheta(j,1,3)
28 if(itype(2).ne.10) then
29 gcart(j,1)=gcart(j,1)+gloc(ialph(2,1),icg)*dalpha(j,1,2)+
30 & gloc(ialph(2,1)+nside,icg)*domega(j,1,2)
33 c Calculating the remainder of dE/ddc2
35 gcart(j,2)=gcart(j,2)+gloc(1,icg)*dphi(j,2,4)+
36 & gloc(nres-2,icg)*dtheta(j,2,3)+gloc(nres-1,icg)*dtheta(j,1,4)
37 if(itype(2).ne.10) then
38 gcart(j,2)=gcart(j,2)+gloc(ialph(2,1),icg)*dalpha(j,2,2)+
39 & gloc(ialph(2,1)+nside,icg)*domega(j,2,2)
41 if(itype(3).ne.10) then
42 gcart(j,2)=gcart(j,2)+gloc(ialph(3,1),icg)*dalpha(j,1,3)+
43 & gloc(ialph(3,1)+nside,icg)*domega(j,1,3)
46 gcart(j,2)=gcart(j,2)+gloc(2,icg)*dphi(j,1,5)
49 c If there are only five residues
52 gcart(j,3)=gcart(j,3)+gloc(1,icg)*dphi(j,3,4)+gloc(2,icg)*
53 & dphi(j,2,5)+gloc(nres-1,icg)*dtheta(j,2,4)+gloc(nres,icg)*
55 if(itype(3).ne.10) then
56 gcart(j,3)=gcart(j,3)+gloc(ialph(3,1),icg)*
57 & dalpha(j,2,3)+gloc(ialph(3,1)+nside,icg)*domega(j,2,3)
59 if(itype(4).ne.10) then
60 gcart(j,3)=gcart(j,3)+gloc(ialph(4,1),icg)*
61 & dalpha(j,1,4)+gloc(ialph(4,1)+nside,icg)*domega(j,1,4)
65 c If there are more than five residues
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) 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) 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)
87 gcart(j,nres-2)=gcart(j,nres-2)+gloc(nres-4,icg)*
88 & dphi(j,3,nres-1)+gloc(nres-3,icg)*dphi(j,2,nres)
89 & +gloc(2*nres-6,icg)*
90 & dtheta(j,2,nres-1)+gloc(2*nres-5,icg)*dtheta(j,1,nres)
91 if(itype(nres-2).ne.10) then
92 gcart(j,nres-2)=gcart(j,nres-2)+gloc(ialph(nres-2,1),icg)*
93 & dalpha(j,2,nres-2)+gloc(ialph(nres-2,1)+nside,icg)*
96 if(itype(nres-1).ne.10) then
97 gcart(j,nres-2)=gcart(j,nres-2)+gloc(ialph(nres-1,1),icg)*
98 & dalpha(j,1,nres-1)+gloc(ialph(nres-1,1)+nside,icg)*
103 c Settind dE/ddnres-1
105 gcart(j,nres-1)=gcart(j,nres-1)+gloc(nres-3,icg)*dphi(j,3,nres)+
106 & gloc(2*nres-5,icg)*dtheta(j,2,nres)
107 if(itype(nres-1).ne.10) then
108 gcart(j,nres-1)=gcart(j,nres-1)+gloc(ialph(nres-1,1),icg)*
109 & dalpha(j,2,nres-1)+gloc(ialph(nres-1,1)+nside,icg)*
113 c The side-chain vector derivatives
115 if(itype(i).ne.10) then
117 gxcart(j,i)=gxcart(j,i)+gloc(ialph(i,1),icg)*dalpha(j,3,i)
118 & +gloc(ialph(i,1)+nside,icg)*domega(j,3,i)
122 c----------------------------------------------------------------------
123 C INTERTYP=1 SC...Ca...Ca...Ca
124 C INTERTYP=2 Ca...Ca...Ca...SC
125 C INTERTYP=3 SC...Ca...Ca...SC
126 c calculating dE/ddc1
130 c write (iout,*) "poczotkoawy",i,gloc_sc(1,i,icg)
132 c write (iout,*) "dtauangle"
137 c write (iout,*) (dtauangle(l,k,j,i),l=1,3)
141 if (nres.lt.2) return
142 if ((nres.lt.3).and.(itype(1).eq.10)) return
143 if ((itype(1).ne.10).and.(itype(1).ne.21)) then
145 cc Derviative was calculated for oposite vector of side chain therefore
146 c there is "-" sign before gloc_sc
147 gxcart(j,1)=gxcart(j,1)-gloc_sc(1,0,icg)*
149 gcart(j,1)=gcart(j,1)+gloc_sc(1,0,icg)*
151 if ((itype(2).ne.10).and.(itype(2).ne.21)) then
152 gxcart(j,1)= gxcart(j,1)
153 & -gloc_sc(3,0,icg)*dtauangle(j,3,1,3)
154 gcart(j,1)=gcart(j,1)+gloc_sc(3,0,icg)*
159 if ((nres.ge.3).and.(itype(3).ne.10).and.(itype(3).ne.21))
162 gcart(j,1)=gcart(j,1)+gloc_sc(2,1,icg)*dtauangle(j,2,1,4)
165 c As potetnial DO NOT depend on omicron anlge their derivative is
167 c & +gloc_sc(intertyp,nres-2,icg)*dtheta(j,1,3)
169 c Calculating the remainder of dE/ddc2
171 if((itype(2).ne.10).and.(itype(2).ne.21)) then
172 if (itype(1).ne.10) gxcart(j,2)=gxcart(j,2)+
173 & gloc_sc(3,0,icg)*dtauangle(j,3,3,3)
174 if ((itype(3).ne.10).and.(nres.ge.3).and.(itype(3).ne.21)) then
175 gxcart(j,2)=gxcart(j,2)-gloc_sc(3,1,icg)*dtauangle(j,3,1,4)
176 cc the - above is due to different vector direction
177 gcart(j,2)=gcart(j,2)+gloc_sc(3,1,icg)*dtauangle(j,3,2,4)
180 gxcart(j,2)=gxcart(j,2)-gloc_sc(1,1,icg)*dtauangle(j,1,1,4)
181 cc the - above is due to different vector direction
182 gcart(j,2)=gcart(j,2)+gloc_sc(1,1,icg)*dtauangle(j,1,2,4)
183 c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,2,4),"gcart"
184 c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,1,4),"gx"
187 if ((itype(1).ne.10).and.(itype(1).ne.21)) then
188 gcart(j,2)=gcart(j,2)+gloc_sc(1,0,icg)*dtauangle(j,1,3,3)
189 c write(iout,*) gloc_sc(1,0,icg),dtauangle(j,1,3,3)
191 if ((itype(3).ne.10).and.(nres.ge.3)) then
192 gcart(j,2)=gcart(j,2)+gloc_sc(2,1,icg)*dtauangle(j,2,2,4)
193 c write(iout,*) gloc_sc(2,1,icg),dtauangle(j,2,2,4)
195 if ((itype(4).ne.10).and.(nres.ge.4)) then
196 gcart(j,2)=gcart(j,2)+gloc_sc(2,2,icg)*dtauangle(j,2,1,5)
197 c write(iout,*) gloc_sc(2,2,icg),dtauangle(j,2,1,5)
200 c write(iout,*) gcart(j,2),itype(2),itype(1),itype(3), "gcart2"
202 c If there are more than five residues
206 c write(iout,*) "before", gcart(j,i)
207 if (itype(i).ne.10) then
208 gxcart(j,i)=gxcart(j,i)+gloc_sc(2,i-2,icg)
209 & *dtauangle(j,2,3,i+1)
210 & -gloc_sc(1,i-1,icg)*dtauangle(j,1,1,i+2)
211 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-1,icg)
212 & *dtauangle(j,1,2,i+2)
213 c write(iout,*) "new",j,i,
214 c & gcart(j,i),gloc_sc(1,i-1,icg),dtauangle(j,1,2,i+2)
216 if (itype(i-1).ne.10) then
217 gxcart(j,i)=gxcart(j,i)+gloc_sc(3,i-2,icg)
218 &*dtauangle(j,3,3,i+1)
220 if (itype(i+1).ne.10) then
221 gxcart(j,i)=gxcart(j,i)-gloc_sc(3,i-1,icg)
222 &*dtauangle(j,3,1,i+2)
223 gcart(j,i)=gcart(j,i)+gloc_sc(3,i-1,icg)
224 &*dtauangle(j,3,2,i+2)
227 if (itype(i-1).ne.10) then
228 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-2,icg)*
229 & dtauangle(j,1,3,i+1)
231 if (itype(i+1).ne.10) then
232 gcart(j,i)=gcart(j,i)+gloc_sc(2,i-1,icg)*
233 & dtauangle(j,2,2,i+2)
234 c write(iout,*) "numer",i,gloc_sc(2,i-1,icg),
235 c & dtauangle(j,2,2,i+2)
237 if (itype(i+2).ne.10) then
238 gcart(j,i)=gcart(j,i)+gloc_sc(2,i,icg)*
239 & dtauangle(j,2,1,i+3)
244 c Setting dE/ddnres-1
247 if ((itype(nres-1).ne.10).and.(itype(nres-1).ne.21)) then
248 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(2,nres-3,icg)
249 & *dtauangle(j,2,3,nres)
250 c write (iout,*) "gxcart(nres-1)", gloc_sc(2,nres-3,icg),
251 c & dtauangle(j,2,3,nres), gxcart(j,nres-1)
252 if (itype(nres-2).ne.10) then
253 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(3,nres-3,icg)
254 & *dtauangle(j,3,3,nres)
256 if ((itype(nres).ne.10).and.(itype(nres).ne.21)) then
257 gxcart(j,nres-1)=gxcart(j,nres-1)-gloc_sc(3,nres-2,icg)
258 & *dtauangle(j,3,1,nres+1)
259 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(3,nres-2,icg)
260 & *dtauangle(j,3,2,nres+1)
263 if ((itype(nres-2).ne.10).and.(itype(nres-2).ne.21)) then
264 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(1,nres-3,icg)*
265 & dtauangle(j,1,3,nres)
267 if ((itype(nres).ne.10).and.(itype(nres).ne.21)) then
268 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(2,nres-2,icg)*
269 & dtauangle(j,2,2,nres+1)
270 c write (iout,*) "gcart(nres-1)", gloc_sc(2,nres-2,icg),
271 c & dtauangle(j,2,2,nres+1), itype(nres-1),itype(nres)
276 if ((nres.ge.3).and.(itype(nres).ne.10))then
278 gxcart(j,nres)=gxcart(j,nres)+gloc_sc(3,nres-2,icg)
279 & *dtauangle(j,3,3,nres+1)+gloc_sc(2,nres-2,icg)
280 & *dtauangle(j,2,3,nres+1)
283 c The side-chain vector derivatives