intoduction of quartic restrains in multichain, bugfix in single chain
[unres.git] / source / unres / src_MD / intcartderiv.F
index dd4db24..c4bf31c 100644 (file)
@@ -52,7 +52,7 @@ c We need dtheta(:,:,i-1) to compute dphi(:,:,i)
 #else
       do i=3,nres
 #endif
-      if ((itype(i-1).ne.10).and.(itype(i-1).ne.21)) then
+      if ((itype(i-1).ne.10).and.(itype(i-1).ne.ntyp1)) then
         cost1=dcos(omicron(1,i))
        sint1=sqrt(1-cost1*cost1)
         cost2=dcos(omicron(2,i))
@@ -61,11 +61,11 @@ c We need dtheta(:,:,i-1) to compute dphi(:,:,i)
 CC Calculate derivative over first omicron (Cai-2,Cai-1,SCi-1) 
           dcosomicron(j,1,1,i)=-(dc_norm(j,i-1+nres)+
      &    cost1*dc_norm(j,i-2))/
-     &   vbld(i-1)
-          domicron(j,1,1,i)=-1/sint1*dcosomicron(j,1,1,i)     
+     &    vbld(i-1)
+          domicron(j,1,1,i)=-1.0/sint1*dcosomicron(j,1,1,i)     
           dcosomicron(j,1,2,i)=-(dc_norm(j,i-2)
      &    +cost1*(dc_norm(j,i-1+nres)))/
-     &   vbld(i-1+nres)
+     &    vbld(i-1+nres)
           domicron(j,1,2,i)=-1/sint1*dcosomicron(j,1,2,i)  
 CC Calculate derivative over second omicron Sci-1,Cai-1 Cai
 CC Looks messy but better than if in loop
@@ -151,11 +151,11 @@ c   Obtaining the gamma derivatives from cosine derivative
 
 Calculate derivative of Tauangle
 #ifdef PARINTDER
-      do i=iphi1_start-1,iphi1_end
+      do i=itau_start,itau_end
 #else
       do i=3,nres
 #endif
-       if ((itype(i-2).eq.21).or.(itype(i-2).eq.10)) cycle
+       if ((itype(i-2).eq.ntyp1).or.(itype(i-2).eq.10)) cycle
 cc dtauangle(j,intertyp,dervityp,residue number)
 cc INTERTYP=1 SC...Ca...Ca..Ca
 c the conventional case
@@ -226,11 +226,11 @@ c        enddo
       enddo
 CC Second case Ca...Ca...Ca...SC
 #ifdef PARINTDER
-      do i=iphi1_start,iphi1_end
+      do i=itau_start,itau_end
 #else
       do i=4,nres
 #endif
-       if ((itype(i-1).eq.21).or.(itype(i-1).eq.10)) cycle
+       if ((itype(i-1).eq.ntyp1).or.(itype(i-1).eq.10)) cycle
 c the conventional case
         sint=dsin(omicron(1,i))
         sint1=dsin(theta(i-1))
@@ -291,7 +291,7 @@ c   Obtaining the gamma derivatives from cosine derivative
      &     dcosomicron(j,1,2,i)-fac0*(dc_norm(j,i-3)-scalp*
      &     dc_norm(j,i-1+nres))/vbld(i-1+nres)
            dtauangle(j,2,3,i)=-1/sing*dcostau(j,2,3,i)
-        write(iout,*) i,j,"else", dtauangle(j,2,3,i) 
+c        write(iout,*) i,j,"else", dtauangle(j,2,3,i) 
          enddo
         endif                                                                                            
       enddo
@@ -300,13 +300,13 @@ c   Obtaining the gamma derivatives from cosine derivative
 CCC third case SC...Ca...Ca...SC
 #ifdef PARINTDER
 
-      do i=iphi1_start-1,iphi1_end
+      do i=itau_start,itau_end
 #else
       do i=3,nres
 #endif
 c the conventional case
-      if ((itype(i-1).eq.21).or.(itype(i-1).eq.10).or.
-     &(itype(i-2).eq.21).or.(itype(i-2).eq.10)) cycle
+      if ((itype(i-1).eq.ntyp1).or.(itype(i-1).eq.10).or.
+     &(itype(i-2).eq.ntyp1).or.(itype(i-2).eq.10)) cycle
         sint=dsin(omicron(1,i))
         sint1=dsin(omicron(2,i-1))
         sing=dsin(tauangle(3,i))
@@ -364,7 +364,7 @@ c   Obtaining the gamma derivatives from cosine derivative
      &     dcosomicron(j,1,2,i)-fac0*(dc_norm2(j,i-2+nres)-scalp*
      &     dc_norm(j,i-1+nres))/vbld(i-1+nres)
            dtauangle(j,3,3,i)=-1/sing*dcostau(j,3,3,i)
-          write(iout,*) "else",i 
+c          write(iout,*) "else",i 
          enddo
         endif                                                                                            
       enddo
@@ -458,12 +458,12 @@ c   obtaining the derivatives of omega from cosines
 #if defined(MPI) && defined(PARINTDER)
       if (nfgtasks.gt.1) then
 #ifdef DEBUG
-cd      write (iout,*) "Gather dtheta"
+       write (iout,*) "Gather dtheta"
 cd      call flush(iout)
-      write (iout,*) "dtheta before gather"
-      do i=1,nres
-        write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),k=1,3),j=1,2)
-      enddo
+c      write (iout,*) "dtheta before gather"
+c      do i=1,nres
+c        write (iout,'(i3,3(3f8.5,3x))') i,((dtheta(j,k,i),k=1,3),j=1,2)
+c      enddo
 #endif
       call MPI_Gatherv(dtheta(1,1,ithet_start),ithet_count(fg_rank),
      &  MPI_THET,dtheta(1,1,1),ithet_count(0),ithet_displ(0),MPI_THET,