correction - adding ehomology_constr
[unres.git] / source / wham / src / energy_p_new.F
index 816e38e..5cfdcce 100644 (file)
@@ -3510,8 +3510,6 @@ c
 c        sgtheta=-gtheta(k)*theta_diff(k)*sigma_theta(k,i)*waga_theta ! right functional form?
           sum_sgtheta=sum_sgtheta+sgtheta ! cum variable
         enddo
-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
 c
 c          For Gaussian-type Urestr
 c
-        ehomology_constr=(waga_dist*odleg+waga_angle*kat+
-     &              waga_theta*Eval+waga_d*Erot)*waga_homology(iset)
+c        ehomology_constr=(waga_dist*odleg+waga_angle*kat+
+c     &              waga_theta*Eval+waga_d*Erot)*waga_homology(iset)
+        ehomology_constr=waga_dist*odleg+waga_angle*kat+
+     &              waga_theta*Eval+waga_d*Erot
 c     write (iout,*) "ehomology_constr=",ehomology_constr
       else
 c
 c          For Lorentzian-type Urestr
 c  
-        ehomology_constr=(-waga_dist*odleg+waga_angle*kat+
-     &              waga_theta*Eval+waga_d*Erot)*waga_homology(iset)
+c        ehomology_constr=(-waga_dist*odleg+waga_angle*kat+
+c     &              waga_theta*Eval+waga_d*Erot)*waga_homology(iset)
+        ehomology_constr=-waga_dist*odleg+waga_angle*kat+
+     &              waga_theta*Eval+waga_d*Erot
 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
 
   748 format(a8,f12.3,a6,f12.3,a7,f12.3)
@@ -4129,7 +4134,8 @@ c      write (iout,*) "ithetyp",(ithetyp(i),i=1,ntyp1)
           enddo
         else
           phii1=0.0d0
-          ityp3=nthetyp+1
+c          ityp3=nthetyp+1
+          ityp3=ithetyp(itype(i))
           do k=1,nsingle
             cosph2(k)=0.0d0
             sinph2(k)=0.0d0
@@ -5249,6 +5255,11 @@ c   3 = SC...Ca...Ca...SCi
           cosphi=dcos(j*tauangle(intertyp,i))
           sinphi=dsin(j*tauangle(intertyp,i))
           esccor=esccor+v1ij*cosphi+v2ij*sinphi
+#define DEBUG
+#ifdef DEBUG
+          esccor_ii=esccor_ii+v1ij*cosphi+v2ij*sinphi
+#endif
+#undef DEBUG
           gloci=gloci+j*(v2ij*cosphi-v1ij*sinphi)
         enddo
         gloc_sc(intertyp,i-3,icg)=gloc_sc(intertyp,i-3,icg)+wsccor*gloci
@@ -5261,6 +5272,9 @@ c     &gloc_sc(intertyp,i-3,icg)
      & ,(v2sccor(j,intertyp,itori,itori1),j=1,6)
         gsccor_loc(i-3)=gsccor_loc(i-3)+gloci
        enddo !intertyp
+#ifdef DEBUG
+       write (iout,*) "i",i,(tauangle(j,i),j=1,3),esccor_ii
+#endif
       enddo
 c        do i=1,nres
 c        write (iout,*) "W@T@F",  gloc_sc(1,i,icg),gloc(i,icg)