File DipoleMatrix.h

Copyright

This code is licensed under the 3-clause BSD license.

Copyright ETH Zurich, Laboratory for Physical Chemistry, Reiher Group.

See LICENSE.txt for details.

namespace Scine

This header file contains functions that allow for common notation for common things that can be done at a different degree of derivatives.

This header contains alias definitions defining which classes to use for the different degrees of derivatives.

namespace Utils
class InvalidDimensionSizeException : public exception

Public Functions

const char *what() const
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.

DipoleMatrix(const DipoleMatrix &rhs)
DipoleMatrix &operator=(const DipoleMatrix &rhs)
DipoleMatrix(DipoleMatrix &&rhs)
DipoleMatrix &operator=(DipoleMatrix &&rhs)
~DipoleMatrix()

Unnamed Group

MatrixWithDerivatives &x()

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

MatrixWithDerivatives &y()
MatrixWithDerivatives &z()

Unnamed Group

const MatrixWithDerivatives &x() const

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

const MatrixWithDerivatives &y() const
const MatrixWithDerivatives &z() const

Unnamed Group

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

Returns the zeroth derivative components by index.

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

const Eigen::MatrixXd &operator[](int index) const
MatrixWithDerivatives &at(int index)

Returns the derivative components by index.

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

const MatrixWithDerivatives &at(int index) const

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.

Private Members

std::array<MatrixWithDerivatives, 3> dipoleMatrices_