Introduction of SS to newcorr and SSS to src_MD-M
[unres.git] / source / unres / src_MD-M-newcorr / energy_p_new_barrier.F
index 42005e1..5e90c17 100644 (file)
@@ -121,6 +121,10 @@ C
 C Calculate electrostatic (H-bonding) energy of the main chain.
 C
   107 continue
+cmc
+cmc Sep-06: egb takes care of dynamic ss bonds too
+cmc
+C      if (dyn_ss) call dyn_set_nss
 c      print *,"Processor",myrank," computed USCSC"
 #ifdef TIMING
       time01=MPI_Wtime() 
@@ -300,6 +304,7 @@ c    Here are the energies showed per procesor if the are more processors
 c    per molecule then we sum it up in sum_energy subroutine 
 c      print *," Processor",myrank," calls SUM_ENERGY"
       call sum_energy(energia,.true.)
+      if (dyn_ss) call dyn_set_nss
 c      print *," Processor",myrank," left SUM_ENERGY"
 #ifdef TIMING
       time_sumene=time_sumene+MPI_Wtime()-time00
@@ -1412,6 +1417,7 @@ C
       include 'COMMON.IOUNITS'
       include 'COMMON.CALC'
       include 'COMMON.CONTROL'
+      include 'COMMON.SBRIDGE'
       logical lprn
       evdw=0.0D0
 ccccc      energy_dec=.false.
@@ -1439,6 +1445,12 @@ C Calculate SC interaction energy.
 C
         do iint=1,nint_gr(i)
           do j=istart(i,iint),iend(i,iint)
+            IF (dyn_ss_mask(i).and.dyn_ss_mask(j)) THEN
+              call dyn_ssbond_ene(i,j,evdwij)
+              evdw=evdw+evdwij
+              if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)') 
+     &                        'evdw',i,j,evdwij,' ss'
+            ELSE
             ind=ind+1
             itypj=iabs(itype(j))
             if (itypj.eq.ntyp1) cycle
@@ -1533,6 +1545,7 @@ C Calculate the radial part of the gradient
             gg(3)=zj*fac
 C Calculate angular part of the gradient.
             call sc_grad
+          endif      ! dyn_ss
           enddo      ! j
         enddo        ! iint
       enddo          ! i
@@ -4280,10 +4293,20 @@ C iii and jjj point to the residues for which the distance is assigned.
 cd        write (iout,*) "i",i," ii",ii," iii",iii," jj",jj," jjj",jjj
 C 24/11/03 AL: SS bridges handled separately because of introducing a specific
 C    distance and angle dependent SS bond potential.
-        if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and.
-     & iabs(itype(jjj)).eq.1) then
-          call ssbond_ene(iii,jjj,eij)
+cmc        if (ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then
+C 18/07/06 MC: Use the convention that the first nss pairs are SS bonds
+c          if (.not.dyn_ss .and. i.le.nss) then
+C 15/02/13 CC dynamic SSbond
+C        if (.not.dyn_ss.and.
+C     &   ii.gt.nres .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then 
+
+        if (.not.dyn_ss .and. i.le.nss) then
+C 15/02/13 CC dynamic SSbond - additional check
+         if (ii.gt.nres 
+     &       .and. itype(iii).eq.1 .and. itype(jjj).eq.1) then    
+       call ssbond_ene(iii,jjj,eij)
           ehpb=ehpb+2*eij
+        endif
 cd          write (iout,*) "eij",eij
         else
 C Calculate the distance between the two points and its difference from the