Cubic Hermite 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 is calculated by the following expression:
where and are the potential values at the neighbouring knots and is the first derivative of at . is the reduced distance .
The functions and are defined as:
where .
Coefficients¶
The Cubic Hermite interpolation needs coefficients per neighbour to determine the interpolated value. The coefficients must be given in the following order: , , , , , , , , where is the position of the knot.
Note
The first derivatives are not the force, that is
In two dimensions only the first 4 coefficients are needed. The index of the
first coefficient for a knot is given by
multi_index_to_offset(index, nknots)
, which is followed by all other
coefficients needed for the node at index
.
[1] | Martin H. Schultz, Spline Analysis (Ch. 3), Prentice-Hall (Englewood Cliffs, N.J) (1972), ISBN 0138354057 |
-
class
halmd.mdsim.forces.interpolation.
cubic_hermite
(args)¶ Construct cubic hermite 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 edges
- args.precision (string) – floating point number precision
Returns: instance of cubic hermite interpolation scheme
If
box
is not given, the argumentslength
andlowest_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
andlowest_corner
both precedebox
.The supported values for
precision
are “single” and “double”. In 3D simulations double precision is recommended also for the GPU as the number of mathematical operations is at the order of 64.-
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