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