small fix in .gitingnore
[unres.git] / source / wham / src / intcor.f
1 C
2 C------------------------------------------------------------------------------
3 C
4       double precision function alpha(i1,i2,i3)
5 c
6 c  Calculates the planar angle between atoms (i1), (i2), and (i3).
7 c
8       implicit real*8 (a-h,o-z)
9       include 'DIMENSIONS'
10       include 'DIMENSIONS.ZSCOPT'
11       include 'COMMON.GEO'
12       include 'COMMON.CHAIN'
13       x12=c(1,i1)-c(1,i2)
14       x23=c(1,i3)-c(1,i2)
15       y12=c(2,i1)-c(2,i2)
16       y23=c(2,i3)-c(2,i2)
17       z12=c(3,i1)-c(3,i2)
18       z23=c(3,i3)-c(3,i2)
19       vnorm=dsqrt(x12*x12+y12*y12+z12*z12)
20       wnorm=dsqrt(x23*x23+y23*y23+z23*z23)
21       scalar=(x12*x23+y12*y23+z12*z23)/(vnorm*wnorm)
22       alpha=arcos(scalar)
23       return
24       end
25 C
26 C------------------------------------------------------------------------------
27 C
28       double precision function beta(i1,i2,i3,i4)
29 c
30 c  Calculates the dihedral angle between atoms (i1), (i2), (i3) and (i4)
31 c
32       implicit real*8 (a-h,o-z)
33       include 'DIMENSIONS'
34       include 'DIMENSIONS.ZSCOPT'
35       include 'COMMON.GEO'
36       include 'COMMON.CHAIN'
37       x12=c(1,i1)-c(1,i2)
38       x23=c(1,i3)-c(1,i2)
39       x34=c(1,i4)-c(1,i3)
40       y12=c(2,i1)-c(2,i2)
41       y23=c(2,i3)-c(2,i2)
42       y34=c(2,i4)-c(2,i3)
43       z12=c(3,i1)-c(3,i2)
44       z23=c(3,i3)-c(3,i2)
45       z34=c(3,i4)-c(3,i3)
46 cd    print '(2i3,3f10.5)',i1,i2,x12,y12,z12
47 cd    print '(2i3,3f10.5)',i2,i3,x23,y23,z23
48 cd    print '(2i3,3f10.5)',i3,i4,x34,y34,z34
49       wx=-y23*z34+y34*z23
50       wy=x23*z34-z23*x34
51       wz=-x23*y34+y23*x34
52       wnorm=dsqrt(wx*wx+wy*wy+wz*wz)
53       vx=y12*z23-z12*y23
54       vy=-x12*z23+z12*x23
55       vz=x12*y23-y12*x23
56       vnorm=dsqrt(vx*vx+vy*vy+vz*vz)
57       if (vnorm.gt.1.0D-13 .and. wnorm.gt.1.0D-13) then
58       scalar=(vx*wx+vy*wy+vz*wz)/(vnorm*wnorm)
59       if (dabs(scalar).gt.1.0D0) 
60      &scalar=0.99999999999999D0*scalar/dabs(scalar)
61       angle=dacos(scalar)
62 cd    print '(2i4,10f7.3)',i2,i3,vx,vy,vz,wx,wy,wz,vnorm,wnorm,
63 cd   &scalar,angle
64       else
65       angle=pi
66       endif 
67 c     if (angle.le.0.0D0) angle=pi+angle
68       tx=vy*wz-vz*wy
69       ty=-vx*wz+vz*wx
70       tz=vx*wy-vy*wx
71       scalar=tx*x23+ty*y23+tz*z23
72       if (scalar.lt.0.0D0) angle=-angle
73       beta=angle
74       return
75       end
76 C
77 C------------------------------------------------------------------------------
78 C
79       double precision function dist(i1,i2)
80 c
81 c  Calculates the distance between atoms (i1) and (i2).
82 c
83       implicit real*8 (a-h,o-z)
84       include 'DIMENSIONS'
85       include 'DIMENSIONS.ZSCOPT'
86       include 'COMMON.GEO'
87       include 'COMMON.CHAIN'
88       x12=c(1,i1)-c(1,i2)
89       y12=c(2,i1)-c(2,i2)
90       z12=c(3,i1)-c(3,i2)
91       dist=dsqrt(x12*x12+y12*y12+z12*z12)
92       return
93       end
94 C