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
16 include 'COMMON.CHAIN'
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.
47 include 'COMMON.CHAIN'
49 include 'COMMON.IOUNITS'
54 double precision pinorm
56 if (n.gt.nphi+ntheta) then
59 alph(ii)=x(nphi+ntheta+i)
60 omeg(ii)=pinorm(x(nphi+ntheta+nside+i))
69 if (theta(i).eq.pi) theta(i)=0.99d0*pi
74 c-------------------------------------------------------------------------
75 logical function convert_side(alphi,omegi)
77 double precision alphi,omegi
78 double precision pinorm
81 C Apply periodicity restrictions.
84 omegi=pinorm(omegi+pi)
89 c-------------------------------------------------------------------------
90 logical function reduce(x)
92 C Apply periodic restrictions to variables.
97 include 'COMMON.CHAIN'
99 logical zm,zmiana,convert_side
101 double precision x(nvar)
102 double precision thetnorm,pinorm
105 x(i-3)=pinorm(x(i-3))
107 if (nvar.gt.nphi+ntheta) then
111 x(ii)=thetnorm(x(ii))
112 x(iii)=pinorm(x(iii))
113 C Apply periodic restrictions.
114 zm=convert_side(x(ii),x(iii))
118 if (nvar.eq.nphi) return
122 x(ii)=dmod(x(ii),dwapi)
123 C Apply periodic restrictions.
124 if (x(ii).gt.pi) then
127 if (iii.gt.0) x(iii)=pinorm(x(iii)+pi)
128 if (i.lt.nres) x(iii+1)=pinorm(x(iii+1)+pi)
131 x(ii)=dmod(pi-x(ii),dwapi)
132 x(ii+nside)=pinorm(-x(ii+nside))
133 zm=convert_side(x(ii),x(ii+nside))
135 else if (x(ii).lt.-pi) then
140 x(ii)=dmod(pi-x(ii),dwapi)
141 x(ii+nside)=pinorm(-pi-x(ii+nside))
142 zm=convert_side(x(ii),x(ii+nside))
144 else if (x(ii).lt.0.0d0) then
147 if (iii.gt.0) x(iii)=pinorm(x(iii)+pi)
148 if (i.lt.nres) x(iii+1)=pinorm(x(iii+1)+pi)
151 x(ii+nside)=pinorm(-x(ii+nside))
152 zm=convert_side(x(ii),x(ii+nside))
159 c--------------------------------------------------------------------------
160 double precision function thetnorm(x)
161 C This function puts x within [0,2Pi].
163 double precision x,xx
166 if (xx.lt.0.0d0) xx=xx+dwapi
167 if (xx.gt.0.9999d0*pi) xx=0.9999d0*pi
171 C--------------------------------------------------------------------
172 subroutine var_to_geom_restr(n,xx)
174 C Update geometry parameters according to the variable array.
179 include 'COMMON.CHAIN'
181 include 'COMMON.IOUNITS'
183 double precision x(maxvar),xx(maxvar)
184 logical change,reduce
185 double precision pinorm
191 alph(ii)=x(nphi+ntheta+i)
192 omeg(ii)=pinorm(x(nphi+ntheta+nside+i))
199 if (theta(i).eq.pi) theta(i)=0.99d0*pi
204 c-------------------------------------------------------------------------