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)
16 include 'COMMON.CHAIN'
18 c 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
32 c print *,i,ialph(i,1),ialph(i,1)+nside,alph(i),omeg(i)
34 x(ialph(i,1)+nside)=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)
47 include 'COMMON.CHAIN'
49 include 'COMMON.IOUNITS'
53 if (n.gt.nphi+ntheta) then
56 alph(ii)=x(nphi+ntheta+i)
57 omeg(ii)=pinorm(x(nphi+ntheta+nside+i))
66 if (theta(i).eq.pi) theta(i)=0.99d0*pi
71 c-------------------------------------------------------------------------
72 logical function convert_side(alphi,omegi)
74 double precision alphi,omegi
75 double precision pinorm
78 C Apply periodicity restrictions.
81 omegi=pinorm(omegi+pi)
86 c-------------------------------------------------------------------------
87 logical function reduce(x)
89 C Apply periodic restrictions to variables.
91 implicit real*8 (a-h,o-z)
94 include 'COMMON.CHAIN'
96 logical zm,zmiana,convert_side
100 x(i-3)=pinorm(x(i-3))
102 if (nvar.gt.nphi+ntheta) then
106 x(ii)=thetnorm(x(ii))
107 x(iii)=pinorm(x(iii))
108 C Apply periodic restrictions.
109 zm=convert_side(x(ii),x(iii))
113 if (nvar.eq.nphi) return
117 x(ii)=dmod(x(ii),dwapi)
118 C Apply periodic restrictions.
119 if (x(ii).gt.pi) then
122 if (iii.gt.0) x(iii)=pinorm(x(iii)+pi)
123 if (i.lt.nres) x(iii+1)=pinorm(x(iii+1)+pi)
126 x(ii)=dmod(pi-x(ii),dwapi)
127 x(ii+nside)=pinorm(-x(ii+nside))
128 zm=convert_side(x(ii),x(ii+nside))
130 else if (x(ii).lt.-pi) then
135 x(ii)=dmod(pi-x(ii),dwapi)
136 x(ii+nside)=pinorm(-pi-x(ii+nside))
137 zm=convert_side(x(ii),x(ii+nside))
139 else if (x(ii).lt.0.0d0) then
142 if (iii.gt.0) x(iii)=pinorm(x(iii)+pi)
143 if (i.lt.nres) x(iii+1)=pinorm(x(iii+1)+pi)
146 x(ii+nside)=pinorm(-x(ii+nside))
147 zm=convert_side(x(ii),x(ii+nside))
154 c--------------------------------------------------------------------------
155 double precision function thetnorm(x)
156 C This function puts x within [0,2Pi].
158 double precision x,xx
161 if (xx.lt.0.0d0) xx=xx+dwapi
162 if (xx.gt.0.9999d0*pi) xx=0.9999d0*pi
166 C--------------------------------------------------------------------
167 subroutine var_to_geom_restr(n,xx)
169 C Update geometry parameters according to the variable array.
171 implicit real*8 (a-h,o-z)
174 include 'COMMON.CHAIN'
176 include 'COMMON.IOUNITS'
177 dimension x(maxvar),xx(maxvar)
178 logical change,reduce
184 alph(ii)=x(nphi+ntheta+i)
185 omeg(ii)=pinorm(x(nphi+ntheta+nside+i))
192 if (theta(i).eq.pi) theta(i)=0.99d0*pi
197 c-------------------------------------------------------------------------