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 cd print *,'nres',nres,' nphi',nphi,' ntheta',ntheta,' nvar',nvar
21 cd print *,i,i-3,phi(i)
26 cd print *,i,i-2+nphi,theta(i)
28 if (n.eq.nphi+ntheta) return
30 if (ialph(i,1).gt.0) then
32 x(ialph(i,1)+nside)=omeg(i)
33 cd print *,i,ialph(i,1),ialph(i,1)+nside,alph(i),omeg(i)
38 C--------------------------------------------------------------------
39 subroutine var_to_geom(n,x)
41 C Update geometry parameters according to the variable array.
43 implicit real*8 (a-h,o-z)
46 include 'COMMON.CHAIN'
48 include 'COMMON.IOUNITS'
52 if (n.gt.nphi+ntheta) then
55 alph(ii)=x(nphi+ntheta+i)
56 omeg(ii)=pinorm(x(nphi+ntheta+nside+i))
65 if (theta(i).eq.pi) theta(i)=0.99d0*pi
70 c-------------------------------------------------------------------------
71 logical function convert_side(alphi,omegi)
73 double precision alphi,omegi
74 double precision pinorm
77 C Apply periodicity restrictions.
80 omegi=pinorm(omegi+pi)
85 c-------------------------------------------------------------------------
86 logical function reduce(x)
88 C Apply periodic restrictions to variables.
90 implicit real*8 (a-h,o-z)
93 include 'COMMON.CHAIN'
95 logical zm,zmiana,convert_side
101 if (nvar.gt.nphi+ntheta) then
105 x(ii)=thetnorm(x(ii))
106 x(iii)=pinorm(x(iii))
107 C Apply periodic restrictions.
108 zm=convert_side(x(ii),x(iii))
112 if (nvar.eq.nphi) return
116 x(ii)=dmod(x(ii),dwapi)
117 C Apply periodic restrictions.
118 if (x(ii).gt.pi) then
121 if (iii.gt.0) x(iii)=pinorm(x(iii)+pi)
122 if (i.lt.nres) x(iii+1)=pinorm(x(iii+1)+pi)
125 x(ii)=dmod(pi-x(ii),dwapi)
126 x(ii+nside)=pinorm(-x(ii+nside))
127 zm=convert_side(x(ii),x(ii+nside))
129 else if (x(ii).lt.-pi) then
134 x(ii)=dmod(pi-x(ii),dwapi)
135 x(ii+nside)=pinorm(-pi-x(ii+nside))
136 zm=convert_side(x(ii),x(ii+nside))
138 else if (x(ii).lt.0.0d0) then
141 if (iii.gt.0) x(iii)=pinorm(x(iii)+pi)
142 if (i.lt.nres) x(iii+1)=pinorm(x(iii+1)+pi)
145 x(ii+nside)=pinorm(-x(ii+nside))
146 zm=convert_side(x(ii),x(ii+nside))
153 c--------------------------------------------------------------------------
154 double precision function thetnorm(x)
155 C This function puts x within [0,2Pi].
157 double precision x,xx
160 if (xx.lt.0.0d0) xx=xx+dwapi
161 if (xx.gt.0.9999d0*pi) xx=0.9999d0*pi
165 C--------------------------------------------------------------------
166 subroutine var_to_geom_restr(n,xx)
168 C Update geometry parameters according to the variable array.
170 implicit real*8 (a-h,o-z)
173 include 'COMMON.CHAIN'
175 include 'COMMON.IOUNITS'
176 dimension x(maxvar),xx(maxvar)
177 logical change,reduce
183 alph(ii)=x(nphi+ntheta+i)
184 omeg(ii)=pinorm(x(nphi+ntheta+nside+i))
191 if (theta(i).eq.pi) theta(i)=0.99d0*pi
196 c-------------------------------------------------------------------------