next up previous contents index
Next: Usage Up: Module constraints_module Previous: Module constraints_module   Contents   Index

Purpose

Contains the Constraint type and constraint subroutines

Constraints are applied using the RATTLE algorithm: H. C. Andersen, JCompPhys 52 24-34 (1983) This itself is based on the SHAKE algorithm: J. P. Ryckaert et al., JCompPhys 23 327-341 (1977)

To integrate the system with constraints Newtons equations of motion have to be modified to

\begin{displaymath}
m\mathbf{a} = \mathbf{F} - \lambda\nabla\sigma
\end{displaymath}

where $\sigma$ is a constraint function (see below) and $\lambda$ is a Lagrange multiplier which is dependent upon atomic positions and velocities.

When the equations of motion are discretised two separate approximation to $\lambda$ must be made so that the positions and velocities both obey the constraint exactly (or to within a specified precision) at each time step.

During the position updates, a Lagrange multiplier $\lambda_j$ attached to a constraint $\sigma_j$, which involves particles $i=1 \ldots N$ is solved for iteratively by the following:

\begin{displaymath}
\lambda_j^S = \frac{2\sigma_j}{(\Delta t)^2 \sum_i \frac{1}{m_i} \nabla_i \sigma_j(t+\Delta t) \cdot
\nabla_i \sigma_j(t)}
\end{displaymath}

The velocity updates also include the $\lambda_j^S\nabla\sigma_j$ term, plus an additional $\lambda_j^R\nabla\sigma_j$ term where $\lambda_j^R$ is solved for via:

\begin{displaymath}
\lambda_j^R = \frac{2\dot{\sigma}_j}{\Delta t \sum_i \frac{1}{m_i} \vert\nabla_i \sigma_j(t+\Delta t)\vert^2}
\end{displaymath}

The full, non-specialised form of the iterative solver is present in the code for added flexibility and to allow users to write and use their own constraint functions, which can be time dependent.

Writing extra constraint subroutines

A constraint subroutine evaluates a constraint function (C), its derivatives with respect to all coordinates (dC_dr) and its full time derivative (dC_dt). A constraint function is a function which evaluates to zero when the constraint is satisfied.

Probably the easiest way of constructing a new subroutine is to copy the following and fill in the gaps:


\begin{boxedminipage}{\textwidth}
\begin{verbatim}subroutine CONSTRAINT(pos,...
...dr = ?
dC_dt = ?end subroutine CONSTRAINT\end{verbatim}
\end{boxedminipage}

A few notes:


next up previous contents index
Next: Usage Up: Module constraints_module Previous: Module constraints_module   Contents   Index
gabor 2009-06-30