Collective Variables Module - Developer Documentation
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
rotation_derivative Struct Reference

Helper class for calculating the derivative of rotation. More...

#include <colvar_rotation_derivative.h>

Inheritance diagram for rotation_derivative:
Inheritance graph
[legend]
Collaboration diagram for rotation_derivative:
Collaboration graph
[legend]

Public Member Functions

 rotation_derivative (const cvm::rotation &rot, const std::vector< cvm::real > &pos1, const std::vector< cvm::real > &pos2, const size_t num_atoms_pos1, const size_t num_atoms_pos2)
 Constructor of the cvm::rotation::derivative class for SOA. More...
 
void prepare_derivative (rotation_derivative_dldq require_dl_dq)
 This function must be called before calc_derivative_wrt_group1 and calc_derivative_wrt_group2 in order to prepare the tmp_Q0Q0 and tmp_Q0Q0_L. More...
 
template<bool use_dl, bool use_dq, bool use_ds>
void calc_derivative_impl (const cvm::rvector(&ds)[4][4], cvm::rvector *_noalias const dl0_out, std::array< cvm::rvector, 4 > *_noalias const dq0_out, std::array< std::array< cvm::rvector, 4 >, 4 > *_noalias const ds_out) const
 Actual implementation of the derivative calculation. More...
 
template<bool use_dl, bool use_dq, bool use_ds>
void calc_derivative_wrt_group1 (size_t ia, cvm::rvector *_noalias const dl0_1_out=nullptr, std::array< cvm::rvector, 4 > *_noalias const dq0_1_out=nullptr, std::array< std::array< cvm::rvector, 4 >, 4 > *_noalias const ds_1_out=nullptr) const
 Calculate the derivatives of S, the leading eigenvalue L and the leading eigenvector Q with respect to m_pos1 More...
 
template<bool use_dl, bool use_dq, bool use_ds>
void calc_derivative_wrt_group2 (size_t ia, cvm::rvector *_noalias const dl0_2_out=nullptr, std::array< cvm::rvector, 4 > *_noalias const dq0_2_out=nullptr, std::array< std::array< cvm::rvector, 4 >, 4 > *_noalias const ds_2_out=nullptr) const
 Calculate the derivatives of S, the leading eigenvalue L and the leading eigenvector Q with respect to m_pos2 More...
 
template<int i>
cvm::rmatrix project_force_to_C_from_dxdqi (cvm::real f_on_q) const
 Project the force on \(q_i\) (or the gradient of \(\frac{\mathrm{d}x}{\mathrm{d}q_i}\)) to the force on the correlation matrix \(C=\mathbf{r}_1^\intercal\mathbf{r}_2\), where \(\mathbf{r}_1\) and \(\mathbf{r}_2\) are \(N\times 3\) matrices containing the atom positions of atom group 1 and atom group 2 after centering on origin. More...
 
template<typename dim4_array_t >
cvm::rmatrix project_force_to_C_from_dxdq (const dim4_array_t &sum_dxdq) const
 Project the force on \(\mathbf{q}\) (or the gradient of \(\frac{\mathrm{d}x}{\mathrm{d}q_i}\)) to the force on the correlation matrix \(C=\mathbf{r}_1^\intercal\mathbf{r}_2\), where \(\mathbf{r}_1\) and \(\mathbf{r}_2\) are \(N\times 3\) matrices containing the atom positions of atom group 1 and atom group 2 after centering on origin. More...
 
cvm::rvector project_force_to_group1 (size_t ia, const cvm::rmatrix &dxdC) const
 Project the force on the correlation matrix \(C\) to \(\mathbf{r}_1\). More...
 
cvm::rvector project_force_to_group2 (size_t ia, const cvm::rmatrix &dxdC) const
 Project the force on the correlation matrix \(C\) to \(\mathbf{r}_2\). More...
 

Public Attributes

const cvm::rotationm_rot
 Reference to the rotation.
 
std::vector< cvm::real >::const_iterator pos1x
 Reference to the atom positions of group 1.
 
std::vector< cvm::real >::const_iterator pos1y
 
std::vector< cvm::real >::const_iterator pos1z
 
std::vector< cvm::real >::const_iterator pos2x
 Reference to the atom positions of group 2.
 
