mdcore  0.1.5
Data Structures | Defines | Functions | Variables
/home/pedro/work/mdcore/src/potential.h File Reference

Go to the source code of this file.

Data Structures

struct  potential

Defines

#define potential_err_ok   0
#define potential_err_null   -1
#define potential_err_malloc   -2
#define potential_err_bounds   -3
#define potential_err_nyi   -4
#define potential_err_ivalsmax   -5
#define potential_degree   5
#define potential_chunk   (potential_degree+3)
#define potential_ivalsa   1
#define potential_ivalsb   10
#define potential_N   100
#define potential_align   64
#define potential_align   64
#define potential_ivalsmax   320
#define potential_escale   (0.079577471545947667882)
#define potential_flag_none   0
#define potential_flag_LJ126   1
#define potential_flag_Ewald   2
#define potential_flag_Coulomb   4
#define potential_flag_single   6

Functions

void potential_clear (struct potential *p)
 Free the memory associated with the given potential.
int potential_init (struct potential *p, double(*f)(double), double(*fp)(double), double(*f6p)(double), FPTYPE a, FPTYPE b, FPTYPE tol)
 Construct a potential from the given function.
int potential_getcoeffs (double(*f)(double), double(*fp)(double), FPTYPE *xi, int n, FPTYPE *c, FPTYPE *err)
 Compute the interpolation coefficients over a given set of nodes.
double potential_getalpha (double(*f6p)(double), double a, double b)
 Compute the parameter $\alpha$ for the optimal node distribution.
struct potentialpotential_create_LJ126 (double a, double b, double A, double B, double tol)
 Creates a potential representing a 12-6 Lennard-Jones potential.
struct potentialpotential_create_LJ126_Ewald (double a, double b, double A, double B, double q, double kappa, double tol)
 Creates a potential representing the sum of a 12-6 Lennard-Jones potential and the real-space part of an Ewald potential.
struct potentialpotential_create_LJ126_Coulomb (double a, double b, double A, double B, double q, double tol)
 Creates a potential representing the sum of a 12-6 Lennard-Jones potential and a shifted Coulomb potential.
struct potentialpotential_create_Ewald (double a, double b, double q, double kappa, double tol)
 Creates a potential representing the real-space part of an Ewald potential.
struct potentialpotential_create_Coulomb (double a, double b, double q, double tol)
 Creates a potential representing a shifted Coulomb potential.
struct potentialpotential_create_harmonic (double a, double b, double K, double r0, double tol)
 Creates a harmonic bond potential.
struct potentialpotential_create_harmonic_angle (double a, double b, double K, double theta0, double tol)
 Creates a harmonic angle potential.
struct potentialpotential_create_harmonic_dihedral (double K, int n, double delta, double tol)
 Creates a harmonic dihedral potential.
double potential_LJ126 (double r, double A, double B)
 A basic 12-6 Lennard-Jones potential.
double potential_LJ126_p (double r, double A, double B)
 A basic 12-6 Lennard-Jones potential (first derivative).
double potential_LJ126_6p (double r, double A, double B)
 A basic 12-6 Lennard-Jones potential (sixth derivative).
double potential_Ewald (double r, double kappa)
 The short-range part of an Ewald summation.
double potential_Ewald_p (double r, double kappa)
 The short-range part of an Ewald summation (first derivative).
double potential_Ewald_6p (double r, double kappa)
 The short-range part of an Ewald summation (sixth derivative).
double potential_Coulomb (double r)
 The Coulomb potential.
double potential_Coulomb_p (double r)
 The Coulomb potential (first derivative).
double potential_Coulomb_6p (double r)
 TheCoulomb potential (sixth derivative).

Variables

int potential_err
struct potential potential_null

Define Documentation

#define potential_align   64
#define potential_align   64
#define potential_degree   5
#define potential_err_bounds   -3
#define potential_err_ivalsmax   -5
#define potential_err_malloc   -2
#define potential_err_null   -1
#define potential_err_nyi   -4
#define potential_err_ok   0
#define potential_escale   (0.079577471545947667882)
#define potential_flag_Coulomb   4
#define potential_flag_Ewald   2
#define potential_flag_LJ126   1
#define potential_flag_none   0
#define potential_flag_single   6
#define potential_ivalsa   1
#define potential_ivalsb   10
#define potential_ivalsmax   320
#define potential_N   100

Function Documentation

void potential_clear ( struct potential p)

Free the memory associated with the given potential.

Parameters:
pPointer to the potential to clear.
double potential_Coulomb ( double  r) [inline]

The Coulomb potential.

Parameters:
rThe interaction radius.
Returns:
The potential $ \frac{1}{4\pi r} $ evaluated at r.
double potential_Coulomb_6p ( double  r) [inline]

TheCoulomb potential (sixth derivative).

Parameters:
rThe interaction radius.
Returns:
The sixth derivative of the potential $ \frac{1}{4\pi r} $ evaluated at r.
double potential_Coulomb_p ( double  r) [inline]

