REMD with HOMOL_NSET>1 and single weight for all homology restraints
[unres.git] / source / unres / src_MD / energy_p_new_barrier.F
index e893d55..15dfccd 100644 (file)
@@ -257,9 +257,9 @@ cd    print *,'nterm=',nterm
 
       if (constr_homology.ge.1) then
         call e_modeller(ehomology_constr)
-        print *,'iset=',iset,'me=',me,ehomology_constr,
-     &  'Processor',fg_rank,' CG group',kolor,
-     &  ' absolute rank',MyRank
+c        print *,'iset=',iset,'me=',me,ehomology_constr,
+c     &  'Processor',fg_rank,' CG group',kolor,
+c     &  ' absolute rank',MyRank
       else
         ehomology_constr=0.0d0
       endif
@@ -4863,6 +4863,8 @@ C
       logical lprn /.false./, lprn1 /.false./
       etheta=0.0D0
       do i=ithet_start,ithet_end
+        if ((itype(i-1).eq.ntyp1).or.(itype(i-2).eq.ntyp1).or.
+     &(itype(i).eq.ntyp1)) cycle
         dethetai=0.0d0
         dephii=0.0d0
         dephii1=0.0d0
@@ -4872,7 +4874,8 @@ C
           coskt(k)=dcos(k*theti2)
           sinkt(k)=dsin(k*theti2)
         enddo
-        if (i.gt.3) then
+C        if (i.gt.3) then
+         if (i.gt.3 .and. itype(i-3).ne.ntyp1) then
 #ifdef OSF
           phii=phi(i)
           if (phii.ne.phii) phii=150.0
           enddo
         else
           phii=0.0d0
-          ityp1=nthetyp+1
+          ityp1=ithetyp(itype(i-2))
           do k=1,nsingle
             cosph1(k)=0.0d0
             sinph1(k)=0.0d0
           enddo 
         endif
-        if (i.lt.nres) then
+        if ((i.lt.nres).and. itype(i+1).ne.ntyp1) then
 #ifdef OSF
           phii1=phi(i+1)
           if (phii1.ne.phii1) phii1=150.0
@@ -4907,7 +4910,7 @@ C
           enddo
         else
           phii1=0.0d0
-          ityp3=nthetyp+1
+          ityp3=ithetyp(itype(i))
           do k=1,nsingle
             cosph2(k)=0.0d0
             sinph2(k)=0.0d0
@@ -6070,11 +6073,8 @@ c      write(iout,*) "constr_homology=",constr_homology
 c      write(iout,*) i, j, k, "TEST K"
          enddo
 
-       if (homol_nset.gt.1)then
-         grad_odl3=waga_dist1(iset)*sum_sgodl/(sum_godl*dij)
-       else
-         grad_odl3=waga_dist*sum_sgodl/(sum_godl*dij)
-       endif
+         grad_odl3=waga_homology(iset)*waga_dist
+     &            *sum_sgodl/(sum_godl*dij)
 c        grad_odl3=sum_sgodl/(sum_godl*dij)
 
 
@@ -6172,11 +6172,7 @@ c         sgdih=-gdih(k)*dih_diff(k)*sigma_dih(k,i)*waga_angle
           sum_sgdih=sum_sgdih+sgdih
         enddo
 c       grad_dih3=sum_sgdih/sum_gdih
-        if (homol_nset.gt.1)then
-         grad_dih3=waga_angle1(iset)*sum_sgdih/sum_gdih
-        else
-         grad_dih3=waga_angle*sum_sgdih/sum_gdih
-        endif
+        grad_dih3=waga_homology(iset)*waga_angle*sum_sgdih/sum_gdih
 
 c      write(iout,*)i,k,gdih,sgdih,beta(i+1,i+2,i+3,i+4),grad_dih3
 ccc      write(iout,747) "GRAD_KAT_1", i, nphi, icg, grad_dih3,
@@ -6274,6 +6270,7 @@ 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
+     &               *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
@@ -6362,7 +6359,7 @@ c         sum_sguscdiff=sum_sguscdiff+sum_guscdiff
 c
 c
 c        New implementation
-         sum_guscdiff = waga_d*sum_guscdiff
+         sum_guscdiff = waga_homology(iset)*waga_d*sum_guscdiff
          do jik=1,3
             duscdiff(jik,i-1)=duscdiff(jik,i-1)+
      &      sum_guscdiff*(dXX_C1tab(jik,i)*dxx+
@@ -6450,13 +6447,8 @@ c
 c Addition of energy of theta angle and SC local geom over constr_homologs ref strs
 c
 c     ehomology_constr=odleg+kat
-      if (homol_nset.gt.1)then
-       ehomology_constr=waga_dist1(iset)*odleg+waga_angle1(iset)*kat+waga_theta*Eval
-     &              +waga_d*Erot     
-      else
-       ehomology_constr=waga_dist*odleg+waga_angle*kat+waga_theta*Eval
-     &              +waga_d*Erot
-      endif
+       ehomology_constr=(waga_dist*odleg+waga_angle*kat+waga_theta*Eval
+     &              +waga_d*Erot)*waga_homology(iset)
 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
@@ -6570,6 +6562,7 @@ c      write (iout,*) "EBACK_SC_COR",iphi_start,iphi_end,nterm_sccor
       esccor=0.0D0
       do i=itau_start,itau_end
         esccor_ii=0.0D0
+        if ((itype(i-2).eq.ntyp1).or.(itype(i-1).eq.ntyp1)) cycle
         isccori=isccortyp(itype(i-2))
         isccori1=isccortyp(itype(i-1))
         phii=phi(i)