src-HCD-5D update
[unres.git] / source / unres / src-HCD-5D / sc_minimize.F
1       subroutine sc_minimize(etot,iretcode,nfun)
2 c     Minimizes side-chains only, leaving backbone frozen
3 crc      implicit none
4
5 c     Includes
6       implicit real*8 (a-h,o-z)
7       include 'DIMENSIONS'
8       include 'COMMON.VAR'
9       include 'COMMON.CHAIN'
10       include 'COMMON.FFIELD'
11
12 c     Output arguments
13       double precision etot
14       integer iretcode,nfun
15
16 c     Local variables
17       integer i
18       double precision orig_w(n_ene),energy(0:n_ene)
19       double precision var(maxvar)
20
21
22 c     Set non side-chain weights to zero (minimization is faster)
23 c     NOTE: e(2) does not actually depend on the side-chain, only CA
24       orig_w(2)=wscp
25       orig_w(3)=welec
26       orig_w(4)=wcorr
27       orig_w(5)=wcorr5
28       orig_w(6)=wcorr6
29       orig_w(7)=wel_loc
30       orig_w(8)=wturn3
31       orig_w(9)=wturn4
32       orig_w(10)=wturn6
33       orig_w(11)=wang
34       orig_w(13)=wtor
35       orig_w(14)=wtor_d
36
37       wscp=0.D0
38       welec=0.D0
39       wcorr=0.D0
40       wcorr5=0.D0
41       wcorr6=0.D0
42       wel_loc=0.D0
43       wturn3=0.D0
44       wturn4=0.D0
45       wturn6=0.D0
46       wang=0.D0
47       wtor=0.D0
48       wtor_d=0.D0
49
50 c     Prepare to freeze backbone
51       do i=1,nres
52         mask_phi(i)=0
53         mask_theta(i)=0
54         mask_side(i)=1
55       enddo
56
57 c     Minimize the side-chains
58       mask_r=.true.
59       call geom_to_var(nvar,var)
60       call minimize(etot,var,iretcode,nfun)
61       call var_to_geom(nvar,var)
62       mask_r=.false.
63
64 c     Put the original weights back and calculate the full energy
65       wscp=orig_w(2)
66       welec=orig_w(3)
67       wcorr=orig_w(4)
68       wcorr5=orig_w(5)
69       wcorr6=orig_w(6)
70       wel_loc=orig_w(7)
71       wturn3=orig_w(8)
72       wturn4=orig_w(9)
73       wturn6=orig_w(10)
74       wang=orig_w(11)
75       wtor=orig_w(13)
76       wtor_d=orig_w(14)
77
78       call chainbuild_extconf
79       call etotal(energy)
80       etot=energy(0)
81
82       return
83       end
84
85