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 if (nres.lt.2) return
133 if ((nres.lt.3).and.(itype(1).eq.10)) return
134 if ((itype(1).ne.10).and.(itype(1).ne.ntyp1)) then
136 cc Derviative was calculated for oposite vector of side chain therefore
137 c there is "-" sign before gloc_sc
138 gxcart(j,1)=gxcart(j,1)-gloc_sc(1,0,icg)*
140 gcart(j,1)=gcart(j,1)+gloc_sc(1,0,icg)*
142 if ((itype(2).ne.10).and.(itype(2).ne.ntyp1)) then
143 gxcart(j,1)= gxcart(j,1)
144 & -gloc_sc(3,0,icg)*dtauangle(j,3,1,3)
145 gcart(j,1)=gcart(j,1)+gloc_sc(3,0,icg)*
150 if ((nres.ge.3).and.(itype(3).ne.10).and.(itype(3).ne.ntyp1))
153 gcart(j,1)=gcart(j,1)+gloc_sc(2,1,icg)*dtauangle(j,2,1,4)
156 c As potetnial DO NOT depend on omicron anlge their derivative is
158 c & +gloc_sc(intertyp,nres-2,icg)*dtheta(j,1,3)
160 c Calculating the remainder of dE/ddc2
162 if((itype(2).ne.10).and.(itype(2).ne.ntyp1)) then
163 if (itype(1).ne.10) gxcart(j,2)=gxcart(j,2)+
164 & gloc_sc(3,0,icg)*dtauangle(j,3,3,3)
165 if ((itype(3).ne.10).and.(nres.ge.3).and.(itype(3).ne.ntyp1))
167 gxcart(j,2)=gxcart(j,2)-gloc_sc(3,1,icg)*dtauangle(j,3,1,4)
168 cc the - above is due to different vector direction
169 gcart(j,2)=gcart(j,2)+gloc_sc(3,1,icg)*dtauangle(j,3,2,4)
172 gxcart(j,2)=gxcart(j,2)-gloc_sc(1,1,icg)*dtauangle(j,1,1,4)
173 cc the - above is due to different vector direction
174 gcart(j,2)=gcart(j,2)+gloc_sc(1,1,icg)*dtauangle(j,1,2,4)
175 c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,2,4),"gcart"
176 c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,1,4),"gx"
179 if ((itype(1).ne.10).and.(itype(1).ne.ntyp1)) then
180 gcart(j,2)=gcart(j,2)+gloc_sc(1,0,icg)*dtauangle(j,1,3,3)
181 c write(iout,*) gloc_sc(1,0,icg),dtauangle(j,1,3,3)
183 if ((itype(3).ne.10).and.(nres.ge.3)) then
184 gcart(j,2)=gcart(j,2)+gloc_sc(2,1,icg)*dtauangle(j,2,2,4)
185 c write(iout,*) gloc_sc(2,1,icg),dtauangle(j,2,2,4)
187 if ((itype(4).ne.10).and.(nres.ge.4)) then
188 gcart(j,2)=gcart(j,2)+gloc_sc(2,2,icg)*dtauangle(j,2,1,5)
189 c write(iout,*) gloc_sc(2,2,icg),dtauangle(j,2,1,5)
192 c write(iout,*) gcart(j,2),itype(2),itype(1),itype(3), "gcart2"
194 c If there are more than five residues
198 c write(iout,*) "before", gcart(j,i)
199 if (itype(i).ne.10) then
200 gxcart(j,i)=gxcart(j,i)+gloc_sc(2,i-2,icg)
201 & *dtauangle(j,2,3,i+1)
202 & -gloc_sc(1,i-1,icg)*dtauangle(j,1,1,i+2)
203 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-1,icg)
204 & *dtauangle(j,1,2,i+2)
205 c write(iout,*) "new",j,i,
206 c & gcart(j,i),gloc_sc(1,i-1,icg),dtauangle(j,1,2,i+2)
208 if (itype(i-1).ne.10) then
209 gxcart(j,i)=gxcart(j,i)+gloc_sc(3,i-2,icg)
210 &*dtauangle(j,3,3,i+1)
212 if (itype(i+1).ne.10) then
213 gxcart(j,i)=gxcart(j,i)-gloc_sc(3,i-1,icg)
214 &*dtauangle(j,3,1,i+2)
215 gcart(j,i)=gcart(j,i)+gloc_sc(3,i-1,icg)
216 &*dtauangle(j,3,2,i+2)
219 if (itype(i-1).ne.10) then
220 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-2,icg)*
221 & dtauangle(j,1,3,i+1)
223 if (itype(i+1).ne.10) then
224 gcart(j,i)=gcart(j,i)+gloc_sc(2,i-1,icg)*
225 & dtauangle(j,2,2,i+2)
226 c write(iout,*) "numer",i,gloc_sc(2,i-1,icg),
227 c & dtauangle(j,2,2,i+2)
229 if (itype(i+2).ne.10) then
230 gcart(j,i)=gcart(j,i)+gloc_sc(2,i,icg)*
231 & dtauangle(j,2,1,i+3)
236 c Setting dE/ddnres-1
239 if ((itype(nres-1).ne.10).and.(itype(nres-1).ne.ntyp1)) then
240 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(2,nres-3,icg)
241 & *dtauangle(j,2,3,nres)
242 c write (iout,*) "gxcart(nres-1)", gloc_sc(2,nres-3,icg),
243 c & dtauangle(j,2,3,nres), gxcart(j,nres-1)
244 if (itype(nres-2).ne.10) then
245 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(3,nres-3,icg)
246 & *dtauangle(j,3,3,nres)
248 if ((itype(nres).ne.10).and.(itype(nres).ne.ntyp1)) then
249 gxcart(j,nres-1)=gxcart(j,nres-1)-gloc_sc(3,nres-2,icg)
250 & *dtauangle(j,3,1,nres+1)
251 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(3,nres-2,icg)
252 & *dtauangle(j,3,2,nres+1)
255 if ((itype(nres-2).ne.10).and.(itype(nres-2).ne.ntyp1)) then
256 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(1,nres-3,icg)*
257 & dtauangle(j,1,3,nres)
259 if ((itype(nres).ne.10).and.(itype(nres).ne.ntyp1)) then
260 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(2,nres-2,icg)*
261 & dtauangle(j,2,2,nres+1)
262 c write (iout,*) "gcart(nres-1)", gloc_sc(2,nres-2,icg),
263 c & dtauangle(j,2,2,nres+1), itype(nres-1),itype(nres)
268 if ((nres.ge.3).and.(itype(nres).ne.10))then
270 gxcart(j,nres)=gxcart(j,nres)+gloc_sc(3,nres-2,icg)
271 & *dtauangle(j,3,3,nres+1)+gloc_sc(2,nres-2,icg)
272 & *dtauangle(j,2,3,nres+1)
275 c The side-chain vector derivatives