The wrong one gradient compontent...
[unres.git] / source / unres / src_MD-M / intcartderiv.F
index d715c19..12d7dee 100644 (file)
@@ -99,7 +99,8 @@ c conventional formulas around 0 and 180.
 #else
       do i=4,nres      
 #endif
-c        if (itype(i-1).eq.21 .or. itype(i-2).eq.21 ) cycle
+c        if (itype(i-2).eq.ntyp1.or. itype(i-1).eq.ntyp1
+c     &      .or. itype(i).eq.ntyp1 .or. itype(i-3).eq.ntyp1) cycle
 c the conventional case
         sint=dsin(theta(i))
        sint1=dsin(theta(i-1))
@@ -124,8 +125,8 @@ c    Obtaining the gamma derivatives from sine derivative
             ctgt=cost/sint
             ctgt1=cost1/sint1
             cosg_inv=1.0d0/cosg
-            if (itype(i-1).ne.ntyp1 .and. itype(i-2).ne.ntyp1) then
-           dsinphi(j,1,i)=-sing*ctgt1*dtheta(j,1,i-1)
+c            if (itype(i-1).ne.ntyp1 .and. itype(i-2).ne.ntyp1) then
+      dsinphi(j,1,i)=-sing*ctgt1*dtheta(j,1,i-1)
      &        -(fac0*vp1(j)+sing*dc_norm(j,i-3))*vbld_inv(i-2)
             dphi(j,1,i)=cosg_inv*dsinphi(j,1,i)
             dsinphi(j,2,i)=
@@ -136,13 +137,13 @@ c    Obtaining the gamma derivatives from sine derivative
      &        +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i)
 c     &        +(fac0*vp3(j)-sing*dc_norm(j,i-1))*vbld_inv(i-1)
             dphi(j,3,i)=cosg_inv*dsinphi(j,3,i)
-            endif
+c            endif
 c Bug fixed 3/24/05 (AL)
         enddo                                              
 c   Obtaining the gamma derivatives from cosine derivative
         else
            do j=1,3
-           if (itype(i-1).ne.ntyp1 .and. itype(i-2).ne.ntyp1) then
+c           if (itype(i-1).ne.ntyp1 .and. itype(i-2).ne.ntyp1) then
            dcosphi(j,1,i)=fac1*dcostheta(j,1,i-1)+fac3*
      &    dcostheta(j,1,i-1)-fac0*(dc_norm(j,i-1)-scalp*
      &     dc_norm(j,i-3))/vbld(i-2)
@@ -155,7 +156,7 @@ c   Obtaining the gamma derivatives from cosine derivative
      &    dcostheta(j,2,i)-fac0*(dc_norm(j,i-3)-scalp*
      &     dc_norm(j,i-1))/vbld(i)
            dphi(j,3,i)=-1/sing*dcosphi(j,3,i)       
-           endif
+c           endif
          enddo
         endif                                                                                           
       enddo