std::vector< cvm::real >::const_iterator pos2y
 
std::vector< cvm::real >::const_iterator pos2z
 
size_t m_num_atoms_pos1
 Number of atoms in group1 (used in SOA)
 
size_t m_num_atoms_pos2
 Number of atoms in group1 (used in SOA)
 
cvm::real tmp_Q0Q0 [4][4]
 Temporary variable that will be updated if prepare_derivative called.
 
cvm::real tmp_Q0Q0_L [4][4][4]
 

Detailed Description

Helper class for calculating the derivative of rotation.

Constructor & Destructor Documentation

◆ rotation_derivative()

rotation_derivative::rotation_derivative ( const cvm::rotation rot,
const std::vector< cvm::real > &  pos1,
const std::vector< cvm::real > &  pos2,
const size_t  num_atoms_pos1,
const size_t  num_atoms_pos2 
)
inline

Constructor of the cvm::rotation::derivative class for SOA.

Parameters
[in]rotThe cvm::rotation object (must have called calc_optimal_rotation before calling calc_derivative_wrt_group1 and calc_derivative_wrt_group2)
[in]pos1The atom positions of group 1
[in]pos2The atom positions of group 2
[in]num_atoms_pos1The number of atoms in group1
[in]num_atoms_pos2The number of atoms in group2

Member Function Documentation

◆ calc_derivative_impl()

template<bool use_dl, bool use_dq, bool use_ds>
void rotation_derivative::calc_derivative_impl ( const cvm::rvector(&)  ds[4][4],
cvm::rvector *_noalias const  dl0_out,
std::array< cvm::rvector, 4 > *_noalias const  dq0_out,
std::array< std::array< cvm::rvector, 4 >, 4 > *_noalias const  ds_out 
) const
inline

Actual implementation of the derivative calculation.

Parameters
[in]dsThe derivative of matrix S with respect to an atom of either group 1 or group 2
[out]dl0_outThe output of derivative of L
[out]dq0_outThe output of derivative of Q
[out]ds_outThe output of derivative of overlap matrix S

◆ calc_derivative_wrt_group1()

template<bool use_dl, bool use_dq, bool use_ds>
void rotation_derivative::calc_derivative_wrt_group1 ( size_t  ia,
cvm::rvector *_noalias const  dl0_1_out = nullptr,
std::array< cvm::rvector, 4 > *_noalias const  dq0_1_out = nullptr,
std::array< std::array< cvm::rvector, 4 >, 4 > *_noalias const  ds_1_out = nullptr 
) const
inline

Calculate the derivatives of S, the leading eigenvalue L and the leading eigenvector Q with respect to m_pos1

Parameters
[in]iaThe index the of atom
[out]dl0_1_outThe output of derivative of L with respect to ia-th atom of group 1
[out]dq0_1_outThe output of derivative of Q with respect to ia-th atom of group 1
[out]ds_1_outThe output of derivative of overlap matrix S with respect to ia-th atom of group 1

◆ calc_derivative_wrt_group2()

template<bool use_dl, bool use_dq, bool use_ds>
void rotation_derivative::calc_derivative_wrt_group2 ( size_t  ia,
cvm::rvector *_noalias const  dl0_2_out = nullptr,
std::array< cvm::rvector, 4 > *_noalias const  dq0_2_out = nullptr,
std::array< std::array< cvm::rvector, 4 >, 4 > *_noalias const  ds_2_out = nullptr 
) const
inline

Calculate the derivatives of S, the leading eigenvalue L and the leading eigenvector Q with respect to m_pos2

Parameters
[in]iaThe index the of atom
[out]dl0_2_outThe output of derivative of L with respect to ia-th atom of group 2
[out]dq0_2_outThe output of derivative of Q with respect to ia-th atom of group 2
[out]ds_2_outThe output of derivative of overlap matrix S with respect to ia-th atom of group 2

◆ prepare_derivative()

void rotation_derivative::prepare_derivative ( rotation_derivative_dldq  require_dl_dq)
inline

This function must be called before calc_derivative_wrt_group1 and calc_derivative_wrt_group2 in order to prepare the tmp_Q0Q0 and tmp_Q0Q0_L.

