Merge branch 'master' of mmka.chem.univ.gda.pl:unres into homology
[unres.git] / source / unres / src_MD / energy_p_new_barrier.F
index f27a831..535e8b2 100644 (file)
@@ -257,6 +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
       else
         ehomology_constr=0.0d0
       endif
@@ -4860,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
@@ -4869,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
@@ -4904,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
@@ -6032,7 +6038,7 @@ c        write (iout,* )"min_odl",min_odl
          odleg2=0.0d0
          do k=1,constr_homology
 c Nie wiem po co to liczycie jeszcze raz!
-c            odleg3=-waga_dist*((distance(i,j,k)**2)/ 
+c            odleg3=-waga_dist(iset)*((distance(i,j,k)**2)/ 
 c     &              (2*(sigma_odl(i,j,k))**2))
             godl(k)=dexp(-distancek(k)+min_odl)
             odleg2=odleg2+godl(k)
@@ -6067,7 +6073,11 @@ 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
 c        grad_odl3=sum_sgodl/(sum_godl*dij)
 
 
@@ -6165,7 +6175,11 @@ 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
-        grad_dih3=waga_angle*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
 
 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,
@@ -6439,8 +6453,13 @@ c
 c Addition of energy of theta angle and SC local geom over constr_homologs ref strs
 c
 c     ehomology_constr=odleg+kat
-      ehomology_constr=waga_dist*odleg+waga_angle*kat+waga_theta*Eval
+      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
 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
@@ -6554,6 +6573,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)