Linear interpolation

When passed to halmd.mdsim.forces.tabulated, this function calculates the potential energy and force from lattice points of precalculated potential energy points and coefficients at the lattice points.

In 1D the interpolated value \tilde V(x) is calculated by the following expression:

\tilde V(x) = (1 - x_r) V(x_0) + x_r V(x_1)

where the neighbouring knots are given by x_0 and x_1 with x_1 > x_0. x_r is the reduced distance \frac{x - x_0}{x_1 - x_0}.

In higher dimensions this scheme is extended to bi- and triliniear interpolation.

Coefficients

The Cubic Hermite interpolation needs one coefficient per neighbour to determine the interpolated value.

class halmd.mdsim.forces.interpolation.linear(args)

Construct linear interpolator.

Parameters:
  • args (table) – keyword arguments
  • args.box – instance of halmd.mdsim.box
  • args.length (table) – length of the (optional, defaults to box.length)
  • args.lowest_corner (table) – distance of the box to the lowest corner (optional, defaults to box.lowest_corner)
  • args.nknots (number table) – number of knots in each dimension, including
  • args.precision (string) – floating point number precision
Returns:

instance of cubic hermite interpolation scheme

If box is not given, the arguments length and lowest_corner have to be supplied. This enables the possibility to have a smaller “unit cell” of the interpolation area, while the simulation box may be multiples of this unit cell. length and lowest_corner both precede box.

The linear interpolator supports “single” and “double” as floating point number precision.

nknots

Returns the number of grid points in each spatial direction as a sequence.

total_knots

Returns the total number of grid knots needed.

grid_basis

Returns the edge lengths of one grid cell.

log(logger)

Output interpolation scheme to logger

Parameters:logger – instance of halmd.io.log.logger