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.21)) 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.21)) 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.21))
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.21)) 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.21)) then
166 gxcart(j,2)=gxcart(j,2)-gloc_sc(3,1,icg)*dtauangle(j,3,1,4)
167 cc the - above is due to different vector direction
168 gcart(j,2)=gcart(j,2)+gloc_sc(3,1,icg)*dtauangle(j,3,2,4)
171 gxcart(j,2)=gxcart(j,2)-gloc_sc(1,1,icg)*dtauangle(j,1,1,4)
172 cc the - above is due to different vector direction
173 gcart(j,2)=gcart(j,2)+gloc_sc(1,1,icg)*dtauangle(j,1,2,4)
174 c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,2,4),"gcart"
175 c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,1,4),"gx"
178 if ((itype(1).ne.10).and.(itype(1).ne.21)) then
179 gcart(j,2)=gcart(j,2)+gloc_sc(1,0,icg)*dtauangle(j,1,3,3)
180 c write(iout,*) gloc_sc(1,0,icg),dtauangle(j,1,3,3)
182 if ((itype(3).ne.10).and.(nres.ge.3)) then
183 gcart(j,2)=gcart(j,2)+gloc_sc(2,1,icg)*dtauangle(j,2,2,4)
184 c write(iout,*) gloc_sc(2,1,icg),dtauangle(j,2,2,4)
186 if ((itype(4).ne.10).and.(nres.ge.4)) then
187 gcart(j,2)=gcart(j,2)+gloc_sc(2,2,icg)*dtauangle(j,2,1,5)
188 c write(iout,*) gloc_sc(2,2,icg),dtauangle(j,2,1,5)
191 c write(iout,*) gcart(j,2),itype(2),itype(1),itype(3), "gcart2"
193 c If there are more than five residues
197 c write(iout,*) "before", gcart(j,i)
198 if (itype(i).ne.10) then
199 gxcart(j,i)=gxcart(j,i)+gloc_sc(2,i-2,icg)
200 & *dtauangle(j,2,3,i+1)
201 & -gloc_sc(1,i-1,icg)*dtauangle(j,1,1,i+2)
202 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-1,icg)
203 & *dtauangle(j,1,2,i+2)
204 c write(iout,*) "new",j,i,
205 c & gcart(j,i),gloc_sc(1,i-1,icg),dtauangle(j,1,2,i+2)
207 if (itype(i-1).ne.10) then
208 gxcart(j,i)=gxcart(j,i)+gloc_sc(3,i-2,icg)
209 &*dtauangle(j,3,3,i+1)
211 if (itype(i+1).ne.10) then
212 gxcart(j,i)=gxcart(j,i)-gloc_sc(3,i-1,icg)
213 &*dtauangle(j,3,1,i+2)
214 gcart(j,i)=gcart(j,i)+gloc_sc(3,i-1,icg)
215 &*dtauangle(j,3,2,i+2)
218 if (itype(i-1).ne.10) then
219 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-2,icg)*
220 & dtauangle(j,1,3,i+1)
222 if (itype(i+1).ne.10) then
223 gcart(j,i)=gcart(j,i)+gloc_sc(2,i-1,icg)*
224 & dtauangle(j,2,2,i+2)
225 c write(iout,*) "numer",i,gloc_sc(2,i-1,icg),
226 c & dtauangle(j,2,2,i+2)
228 if (itype(i+2).ne.10) then
229 gcart(j,i)=gcart(j,i)+gloc_sc(2,i,icg)*
230 & dtauangle(j,2,1,i+3)
235 c Setting dE/ddnres-1
238 if ((itype(nres-1).ne.10).and.(itype(nres-1).ne.21)) then
239 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(2,nres-3,icg)
240 & *dtauangle(j,2,3,nres)
241 c write (iout,*) "gxcart(nres-1)", gloc_sc(2,nres-3,icg),
242 c & dtauangle(j,2,3,nres), gxcart(j,nres-1)
243 if (itype(nres-2).ne.10) then
244 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(3,nres-3,icg)
245 & *dtauangle(j,3,3,nres)
247 if ((itype(nres).ne.10).and.(itype(nres).ne.21)) then
248 gxcart(j,nres-1)=gxcart(j,nres-1)-gloc_sc(3,nres-2,icg)
249 & *dtauangle(j,3,1,nres+1)
250 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(3,nres-2,icg)
251 & *dtauangle(j,3,2,nres+1)
254 if ((itype(nres-2).ne.10).and.(itype(nres-2).ne.21)) then
255 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(1,nres-3,icg)*
256 & dtauangle(j,1,3,nres)
258 if ((itype(nres).ne.10).and.(itype(nres).ne.21)) then
259 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(2,nres-2,icg)*
260 & dtauangle(j,2,2,nres+1)
261 c write (iout,*) "gcart(nres-1)", gloc_sc(2,nres-2,icg),
262 c & dtauangle(j,2,2,nres+1), itype(nres-1),itype(nres)
267 if ((nres.ge.3).and.(itype(nres).ne.10))then
269 gxcart(j,nres)=gxcart(j,nres)+gloc_sc(3,nres-2,icg)
270 & *dtauangle(j,3,3,nres+1)+gloc_sc(2,nres-2,icg)
271 & *dtauangle(j,2,3,nres+1)
274 c The side-chain vector derivatives