Vector calculus notes (1)

Problem: given a series molecules $i=1,\dots,N$, connected with junction atoms $\mathbf{x}_i^k$, for $k=1,2,…m$ if there are $m_i$ atoms from molecule $i$ that are bonded with other molecules. The connection bonds are defined as $\mathbf{b}_i := \lbrace\mathbf{x}_j^{k_1}-\mathbf{x}_i^{k_2}|\forall k_1, k_2\, \mathrm{and}\, \forall j\in \mathrm{neighbor\, of}\, i\rbrace$, assume that the center-of-mass of the molecules are fixed, but are rotatable, minimize $\sum_i |\mathbf{b}_i|^2$ with a series of rotation matrices $R_i$:

$$ R_i = \min_{R_i}(L:= \sum_i \sum_{j \in \mathrm{neighbor\, of}\, i} \sum_{k_1,k_2} |\mathrm{pbc}(R_j \mathbf{x}_{j}^{k_1} – R_i \mathbf{x}_{i}^{k_2})|^2) $$

with constraint

$$ c_1=\sum_i |R_i^TR_i – I|^2 = 0 $$

$$ c_2=\det(R_i) – 1=0 $$

the constraint ensures $R^T R =I$ and $\det(R)=1$ for each rotation matrix thus $R_i$ are rotation matrices. The periodic boundary condition is introduced for most simulation systems.

Minimization procedure includes calculation of jacobian of loss and constraint functions:

$$ \frac{\partial L}{\partial R_i} = -2 \sum_{j \in \mathrm{neighbor\, of}\, i} \sum_{k_1, k_2} \mathrm{pbc}(R_{j} \mathbf{x}_{j}^{k_1} – R_i \mathbf{x}_i^{k_2})^T \mathbf{x}_i^{k_2} $$

and

$$\frac{\partial c_1}{\partial R_i} = 4 (R_i R_i^T – I) R_i $$

$$\frac{\partial c_2}{\partial R_i} = \det(R_i) (R_i^{-1})^T $$

Or the merged constraint (?):

$$ c = \sum_i |R_i^TR_i – I|^2 + (\det (R_i)-1)^2 = 0 $$

with

$$\frac{\partial c}{\partial R_i} = 4 (R_i R_i^T – I) R_i + 2(\det(R_i)-1)\det(R_i)(R_i^{-1})^T $$

def cons_jac(R): # Only the second part
    R = R.reshape(-1, 3, 3)
    det = np.linalg.det(R)
    inv = np.linalg.pinv(R)
    return 2 * det[:, None, None] * (det[:, None, None] - 1) * np.swapaxes(inv, (1, 2))

No Comments.

Back2Top ^