include 'COMMON.INTERACT'
include 'COMMON.MD'
include 'COMMON.IOUNITS'
-
+ include 'COMMON.SCCOR'
c calculating dE/ddc1
- if (nres.lt.3) return
+ if (nres.lt.3) go to 18
do j=1,3
gcart(j,1)=gcart(j,1)+gloc(1,icg)*dphi(j,1,4)
& +gloc(nres-2,icg)*dtheta(j,1,3)
& gloc(ialph(2,1)+nside,icg)*domega(j,1,2)
endif
enddo
+C write (iout,*) "????A CO TO??"
c Calculating the remainder of dE/ddc2
do j=1,3
gcart(j,2)=gcart(j,2)+gloc(1,icg)*dphi(j,2,4)+
& gloc(nres-2,icg)*dtheta(j,2,3)+gloc(nres-1,icg)*dtheta(j,1,4)
- if(itype(2).ne.10) then
+ if((itype(2).ne.10).and.(itype(2).ne.ntyp1)) then
gcart(j,2)=gcart(j,2)+gloc(ialph(2,1),icg)*dalpha(j,2,2)+
& gloc(ialph(2,1)+nside,icg)*domega(j,2,2)
endif
- if(itype(3).ne.10) then
+ if((itype(3).ne.10).and.(itype(3).ne.21)) then
gcart(j,2)=gcart(j,2)+gloc(ialph(3,1),icg)*dalpha(j,1,3)+
& gloc(ialph(3,1)+nside,icg)*domega(j,1,3)
endif
endif
enddo
endif
+C write (iout,*) "Poniezej blad??",ialph(3,1),nside,ialph(4,1)
c If there are more than five residues
if(nres.gt.5) then
do i=3,nres-3
& +gloc(i-1,icg)*dphi(j,2,i+2)+
& gloc(i,icg)*dphi(j,1,i+3)+gloc(nres+i-4,icg)*dtheta(j,2,i+1)+
& gloc(nres+i-3,icg)*dtheta(j,1,i+2)
- if(itype(i).ne.10) then
+ if((itype(i).ne.10).and.(itype(i).ne.ntyp1)) then
gcart(j,i)=gcart(j,i)+gloc(ialph(i,1),icg)*dalpha(j,2,i)+
& gloc(ialph(i,1)+nside,icg)*domega(j,2,i)
endif
- if(itype(i+1).ne.10) then
+ if((itype(i+1).ne.10).and.(itype(i+1).ne.ntyp1)) then
gcart(j,i)=gcart(j,i)+gloc(ialph(i+1,1),icg)*dalpha(j,1,i+1)
& +gloc(ialph(i+1,1)+nside,icg)*domega(j,1,i+1)
endif
enddo
enddo
endif
-c Setting dE/ddnres-2
+c Setting dE/ddnres-2
+C write(iout,*) "ATUCHUJ?"
if(nres.gt.5) then
do j=1,3
gcart(j,nres-2)=gcart(j,nres-2)+gloc(nres-4,icg)*
& dphi(j,3,nres-1)+gloc(nres-3,icg)*dphi(j,2,nres)
& +gloc(2*nres-6,icg)*
& dtheta(j,2,nres-1)+gloc(2*nres-5,icg)*dtheta(j,1,nres)
- if(itype(nres-2).ne.10) then
+ if((itype(nres-2).ne.10).and.(itype(nres-2).ne.ntyp1)) then
gcart(j,nres-2)=gcart(j,nres-2)+gloc(ialph(nres-2,1),icg)*
& dalpha(j,2,nres-2)+gloc(ialph(nres-2,1)+nside,icg)*
& domega(j,2,nres-2)
endif
- if(itype(nres-1).ne.10) then
+ if((itype(nres-1).ne.10).and.(itype(nres-1).ne.ntyp1)) then
gcart(j,nres-2)=gcart(j,nres-2)+gloc(ialph(nres-1,1),icg)*
& dalpha(j,1,nres-1)+gloc(ialph(nres-1,1)+nside,icg)*
& domega(j,1,nres-1)
do j=1,3
gcart(j,nres-1)=gcart(j,nres-1)+gloc(nres-3,icg)*dphi(j,3,nres)+
& gloc(2*nres-5,icg)*dtheta(j,2,nres)
- if(itype(nres-1).ne.10) then
+ if((itype(nres-1).ne.10).and.(itype(nres-1).ne.ntyp1)) then
gcart(j,nres-1)=gcart(j,nres-1)+gloc(ialph(nres-1,1),icg)*
& dalpha(j,2,nres-1)+gloc(ialph(nres-1,1)+nside,icg)*
& domega(j,2,nres-1)
enddo
c The side-chain vector derivatives
do i=2,nres-1
- if(itype(i).ne.10 .and. itype(i).ne.21) then
+ if(itype(i).ne.10 .and. itype(i).ne.ntyp1) then
do j=1,3
gxcart(j,i)=gxcart(j,i)+gloc(ialph(i,1),icg)*dalpha(j,3,i)
& +gloc(ialph(i,1)+nside,icg)*domega(j,3,i)
enddo
endif
- enddo
+ enddo
+C write(iout,*) "TU DOCHODZE"
+
+c----------------------------------------------------------------------
+C INTERTYP=1 SC...Ca...Ca...Ca
+C INTERTYP=2 Ca...Ca...Ca...SC
+C INTERTYP=3 SC...Ca...Ca...SC
+c calculating dE/ddc1
+ 18 continue
+c do i=1,nres
+c gloc(i,icg)=0.0D0
+c write (iout,*) "poczotkoawy",i,gloc_sc(1,i,icg)
+c enddo
+ if (nres.lt.2) return
+ if ((nres.lt.3).and.(itype(1).eq.10)) return
+ if ((itype(1).ne.10).and.(itype(1).ne.ntyp1)) then
+ do j=1,3
+cc Derviative was calculated for oposite vector of side chain therefore
+c there is "-" sign before gloc_sc
+ gxcart(j,1)=gxcart(j,1)-gloc_sc(1,0,icg)*
+ & dtauangle(j,1,1,3)
+ gcart(j,1)=gcart(j,1)+gloc_sc(1,0,icg)*
+ & dtauangle(j,1,2,3)
+ if ((itype(2).ne.10).and.(itype(2).ne.ntyp1)) then
+ gxcart(j,1)= gxcart(j,1)
+ & -gloc_sc(3,0,icg)*dtauangle(j,3,1,3)
+ gcart(j,1)=gcart(j,1)+gloc_sc(3,0,icg)*
+ & dtauangle(j,3,2,3)
+ endif
+ enddo
+ endif
+ if ((nres.ge.3).and.(itype(3).ne.10).and.(itype(3).ne.ntyp1))
+ & then
+ do j=1,3
+ gcart(j,1)=gcart(j,1)+gloc_sc(2,1,icg)*dtauangle(j,2,1,4)
+ enddo
+ endif
+c As potetnial DO NOT depend on omicron anlge their derivative is
+c ommited
+c & +gloc_sc(intertyp,nres-2,icg)*dtheta(j,1,3)
+
+c Calculating the remainder of dE/ddc2
+ do j=1,3
+ if((itype(2).ne.10).and.(itype(2).ne.ntyp1)) then
+ if (itype(1).ne.10) gxcart(j,2)=gxcart(j,2)+
+ & gloc_sc(3,0,icg)*dtauangle(j,3,3,3)
+ if ((itype(3).ne.10).and.(nres.ge.3).and.(itype(3).ne.ntyp1))
+ & then
+ gxcart(j,2)=gxcart(j,2)-gloc_sc(3,1,icg)*dtauangle(j,3,1,4)
+cc the - above is due to different vector direction
+ gcart(j,2)=gcart(j,2)+gloc_sc(3,1,icg)*dtauangle(j,3,2,4)
+ endif
+ if (nres.gt.3) then
+ gxcart(j,2)=gxcart(j,2)-gloc_sc(1,1,icg)*dtauangle(j,1,1,4)
+cc the - above is due to different vector direction
+ gcart(j,2)=gcart(j,2)+gloc_sc(1,1,icg)*dtauangle(j,1,2,4)
+c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,2,4),"gcart"
+c write(iout,*) gloc_sc(1,1,icg),dtauangle(j,1,1,4),"gx"
+ endif
+ endif
+ if ((itype(1).ne.10).and.(itype(1).ne.ntyp1)) then
+ gcart(j,2)=gcart(j,2)+gloc_sc(1,0,icg)*dtauangle(j,1,3,3)
+c write(iout,*) gloc_sc(1,0,icg),dtauangle(j,1,3,3)
+ endif
+ if ((itype(3).ne.10).and.(nres.ge.3)) then
+ gcart(j,2)=gcart(j,2)+gloc_sc(2,1,icg)*dtauangle(j,2,2,4)
+c write(iout,*) gloc_sc(2,1,icg),dtauangle(j,2,2,4)
+ endif
+ if ((itype(4).ne.10).and.(nres.ge.4)) then
+ gcart(j,2)=gcart(j,2)+gloc_sc(2,2,icg)*dtauangle(j,2,1,5)
+c write(iout,*) gloc_sc(2,2,icg),dtauangle(j,2,1,5)
+ endif
+
+c write(iout,*) gcart(j,2),itype(2),itype(1),itype(3), "gcart2"
+ enddo
+c If there are more than five residues
+ if(nres.ge.5) then
+ do i=3,nres-2
+ do j=1,3
+c write(iout,*) "before", gcart(j,i)
+ if ((itype(i).ne.10).and.(itype(i).ne.ntyp1)) then
+ gxcart(j,i)=gxcart(j,i)+gloc_sc(2,i-2,icg)
+ & *dtauangle(j,2,3,i+1)
+ & -gloc_sc(1,i-1,icg)*dtauangle(j,1,1,i+2)
+ gcart(j,i)=gcart(j,i)+gloc_sc(1,i-1,icg)
+ & *dtauangle(j,1,2,i+2)
+c write(iout,*) "new",j,i,
+c & gcart(j,i),gloc_sc(1,i-1,icg),dtauangle(j,1,2,i+2)
+ if (itype(i-1).ne.10) then
+ gxcart(j,i)=gxcart(j,i)+gloc_sc(3,i-2,icg)
+ &*dtauangle(j,3,3,i+1)
+ endif
+ if (itype(i+1).ne.10) then
+ gxcart(j,i)=gxcart(j,i)-gloc_sc(3,i-1,icg)
+ &*dtauangle(j,3,1,i+2)
+ gcart(j,i)=gcart(j,i)+gloc_sc(3,i-1,icg)
+ &*dtauangle(j,3,2,i+2)
+ endif
+ endif
+ if (itype(i-1).ne.10) then
+ gcart(j,i)=gcart(j,i)+gloc_sc(1,i-2,icg)*
+ & dtauangle(j,1,3,i+1)
+ endif
+ if (itype(i+1).ne.10) then
+ gcart(j,i)=gcart(j,i)+gloc_sc(2,i-1,icg)*
+ & dtauangle(j,2,2,i+2)
+c write(iout,*) "numer",i,gloc_sc(2,i-1,icg),
+c & dtauangle(j,2,2,i+2)
+ endif
+ if (itype(i+2).ne.10) then
+ gcart(j,i)=gcart(j,i)+gloc_sc(2,i,icg)*
+ & dtauangle(j,2,1,i+3)
+ endif
+ enddo
+ enddo
+ endif
+c Setting dE/ddnres-1
+ if(nres.ge.4) then
+ do j=1,3
+ if ((itype(nres-1).ne.10).and.(itype(nres-1).ne.ntyp1)) then
+ gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(2,nres-3,icg)
+ & *dtauangle(j,2,3,nres)
+c write (iout,*) "gxcart(nres-1)", gloc_sc(2,nres-3,icg),
+c & dtauangle(j,2,3,nres), gxcart(j,nres-1)
+ if (itype(nres-2).ne.10) then
+ gxcart(j,nres-1)=gxcart(j,nres-1)+gloc_sc(3,nres-3,icg)
+ & *dtauangle(j,3,3,nres)
+ endif
+ if ((itype(nres).ne.10).and.(itype(nres).ne.ntyp1)) then
+ gxcart(j,nres-1)=gxcart(j,nres-1)-gloc_sc(3,nres-2,icg)
+ & *dtauangle(j,3,1,nres+1)
+ gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(3,nres-2,icg)
+ & *dtauangle(j,3,2,nres+1)
+ endif
+ endif
+ if ((itype(nres-2).ne.10).and.(itype(nres-2).ne.ntyp1)) then
+ gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(1,nres-3,icg)*
+ & dtauangle(j,1,3,nres)
+ endif
+ if ((itype(nres).ne.10).and.(itype(nres).ne.ntyp1)) then
+ gcart(j,nres-1)=gcart(j,nres-1)+gloc_sc(2,nres-2,icg)*
+ & dtauangle(j,2,2,nres+1)
+c write (iout,*) "gcart(nres-1)", gloc_sc(2,nres-2,icg),
+c & dtauangle(j,2,2,nres+1), itype(nres-1),itype(nres)
+ endif
+ enddo
+ endif
+c Settind dE/ddnres
+ if ((nres.ge.3).and.(itype(nres).ne.10).and.
+ & (itype(nres).ne.ntyp1))then
+ do j=1,3
+ gxcart(j,nres)=gxcart(j,nres)+gloc_sc(3,nres-2,icg)
+ & *dtauangle(j,3,3,nres+1)+gloc_sc(2,nres-2,icg)
+ & *dtauangle(j,2,3,nres+1)
+ enddo
+ endif
+c The side-chain vector derivatives
return
end