-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyze.c
205 lines (193 loc) · 5.82 KB
/
analyze.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/* analyze.c
*
* routine to analyze energy and force for AMMP.
*
* analyzes the potential due to each kind of potential used
*
*/
/*
* copyright 1992 Robert W. Harrison
*
* This notice may not be removed
* This program may be copied for scientific use
* It may not be sold for profit without explicit
* permission of the author(s) who retain any
* commercial rights including the right to modify
* this notice
*/
#define ANSI 1
/* misc includes - ANSI and some are just to be safe */
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#ifdef ANSI
#include <stdlib.h>
#endif
#include "ammp.h"
/* ATOM structure contains a serial number for indexing into
* arrays and the like (a Hessian)
* but otherwise is self-contained. Note the hooks for Non-bonded potentials
*/
void analyze( vfs,nfs,ilow,ihigh,op )
int (*vfs[])();
int nfs;
FILE *op;
int ilow,ihigh;
{
/* block of function used in eval()
* only the v_stuff are needed
*/
int v_bond(),f_bond(),v_angle(),f_angle();
int v_dill(),f_dill();
int v_mmbond(),f_mmbond(),v_mmangle(),f_mmangle();
int v_periodic(),f_periodic();
int v_nonbon(),f_nonbon(),v_torsion(),f_torsion();
int v_ttarget(),f_ttarget();
int v_screen(),f_screen();
int atom(),bond(),angle(),torsion();
int v_hybrid(),f_hybrid();
int v_step(),f_step();
int v_swarm(),f_swarm(),a_swarm();
int morse(),v_morse(),f_morse();
int restrain(),v_restrain(),f_restrain();
int tether(),v_tether(),f_tether();
int u_v_nonbon(), u_f_nonbon();
int v_abc();
int v_noel(),a_noel();
int v_ho_noel();
int a_bond(),a_mmbond(),a_angle(),a_mmangle();
int a_nonbon(),a_torsion(),a_hybrid(),a_restrain();
int a_react();
int a_ttarget();
int a_tether();
int a_screen();
int a_abc(),a_step();
int v_image(),a_image();
int v_polar(),a_polar();
float V,vt;
int ifs;
int i,j;
i = ilow;
j = ihigh;
if( ihigh < ilow ) j = ilow;
V = 0.;
for( ifs = 0; ifs < nfs; ifs++ )
{
vt = 0.;
/* (*vfs[ifs])(&vt,0.); */
if( vfs[ifs] == v_bond)
{ a_bond(&vt,0.,i,j,op);fprintf( op," %f bond energy\n",vt); goto DONE;}
if( vfs[ifs] == v_mmbond)
{a_mmbond(&vt,0.,i,j,op); fprintf( op," %f mm bond energy\n",vt); goto DONE;}
if( vfs[ifs] == v_mmangle)
{a_mmangle(&vt,0.,i,j,op); fprintf( op," %f mm angle energy\n",vt); goto DONE;}
if( vfs[ifs] == v_angle)
{a_angle(&vt,0.,i,j,op); fprintf( op," %f angle energy\n",vt); goto DONE;}
if( vfs[ifs] == v_abc)
{a_abc(&vt,0.,i,j,op); fprintf( op," %f abc energy\n",vt); goto DONE;}
if( vfs[ifs] == v_noel)
{a_noel(&vt,0.,i,j,op); fprintf( op," %f noel energy\n",vt); goto DONE;}
if( vfs[ifs] == v_ho_noel)
{a_noel(&vt,0.,i,j,op); fprintf( op," %f noel energy\n",vt); goto DONE;}
if( vfs[ifs] == u_v_nonbon)
{a_nonbon(&vt,0.,i,j,op); fprintf( op," %f non-bonded energy\n",vt); goto DONE;}
if( vfs[ifs] == v_nonbon)
{a_nonbon(&vt,0.,i,j,op); fprintf( op," %f non-bonded energy\n",vt); goto DONE;}
if( vfs[ifs] == v_polar)
{a_polar(&vt,0.,i,j,op); fprintf( op," %f polarization non-bonded energy\n",vt); goto DONE;}
if( vfs[ifs] == v_screen)
{a_screen(&vt,0.,i,j,op); fprintf( op," %f screened non-bonded energy\n",vt); goto DONE;}
if( vfs[ifs] == v_torsion)
{a_torsion(&vt,0.,i,j,op); fprintf( op," %f torsion energy\n",vt); goto DONE;}
if( vfs[ifs] == v_hybrid)
{a_hybrid(&vt,0.,i,j,op); fprintf( op," %f hybrid energy\n",vt); goto DONE;}
if( vfs[ifs] == v_periodic)
{ goto DONE;}
if( vfs[ifs] == v_tether)
{a_tether(&vt,0.,i,j,op); fprintf( op," %f tether restraint energy\n",vt); goto DONE;}
if( vfs[ifs] == v_restrain)
{a_restrain(&vt,0.,i,j,op); fprintf( op," %f restraint bond energy\n",vt); goto DONE;}
if( vfs[ifs] == v_morse)
{ goto DONE;}
if( vfs[ifs] == v_image)
{ a_image(&vt,0., i,j,op); fprintf(op," %f image energy\n",vt);
goto DONE; }
if( vfs[ifs] == v_step)
{ a_step(&vt,0.,i,j,op); fprintf(op,"%f step energy\n",vt); goto DONE;}
if( vfs[ifs] == v_swarm)
{a_swarm(&vt,0.,i,j,op); fprintf(op,"%f swarm energy\n",vt); goto DONE;}
if( vfs[ifs] == v_ttarget)
{a_ttarget(&vt,0.,i,j,op); fprintf( op," %f torsion target energy\n",vt); goto DONE;}
if( vfs[ifs] == v_dill)
{ a_dill(&vt,0.,i,j,op);fprintf( op," %f dill energy\n",vt); goto DONE;}
DONE:
/* next statement is needed because cannot have a label at an end loop */
V += vt;
vt = 0.;
}
fprintf( op," %f total potential energy\n",V);
/* end of routine */
}
void range_analyze( vfs,nfs,ilow,ihigh,jlow,jhigh,op )
int (*vfs[])();
int nfs;
FILE *op;
int ilow,ihigh;
int jlow,jhigh;
{
/* block of function used in eval()
* only the v_stuff are needed
*/
int v_bond(),f_bond(),v_angle(),f_angle();
int v_dill(),f_dill();
int v_mmbond(),f_mmbond(),v_mmangle(),f_mmangle();
int v_periodic(),f_periodic();
int v_nonbon(),f_nonbon(),v_torsion(),f_torsion();
int v_ttarget(),f_ttarget();
int v_screen(),f_screen();
int atom(),bond(),angle(),torsion();
int v_hybrid(),f_hybrid();
int v_step(),f_step();
int v_swarm(),f_swarm(),a_swarm();
int morse(),v_morse(),f_morse();
int restrain(),v_restrain(),f_restrain();
int tether(),v_tether(),f_tether();
int u_v_nonbon(), u_f_nonbon();
int v_abc();
int v_noel(),a_noel();
int v_ho_noel();
int a_bond(),a_mmbond(),a_angle(),a_mmangle();
int a_nonbon(),a_torsion(),a_hybrid(),a_restrain();
int a_react();
int a_ttarget();
int a_tether();
int a_screen();
int a_abc(),a_step();
int v_image(),a_image();
int v_polar(),a_polar();
float V,vt;
int ifs;
int i,j;
int k,l;
i = ilow;
j = ihigh;
if( ihigh < ilow ) {j = ilow; i = ihigh;}
k = jlow;
l = jhigh;
if( jhigh< jlow) { k = jhigh; l = jlow;}
V = 0.;
for( ifs = 0; ifs < nfs; ifs++ )
{
vt = 0.;
if( vfs[ifs] == u_v_nonbon)
{range_nonbon(&vt,0.,i,j,k,l,op); fprintf( op," %f non-bonded energy\n",vt); goto DONE;}
if( vfs[ifs] == v_nonbon)
{range_nonbon(&vt,0.,i,j,k,l,op); fprintf( op," %f non-bonded energy\n",vt); goto DONE;}
DONE:
/* next statement is needed because cannot have a label at an end loop */
V += vt;
vt = 0.;
}
fprintf( op," %f total potential energy\n",V);
/* end of routine */
}