ergo
slr.cc File Reference
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <vector>
#include "mat_gblas.h"
#include "slr.h"
#include "solve_lin_eq_syst.h"
#include "utilities.h"
#include "output.h"
#include "units.h"

Namespaces

 LR
 

Functions

ergo_real LR::dot (int len, const ergo_real *a, const ergo_real *b)
 returns dot_product(a, b) More...
 
ergo_real LR::operator* (const VarVector &a, const VarVector &b)
 
ergo_real LR::operator* (const VarVector &a, const VarVectorProxyOp< false, false > &b)
 
ergo_real LR::operator* (const VarVector &a, const VarVectorProxyOp< true, false > &b)
 
ergo_real LR::operator* (const VarVector &a, const VarVectorProxyOp< false, true > &b)
 
VarVectorProxyOp< false, false > LR::operator* (ergo_real s, const VarVector &v)
 
template<bool MultByS, bool SwapXY>
VarVectorProxyOp< MultByS, SwapXY > LR::operator* (ergo_real s, const VarVectorProxyOp< MultByS, SwapXY > &v)
 
VarVector & LR::operator+= (VarVector &a, const VarVectorProxyOp< false, false > &proxy)
 
VarVector & LR::operator+= (VarVector &a, const VarVectorProxyOp< true, false > &proxy)
 
VarVector & LR::operator+= (VarVector &a, const VarVectorProxyOp< false, true > &proxy)
 
VarVector & LR::operator+= (VarVector &a, const VarVectorProxyOp< true, true > &proxy)
 
const VarVectorProxyOp< false, true > LR::swapXY (const VarVector &arg)
 returns a proxy object corresponding to a swapped vector. More...
 
const VarVectorProxyOp< true, false > LR::sTimes (const VarVector &arg)
 returns a proxy object corresponding to a vector multiplied by S[2], i.e. More...
 
template<bool SwapXY>
VarVectorProxyOp< true, SwapXY > LR::sTimes (const VarVectorProxyOp< false, SwapXY > &arg)
 
static void LR::precondition (VarVector &v, const VarVector &e2diag, ergo_real shift)
 pre-condition a vector given an approximation of the E[2] operator diagonal and a shift of the S[2] operator. More...
 
static void LR::commuteWithDMO (int nbast, int nocc, ergo_real *mat)
 mat := [mat, D_MO] More...
 
static void LR::gemm (int n, const char *at, const ergo_real *a, const char *bt, const ergo_real *b, ergo_real alpha, ergo_real beta, ergo_real *c)
 
static void LR::commute (int nbast, const ergo_real *a, const ergo_real *b, ergo_real f, ergo_real *res)
 res := f*res + [a, b] More...
 

Detailed Description

contains a Simple Linear Response implementation based on the MO orbital picture. Copyright(c) Pawel Salek 2006.

Author
: Pawel Salek responsible

The solver is generic: it can handle both linear sets of equations and eigenvalue problems. The variable parts are implemented by subclasses. A subclass must implement following functions:

  • getResidual(trial) - returns a residual vector being a difference between true solution and the solution in the subspace.

    In case of the set of equations, residual is computed in 3 steps: Solution in the subspace: Xsub = (Asub-freq*Ssub)\Ysub; Solution expanded out fo subspace: X=v*Xsub; Residual vector: residualv= (Av-freq*Sv)*Xsub - Y;

    In case of the eigenvalue problem, more steps are needed: Solution in the subspace: [ Xsub, lambda ] = eig(Asub, Ssub); Pick first positive eigenvalue l1 = lambda(step+1); Pick corresponding eigenvector: Xsub = Xsub(:,step+1); Residual Vector: residualv = (Av-l1*Sv)*Xsub;

  • getPreconditonerShift() - get the preconditioner shift. In case of the set of equations, it is shifted by the constant frequency. In case of set of eigenvalues, it is shifted by the best approximation to the required solution, obtained in the first step from the difference of KS matrix eigenvalues or taken as the Ritz value when they are available.
  • all other stuff, like vector transformation and subspace extension are handled by the generic solver.

Example usage:

MyE2Evaluator e2;
EigenSolver solver(nbast, nocc, fock_matrix, overlap_matrix);
solver.solve(e2);
printf("Lowest eigenvalue: %f\n", solver.getFreq());

The important stuff will get printed but also a solution should probably be returned in some convenient way.