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 print *,"wchodze22",ialph(2,1)
89 gcart(j,nres-2)=gcart(j,nres-2)+gloc(nres-4,icg)*
90 & dphi(j,3,nres-1)+gloc(nres-3,icg)*dphi(j,2,nres)
91 & +gloc(2*nres-6,icg)*
92 & dtheta(j,2,nres-1)+gloc(2*nres-5,icg)*dtheta(j,1,nres)
93 if(itype(nres-2).ne.10) then
94 gcart(j,nres-2)=gcart(j,nres-2)+gloc(ialph(nres-2,1),icg)*
95 & dalpha(j,2,nres-2)+gloc(ialph(nres-2,1)+nside,icg)*
98 if(itype(nres-1).ne.10) then
99 gcart(j,nres-2)=gcart(j,nres-2)+gloc(ialph(nres-1,1),icg)*
100 & dalpha(j,1,nres-1)+gloc(ialph(nres-1,1)+nside,icg)*
105 c Settind dE/ddnres-1
107 gcart(j,nres-1)=gcart(j,nres-1)+gloc(nres-3,icg)*dphi(j,3,nres)+
108 & gloc(2*nres-5,icg)*dtheta(j,2,nres)
109 if(itype(nres-1).ne.10) then
110 gcart(j,nres-1)=gcart(j,nres-1)+gloc(ialph(nres-1,1),icg)*
111 & dalpha(j,2,nres-1)+gloc(ialph(nres-1,1)+nside,icg)*
115 c The side-chain vector derivatives
117 if(itype(i).ne.10 .and. itype(i).ne.ntyp1) then
119 gxcart(j,i)=gxcart(j,i)+gloc(ialph(i,1),icg)*dalpha(j,3,i)
120 & +gloc(ialph(i,1)+nside,icg)*domega(j,3,i)
124 c----------------------------------------------------------------------
125 C INTERTYP=1 SC...Ca...Ca...Ca
126 C INTERTYP=2 Ca...Ca...Ca...SC
127 C INTERTYP=3 SC...Ca...Ca...SC
128 c calculating dE/ddc1
132 c write (iout,*) i,gloc_sc(1,i,icg)
134 C print *,"tu dochodze??"
135 if (nres.lt.2) return
136 if ((nres.lt.3).and.(itype(1).eq.10)) return
137 if ((itype(1).ne.10).and.(itype(1).ne.ntyp1)) then
139 cc Derviative was calculated for oposite vector of side chain therefore
140 c there is "-" sign before gloc_sc
141 gxcart(j,1)=gxcart(j,1)-gloc_sc(1,0,icg)*
143 gcart(j,1)=gcart(j,1)+gloc_sc(1,0,icg)*
145 if ((itype(2).ne.10).and.(itype(2).ne.ntyp1)) then
146 gxcart(j,1)= gxcart(j,1)
147 & -gloc_sc(3,0,icg)*dtauangle(j,3,1,3)
148 gcart(j,1)=gcart(j,1)+gloc_sc(3,0,icg)*
153 if ((nres.ge.3).and.(itype(3).ne.10).and.(itype(3).ne.ntyp1))
156 gcart(j,1)=gcart(j,1)+gloc_sc(2,1,icg)*dtauangle(j,2,1,4)
159 c As potetnial DO NOT depend on omicron anlge their derivative is
161 c & +gloc_sc(intertyp,nres-2,icg)*dtheta(j,1,3)
163 c Calculating the remainder of dE/ddc2
165 if((itype(2).ne.10).and.(itype(2).ne.ntyp1)) then
166 if (itype(1).ne.10) gxcart(j,2)=gxcart(j,2)+
167 & gloc_sc(3,0,icg)*dtauangle(j,3,3,3)
168 if ((itype(3).ne.10).and.(nres.ge.3).and.(itype(3).ne.ntyp1))
170 gxcart(j,2)=gxcart(j,2)-gloc_sc(3,1,icg)*dtauangle(j,3,1,4)
171 cc the - above is due to different vector direction
172 gcart(j,2)=gcart(j,2)+gloc_sc(3,1,icg)*dtauangle(j,3,2,4)
175 gxcart(j,2)=gxcart(j,2)-gloc_sc(1,1,icg)*dtauangle(j,1,1,4)
176 cc the - above is due to different vector direction
177 gcart(j,2)=gcart(j,2)+gloc_sc(1,1,icg)*dtauangle(j,1,2,4)
178 c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,2,4),"gcart"
179 c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,1,4),"gx"
182 if ((itype(1).ne.10).and.(itype(1).ne.ntyp1)) then
183 gcart(j,2)=gcart(j,2)+gloc_sc(1,0,icg)*dtauangle(j,1,3,3)
184 c write(iout,*) gloc_sc(1,0,icg),dtauangle(j,1,3,3)
186 if ((itype(3).ne.10).and.(nres.ge.3)) then
187 gcart(j,2)=gcart(j,2)+gloc_sc(2,1,icg)*dtauangle(j,2,2,4)
188 c write(iout,*) gloc_sc(2,1,icg),dtauangle(j,2,2,4)
190 if ((itype(4).ne.10).and.(nres.ge.4)) then
191 gcart(j,2)=gcart(j,2)+gloc_sc(2,2,icg)*dtauangle(j,2,1,5)
192 c write(iout,*) gloc_sc(2,2,icg),dtauangle(j,2,1,5)
195 c write(iout,*) gcart(j,2),itype(2),itype(1),itype(3), "gcart2"
197 c If there are more than five residues
201 c write(iout,*) "before", gcart(j,i)
202 if ((itype(i).ne.10).and.(itype(i).ne.ntyp1)) then
203 gxcart(j,i)=gxcart(j,i)+gloc_sc(2,i-2,icg)
204 & *dtauangle(j,2,3,i+1)
205 & -gloc_sc(1,i-1,icg)*dtauangle(j,1,1,i+2)
206 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-1,icg)
207 & *dtauangle(j,1,2,i+2)
208 c write(iout,*) "new",j,i,
209 c & gcart(j,i),gloc_sc(1,i-1,icg),dtauangle(j,1,2,i+2)
210 if (itype(i-1).ne.10) then
211 gxcart(j,i)=gxcart(j,i)+gloc_sc(3,i-2,icg)
212 &*dtauangle(j,3,3,i+1)
214 if (itype(i+1).ne.10) then
215 gxcart(j,i)=gxcart(j,i)-gloc_sc(3,i-1,icg)
216 &*dtauangle(j,3,1,i+2)
217 gcart(j,i)=gcart(j,i)+gloc_sc(3,i-1,icg)
218 &*dtauangle(j,3,2,i+2)
221 if (itype(i-1).ne.10) then
222 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-2,icg)*
223 & dtauangle(j,1,3,i+1)
225 if (itype(i+1).ne.10) then
226 gcart(j,i)=gcart(j,i)+gloc_sc(2,i-1,icg)*
227 & dtauangle(j,2,2,i+2)
228 c write(iout,*) "numer",i,gloc_sc(2,i-1,icg),
229 c & dtauangle(j,2,2,i+2)
231 if (itype(i+2).ne.10) then
232 gcart(j,i)=gcart(j,i)+gloc_sc(2,i,icg)*
233 & dtauangle(j,2,1,i+3)
238 c Setting dE/ddnres-1
241 if ((itype(nres-1).ne.10).and.(itype(nres-1).ne.ntyp1)) then
242 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(2,nres-3,icg)
243 & *dtauangle(j,2,3,nres)
244 c write (iout,*) "gxcart(nres-1)", gloc_sc(2,nres-3,icg),
245 c & dtauangle(j,2,3,nres), gxcart(j,nres-1)
246 if (itype(nres-2).ne.10) then
247 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(3,nres-3,icg)
248 & *dtauangle(j,3,3,nres)
250 if ((itype(nres).ne.10).and.(itype(nres).ne.ntyp1)) then
251 gxcart(j,nres-1)=gxcart(j,nres-1)-gloc_sc(3,nres-2,icg)
252 & *dtauangle(j,3,1,nres+1)
253 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(3,nres-2,icg)
254 & *dtauangle(j,3,2,nres+1)
257 if ((itype(nres-2).ne.10).and.(itype(nres-2).ne.ntyp1)) then
258 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(1,nres-3,icg)*
259 & dtauangle(j,1,3,nres)
261 if ((itype(nres).ne.10).and.(itype(nres).ne.ntyp1)) then
262 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(2,nres-2,icg)*
263 & dtauangle(j,2,2,nres+1)
264 c write (iout,*) "gcart(nres-1)", gloc_sc(2,nres-2,icg),
265 c & dtauangle(j,2,2,nres+1), itype(nres-1),itype(nres)
270 if ((nres.ge.3).and.(itype(nres).ne.10).and.
271 & (itype(nres).ne.ntyp1))then
273 gxcart(j,nres)=gxcart(j,nres)+gloc_sc(3,nres-2,icg)
274 & *dtauangle(j,3,3,nres+1)+gloc_sc(2,nres-2,icg)
275 & *dtauangle(j,2,3,nres+1)
278 c The side-chain vector derivatives
279 C if (SELFGUIDE.gt.0) then
281 C gcart(j,afmbeg)=gcart(j,afmbeg)+gcart(j,afmend)
282 C gcart(j,afmbeg)=0.0d0
283 C gcart(j,afmend)=0.0d0