votca 2026-dev
Loading...
Searching...
No Matches
votca::xtp::EwaldBlockJacobiPreconditioner Class Reference

Block-Jacobi preconditioner for the PCG solve of EwaldPeriodicDipoleOperator. More...

#include <ewaldblockjacobipreconditioner.h>

Collaboration diagram for votca::xtp::EwaldBlockJacobiPreconditioner:

Public Types

enum  { ColsAtCompileTime = Eigen::Dynamic , MaxColsAtCompileTime = Eigen::Dynamic }
using StorageIndex = votca::Index

Public Member Functions

 EwaldBlockJacobiPreconditioner ()
 EwaldBlockJacobiPreconditioner (EwaldRegistry &registry, std::vector< Index > ids, double alpha_ewald, double thole_a)
Index rows () const
Index cols () const
template<typename MatType>
EwaldBlockJacobiPreconditioner & analyzePattern (const MatType &)
template<typename MatType>
EwaldBlockJacobiPreconditioner & factorize (const MatType &)
template<typename MatType>
EwaldBlockJacobiPreconditioner & compute (const MatType &)
template<typename Rhs, typename Dest>
void _solve_impl (const Rhs &b, Dest &x) const
template<typename Rhs>
const Eigen::Solve< EwaldBlockJacobiPreconditioner, Rhs > solve (const Eigen::MatrixBase< Rhs > &b) const
Eigen::ComputationInfo info () const

Private Types

using Scalar = double
using Vector = Eigen::VectorXd

Private Member Functions

void BuildOffsets ()
void FactorizeBlocks ()

Private Attributes

EwaldRegistry * registry_ = nullptr
std::vector< Index > ids_
std::optional< EwaldRealSpaceInteractor > intra_interactor_
std::vector< Index > offsets_
Index size_ = 0
std::vector< Eigen::LDLT< Eigen::MatrixXd > > factorizations_
bool is_initialized_

Detailed Description

Block-Jacobi preconditioner for the PCG solve of EwaldPeriodicDipoleOperator.

Usage: Eigen::ConjugateGradient default-constructs its preconditioner member and cg.compute(op) only calls that member's compute(), so a constructed instance must be assigned after compute():

Eigen::ConjugateGradient<Op, Lower|Upper, EwaldBlockJacobiPreconditioner> cg; cg.compute(op); cg.preconditioner() = EwaldBlockJacobiPreconditioner(registry, ids, alpha_ewald, thole_a); x = cg.solveWithGuess(b, x0);

Eigen::DiagonalPreconditioner only sees the same-site getPInv() blocks and ignores the Thole-damped intramolecular coupling of EwaldPeriodicDipoleOperator::AddIntraSegmentCoupling. With that preconditioner a ~5000-site PCG solve diverged once intramolecular Thole damping was enabled. The isolated intramolecular block itself is SPD when Thole damped (methane, thole_a = 0.6: min eigenvalue ~0.05; undamped ~-0.12), so it is a valid preconditioner block.

For every segment in ids the dense 3*N_site x 3*N_site block of getPInv() on the diagonal minus the intramolecular coupling is built and factorized once with LDLT. LDLT rather than LLT because the block can be nearly singular (min eigenvalue ~0.0016 at thole_a = 1.0 for methane). Single-site segments reduce to the plain diagonal block.

solve(b) applies each segment's factorization to its slice of b (block Jacobi): intramolecular coupling is treated exactly, intermolecular (periodic) coupling is left to the outer PCG iteration.

Definition at line 50 of file ewaldblockjacobipreconditioner.h.

Member Typedef Documentation

◆ Scalar

◆ StorageIndex

◆ Vector

using votca::xtp::EwaldBlockJacobiPreconditioner::Vector = Eigen::VectorXd
private

Definition at line 52 of file ewaldblockjacobipreconditioner.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
ColsAtCompileTime 
MaxColsAtCompileTime 

Definition at line 56 of file ewaldblockjacobipreconditioner.h.

Constructor & Destructor Documentation

◆ EwaldBlockJacobiPreconditioner() [1/2]

votca::xtp::EwaldBlockJacobiPreconditioner::EwaldBlockJacobiPreconditioner ( )
inline

Definition at line 61 of file ewaldblockjacobipreconditioner.h.

