Adding dyn_ss and triss potentials to src-M wham
[unres.git] / source / wham / src-M / energy_p_new.F
index 413817c..09244ec 100644 (file)
@@ -232,6 +232,7 @@ c     &   +wsccor*fact(1)*gsccor_loc(i)
 c BYLA ROZNICA Z CLUSTER< OSTATNIA LINIA DODANA
       enddo
       endif
+      if (dyn_ss) call dyn_set_nss
       return
       end
 C------------------------------------------------------------------------
@@ -783,6 +784,7 @@ C
       include 'COMMON.ENEPS'
       include 'COMMON.IOUNITS'
       include 'COMMON.CALC'
+      include 'COMMON.SBRIDGE'
       logical lprn
       common /srutu/icall
       integer icant
@@ -814,6 +816,26 @@ 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
+C              if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)')
+C     &                        'evdw',i,j,evdwij,' ss'
+C triple bond artifac removal
+             do k=j+1,iend(i,iint)
+C search over all next residues
+              if (dyn_ss_mask(k)) then
+C check if they are cysteins
+C              write(iout,*) 'k=',k
+              call triple_ssbond_ene(i,j,k,evdwij)
+C call the energy function that removes the artifical triple disulfide
+C bond the soubroutine is located in ssMD.F
+              evdw=evdw+evdwij
+C              if (energy_dec) write (iout,'(a6,2i5,0pf7.3,a3)')
+C     &                        'evdw',i,j,evdwij,'tss'
+              endif!dyn_ss_mask(k)
+             enddo! k
+            ELSE
             ind=ind+1
             itypj=iabs(itype(j))
             if (itypj.eq.ntyp1) cycle
@@ -907,6 +929,7 @@ C Calculate the radial part of the gradient
 C Calculate angular part of the gradient.
             call sc_grad
             endif
+            ENDIF    ! dyn_ss            
           enddo      ! j
         enddo        ! iint
       enddo          ! i
@@ -2943,10 +2966,15 @@ C iii and jjj point to the residues for which the distance is assigned.
         endif
 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. 
+C        if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and. 
+C     & iabs(itype(jjj)).eq.1) then
+
+       if (.not.dyn_ss .and. i.le.nss) then
+         if (ii.gt.nres .and. iabs(itype(iii)).eq.1 .and.
      & iabs(itype(jjj)).eq.1) then
           call ssbond_ene(iii,jjj,eij)
           ehpb=ehpb+2*eij
+           endif
         else
 C Calculate the distance between the two points and its difference from the
 C target distance.