Fixed the homology gradient in finegrain mode
[unres.git] / source / unres / src_MD / energy_p_new_barrier.F
index d07d135..002f211 100644 (file)
@@ -543,6 +543,7 @@ cMS$ATTRIBUTES C ::  proc_proc
       include 'COMMON.TIME1'
       include 'COMMON.MAXGRAD'
       include 'COMMON.SCCOR'
+      include 'COMMON.MD'
 #ifdef TIMING
 #ifdef MPI
       time01=MPI_Wtime()
@@ -813,6 +814,14 @@ c      enddo
 #endif
         enddo
       enddo 
+      if (constr_homology.gt.0) then
+        do i=1,nct
+          do j=1,3
+            gradc(j,i,icg)=gradc(j,i,icg)+duscdiff(j,i)
+            gradx(j,i,icg)=gradx(j,i,icg)+duscdiffx(j,i)
+          enddo
+        enddo
+      endif
 #ifdef DEBUG
       write (iout,*) "gloc before adding corr"
       do i=1,4*nres
@@ -4862,6 +4871,8 @@ C
      & sinph1ph2(maxdouble,maxdouble)
       logical lprn /.false./, lprn1 /.false./
       etheta=0.0D0
+c      write (iout,*) "EBEND ithet_start",ithet_start,
+c     &     " ithet_end",ithet_end
       do i=ithet_start,ithet_end
         if ((itype(i-1).eq.ntyp1).or.(itype(i-2).eq.ntyp1).or.
      &(itype(i).eq.ntyp1)) cycle
@@ -6328,8 +6339,11 @@ c       grad_theta3=sum_sgtheta/sum_gtheta 1/*theta(i)? s. line below
 c       grad_theta3=sum_sgtheta/sum_gtheta
 c
 c       Final value of gradient using same var as in Econstr_back
-        dutheta(i-2)=sum_sgtheta/sum_gtheta*waga_theta
+        gloc(nphi+i-2,icg)=gloc(nphi+i-2,icg)
+     &      +sum_sgtheta/sum_gtheta*waga_theta
      &               *waga_homology(iset)
+c        dutheta(i-2)=sum_sgtheta/sum_gtheta*waga_theta
+c     &               *waga_homology(iset)
 c       dutheta(i)=sum_sgtheta/sum_gtheta
 c
 c       Uconst_back=Uconst_back+waga_theta*utheta(i) ! waga_theta added as weight
@@ -6525,9 +6539,12 @@ c
      &              waga_theta*Eval+waga_d*Erot)*waga_homology(iset)
 c     write (iout,*) "ehomology_constr=",ehomology_constr
       endif
-c     write (iout,*) "odleg",odleg," kat",kat," Uconst_back",Uconst_back
-c     write (iout,*) "ehomology_constr",ehomology_constr
-c     ehomology_constr=odleg+kat+Uconst_back
+#ifdef DEBUG
+      write (iout,*) "odleg",waga_dist,odleg," kat",waga_angle,kat,
+     & "Eval",waga_theta,eval,
+     &   "Erot",waga_d,Erot
+      write (iout,*) "ehomology_constr",ehomology_constr
+#endif
       return
 c
 c FP 01/15 end