File: AdForceFieldFunctions.h

package info (click to toggle)
adun.app 0.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 6,824 kB
  • ctags: 713
  • sloc: objc: 49,683; ansic: 4,680; sh: 523; python: 79; makefile: 67; cpp: 33
file content (248 lines) | stat: -rwxr-xr-x 8,017 bytes parent folder | download
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*
   Project: Adun

   Copyright (C) 2005 Michael Johnston & Jordi Villa-Freixa

   Author: Michael Johnston

   This application is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This application is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU General Public
   License along with this library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/

#ifndef AD_FORCEFIELD_FUNCTIONS
#define AD_FORCEFIELD_FUNCTIONS

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <float.h>
#include <fenv.h>
#include "Base/AdVector.h"
#include "Base/AdLinkedList.h"

/**
Debugging
*/

//If BASE_DEBUG is defined, define
//BASE_BONDED_DEBUG & BASE_NONBONDED_DEBUG if they're not
//already defined.

#ifdef BASE_DEBUG
#ifndef BASE_BONDED_DEBUG
#define BASE_BONDED_DEBUG
#endif
#ifndef BASE_NONBONDED_DEBUG
#define BASE_NONBONDED_DEBUG
#endif
#endif

extern bool __HarmonicBondEnergyDebug__;
extern bool __HarmonicBondForceDebug__;
extern bool __HarmonicAngleEnergyDebug__;
extern bool __HarmonicAngleForceDebug__;
extern bool __FourierTorsionEnergyDebug__;
extern bool __FourierTorsionForceDebug__;
extern bool __HarmonicImproperTorsionEnergyDebug__;
extern bool __HarmonicImproperTorsionForceDebug__;
extern bool __NonbondedEnergyDebug__;
extern bool __NonbondedForceDebug__;
extern bool __ShiftedNonbondedEnergyDebug__;
extern bool __ShiftedNonbondedForceDebug__;
extern bool __GRFNonbondedEnergyDebug__;
extern bool __GRFNonbondedForceDebug__;

inline void AdNonbondedEnergyLog(char* cutType, char* ljType, int a1, int a2, double ljA,
		double ljB, double charge, double sep, double estPot, double ljPot,
		bool flag);
inline void AdNonbondedForceLog(char* cutType, char* ljType, int a1, int a2, double ljA,
		double ljB, double charge, double sep, double estPot, double ljPot, double force, 
		bool flag);
/**
\defgroup Functions Functions
\ingroup Base
*/

/**
\defgroup Types Types
\ingroup Base
*/

/**
These are the primitive functions used to calculate the energy and force
terms of a force field. 
\defgroup ForceFieldFunctions Force Field 
\ingroup Functions
@{
*/

/*
 * Harmonic Bond
 */

/** Calculates the energy of a bond using a harmonic bond function */
inline void AdHarmonicBondEnergy(double *bond, double **coordinates, double *bnd_pot);
/** Calculates the energy and force of a bond using a harmonic bond function */
inline void AdHarmonicBondForce(double* bond, double **coordinates, double **forces, double* bnd_pot);
/**
Enzymix force field uses k*(x-x0)² instead of k/2*(x-xo)² like other force fields
*/
inline void AdEnzymixBondEnergy(double* bond, double **coordinates, double* bnd_pot);
/**
As harmonic force except force magnitude is 2k*(x-x0) instead of k*(x-xo) like other force fields
*/
inline void AdEnzymixBondForce(double* bond, double **coordinates, double **forces, double* bnd_pot);

/*
 * Harmonic Angle
 */

/** Calculates the energy of an angle using a harmonic angle function */
inline void AdHarmonicAngleEnergy(double *interaction, double **coordinates, double *ang_pot);
inline void AdHarmonicAngleForce(double *interaction, double **coordinates, double **forces, double *ang_pot);
/**
Enzymix force field uses k*(x-x0)² instead of k/2*(x-xo)² like other force fields
Where x is the angle.
*/
inline void AdEnzymixAngleEnergy(double *interaction, double** coordinates, double *ang_pot);
inline void AdEnzymixAngleForce(double *interaction, double **coordinates, double **forces,  double *ang_pot);

/*
 * fourier torsion
 */