◆ EwaldBlockJacobiPreconditioner() [2/2]

votca::xtp::EwaldBlockJacobiPreconditioner::EwaldBlockJacobiPreconditioner ( EwaldRegistry & registry,
std::vector< Index > ids,
double alpha_ewald,
double thole_a )
inline

Definition at line 65 of file ewaldblockjacobipreconditioner.h.

Member Function Documentation

◆ _solve_impl()

template<typename Rhs, typename Dest>
void votca::xtp::EwaldBlockJacobiPreconditioner::_solve_impl ( const Rhs & b,
Dest & x ) const
inline

Definition at line 95 of file ewaldblockjacobipreconditioner.h.

◆ analyzePattern()

template<typename MatType>
EwaldBlockJacobiPreconditioner & votca::xtp::EwaldBlockJacobiPreconditioner::analyzePattern ( const MatType & )
inline

Definition at line 82 of file ewaldblockjacobipreconditioner.h.

◆ BuildOffsets()

void votca::xtp::EwaldBlockJacobiPreconditioner::BuildOffsets ( )
inlineprivate

Definition at line 123 of file ewaldblockjacobipreconditioner.h.

◆ cols()

Index votca::xtp::EwaldBlockJacobiPreconditioner::cols ( ) const
inline

Definition at line 76 of file ewaldblockjacobipreconditioner.h.

◆ compute()

template<typename MatType>
EwaldBlockJacobiPreconditioner & votca::xtp::EwaldBlockJacobiPreconditioner::compute ( const MatType & )
inline

Definition at line 90 of file ewaldblockjacobipreconditioner.h.

◆ factorize()

template<typename MatType>
EwaldBlockJacobiPreconditioner & votca::xtp::EwaldBlockJacobiPreconditioner::factorize ( const MatType & )
inline

Definition at line 86 of file ewaldblockjacobipreconditioner.h.

◆ FactorizeBlocks()

void votca::xtp::EwaldBlockJacobiPreconditioner::FactorizeBlocks ( )
inlineprivate

Definition at line 142 of file ewaldblockjacobipreconditioner.h.

◆ info()

Eigen::ComputationInfo votca::xtp::EwaldBlockJacobiPreconditioner::info ( ) const
inline

Definition at line 120 of file ewaldblockjacobipreconditioner.h.

◆ rows()

Index votca::xtp::EwaldBlockJacobiPreconditioner::rows ( ) const
inline

Definition at line 75 of file ewaldblockjacobipreconditioner.h.

◆ solve()

template<typename Rhs>
const Eigen::Solve< EwaldBlockJacobiPreconditioner, Rhs > votca::xtp::EwaldBlockJacobiPreconditioner::solve ( const Eigen::MatrixBase< Rhs > & b) const
inline

Definition at line 109 of file ewaldblockjacobipreconditioner.h.

Member Data Documentation

◆ factorizations_

std::vector<Eigen::LDLT<Eigen::MatrixXd> > votca::xtp::EwaldBlockJacobiPreconditioner::factorizations_
private

Definition at line 196 of file ewaldblockjacobipreconditioner.h.

◆ ids_

std::vector<Index> votca::xtp::EwaldBlockJacobiPreconditioner::ids_
private

Definition at line 192 of file ewaldblockjacobipreconditioner.h.

◆ intra_interactor_

std::optional<EwaldRealSpaceInteractor> votca::xtp::EwaldBlockJacobiPreconditioner::intra_interactor_
private

Definition at line 193 of file ewaldblockjacobipreconditioner.h.

◆ is_initialized_

bool votca::xtp::EwaldBlockJacobiPreconditioner::is_initialized_
private

Definition at line 197 of file ewaldblockjacobipreconditioner.h.

◆ offsets_

std::vector<Index> votca::xtp::EwaldBlockJacobiPreconditioner::offsets_
private

Definition at line 194 of file ewaldblockjacobipreconditioner.h.

◆ registry_

EwaldRegistry* votca::xtp::EwaldBlockJacobiPreconditioner::registry_ = nullptr
private

Definition at line 191 of file ewaldblockjacobipreconditioner.h.

◆ size_

Index votca::xtp::EwaldBlockJacobiPreconditioner::size_ = 0
private

Definition at line 195 of file ewaldblockjacobipreconditioner.h.


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