Class Scine::Utils::QuadrupoleMatrix

class QuadrupoleMatrix

Class representing quadrupole matrix integrals with derivatives up to 2nd order.

This class stores the quadrupole integrals \(\langle mu|q_{rr}|nu \rangle\) and their derivatives in their three components x, y, z.

The class stores only the upper diagonal of the quadrupole moment tensor: xx, xy, xz, yy, yz, zz. The derivatives are accessible through the .derivatives() method of the underlying AutomaticDifferentiation::First3D/Second3D class. The templated getters and setters allow for efficient witing of generic code, independent from the desired derivative order. One just has to have specializations for all orders.

int arbitraryDimension = 10;
QuadrupoleMatrix quadrupoleMatrixZero, quadrupoleMatrixFirst;

// Fill QuadrupoleMatrix with random values and derivatives.
DerivType = Eigen::Matrix<AutomaticDifferentiation::First3D, Eigen::Dynamic, Eigen::Dynamic>;

Eigen::MatrixXd XXMatrix = Eigen::MatrixXd::Random(arbitraryDimension, arbitraryDimension);
Eigen::MatrixXd XYMatrix = Eigen::MatrixXd::Random(arbitraryDimension, arbitraryDimension);
Eigen::MatrixXd XZMatrix = Eigen::MatrixXd::Random(arbitraryDimension, arbitraryDimension);
Eigen::MatrixXd YYMatrix = Eigen::MatrixXd::Random(arbitraryDimension, arbitraryDimension);
Eigen::MatrixXd YZMatrix = Eigen::MatrixXd::Random(arbitraryDimension, arbitraryDimension);
Eigen::MatrixXd ZZMatrix = Eigen::MatrixXd::Random(arbitraryDimension, arbitraryDimension);
DerivType XXderivatives, XYderivatives, XZderivatives,
          YYderivatives, YZderivatives, ZZderivatives;
XXderivatives.resize(arbitraryDimension, arbitraryDimension);
XYderivatives.resize(arbitraryDimension, arbitraryDimension);
XZderivatives.resize(arbitraryDimension, arbitraryDimension);
YYderivatives.resize(arbitraryDimension, arbitraryDimension);
YZderivatives.resize(arbitraryDimension, arbitraryDimension);
ZZderivatives.resize(arbitraryDimension, arbitraryDimension);
for (int i = 0; i < arbitraryDimension; ++i) {
  for (int j = 0; j < arbitraryDimension; ++j) {
    XXderivatives(i, j) = {XXMatrix(i, j), Eigen::Vector3d::Random()};
    XYderivatives(i, j) = {XYMatrix(i, j), Eigen::Vector3d::Random()};
    XZderivatives(i, j) = {XZMatrix(i, j), Eigen::Vector3d::Random()};
    YYderivatives(i, j) = {YYMatrix(i, j), Eigen::Vector3d::Random()};
    YZderivatives(i, j) = {YZMatrix(i, j), Eigen::Vector3d::Random()};
    ZZderivatives(i, j) = {ZZMatrix(i, j), Eigen::Vector3d::Random()};
  }
}
// Fill with the zero-th derivative integrals
quadrupoleMatrixZero.xx().get<derivOrder::zero>(XXMatrix);
quadrupoleMatrixZero.xy().get<derivOrder::zero>(XYMatrix);
quadrupoleMatrixZero.xz().get<derivOrder::zero>(XZMatrix);
quadrupoleMatrixZero.yy().get<derivOrder::zero>(YYMatrix);
quadrupoleMatrixZero.yz().get<derivOrder::zero>(YZMatrix);
quadrupoleMatrixZero.zz().get<derivOrder::zero>(ZZMatrix);

// Fill with the first derivative integrals
quadrupoleMatrixFirst.xx().get<derivOrder::one>(XXderivatives);
quadrupoleMatrixFirst.xy().get<derivOrder::one>(XYderivatives);
quadrupoleMatrixFirst.xz().get<derivOrder::one>(XZderivatives);
quadrupoleMatrixFirst.yy().get<derivOrder::one>(YYderivatives);
quadrupoleMatrixFirst.yz().get<derivOrder::one>(YZderivatives);
quadrupoleMatrixFirst.zz().get<derivOrder::one>(ZZderivatives);

// Get the zeroth and first derivatives of the first element of the first derivative matrix
quadrupoleMatrixZero.xx().get<derivOrder::zero>()(0, 0);
// Get the zeroth and first derivatives of the first element of the first derivative matrix
quadrupoleMatrixFirst.xx().get<derivOrder::one>()(0, 0).value();
quadrupoleMatrixFirst.xx().get<derivOrder::one>()(0, 0).derivatives();

Unnamed Group

QuadrupoleMatrix()

Rule of 6.

Unnamed Group

MatrixWithDerivatives &xx()

Setters for the xx, xy, xz, yy, yz, and zz components of the matrix.

Note: the quadrupole moment integral matrix is symmetric. So, only upper triangle is exposed.

Unnamed Group

const MatrixWithDerivatives &xx() const

Setters for the xx, xy, xz, yy, yz, and zz components of the matrix.

Note: the quadrupole moment integral matrix is symmetric. So, only upper triangle is exposed.

Unnamed Group

Eigen::MatrixXd &operator[](int index)

Returns the components by index.

Indices are ordered as xx, xy, xz, yy, yz, zz.

Unnamed Group

MatrixWithDerivatives &at(int index)

Returns the derivative matrices components by index.

Public Functions

void reset(int dimension)

Resets the quadrupole matrix.

Parameters
  • dimension: the number of basis function in the system, i.e. the dimension of the integral matrices.