/** calculates the energy of a proper torsion using a fourier torsion function */
inline void AdFourierTorsionEnergy(double *interaction, double **coordinates, double *tor_pot);
inline void AdFourierTorsionForce(double *interaction, double **coordinates, double **forces, double *tor_pot);
/*
Calculate the torsion angle for four atoms. Torsion 4 element array each element an atom index. The
atoms position must be given by the corresponding row in coordinates.
*/
inline double AdCalculateTorsionAngle(int* torsion, double** coordinates);

/*
 * harmonic improper  torsion
 */

/** calculates the energy of an improper torsion using a harmonic function */
inline void AdHarmonicImproperTorsionEnergy(double *interaction, double **coordinates , double *itor_pot);
inline void AdHarmonicImproperTorsionForce(double *interaction, double **coordinates, double **forces, double *itor_pot);

/** Calculates the combined energy of a coloumb electrostatic and lennard jones A term.
Lennard Jones A uses parameters A and B. These functions are optimised for use in
Adun AdForceField obects.
\todo Possibly move the separation and cutoff rejection code to AdunKernel classes  */
inline void AdCoulombAndLennardJonesAEnergy(ListElement* interaction, 
		double** coordinates, 
		double EPSILON_RP,
		double cutoff,
		double* vdw_pot, 
		double* est_pot);
inline void AdCoulombAndLennardJonesAForce(ListElement* interaction, 
		double** coordinates, 
		double** forces,
		double EPSILON_RP, 
		double cutoff,
		double* vdw_pot, 
		double* est_pot);
inline void AdShiftedCoulombAndLennardJonesAEnergy(ListElement* interaction, 
		double** coordinates, 
		double EPSILON_RP,
		double cut,
		double r_cutoff2,
		double* vdw_pot, 
		double* est_pot);
inline void AdShiftedCoulombAndLennardJonesAForce(ListElement* interaction, 
		double** coordinates, 
		double** forces,
		double EPSILON_RP, 
		double cut,
		double r_cutoff2,
		double* vdw_pot, 
		double* est_pot);
inline void AdGRFCoulombAndLennardJonesAEnergy(ListElement* interaction, 
		double** coordinates, 
		double EPSILON_RP, 
		double cutoff,
		double b0, 
		double b1,
		double* vdw_pot, 
		double* est_pot); 
inline void AdGRFCoulombAndLennardJonesAForce(ListElement* interaction, 
		double** coordinates, 
		double** forces,
		double EPSILON_RP, 
		double cutoff,
		double b0, 
		double b1,
		double* vdw_pot, 
		double* est_pot); 
/** Calculates the combined energy of a coloumb electrostatic and lennard jones B term.
Lennard Jones A uses parameters well depth and equilibrium separation. 
These functions are optimised for use in Adun AdForceField obects.*/
inline void AdCoulombAndLennardJonesBEnergy(ListElement* interaction, 
		double** coordinates, 
		double EPSILON_RP, 
		double cutoff,
		double* vdw_pot, 
		double* est_pot);
inline void AdCoulombAndLennardJonesBForce(ListElement* interaction, 
		double** coordinates, 
		double** forces,
		double EPSILON_RP, 
		double cutoff,
		double* vdw_pot, 
		double* est_pot);
inline void AdShiftedCoulombAndLennardJonesBForce(ListElement* interaction, 
		double** coordinates, 
		double** forces,
		double EPSILON_RP, 
		double cut,
		double r_cutoff2,
		double* vdw_pot, 
		double* est_pot);
inline void AdShiftedCoulombAndLennardJonesBEnergy(ListElement* interaction, 
		double** coordinates, 
		double EPSILON_RP, 
		double cut,
		double r_cutoff2,
		double* vdw_pot, 
		double* est_pot);
inline void AdGRFCoulombAndLennardJonesBEnergy(ListElement* interaction, 
		double** coordinates, 
		double EPSILON_RP, 
		double cutoff,
		double b0, 
		double b1,
		double* vdw_pot, 
		double* est_pot); 
inline void AdGRFCoulombAndLennardJonesBForce(ListElement* interaction, 
		double** coordinates, 
		double** forces,
		double EPSILON_RP, 
		double cutoff,
		double b0, 
		double b1,
		double* vdw_pot, 
		double* est_pot); 
//test		
inline void AdCoulombAndLennardJonesAForceTest(ListElement* interaction, 
		Vector3D* seperation_s, 
		double** forces,
		double EPSILON_RP, 
		double* vdw_pot, 
		double* est_pot);
/** \@}**/
#endif