1 subroutine geom_to_var(n,x)
3 C Transfer the geometry parameters to the variable array.
4 C The positions of variables are as follows:
5 C 1. Virtual-bond torsional angles: 1 thru nres-3
6 C 2. Virtual-bond valence angles: nres-2 thru 2*nres-5
7 C 3. The polar angles alpha of local SC orientation: 2*nres-4 thru
9 C 4. The torsional angles omega of SC orientation: 2*nres-4+nside+1
10 C thru 2*nre-4+2*nside
12 implicit real*8 (a-h,o-z)
14 include 'DIMENSIONS.ZSCOPT'
17 include 'COMMON.CHAIN'
18 double precision x(maxvar)
19 cd print *,'nres',nres,' nphi',nphi,' ntheta',ntheta,' nvar',nvar
22 cd print *,i,i-3,phi(i)
27 cd print *,i,i-2+nphi,theta(i)
29 if (n.eq.nphi+ntheta) return
31 if (ialph(i,1).gt.0) then
33 x(ialph(i,1)+nside)=omeg(i)
34 cd print *,i,ialph(i,1),ialph(i,1)+nside,alph(i),omeg(i)
39 C--------------------------------------------------------------------
40 subroutine var_to_geom(n,x)
42 C Update geometry parameters according to the variable array.
44 implicit real*8 (a-h,o-z)
46 include 'DIMENSIONS.ZSCOPT'
48 include 'COMMON.CHAIN'
50 include 'COMMON.IOUNITS'
54 if (n.gt.nphi+ntheta) then
57 alph(ii)=x(nphi+ntheta+i)
58 omeg(ii)=pinorm(x(nphi+ntheta+nside+i))
67 if (theta(i).eq.pi) theta(i)=0.99d0*pi
72 c-------------------------------------------------------------------------
73 logical function convert_side(alphi,omegi)
75 double precision alphi,omegi
76 double precision pinorm
79 C Apply periodicity restrictions.
82 omegi=pinorm(omegi+pi)
87 c-------------------------------------------------------------------------
88 logical function reduce(x)
90 C Apply periodic restrictions to variables.
92 implicit real*8 (a-h,o-z)
94 include 'DIMENSIONS.ZSCOPT'
96 include 'COMMON.CHAIN'
98 logical zm,zmiana,convert_side
102 x(i-3)=pinorm(x(i-3))
104 if (nvar.gt.nphi+ntheta) then
108 x(ii)=thetnorm(x(ii))
109 x(iii)=pinorm(x(iii))
110 C Apply periodic restrictions.
111 zm=convert_side(x(ii),x(iii))
115 if (nvar.eq.nphi) return
119 x(ii)=dmod(x(ii),dwapi)
120 C Apply periodic restrictions.
121 if (x(ii).gt.pi) then
124 if (iii.gt.0) x(iii)=pinorm(x(iii)+pi)
125 if (i.lt.nres) x(iii+1)=pinorm(x(iii+1)+pi)
128 x(ii)=dmod(pi-x(ii),dwapi)
129 x(ii+nside)=pinorm(-x(ii+nside))
130 zm=convert_side(x(ii),x(ii+nside))
132 else if (x(ii).lt.-pi) then
137 x(ii)=dmod(pi-x(ii),dwapi)
138 x(ii+nside)=pinorm(-pi-x(ii+nside))
139 zm=convert_side(x(ii),x(ii+nside))
141 else if (x(ii).lt.0.0d0) then
144 if (iii.gt.0) x(iii)=pinorm(x(iii)+pi)
145 if (i.lt.nres) x(iii+1)=pinorm(x(iii+1)+pi)
148 x(ii+nside)=pinorm(-x(ii+nside))
149 zm=convert_side(x(ii),x(ii+nside))
156 c--------------------------------------------------------------------------
157 double precision function thetnorm(x)
158 C This function puts x within [0,0.9999*Pi].
160 double precision x,xx
165 else if (xx.lt.0.0d0) then
167 else if (xx.gt.pi) then
170 if (xx.gt.0.9999d0*pi) xx=0.9999d0*pi