update new files
[unres.git] / source / unres / src_MD-M-SAXS.safe / b
1 C Calculate the distance between the two points and its difference from the
2 C target distance.
3           dd=dist(ii,jj)
4           write (iout,*) "ELSE: dd",dd," constr_dist",constr_dist
5           if (constr_dist.eq.11) then
6             ehpb=ehpb+fordepth(i)!**4.0d0
7      &           *rlornmr1(dd,dhpb(i),dhpb1(i),forcon(i))
8             fac=fordepth(i)!**4.0d0
9      &           *rlornmr1prim(dd,dhpb(i),dhpb1(i),forcon(i))/dd
10             if(energy_dec)write (iout,'(a6,2i5,6f10.3)') "edisl",ii,jj,
11      &        dd,dhpb(i),dhpb1(i),forcon(i),fordepth(i),ehpb
12           else if (constr_dist.eq.10) then
13 c AL 6//19/2018 cross-link restraints
14             xdis = (dd/forcon(i))**2
15             write (iout,*) "HERE: xdis",xdis
16             expon = dexp(-xx)
17             aux=(dhpb(i)+dhpb1(i)*xx)*expon+fordepth(i)
18             ehpb=ehpb-wboltzd*dlog(aux)
19             fac=-wboltzd*dhpb1(i)*(1.0d0-xx)*dxpon/(aux*forcon(i)**2)
20             if (energy_dec)write(iout,'(a6,2i5,6f10.3)') "edisl",ii,jj,
21      &        dd,dhpb(i),dhpb1(i),forcon(i),fordepth(i),ehpb
22           else   
23 c Quadratic or quartic  restraints
24             if (dhpb1(i).gt.0.0d0) then
25               ehpb=ehpb+2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
26               fac=forcon(i)*gnmr1prim(dd,dhpb(i),dhpb1(i))/dd
27 c             write (iout,*) "alph nmr",
28 c     &       dd,2*forcon(i)*gnmr1(dd,dhpb(i),dhpb1(i))
29             else
30               rdis=dd-dhpb(i)
31 C Get the force constant corresponding to this distance.
32               waga=forcon(i)
33 C Calculate the contribution to energy.
34               ehpb=ehpb+waga*rdis*rdis
35 c            write (iout,*) "alpha reg",dd,waga*rdis*rdis
36 C
37 C Evaluate gradient.
38 C
39               fac=waga*rdis/dd
40             endif
41           endif
42 c Calculate Cartesian gradient
43           do j=1,3
44             ggg(j)=fac*(c(j,jj)-c(j,ii))
45           enddo
46 cd      print '(i3,3(1pe14.5))',i,(ggg(j),j=1,3)
47 C If this is a SC-SC distance, we need to calculate the contributions to the
48 C Cartesian gradient in the SC vectors (ghpbx).
49           if (iii.lt.ii) then
50             do j=1,3
51               ghpbx(j,iii)=ghpbx(j,iii)-ggg(j)
52               ghpbx(j,jjj)=ghpbx(j,jjj)+ggg(j)
53             enddo
54           endif
55 cgrad        do j=iii,jjj-1
56 cgrad          do k=1,3
57 cgrad            ghpbc(k,j)=ghpbc(k,j)+ggg(k)
58 cgrad          enddo
59 cgrad        enddo
60           do k=1,3
61             ghpbc(k,jjj)=ghpbc(k,jjj)+ggg(k)
62             ghpbc(k,iii)=ghpbc(k,iii)-ggg(k)
63           enddo
64         endif
65