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) go to 18
20 gcart(j,1)=gcart(j,1)+gloc(1,icg)*dphi(j,1,4)
21 & +gloc(nres-2,icg)*dtheta(j,1,3)
22 if(itype(2).ne.10) then
23 gcart(j,1)=gcart(j,1)+gloc(ialph(2,1),icg)*dalpha(j,1,2)+
24 & gloc(ialph(2,1)+nside,icg)*domega(j,1,2)
27 C write (iout,*) "????A CO TO??"
28 c Calculating the remainder of dE/ddc2
30 gcart(j,2)=gcart(j,2)+gloc(1,icg)*dphi(j,2,4)+
31 & gloc(nres-2,icg)*dtheta(j,2,3)+gloc(nres-1,icg)*dtheta(j,1,4)
32 if((itype(2).ne.10).and.(itype(2).ne.ntyp1)) then
33 gcart(j,2)=gcart(j,2)+gloc(ialph(2,1),icg)*dalpha(j,2,2)+
34 & gloc(ialph(2,1)+nside,icg)*domega(j,2,2)
36 if((itype(3).ne.10).and.(itype(3).ne.21)) then
37 gcart(j,2)=gcart(j,2)+gloc(ialph(3,1),icg)*dalpha(j,1,3)+
38 & gloc(ialph(3,1)+nside,icg)*domega(j,1,3)
41 gcart(j,2)=gcart(j,2)+gloc(2,icg)*dphi(j,1,5)
44 c If there are only five residues
47 gcart(j,3)=gcart(j,3)+gloc(1,icg)*dphi(j,3,4)+gloc(2,icg)*
48 & dphi(j,2,5)+gloc(nres-1,icg)*dtheta(j,2,4)+gloc(nres,icg)*
50 if(itype(3).ne.10) then
51 gcart(j,3)=gcart(j,3)+gloc(ialph(3,1),icg)*
52 & dalpha(j,2,3)+gloc(ialph(3,1)+nside,icg)*domega(j,2,3)
54 if(itype(4).ne.10) then
55 gcart(j,3)=gcart(j,3)+gloc(ialph(4,1),icg)*
56 & dalpha(j,1,4)+gloc(ialph(4,1)+nside,icg)*domega(j,1,4)
60 C write (iout,*) "Poniezej blad??",ialph(3,1),nside,ialph(4,1)
61 c If there are more than five residues
65 gcart(j,i)=gcart(j,i)+gloc(i-2,icg)*dphi(j,3,i+1)
66 & +gloc(i-1,icg)*dphi(j,2,i+2)+
67 & gloc(i,icg)*dphi(j,1,i+3)+gloc(nres+i-4,icg)*dtheta(j,2,i+1)+
68 & gloc(nres+i-3,icg)*dtheta(j,1,i+2)
69 if((itype(i).ne.10).and.(itype(i).ne.ntyp1)) then
70 gcart(j,i)=gcart(j,i)+gloc(ialph(i,1),icg)*dalpha(j,2,i)+
71 & gloc(ialph(i,1)+nside,icg)*domega(j,2,i)
73 if((itype(i+1).ne.10).and.(itype(i+1).ne.ntyp1)) then
74 gcart(j,i)=gcart(j,i)+gloc(ialph(i+1,1),icg)*dalpha(j,1,i+1)
75 & +gloc(ialph(i+1,1)+nside,icg)*domega(j,1,i+1)
81 C write(iout,*) "ATUCHUJ?"
84 gcart(j,nres-2)=gcart(j,nres-2)+gloc(nres-4,icg)*
85 & dphi(j,3,nres-1)+gloc(nres-3,icg)*dphi(j,2,nres)
86 & +gloc(2*nres-6,icg)*
87 & dtheta(j,2,nres-1)+gloc(2*nres-5,icg)*dtheta(j,1,nres)
88 if((itype(nres-2).ne.10).and.(itype(nres-2).ne.ntyp1)) then
89 gcart(j,nres-2)=gcart(j,nres-2)+gloc(ialph(nres-2,1),icg)*
90 & dalpha(j,2,nres-2)+gloc(ialph(nres-2,1)+nside,icg)*
93 if((itype(nres-1).ne.10).and.(itype(nres-1).ne.ntyp1)) then
94 gcart(j,nres-2)=gcart(j,nres-2)+gloc(ialph(nres-1,1),icg)*
95 & dalpha(j,1,nres-1)+gloc(ialph(nres-1,1)+nside,icg)*
100 c Settind dE/ddnres-1
102 gcart(j,nres-1)=gcart(j,nres-1)+gloc(nres-3,icg)*dphi(j,3,nres)+
103 & gloc(2*nres-5,icg)*dtheta(j,2,nres)
104 if((itype(nres-1).ne.10).and.(itype(nres-1).ne.ntyp1)) then
105 gcart(j,nres-1)=gcart(j,nres-1)+gloc(ialph(nres-1,1),icg)*
106 & dalpha(j,2,nres-1)+gloc(ialph(nres-1,1)+nside,icg)*
110 c The side-chain vector derivatives
112 if(itype(i).ne.10 .and. itype(i).ne.ntyp1) then
114 gxcart(j,i)=gxcart(j,i)+gloc(ialph(i,1),icg)*dalpha(j,3,i)
115 & +gloc(ialph(i,1)+nside,icg)*domega(j,3,i)
119 C write(iout,*) "TU DOCHODZE"
121 c----------------------------------------------------------------------
122 C INTERTYP=1 SC...Ca...Ca...Ca
123 C INTERTYP=2 Ca...Ca...Ca...SC
124 C INTERTYP=3 SC...Ca...Ca...SC
125 c calculating dE/ddc1
129 c write (iout,*) "poczotkoawy",i,gloc_sc(1,i,icg)
131 if (nres.lt.2) return
132 if ((nres.lt.3).and.(itype(1).eq.10)) return
133 if ((itype(1).ne.10).and.(itype(1).ne.ntyp1)) then
135 cc Derviative was calculated for oposite vector of side chain therefore
136 c there is "-" sign before gloc_sc
137 gxcart(j,1)=gxcart(j,1)-gloc_sc(1,0,icg)*
139 gcart(j,1)=gcart(j,1)+gloc_sc(1,0,icg)*
141 if ((itype(2).ne.10).and.(itype(2).ne.ntyp1)) then
142 gxcart(j,1)= gxcart(j,1)
143 & -gloc_sc(3,0,icg)*dtauangle(j,3,1,3)
144 gcart(j,1)=gcart(j,1)+gloc_sc(3,0,icg)*
149 if ((nres.ge.3).and.(itype(3).ne.10).and.(itype(3).ne.ntyp1))
152 gcart(j,1)=gcart(j,1)+gloc_sc(2,1,icg)*dtauangle(j,2,1,4)
155 c As potetnial DO NOT depend on omicron anlge their derivative is
157 c & +gloc_sc(intertyp,nres-2,icg)*dtheta(j,1,3)
159 c Calculating the remainder of dE/ddc2
161 if((itype(2).ne.10).and.(itype(2).ne.ntyp1)) then
162 if (itype(1).ne.10) gxcart(j,2)=gxcart(j,2)+
163 & gloc_sc(3,0,icg)*dtauangle(j,3,3,3)
164 if ((itype(3).ne.10).and.(nres.ge.3).and.(itype(3).ne.ntyp1))
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.ntyp1)) 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).and.(itype(i).ne.ntyp1)) 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)
206 if (itype(i-1).ne.10) then
207 gxcart(j,i)=gxcart(j,i)+gloc_sc(3,i-2,icg)
208 &*dtauangle(j,3,3,i+1)
210 if (itype(i+1).ne.10) then
211 gxcart(j,i)=gxcart(j,i)-gloc_sc(3,i-1,icg)
212 &*dtauangle(j,3,1,i+2)
213 gcart(j,i)=gcart(j,i)+gloc_sc(3,i-1,icg)
214 &*dtauangle(j,3,2,i+2)
217 if (itype(i-1).ne.10) then
218 gcart(j,i)=gcart(j,i)+gloc_sc(1,i-2,icg)*
219 & dtauangle(j,1,3,i+1)
221 if (itype(i+1).ne.10) then
222 gcart(j,i)=gcart(j,i)+gloc_sc(2,i-1,icg)*
223 & dtauangle(j,2,2,i+2)
224 c write(iout,*) "numer",i,gloc_sc(2,i-1,icg),
225 c & dtauangle(j,2,2,i+2)
227 if (itype(i+2).ne.10) then
228 gcart(j,i)=gcart(j,i)+gloc_sc(2,i,icg)*
229 & dtauangle(j,2,1,i+3)
234 c Setting dE/ddnres-1
237 if ((itype(nres-1).ne.10).and.(itype(nres-1).ne.ntyp1)) then
238 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(2,nres-3,icg)
239 & *dtauangle(j,2,3,nres)
240 c write (iout,*) "gxcart(nres-1)", gloc_sc(2,nres-3,icg),
241 c & dtauangle(j,2,3,nres), gxcart(j,nres-1)
242 if (itype(nres-2).ne.10) then
243 gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(3,nres-3,icg)
244 & *dtauangle(j,3,3,nres)
246 if ((itype(nres).ne.10).and.(itype(nres).ne.ntyp1)) then
247 gxcart(j,nres-1)=gxcart(j,nres-1)-gloc_sc(3,nres-2,icg)
248 & *dtauangle(j,3,1,nres+1)
249 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(3,nres-2,icg)
250 & *dtauangle(j,3,2,nres+1)
253 if ((itype(nres-2).ne.10).and.(itype(nres-2).ne.ntyp1)) then
254 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(1,nres-3,icg)*
255 & dtauangle(j,1,3,nres)
257 if ((itype(nres).ne.10).and.(itype(nres).ne.ntyp1)) then
258 gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(2,nres-2,icg)*
259 & dtauangle(j,2,2,nres+1)
260 c write (iout,*) "gcart(nres-1)", gloc_sc(2,nres-2,icg),
261 c & dtauangle(j,2,2,nres+1), itype(nres-1),itype(nres)
266 if ((nres.ge.3).and.(itype(nres).ne.10).and.
267 & (itype(nres).ne.ntyp1))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