source: energy.f

Last change on this file was 32289cd, checked in by baerbaer <baerbaer@…>, 14 years ago

Explicitly declare variables.

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/smmp/trunk@33 26dc1dd8-5c4e-0410-9ffe-d298b4865968

  • Property mode set to 100644
File size: 4.6 KB
Line 
1! **************************************************************
2!
3! This file contains the subroutines: energy, enyinternal
4!
5! Copyright 2003-2005 Frank Eisenmenger, U.H.E. Hansmann,
6! Shura Hayryan, Chin-Ku
7! Copyright 2007 Frank Eisenmenger, U.H.E. Hansmann,
8! Jan H. Meinke, Sandipan Mohanty
9!
10! **************************************************************
11
12 real*8 function energy()
13! ------------------------------------------
14! PURPOSE: calculate the *total* energy of the system
15!
16! ientyp = 0 for ECEPP3, 1 for FLEX, 2 for Lund
17! 3 for ECEPP3 with Abagyan corrections
18!
19! CALLS: enyflx,enyreg,enyshe,enysol,esolan,setvar, eninteract
20!
21! -------------------------------------------------
22
23 include 'INCL.H'
24 double precision esm, teysl, enyshe, enyflx, enylun, enyreg
25 double precision enysol, esolan, exvlun, eyabgn, eninteract
26
27 integer i
28
29 double precision teysm, teyel, teyvw, teyhb, teyvr
30! print *,'energy function with ientyp = ',ientyp
31 esm = 0.d0
32 teysm = 0.d0
33 teyel = 0.d0
34 teyvw = 0.d0
35 teyhb = 0.d0
36 teyvr = 0.d0
37 teysl = 0.d0
38
39 do i = 1,ntlml
40 eysm=0
41 eyel=0
42 eyvr=0
43 eyhb=0
44 eyvw=0
45 eysl=0
46
47 call setvar(i,vlvr) ! set variables & rebuild
48
49 if (ientyp.eq.0.or.ientyp.eq.3) then
50 esm=esm+enyshe(i)
51 else if (ientyp.eq.1) then
52 esm=esm+enyflx(i)
53 else if (ientyp.eq.2) then
54 esm=enylun(i)
55 endif
56
57 teysm = teysm + eysm
58 teyel = teyel + eyel
59 teyhb = teyhb + eyhb
60 teyvr = teyvr + eyvr
61 if (ientyp.eq.2) then
62! The Lund term stores the hydrophobicity energy in eysl
63 teysl = teysl + eysl
64 else
65! .. and the excluded volume term in eyvw, which is calculated once.
66 teyvw = teyvw + eyvw
67 endif
68
69 if (ireg.eq.1) eyrg=enyreg(i)
70
71 enddo
72
73 if (ientyp.ne.2) then
74! Don't touch eysl if using Lund potential, as enylun stores
75! its hydrophobicity term there.
76 if (itysol.gt.0) then
77 esm=esm+enysol(0)
78 teysl = teysl+eysl
79 else if (itysol.lt.0) then
80 eysl = esolan(0)
81 teysl = teysl + eysl
82 esm = esm + eysl
83 else
84 eysl=0.d0
85 endif
86 else
87! Add excluded volume term and save it in eyvw
88 esm=esm+exvlun(0)
89 teyvw = teyvw+eyvw
90 endif
91
92! The Abagyan entropic corrections depend on the area exposed to the
93! solvent for each residue. So, this term has to be evaluated after the
94! solvent term.
95 eyab=0.0
96 if (ientyp.eq.3) then
97 do i = 1,ntlml
98 eyab=eyab+eyabgn(i)
99 enddo
100 endif
101 esm=esm+eyab
102! Partial energies for the entire system. If you need the partial
103! energies for a single molecule call enyinternal.
104 eysm = teysm
105 eyel = teyel
106 eyvw = teyvw
107 eyhb = teyhb
108 eyvr = teyvr
109 eysl = teysl
110
111 if (ientyp.ne.2) then
112! This is temporary. eninteract() does not yet know how to calculate
113! interactions using the Lund potential.
114 energy = esm + eninteract()
115 return
116 endif
117 energy=esm
118 return
119 end
120
121!c Calculates the internal energy for a single molecule.
122! All the partial energies are thus set to their values for molecule
123! nml.
124!
125! @param nml the ID of the molecule
126! @return internal energy of a single molecule
127!
128! @author Jan H. Meinke <j.meinke@fz-juelich.de>
129 real*8 function enyinternal(nml)
130
131!f2py intent(in) nml
132
133 include 'INCL.H'
134 double precision esm, enyshe, enyflx, enylun, enyreg, enysol
135 double precision esolan, exvlun, eyabgn
136
137 integer nml, i
138
139 esm = 0.d0
140
141 call setvar(nml,vlvr)
142
143 if (ientyp.eq.0.or.ientyp.eq.3) then
144 esm=esm+enyshe(nml)
145 else if (ientyp.eq.1) then
146 esm=esm+enyflx(nml)
147 else if (ientyp.eq.2) then
148 esm=esm+enylun(nml)
149 endif
150
151 if (ireg.eq.1) eyrg=enyreg(nml)
152
153 if (ientyp.ne.2) then
154 if (itysol.gt.0) then
155 esm=esm+enysol(nml)
156 elseif (itysol.lt.0) then
157 esm=esm+esolan(nml)
158 else
159 eysl=0.d0
160 endif
161 else
162 esm=esm+exvlun(nml)
163 endif
164! The Abagyan entropic corrections depend on the area exposed to the
165! solvent for each residue. So, this term has to be evaluated after the
166! solvent term.
167 eyab=0.0
168 if (ientyp.eq.3) then
169 do i=1,ntlml
170 eyab=eyab + eyabgn(i)
171 enddo
172 endif
173 esm=esm+eyab
174
175 enyinternal = esm
176 return
177 end
Note: See TracBrowser for help on using the repository browser.