update
[unres.git] / source / unres / src_MD-M / gradient_p.F
index effd955..e79f6b0 100644 (file)
@@ -88,6 +88,15 @@ C
 C Add the components corresponding to local energy terms.
 C
    10 continue
+c Add the usampl contributions
+      if (usampl) then
+         do i=1,nres-3
+           gloc(i,icg)=gloc(i,icg)+dugamma(i)
+         enddo
+         do i=1,nres-2
+           gloc(nphi+i,icg)=gloc(nphi+i,icg)+dutheta(i)
+         enddo
+      endif
       do i=1,nvar
 cd      write (iout,*) 'i=',i,'g=',g(i),' gloc=',gloc(i,icg)
         g(i)=g(i)+gloc(i,icg)
@@ -271,29 +280,45 @@ c
       time00=MPI_Wtime()
 #endif
       icg=1
-      call sum_gradient
-#ifdef TIMING
+#ifdef DEBUG
+      write (iout,*) "gradc, gradx, gloc before sum_gradient"
+      do i=1,nres-1
+        write (iout,'(i5,2(3f10.5,5x),f10.5)') i,(gradc(j,i,icg),j=1,3),
+     &    (gradx(j,i,icg),j=1,3),gloc(i,icg)
+      enddo
 #endif
+      call sum_gradient
 #ifdef DEBUG
-      write (iout,*) "After sum_gradient"
+      write (iout,*) "gradc, gradx, gloc after sum_gradient"
       do i=1,nres-1
-        write (iout,*) i," gradc  ",(gradc(j,i,icg),j=1,3)
-        write (iout,*) i," gradx  ",(gradx(j,i,icg),j=1,3)
+        write (iout,'(i5,2(3f10.5,5x),f10.5)') i,(gradc(j,i,icg),j=1,3),
+     &    (gradx(j,i,icg),j=1,3),gloc(i,icg)
       enddo
 #endif
 c If performing constraint dynamics, add the gradients of the constraint energy
       if(usampl.and.totT.gt.eq_time) then
+#ifdef DEBUG
+         write (iout,*) "dudconst, duscdiff, dugamma,dutheta"
+         write (iout,*) "wumb",wumb
+         do i=1,nct
+           write (iout,'(i5,3f10.5,5x,3f10.5,5x,2f10.5)')
+     &      i,(dudconst(j,i),j=1,3),(duscdiff(j,i),j=1,3),
+     &      dugamma(i),dutheta(i)
+         enddo
+#endif
          do i=1,nct
            do j=1,3
-             gradc(j,i,icg)=gradc(j,i,icg)+dudconst(j,i)+duscdiff(j,i)
-             gradx(j,i,icg)=gradx(j,i,icg)+dudxconst(j,i)+duscdiffx(j,i)
+             gradc(j,i,icg)=gradc(j,i,icg)+
+     &          wumb*(dudconst(j,i)+duscdiff(j,i))
+             gradx(j,i,icg)=gradx(j,i,icg)+
+     &          wumb*(dudxconst(j,i)+duscdiffx(j,i))
            enddo
          enddo
          do i=1,nres-3
-           gloc(i,icg)=gloc(i,icg)+dugamma(i)
+           gloc(i,icg)=gloc(i,icg)+wumb*dugamma(i)
          enddo
          do i=1,nres-2
-           gloc(nphi+i,icg)=gloc(nphi+i,icg)+dutheta(i)
+           gloc(nphi+i,icg)=gloc(nphi+i,icg)+wumb*dutheta(i)
          enddo
       endif 
 #ifdef TIMING
@@ -314,8 +339,9 @@ cd      write(iout,*) 'calling int_to_cart'
           gxcart(j,i)=gradx(j,i,icg)
         enddo
 #ifdef DEBUG
-        write (iout,'(i5,2(3f10.5,5x),f10.5)') i,(gcart(j,i),j=1,3),
-     &    (gxcart(j,i),j=1,3),gloc(i,icg)
+        write (iout,'(i5,2(3f10.5,5x),2f10.5)') i,(gcart(j,i),j=1,3),
+     &    (gxcart(j,i),j=1,3),gloc(i,icg),gloc(i+nphi,icg)
+        call flush(iout)
 #endif
       enddo
 #ifdef TIMING
@@ -345,10 +371,13 @@ C-------------------------------------------------------------------------
       include 'COMMON.CHAIN'
       include 'COMMON.VAR'
       include 'COMMON.MD'
+      include 'COMMON.SCCOR'
+      include 'COMMON.SHIELD'
+      maxshieldlist=0
 C
 C Initialize Cartesian-coordinate gradient
 C
-      do i=1,nres
+      do i=-1,nres
        do j=1,3
          gvdwx(j,i)=0.0D0
           gradx_scp(j,i)=0.0D0
@@ -356,6 +385,24 @@ C
           gvdwc_scp(j,i)=0.0D0
           gvdwc_scpp(j,i)=0.0d0
          gelc (j,i)=0.0D0
+C below is zero grad for shielding in order: ees (p-p)
+C ecorr4, eturn3, eturn4, eel_loc, c denotes calfa,x is side-chain
+          gshieldx(j,i)=0.0d0
+          gshieldc(j,i)=0.0d0
+          gshieldc_loc(j,i)=0.0d0
+          gshieldx_ec(j,i)=0.0d0
+          gshieldc_ec(j,i)=0.0d0
+          gshieldc_loc_ec(j,i)=0.0d0
+          gshieldx_t3(j,i)=0.0d0
+          gshieldc_t3(j,i)=0.0d0
+          gshieldc_loc_t3(j,i)=0.0d0
+          gshieldx_t4(j,i)=0.0d0
+          gshieldc_t4(j,i)=0.0d0
+          gshieldc_loc_t4(j,i)=0.0d0
+          gshieldx_ll(j,i)=0.0d0
+          gshieldc_ll(j,i)=0.0d0
+          gshieldc_loc_ll(j,i)=0.0d0
+C end of zero grad for shielding
          gelc_long(j,i)=0.0D0
           gradb(j,i)=0.0d0
           gradbx(j,i)=0.0d0
@@ -380,6 +427,25 @@ C
           gradx(j,i,icg)=0.0d0
           gscloc(j,i)=0.0d0
           gsclocx(j,i)=0.0d0
+          gliptranc(j,i)=0.0d0
+          gliptranx(j,i)=0.0d0
+          gradafm(j,i)=0.0d0
+          grad_shield(j,i)=0.0d0
+          gg_tube(j,i)=0.0d0
+          gg_tube_sc(j,i)=0.0d0
+C grad_shield_side is Cbeta sidechain gradient
+          do kk=1,maxshieldlist
+           grad_shield_side(j,kk,i)=0.0d0
+           grad_shield_loc(j,kk,i)=0.0d0
+
+C grad_shield_side_ca is Calfa sidechain gradient
+
+
+C           grad_shield_side_ca(j,kk,i)=0.0d0
+          enddo
+          do intertyp=1,3
+           gloc_sc(intertyp,i,icg)=0.0d0
+          enddo
         enddo
       enddo
 C