Class Scine::Utils::DipoleMatrix

class DipoleMatrix

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

This class stores the dipole integrals \(\langle mu|r|nu \rangle\) and their derivatives in their three components x, y, z.

The derivatives are accessible through the .derivatives() method of the underlying AutomaticDifferentiation::First3D/Second3D class.

int arbitraryDimension = 10;
DipoleMatrix dippoleMatrixZero, dipoleMatrixFirst;

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

Eigen::MatrixXd XMatrix = Eigen::MatrixXd::Random(arbitraryDimension, arbitraryDimension);
Eigen::MatrixXd YMatrix = Eigen::MatrixXd::Random(arbitraryDimension, arbitraryDimension);
Eigen::MatrixXd ZMatrix = Eigen::MatrixXd::Random(arbitraryDimension, arbitraryDimension);
DerivType Xderivatives, Yderivatives, Zderivatives;
Xderivatives.resize(arbitraryDimension, arbitraryDimension);
Yderivatives.resize(arbitraryDimension, arbitraryDimension);
Zderivatives.resize(arbitraryDimension, arbitraryDimension);
for (int i = 0; i < arbitraryDimension; ++i) {
  for (int j = 0; j < arbitraryDimension; ++j) {
    Xderivatives(i, j) = {XMatrix(i, j), Eigen::Vector3d::Random()};
    Yderivatives(i, j) = {YMatrix(i, j), Eigen::Vector3d::Random()};
    Zderivatives(i, j) = {ZMatrix(i, j), Eigen::Vector3d::Random()};
  }
}
// Fill zeroth order dipole matrix
dipoleMatrixZero.x().get<derivOrder::zero>(XMatrix);
dipoleMatrixZero.y().get<derivOrder::zero>(YMatrix);
dipoleMatrixZero.z().get<derivOrder::zero>(ZMatrix);

// Fill first order dipole matrix with the first derivative integrals
dipoleMatrixFirst.x().get<derivOrder::one>(Xderivatives);
dipoleMatrixFirst.y().get<derivOrder::one>(Yderivatives);
dipoleMatrixFirst.z().get<derivOrder::one>(Zderivatives);

// Get the zeroth and first derivatives of the first element of the first derivative matrix
dipoleMatrixZero.x().get<derivOrder::zero>()(0, 0);
// Get the zeroth and first derivatives of the first element of the first derivative matrix
AutomaticDifferentiation::getValue3DAsDouble(dipoleMatrixFirst.x().get<derivOrder::one>()(0, 0));
// or
dipoleMatrixFirst.x().get<derivOrder::one>()(0, 0).value();
dipoleMatrixFirst.x().get<derivOrder::one>()(0, 0).derivatives();

Unnamed Group

DipoleMatrix()

Rule of 6.

Unnamed Group

MatrixWithDerivatives &x()

Setters for the x, y and z components of the matrix.

Unnamed Group

const MatrixWithDerivatives &x() const

Getters for the x, y and z components of the matrix.

Unnamed Group

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

Returns the zeroth derivative components by index.

0 is x, 1 is y and 2 is z.

MatrixWithDerivatives &at(int index)

Returns the derivative components by index.

0 is x, 1 is y and 2 is z.

Public Functions

void reset(int dimension)

Resets the dipole matrix.

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