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 C print *,"wchodze22",ialph(2,1)
19 if (nres.lt.3) go to 18
21 gcart(j,1)=gcart(j,1)+gloc(1,icg)*dphi(j,1,4)
22 & +gloc(nres-2,icg)*dtheta(j,1,3)
23 if(itype(2).ne.10) then
24 gcart(j,1)=gcart(j,1)+gloc(ialph(2,1),icg)*dalpha(j,1,2)+
25 & gloc(ialph(2,1)+nside,icg)*domega(j,1,2)
28 C print *,"wchodze22",ialph(2,1)
29 c Calculating the remainder of dE/ddc2
31 gcart(j,2)=gcart(j,2)+gloc(1,icg)*dphi(j,2,4)+
32 & gloc(nres-2,icg)*dtheta(j,2,3)+gloc(nres-1,icg)*dtheta(j,1,4)
33 if(itype(2).ne.10) then
34 gcart(j,2)=gcart(j,2)+gloc(ialph(2,1),icg)*dalpha(j,2,2)+
35 & gloc(ialph(2,1)+nside,icg)*domega(j,2,2)
37 if(itype(3).ne.10) then
38 gcart(j,2)=gcart(j,2)+gloc(ialph(3,1),icg)*dalpha(j,1,3)+
39 & gloc(ialph(3,1)+nside,icg)*domega(j,1,3)
42 gcart(j,2)=gcart(j,2)+gloc(2,icg)*dphi(j,1,5)
45 C print *,"wchodze22",ialph(2,1)
46 c If there are only five residues
49 gcart(j,3)=gcart(j,3)+gloc(1,icg)*dphi(j,3,4)+gloc(2,icg)*
50 & dphi(j,2,5)+gloc(nres-1,icg)*dtheta(j,2,4)+gloc(nres,icg)*
52 if(itype(3).ne.10) then
53 gcart(j,3)=gcart(j,3)+gloc(ialph(3,1),icg)*
54 & dalpha(j,2,3)+gloc(ialph(3,1)+nside,icg)*domega(j,2,3)
56 if(itype(4).ne.10) then
57 gcart(j,3)=gcart(j,3)+gloc(ialph(4,1),icg)*
58 & dalpha(j,1,4)+gloc(ialph(4,1)+nside,icg)*domega(j,1,4)
62 c If there are more than five residues
64 C print *,"wchodze22",ialph(2,1)
66 C print *,i,ialph(i,1)+nside
68 gcart(j,i)=gcart(j,i)+gloc(i-2,icg)*dphi(j,3,i+1)
69 & +gloc(i-1,icg)*dphi(j,2,i+2)+
70 & gloc(i,icg)*dphi(j,1,i+3)+gloc(nres+i-4,icg)*dtheta(j,2,i+1)+
71 & gloc(nres+i-3,icg)*dtheta(j,1,i+2)
72 if((itype(i).ne.10).and.(itype(i).ne.ntyp1)) then
73 gcart(j,i)=gcart(j,i)+gloc(ialph(i,1),icg)*dalpha(j,2,i)+
74 & gloc(ialph(i,1)+nside,icg)*domega(j,2,i)
76 if((itype(i+1).ne.10).and.(itype(i+1).ne.ntyp1)) then
77 gcart(j,i)=gcart(j,i)+gloc(ialph(i+1,1),icg)*dalpha(j,1,i+1)
78 & +gloc(ialph(i+1,1)+nside,icg)*domega(j,1,i+1)
83 C print *,"wchodze22",ialph(2,1)
88 gcart(j,nres-2)=gcart(j,nres-2)+gloc(nres-4,icg)*
89 & dphi(j,3,nres-1)+gloc(nres-3,icg)*dphi(j,2,nres)
90 & +gloc(2*nres-6,icg)*
91 & dtheta(j,2,nres-1)+gloc(2*nres-5,icg)*dtheta(j,1,nres)
92 if(itype(nres-2).ne.10) then
93 gcart(j,nres-2)=gcart(j,nres-2)+gloc(ialph(nres-2,1),icg)*
94 & dalpha(j,2,nres-2)+gloc(ialph(nres-2,1)+nside,icg)*
97 if(itype(nres-1).ne.10) then
98 gcart(j,nres-2)=gcart(j,nres-2)+gloc(ialph(nres-1,1),icg)*
99 & dalpha(j,1,nres-1)+gloc(ialph(nres-1,1)+nside,icg)*
104 c Settind dE/ddnres-1
106 gcart(j,nres-1)=gcart(j,nres-1)+gloc(nres-3,icg)*dphi(j,3,nres)+
107 & gloc(2*nres-5,icg)*dtheta(j,2,nres)
108 if(itype(nres-1).ne.10) then
109 gcart(j,nres-1)=gcart(j,nres-1)+gloc(ialph(nres-1,1),icg)*
110 & dalpha(j,2,nres-1)+gloc(ialph(nres-1,1)+nside,icg)*
114 c The side-chain vector derivatives
116 if(itype(i).ne.10 .and. itype(i).ne.ntyp1) then
118 gxcart(j,i)=gxcart(j,i)+gloc(ialph(i,1),icg)*dalpha(j,3,i)
119 & +gloc(ialph(i,1)+nside,icg)*domega(j,3,i)
123 c----------------------------------------------------------------------
124 C INTERTYP=1 SC...Ca...Ca...Ca
125 C INTERTYP=2 Ca...Ca...Ca...SC
126 C INTERTYP=3 SC...Ca...Ca...SC
127 c calculating dE/ddc1
131 c write (iout,*) "poczotkoawy",i,gloc_sc(1,i,icg)
133 C print *,"tu dochodze??"
134 if (nres.lt.2) return
135 if ((nres.lt.3).and.(itype(1).eq.10)) return
136 if ((itype(1).ne.10).and.(itype(1).ne.ntyp1)) then
138 cc Derviative was calculated for oposite vector of side chain therefore
139 c there is "-" sign before gloc_sc
140 gxcart(j,1)=gxcart(j,1)-gloc_sc(1,0,icg)*
142 gcart(j,1)=gcart(j,1)+gloc_sc(1,0,icg)*
144 if ((itype(2).ne.10).and.(itype(2).ne.ntyp1)) then
145 gxcart(j,1)= gxcart(j,1)
146 & -gloc_sc(3,0,icg)*dtauangle(j,3,1,3)
147 gcart(j,1)=gcart(j,1)+gloc_sc(3,0,icg)*
152 if ((nres.ge.3).and.(itype(3).ne.10).and.(itype(3).ne.ntyp1))
155 gcart(j,1)=gcart(j,1)+gloc_sc(2,1,icg)*dtauangle(j,2,1,4)
158 c As potetnial DO NOT depend on omicron anlge their derivative is
160 c & +gloc_sc(intertyp,nres-2,icg)*dtheta(j,1,3)
162 c Calculating the remainder of dE/ddc2
164 if((itype(2).ne.10).and.(itype(2).ne.ntyp1)) then
165 if (itype(1).ne.10) gxcart(j,2)=gxcart(j,2)+
166 & gloc_sc(3,0,icg)*dtauangle(j,3,3,3)
167 if ((itype(3).ne.10).and.(nres.ge.3).and.(itype(3).ne.ntyp1))
169 gxcart(j,2)=gxcart(j,2)-gloc_sc(3,1,icg)*dtauangle(j,3,1,4)
170 cc the - above is due to different vector direction
171 gcart(j,2)=gcart(j,2)+gloc_sc(3,1,icg)*dtauangle(j,3,2,4)
174 gxcart(j,2)=gxcart(j,2)-gloc_sc(1,1,icg)*dtauangle(j,1,1,4)
175 cc the - above is due to different vector direction
176 gcart(j,2)=gcart(j,2)+gloc_sc(1,1,icg)*dtauangle(j,1,2,4)
177 c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,2,4),"gcart"
178 c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,1,4),"gx"
181 if ((itype(1).ne.10).and.(itype(1).ne.ntyp1)) then
182 gcart(j,2)=gcart(j,2)+gloc_sc(1,0,icg)*dtauangle(j,1,3,3)
183 c write(iout,*) gloc_sc(1,0,icg),dtauangle(j,1,3,3)
185 if ((itype(3).ne.10).and.(nres.ge.3)) then
186 gcart(j,2)=gcart(j,2)+gloc_sc(2,1,icg)*dtauangle(j,2,2,4)
187 c write(iout,*) gloc_sc(2,1,icg),dtauangle(j,2,2,4)
189 if ((itype(4).ne.10).and.(nres.ge.4)) then
190 gcart(j,2)=gcart(j,2)+gloc_sc(2,2,icg)*dtauangle(j,2,1,5)
191 c write(iout,*) gloc_sc(2,2,icg),dtauangle(j,2,1,5)
194 c write(iout,*) gcart(j,2),itype(2),itype(1),itype(3), "gcart2"
196 c If there are more than five residues
200 c write(iout,*) "before", gcart(j,i)
201 if ((itype(i).ne.10).and.(itype(i).ne.ntyp1)) then
202 gxcart(j,i)=gxcart(j,i)+gloc_sc(2,i-2,icg)
203 & *dtauangle(j,2,3,i+1)
204 & -gloc_sc(1,i-1,icg)*dtauangle(j,1,1,i+2)
205 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-1,icg)
206 & *dtauangle(j,1,2,i+2)
207 c write(iout,*) "new",j,i,
208 c & gcart(j,i),gloc_sc(1,i-1,icg),dtauangle(j,1,2,i+2)
209 if (itype(i-1).ne.10) then
210 gxcart(j,i)=gxcart(j,i)+gloc_sc(3,i-2,icg)
211 &*dtauangle(j,3,3,i+1)
213 if (itype(i+1).ne.10) then
214 gxcart(j,i)=gxcart(j,i)-gloc_sc(3,i-1,icg)
215 &*dtauangle(j,3,1,i+2)
216 gcart(j,i)=gcart(j,i)+gloc_sc(3,i-1,icg)
217 &*dtauangle(j,3,2,i+2)
220 if (itype(i-1).ne.10) then
221 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-2,icg)*
222 & dtauangle(j,1,3,i+1)
224 if (itype(i+1).ne.10) then
225 gcart(j,i)=gcart(j,i)+gloc_sc(2,i-1,icg)*
226 & dtauangle(j,2,2,i+2)
227 c write(iout,*) "numer",i,gloc_sc(2,i-1,icg),
228 c & dtauangle(j,2,2,i+2)
230 if (itype(i+2).ne.10) then
231 gcart(j,i)=gcart(j,i)+gloc_sc(2,i,icg)*
232 & dtauangle(j,2,1,i+3)
237 c Setting dE/ddnres-1
240 if ((itype(nres-1).ne.10).and.(itype(nres-1).ne.ntyp1)) then
241 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(2,nres-3,icg)
242 & *dtauangle(j,2,3,nres)
243 c write (iout,*) "gxcart(nres-1)", gloc_sc(2,nres-3,icg),
244 c & dtauangle(j,2,3,nres), gxcart(j,nres-1)
245 if (itype(nres-2).ne.10) then
246 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(3,nres-3,icg)
247 & *dtauangle(j,3,3,nres)
249 if ((itype(nres).ne.10).and.(itype(nres).ne.ntyp1)) then
250 gxcart(j,nres-1)=gxcart(j,nres-1)-gloc_sc(3,nres-2,icg)
251 & *dtauangle(j,3,1,nres+1)
252 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(3,nres-2,icg)
253 & *dtauangle(j,3,2,nres+1)
256 if ((itype(nres-2).ne.10).and.(itype(nres-2).ne.ntyp1)) then
257 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(1,nres-3,icg)*
258 & dtauangle(j,1,3,nres)
260 if ((itype(nres).ne.10).and.(itype(nres).ne.ntyp1)) then
261 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(2,nres-2,icg)*
262 & dtauangle(j,2,2,nres+1)
263 c write (iout,*) "gcart(nres-1)", gloc_sc(2,nres-2,icg),
264 c & dtauangle(j,2,2,nres+1), itype(nres-1),itype(nres)
269 if ((nres.ge.3).and.(itype(nres).ne.10).and.
270 & (itype(nres).ne.ntyp1))then
272 gxcart(j,nres)=gxcart(j,nres)+gloc_sc(3,nres-2,icg)
273 & *dtauangle(j,3,3,nres+1)+gloc_sc(2,nres-2,icg)
274 & *dtauangle(j,2,3,nres+1)
277 c The side-chain vector derivatives