The Coulomb potential (first derivative).

Parameters:
rThe interaction radius.
Returns:
The first derivative of the potential $ \frac{1}{4\pi r} $ evaluated at r.
struct potential* potential_create_Coulomb ( double  a,
double  b,
double  q,
double  tol 
) [read]

Creates a potential representing a shifted Coulomb potential.

Parameters:
aThe smallest radius for which the potential will be constructed.
bThe largest radius for which the potential will be constructed.
qThe charge scaling of the potential.
tolThe tolerance to which the interpolation should match the exact potential.
Returns:
A newly-allocated potential representing the potential $ \frac{1}{4\pi r} $ in $[a,b]$ or NULL on error (see potential_err).
struct potential* potential_create_Ewald ( double  a,
double  b,
double  q,
double  kappa,
double  tol 
) [read]

Creates a potential representing the real-space part of an Ewald potential.

Parameters:
aThe smallest radius for which the potential will be constructed.
bThe largest radius for which the potential will be constructed.
qThe charge scaling of the potential.
kappaThe screening distance of the Ewald potential.
tolThe tolerance to which the interpolation should match the exact potential.
Returns:
A newly-allocated potential representing the potential $ q\frac{\mbox{erfc}(\kappa r}{r} $ in $[a,b]$ or NULL on error (see potential_err).
struct potential* potential_create_harmonic ( double  a,
double  b,
double  K,
double  r0,
double  tol 
) [read]

Creates a harmonic bond potential.

Parameters:
aThe smallest radius for which the potential will be constructed.
bThe largest radius for which the potential will be constructed.
KThe energy of the bond.
r0The minimum energy distance.
tolThe tolerance to which the interpolation should match the exact potential.
Returns:
A newly-allocated potential representing the potential $ K(r-r_0)^2 $ in $[a,b]$ or NULL on error (see potential_err).
struct potential* potential_create_harmonic_angle ( double  a,
double  b,
double  K,
double  theta0,
double  tol 
) [read]

Creates a harmonic angle potential.

Parameters:
aThe smallest angle for which the potential will be constructed.
bThe largest angle for which the potential will be constructed.
KThe energy of the angle.
theta0The minimum energy angle.
tolThe tolerance to which the interpolation should match the exact potential.
Returns:
A newly-allocated potential representing the potential $ K(\arccos(r)-r_0)^2 $ in $[a,b]$ or NULL on error (see potential_err).
struct potential* potential_create_harmonic_dihedral ( double  K,
int  n,
double  delta,
double  tol 
) [read]

Creates a harmonic dihedral potential.

Parameters:
KThe energy of the dihedral.
nThe multiplicity of the dihedral.
deltaThe minimum energy dihedral.
tolThe tolerance to which the interpolation should match the exact potential.
Returns:
A newly-allocated potential representing the potential $ K(1 + \cos(n\arccos(r)-delta) $ in $[-1,1]$ or NULL on error (see potential_err).
struct potential* potential_create_LJ126 ( double  a,
double  b,
double  A,
double  B,
double  tol 
) [read]

Creates a potential representing a 12-6 Lennard-Jones potential.

Parameters:
aThe smallest radius for which the potential will be constructed.
bThe largest radius for which the potential will be constructed.
AThe first parameter of the Lennard-Jones potential.
BThe second parameter of the Lennard-Jones potential.
tolThe tolerance to which the interpolation should match the exact potential.
Returns:
A newly-allocated potential representing the potential $ \left( \frac{A}{r^{12}} - \frac{B}{r^6} \right) $ in $[a,b]$ or NULL on error (see potential_err).
struct potential* potential_create_LJ126_Coulomb ( double  a,
double  b,
double  A,
double  B,
double  q,
double  tol 
) [read]

Creates a potential representing the sum of a 12-6 Lennard-Jones potential and a shifted Coulomb potential.

Parameters:
aThe smallest radius for which the potential will be constructed.
bThe largest radius for which the potential will be constructed.
AThe first parameter of the Lennard-Jones potential.
BThe second parameter of the Lennard-Jones potential.
qThe charge scaling of the potential.
tolThe tolerance to which the interpolation should match the exact potential.
Returns:
A newly-allocated potential representing the potential $ \left( \frac{A}{r^{12}} - \frac{B}{r^6} \right) $ in $[a,b]$ or NULL on error (see potential_err).
struct potential* potential_create_LJ126_Ewald ( double  a,
double  b,
double  A,
double  B,
double  q,
double  kappa,
double  tol 
) [read]

Creates a potential representing the sum of a 12-6 Lennard-Jones potential and the real-space part of an Ewald potential.

Parameters:
aThe smallest radius for which the potential will be constructed.
bThe largest radius for which the potential will be constructed.
AThe first parameter of the Lennard-Jones potential.
BThe second parameter of the Lennard-Jones potential.
qThe charge scaling of the potential.
kappaThe screening distance of the Ewald potential.
tolThe tolerance to which the interpolation should match the exact potential.
Returns:
A newly-allocated potential representing the potential $ \left( \frac{A}{r^{12}} - \frac{B}{r^6} \right) $ in $[a,b]$ or NULL on error (see potential_err).
double potential_Ewald ( double  r,
double  kappa 
) [inline]

The short-range part of an Ewald summation.

Parameters:
rThe interaction radius.
kappaThe screening length of the Ewald summation.
Returns:
The potential $ \frac{\mbox{erfc}( \kappa r )}{r} $ evaluated at r.
double potential_Ewald_6p ( double  r,
double  kappa 
) [inline]

The short-range part of an Ewald summation (sixth derivative).

Parameters:
rThe interaction radius.
kappaThe screening length of the Ewald summation.
Returns:
The sixth derivative of the potential $ \frac{\mbox{erfc}( \kappa r )}{r} $ evaluated at r.
double potential_Ewald_p ( double  r,
double  kappa 
) [inline]

The short-range part of an Ewald summation (first derivative).

Parameters:
rThe interaction radius.
kappaThe screening length of the Ewald summation.
Returns:
The first derivative of the potential $ \frac{\mbox{erfc}( \kappa r )}{r} $ evaluated at r.
double potential_getalpha ( double(*)(double)  f6p,
double  a,
double  b 
)

Compute the parameter $\alpha$ for the optimal node distribution.

Parameters:
f6pPointer to a function representing the 6th derivative of the interpoland.
aLeft limit of the interpolation.
bRight limit of the interpolation.
Returns:
The computed value for $\alpha$.

The value $\alpha$ is computed using Brent's algortihm to 4 decimal digits.

int potential_getcoeffs ( double(*)(double)  f,
double(*)(double)  fp,
FPTYPE *  xi,
int  n,
FPTYPE *  c,
FPTYPE *  err 
)

Compute the interpolation coefficients over a given set of nodes.

Parameters:
fPointer to the function to be interpolated.
fpPointer to the first derivative of f.
xiPointer to an array of nodes between whicht the function f will be interpolated.
nNumber of nodes in xi.
cPointer to an array in which to store the interpolation coefficients.
errPointer to a floating-point value in which an approximation of the interpolation error, relative to the maximum of f in each interval, is stored.
Returns:
potential_err_ok or < 0 on error (see potential_err).

Compute the coefficients of the function f with derivative fp over the n intervals between the xi and store an estimate of the maximum locally relative interpolation error in err.

The array to which c points must be large enough to hold at least potential_degree x n values of type #FPTYPE.

int potential_init ( struct potential p,
double(*)(double)  f,
double(*)(double)  fp,
double(*)(double)  f6p,
FPTYPE  a,
FPTYPE  b,
FPTYPE  tol 
)

Construct a potential from the given function.

Parameters:
pA pointer to an empty potential.
fA pointer to the potential function to be interpolated.
fpA pointer to the first derivative of f.
f6pA pointer to the sixth derivative of f.
aThe smallest radius for which the potential will be constructed.
bThe largest radius for which the potential will be constructed.
tolThe absolute tolerance to which the interpolation should match the exact potential.
Returns:
potential_err_ok or <0 on error (see potential_err).

Computes an interpolated potential function from f in [a,b] to the locally relative tolerance tol.

The sixth derivative f6p is used to compute the optimal node distribution. If f6p is NULL, the derivative is approximated numerically.

The zeroth interval contains a linear extension of f for values < a.

double potential_LJ126 ( double  r,
double  A,
double  B 
) [inline]

A basic 12-6 Lennard-Jones potential.

Parameters:
rThe interaction radius.
AFirst parameter of the potential.
BSecond parameter of the potential.
Returns:
The potential $ \left( \frac{A}{r^{12}} - \frac{B}{r^6} \right) $ evaluated at r.
double potential_LJ126_6p ( double  r,
double  A,
double  B 
) [inline]

A basic 12-6 Lennard-Jones potential (sixth derivative).

Parameters:
rThe interaction radius.
AFirst parameter of the potential.
BSecond parameter of the potential.
Returns:
The sixth derivative of the potential $ \left( \frac{A}{r^{12}} - \frac{B}{r^6} \right) $ evaluated at r.
double potential_LJ126_p ( double  r,
double  A,
double  B 
) [inline]

A basic 12-6 Lennard-Jones potential (first derivative).

Parameters:
rThe interaction radius.
AFirst parameter of the potential.
BSecond parameter of the potential.
Returns:
The first derivative of the potential $ \left( \frac{A}{r^{12}} - \frac{B}{r^6} \right) $ evaluated at r.

Variable Documentation

ID of the last error.

The last error

Fictitious null potential.

 All Data Structures Files Functions Variables Typedefs Enumerator Defines