Parameters
[in]require_dl_dqRequire the calculation of the derivatives of L or/and Q with respect to atoms.

◆ project_force_to_C_from_dxdq()

template<typename dim4_array_t >
cvm::rmatrix rotation_derivative::project_force_to_C_from_dxdq ( const dim4_array_t &  sum_dxdq) const
inline

Project the force on \(\mathbf{q}\) (or the gradient of \(\frac{\mathrm{d}x}{\mathrm{d}q_i}\)) to the force on the correlation matrix \(C=\mathbf{r}_1^\intercal\mathbf{r}_2\), where \(\mathbf{r}_1\) and \(\mathbf{r}_2\) are \(N\times 3\) matrices containing the atom positions of atom group 1 and atom group 2 after centering on origin.

See also project_force_to_C_from_dxdqi().

Template Parameters
dim4_array_tThe type of force acting on \(\mathbf{q}\).
Parameters
[in]sum_dxdqThe force on \(\mathbf{q}\) or the gradient vector \((\frac{\mathrm{d}x}{\mathrm{d}q_0}, \frac{\mathrm{d}x}{\mathrm{d}q_1}, \frac{\mathrm{d}x}{\mathrm{d}q_2}, \frac{\mathrm{d}x}{\mathrm{d}q_3})\).
Returns
A 3x3 matrix. The matrix element at row \(j\) and column \(k\) is \(\sum_{i=0}^3 f_{q_i}\frac{\mathrm{d}q_i}{\mathrm{d}C_{jk}}\).

◆ project_force_to_C_from_dxdqi()

template<int i>
cvm::rmatrix rotation_derivative::project_force_to_C_from_dxdqi ( cvm::real  f_on_q) const
inline

Project the force on \(q_i\) (or the gradient of \(\frac{\mathrm{d}x}{\mathrm{d}q_i}\)) to the force on the correlation matrix \(C=\mathbf{r}_1^\intercal\mathbf{r}_2\), where \(\mathbf{r}_1\) and \(\mathbf{r}_2\) are \(N\times 3\) matrices containing the atom positions of atom group 1 and atom group 2 after centering on origin.

This function can be only called after prepare_derivative(rotation_derivative_dldq::use_dq). It mulitplies the input with \(\frac{\mathrm{d}q_i}{\mathrm{d}C}\).

Template Parameters
iThe i-th component of the quaternion, must be in the range [0, 3]
Parameters
[in]f_on_qThe force on \(q_i\) or the gradient of \(\frac{\mathrm{d}x}{\mathrm{d}q_i}\)
Returns
A 3x3 matrix. The matrix element at row \(j\) and column \(k\) is \(f_{q_i}\frac{\mathrm{d}q_i}{\mathrm{d}C_{jk}}\).

◆ project_force_to_group1()

cvm::rvector rotation_derivative::project_force_to_group1 ( size_t  ia,
const cvm::rmatrix dxdC 
) const
inline

Project the force on the correlation matrix \(C\) to \(\mathbf{r}_1\).

Let \(C=\mathbf{r}_1^\intercal\mathbf{r}_2\), and the force on \(C\) be \(F_{C}\). This function returns the force on the i-th atom of \(\mathbf{r}_1\).

Parameters
[in]iaThe atom index of the i-th atom in \(\mathbf{r}_1\)
[in]dxdCThe 3x3 matrix containing the forces on each element of \(C\)
Returns
The force on the i-th atom of \(\mathbf{r}_1\)

◆ project_force_to_group2()

cvm::rvector rotation_derivative::project_force_to_group2 ( size_t  ia,
const cvm::rmatrix dxdC 
) const
inline

Project the force on the correlation matrix \(C\) to \(\mathbf{r}_2\).

Let \(C=\mathbf{r}_1^\intercal\mathbf{r}_2\), and the force on \(C\) be \(F_{C}\). This function returns the force on the i-th atom of \(\mathbf{r}_2\).

Parameters
[in]iaThe atom index of the i-th atom in \(\mathbf{r}_2\)
[in]dxdCThe 3x3 matrix containing the forces on each element of \(C\)
Returns
The force on the i-th atom of \(\mathbf{r}_2\)

The documentation for this struct was generated from the following file: