ergo
PurificationGeneral< MatrixType > Class Template Referenceabstract

PurificationGeneral is an abstract class which provides an interface for SP2, SP2ACC and possibly other recursive expansions. More...

#include <purification_general.h>

Inheritance diagram for PurificationGeneral< MatrixType >:
Purification_sp2< MatrixType > Purification_sp2acc< MatrixType >

Public Types

typedef ergo_real real
 
typedef intervalType IntervalType
 
typedef mat::normType NormType
 
typedef std::vector< int > VectorTypeInt
 
typedef std::vector< realVectorTypeReal
 
typedef generalVector VectorType
 
typedef MatrixType MatrixTypeWrapper
 

Public Member Functions

 PurificationGeneral ()
 
virtual void initialize (const MatrixType &F_, const IntervalType &lumo_bounds_, const IntervalType &homo_bounds_, int maxit_, real error_sub_, real error_eig_, bool use_new_stopping_criterion_, NormType norm_truncation, NormType norm_stop_crit, int nocc_)
 Set imporatant parameters for the recursive expansion.
 
virtual void PurificationStart ()
 Start recursive expansion.
 
virtual void clear ()
 Clear all matrices in the class.
 
void set_spectrum_bounds (real eigmin, real eigmax)
 Set spectrum bounds.
 
void get_spectrum_bounds (real &eigmin, real &eigmax)
 Get spectrum bounds.
 
int get_exact_number_of_puri_iterations ()
 
int get_est_number_of_puri_iterations ()
 
virtual real total_subspace_error (int it)
 
void set_eigenvectors_params (string eigenvectors_method_, string eigenvectors_iterative_method_, real eigensolver_accuracy_, int eigensolver_maxiter_, int scf_step_, bool try_eigv_on_next_iteration_if_fail_)
 Set parameters for computing eigenvectors.
 
void set_eigenvectors_params (string eigenvectors_method_, string eigenvectors_iterative_method_, real eigensolver_accuracy_, int eigensolver_maxiter_, int scf_step_, bool try_eigv_on_next_iteration_if_fail_, bool use_prev_vector_as_initial_guess_, const std::vector< VectorType > &eigVecOCCRef, const std::vector< VectorType > &eigVecUNOCCRef)
 Set parameters for computing eigenvectors - long version.
 
void extract_computed_eigenpairs (std::vector< VectorType > &eigVecUNOCCref, std::vector< VectorType > &eigVecOCCref, std::vector< real > &eigValUNOCCref, std::vector< real > &eigValOCCref)
 
void set_compute_eigenvectors_in_each_iteration ()
 
void unset_compute_eigenvectors_in_each_iteration ()
 
void set_number_of_eigenvectors_to_compute (const int occ, const int unocc)
 
int get_number_of_occ_eigenvectors_to_compute () const
 
int get_number_of_unocc_eigenvectors_to_compute () const
 
void set_jump_over_X_iter_proj_method (int val)
 
int get_jump_over_X_iter_proj_method () const
 
void set_go_back_X_iter_proj_method (int val)
 
int get_go_back_X_iter_proj_method () const
 
void compute_eigenvectors_without_diagonalization_on_F (const MatrixType &F, int eigensolver_maxiter_for_F)
 
void gen_matlab_file_norm_diff (const char *filename) const
 Create MATLAB .m file which plots the idempotency error in each recursive expansion iteration.
 
void gen_matlab_file_threshold (const char *filename) const
 Create MATLAB .m file which plots the actual introduced error after truncation of the matrix X_i in each recursive expansion iteration.
 
void gen_matlab_file_nnz (const char *filename) const
 Create MATLAB .m file which plots the number of non-zero elements in matrices X_i and X_i^2 in each recursive expansion iteration.
 
void gen_matlab_file_eigs (const char *filename) const
 Create MATLAB .m file which plots the homo and lumo bounds in each recursive expansion iteration.
 
void gen_matlab_file_time (const char *filename) const
 Create MATLAB .m file which creates a bar plot presenting time spent on various parts of the iteration (such as matrix square and computation of eigenvectors) in each recursive expansion iteration.
 
virtual ~PurificationGeneral ()
 Create MATLAB .m file which plots a condition number of a problem of computing the density matrix in each recursive expansion iteration.
 

Static Public Member Functions

static real get_epsilon ()
 Get machine epsilon.
 
static real get_max_double ()
 Get largest number.
 
static real get_min_double ()
 Get smallest number.
 

Public Attributes

PuriInfo info
 Fill in during purification with useful information.
 
MatrixType X
 Matrix X.
 
MatrixType Xsq
 Matrix X^2.
 

Protected Member Functions

virtual bool is_initialized () const
 Check is function initialize() is already called.
 
virtual bool puri_is_prepared () const
 Check is function prepare_to_purification() is already called.
 
virtual void prepare_to_purification ()
 Prepare data for recursive expansion.
 
virtual void prepare_to_purification_eigenvectors ()
 Prepare data related to the eigenvectors computations.
 
virtual void purification_process ()
 Run recursive expansion.
 
virtual void eigenvalue_bounds_estimation ()
 Estimate eigenvalues near homo-lumo gap.
 
void save_matrix_now (string str)
 
void save_matrix_A_now (const MatrixType &A, string str)
 
virtual void compute_spectrum_bounds ()
 Compute spectrum bounds.
 
virtual void compute_X ()
 Get matrix X0 by mapping spectrum of F into [0,1] in reverse order.
 
void map_bounds_to_0_1 ()
 Get eigenvalue bounds for X0.
 
virtual void check_standard_stopping_criterion (const real XmX2_norm, int &stop)
 Check stopping criterion (obsolete).
 
virtual void check_new_stopping_criterion (const int it, const real XmX2_norm_it, const real XmX2_norm_itm2, const real XmX2_trace, int &stop, real &estim_order)
 Check stopping criterion.
 
virtual void stopping_criterion (IterationInfo &iter_info, int &stop, real &estim_order)
 Choose stopping criterion and check it.
 
int get_int_eig_iter_method (string eigenvectors_iterative_method)
 
int get_int_eig_method (string eigenvectors_method)
 
void compute_eigenvectors_without_diagonalization (int it, IterationInfo &iter_info)
 Compute HOMO and LUMO eigenvalues and eigenvectors of the matrix F.
 
void compute_eigenvectors_without_diagonalization_last_iter_proj ()
 
void projection_method_one_puri_iter (int current_iteration)
 
void compute_eigenvector (MatrixType const &M, std::vector< VectorType > &eigVec, std::vector< real > &eigVal, int it, bool is_homo)
 
void set_eigenvectors_params_basic (string eigenvectors_method_, string eigenvectors_iterative_method_, real eigensolver_accuracy_, int eigensolver_maxiter_, int scf_step_, bool try_eigv_on_next_iteration_if_fail_, bool use_prev_vector_as_initial_guess_)
 Set parameters for computing eigenvectors.
 
double get_nnz_X (size_t &nnzX)
 Get nnz of X in %.
 
double get_nnz_X ()
 Get nnz of X in %.
 
double get_nnz_Xsq (size_t &nnzXsq)
 Get nnz of X^2 in %.
 
double get_nnz_Xsq ()
 Get nnz of X^2 in %.
 
void estimate_homo_lumo (const VectorTypeReal &XmX2_norm_mixed, const VectorTypeReal &XmX2_norm_frob, const VectorTypeReal &XmX2_trace)
 Get homo and lumo bounds from traces and norms of Xi-Xi^2.
 
void get_eigenvalue_estimates (const VectorTypeReal &XmX2_norm_mixed, const VectorTypeReal &XmX2_norm_frob, const VectorTypeReal &XmX2_trace)
 Get homo and lumo bounds from traces and norms of Xi-Xi^2.
 
virtual void determine_iteration_for_eigenvectors ()
 Determine in which iterations will be computed homo and lumo eigenvectors.
 
virtual void get_iterations_for_lumo_and_homo (int &chosen_iter_lumo, int &chosen_iter_homo)
 Find the best iterations for computing eigenvectors.
 
virtual void check_eigenvectors_at_the_end ()
 
virtual void discard_homo_eigenvector ()
 
virtual void discard_lumo_eigenvector ()
 
void output_norms_and_traces (IterationInfo &iter_info) const
 
void output_separate_total_times (PuriInfo &info) const
 
void output_time_WriteAndReadAll () const
 
void check_homo_lumo_eigenvalues (real &eigVal, VectorType &eigVec, bool &is_homo, bool &is_lumo, const int iter)
 
void get_eigenvalue_of_F_from_eigv_of_Xi (real &eigVal, const VectorType &eigVec)
 
void save_selected_eigenvector_to_file (const VectorType &v, int num, bool is_homo, int it=-1)
 
virtual void truncate_matrix (real &thresh, int it)
 
virtual void set_truncation_parameters ()
 
void find_shifts_every_iter ()
 /brief Find shifts sigma which will be used for construction of the filtering polynomial for computing eigenvectors.
 
void writeToTmpFile (MatrixType &A) const
 
void readFromTmpFile (MatrixType &A) const
 
virtual void set_init_params ()=0
 
virtual void estimate_number_of_iterations (int &estim_num_iter)=0
 
virtual void purify_X (const int it)=0
 
virtual void purify_bounds (const int it)=0
 
virtual void save_other_iter_info (IterationInfo &iter_info, int it)=0
 
virtual void apply_inverse_poly_vector (const int it, VectorTypeReal &bounds_from_it)=0
 
virtual void return_constant_C (const int it, real &Cval)=0
 
virtual real apply_poly (const int it, real x)=0
 
virtual real compute_derivative (const int it, real x, real &DDf)=0
 

Protected Attributes

MatrixType F
 Matrix F.
 
std::vector< MatrixTypevec_matrices_Xi
 Save matrices Xi in each iteration (if used projection method for computing eigenvectors).
 
bool initialized_flag
 
bool puri_is_prepared_flag
 
bool use_new_stopping_criterion
 True for new stopping criterion.
 
int additional_iterations
 Do a few more iterations after convergence.
 
int maxit
 Maximum number of iterations.
 
int check_stopping_criterion_iter
 Iteration when to start to check stopping criterion.
 
int nocc
 Number of occupied orbitals.
 
NormType normPuriTrunc
 Norm used for the truncation of matrices.
 
NormType normPuriStopCrit
 Norm used in the stopping criterion Can be mat::frobNorm, mat::mixedNorm, or mat::euclNorm.
 
real error_sub
 Allowed error in invariant subspaces.
 
real error_eig
 Error in eigenvalues (used just in old stopping criterion).
 
real error_per_it
 Error allowed in each iteration due to truncation.
 
real constant_C
 Asymptotic constant C needed for the new stopping criterion.
 
real gammaStopEstim
 Used on the stopping criterion for estimation of eigenvalues from purification.
 
VectorTypeInt VecPoly
 Polynomials computed in the function estimated_number_of_iterations() VecPoly[i] = 1 if we use X=X^2 VecPoly[i] = 0 if we use X=2X-X^2 (or their accelerated versions)
 
VectorTypeReal VecGap
 Gap computed using inner homo and lumo bounds on each iteration.
 
VectorTypeReal ITER_ERROR_VEC
 (Eigenvectors) Maximum error introduced in each iteration.
 
VectorTypeReal SIGMA_HOMO_VEC
 
VectorTypeReal SIGMA_LUMO_VEC
 (Eigenvectors) Approximation of shifts in each iteration.
 
VectorTypeReal EIG_ABS_GAP_LUMO_VEC
 
VectorTypeReal EIG_ABS_GAP_HOMO_VEC
 (Eigenvectors) Absolute and relative gap in filter for lumo eigenvalue.
 
VectorTypeReal EIG_REL_GAP_LUMO_VEC
 
VectorTypeReal EIG_REL_GAP_HOMO_VEC
 (Eigenvectors) Absolute and relative gap in filter for homo eigenvalue.
 
int number_of_occ_eigenvectors
 
int number_of_unocc_eigenvectors
 
int jump_over_X_iter_proj_method
 
int go_back_X_iter_proj_method
 
IntervalType homo_bounds
 (1-homo) bounds for Xi in iteration i
 
IntervalType lumo_bounds
 Lumo bounds for Xi in iteration i.
 
IntervalType homo_bounds_X0
 Initial lumo bounds for X.
 
IntervalType lumo_bounds_X0
 Initial lumo bounds for X.
 
IntervalType homo_bounds_F
 Initial lumo bounds for F.
 
IntervalType lumo_bounds_F
 Initial homo bounds for F.
 
IntervalType homo_bounds_F_new
 
IntervalType lumo_bounds_F_new
 
IntervalType spectrum_bounds
 Outer bounds for the whole spectrum of F/Xi.
 
bool computed_spectrum_bounds
 
int eigenvectors_method
 Chosen method for computing eigenvectors.
 
int eigenvectors_iterative_method
 Chosen eigensolver.
 
real eigensolver_accuracy
 Accuracy of the eigenvalue problem solver.
 
int eigensolver_maxiter
 Maximum number of iterations for eigensolver.
 
string eigenvectors_method_str
 
string eigenvectors_iterative_method_str
 
bool use_prev_vector_as_initial_guess
 
bool compute_eigenvectors_in_this_SCF_cycle
 
bool try_eigv_on_next_iteration_if_fail
 
VectorType eigVecLUMORef
 
VectorType eigVecHOMORef
 
std::vector< VectorTypeeigVecOCC
 Here we save eigenvectors corresponding to the occupied orbitals.
 
std::vector< VectorTypeeigVecUNOCC
 Here we save eigenvectors corresponding to the unoccupied orbitals.
 
std::vector< realeigValOCC
 Here we save eigenvalues corresponding to the occupied orbitals.
 
std::vector< realeigValUNOCC
 Here we save eigenvalues corresponding to the unoccupied orbitals.
 
real eigValLUMO
 
real eigValHOMO
 
int iter_for_homo
 
int iter_for_lumo
 
VectorTypeInt good_iterations_homo
 Iterations where homo eigenvector can be computed.
 
VectorTypeInt good_iterations_lumo
 Iterations where homo eigenvector can be computed.
 
VectorTypeInt really_good_iterations_homo
 Iterations where homo eigenvector is actually computed.
 
VectorTypeInt really_good_iterations_lumo
 Iterations where lumo eigenvector is actually computed.
 
int scf_step
 
bool compute_eigenvectors_in_each_iteration
 Compute homo and lumo eigenpairs in every iteration and save eigenvectors in txt files.
 

Detailed Description

template<typename MatrixType>
class PurificationGeneral< MatrixType >

PurificationGeneral is an abstract class which provides an interface for SP2, SP2ACC and possibly other recursive expansions.

Template Parameters
MatrixTypeType of a matrix (ex. symmMatrix).

Member Typedef Documentation

◆ IntervalType

◆ MatrixTypeWrapper

template<typename MatrixType>
typedef MatrixType PurificationGeneral< MatrixType >::MatrixTypeWrapper

◆ NormType

◆ real

◆ VectorType

◆ VectorTypeInt

template<typename MatrixType>
typedef std::vector<int> PurificationGeneral< MatrixType >::VectorTypeInt

◆ VectorTypeReal

template<typename MatrixType>
typedef std::vector<real> PurificationGeneral< MatrixType >::VectorTypeReal

Constructor & Destructor Documentation

◆ PurificationGeneral()

◆ ~PurificationGeneral()

template<typename MatrixType>
virtual PurificationGeneral< MatrixType >::~PurificationGeneral ( )
inlinevirtual

Create MATLAB .m file which plots a condition number of a problem of computing the density matrix in each recursive expansion iteration.

The condition number is equal to inverse of the homo-lumo gap approximation. Create PYTHON .py file which plots number of non-zero elements in matrices X_i and X_i^2 in each recursive expansion iteration.

Member Function Documentation

◆ apply_inverse_poly_vector()

template<typename MatrixType>
virtual void PurificationGeneral< MatrixType >::apply_inverse_poly_vector ( const int it,
VectorTypeReal & bounds_from_it )
protectedpure virtual

Referenced by estimate_homo_lumo().

◆ apply_poly()

template<typename MatrixType>
virtual real PurificationGeneral< MatrixType >::apply_poly ( const int it,
real x )
protectedpure virtual

◆ check_eigenvectors_at_the_end()

◆ check_homo_lumo_eigenvalues()

◆ check_new_stopping_criterion()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::check_new_stopping_criterion ( const int it,
const real XmX2_norm_it,
const real XmX2_norm_itm2,
const real XmX2_trace,
int & stop,
real & estim_order )
protectedvirtual

Check stopping criterion.

The new stopping criterion based on the order of convergence is used, see article "Parameterless Stopping Criteria for Recursive Density Matrix Expansions", J. Chem. Theory Comput., 2016, 12 (12), pp 5788–5802 DOI: 10.1021/acs.jctc.6b00626

References constant_C, do_output(), get_epsilon(), LOG_AREA_DENSFROMF, LOG_CAT_INFO, ORDER, return_constant_C(), template_blas_log(), template_blas_pow(), template_blas_sqrt(), and VecPoly.

Referenced by stopping_criterion().

◆ check_standard_stopping_criterion()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::check_standard_stopping_criterion ( const real XmX2_norm,
int & stop )
protectedvirtual

Check stopping criterion (obsolete).

Use stopping criterion based on user defined threshold values.

References do_output(), error_eig, homo_bounds, LOG_AREA_DENSFROMF, LOG_CAT_INFO, and lumo_bounds.

Referenced by stopping_criterion().

◆ clear()

template<typename MatrixType>
virtual void PurificationGeneral< MatrixType >::clear ( )
inlinevirtual

Clear all matrices in the class.

Needed to be called if Chunks and Tasks are used, since we need to delete all ChunkIDs before exiting the program.

Referenced by GetDensFromFock::get_dens_from_fock_sparse(), and main().

◆ compute_derivative()

template<typename MatrixType>
virtual real PurificationGeneral< MatrixType >::compute_derivative ( const int it,
real x,
real & DDf )
protectedpure virtual

◆ compute_eigenvector()

◆ compute_eigenvectors_without_diagonalization()

◆ compute_eigenvectors_without_diagonalization_last_iter_proj()

◆ compute_eigenvectors_without_diagonalization_on_F()

◆ compute_spectrum_bounds()

◆ compute_X()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::compute_X ( )
protectedvirtual

Get matrix X0 by mapping spectrum of F into [0,1] in reverse order.

References do_output(), LOG_AREA_DENSFROMF, LOG_CAT_INFO, spectrum_bounds, and X.

Referenced by prepare_to_purification().

◆ determine_iteration_for_eigenvectors()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::determine_iteration_for_eigenvectors ( )
protectedvirtual

◆ discard_homo_eigenvector()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::discard_homo_eigenvector ( )
protectedvirtual

References eigVecOCC, and info.

Referenced by check_eigenvectors_at_the_end().

◆ discard_lumo_eigenvector()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::discard_lumo_eigenvector ( )
protectedvirtual

References eigVecUNOCC, and info.

Referenced by check_eigenvectors_at_the_end().

◆ eigenvalue_bounds_estimation()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::eigenvalue_bounds_estimation ( )
protectedvirtual

◆ estimate_homo_lumo()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::estimate_homo_lumo ( const VectorTypeReal & XmX2_norm_mixed,
const VectorTypeReal & XmX2_norm_frob,
const VectorTypeReal & XmX2_trace )
protected

Get homo and lumo bounds from traces and norms of Xi-Xi^2.

Called by get_eigenvalue_estimates().

Used at the end of the recursive expansion. See article SIAM J. Sci. Comput., 36(2), B147–B170.

References apply_inverse_poly_vector(), gammaStopEstim, get_epsilon(), homo_bounds_F_new, info, lumo_bounds_F_new, spectrum_bounds, and template_blas_sqrt().

Referenced by get_eigenvalue_estimates().

◆ estimate_number_of_iterations()

template<typename MatrixType>
virtual void PurificationGeneral< MatrixType >::estimate_number_of_iterations ( int & estim_num_iter)
protectedpure virtual

◆ extract_computed_eigenpairs()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::extract_computed_eigenpairs ( std::vector< VectorType > & eigVecUNOCCref,
std::vector< VectorType > & eigVecOCCref,
std::vector< real > & eigValUNOCCref,
std::vector< real > & eigValOCCref )
inline

◆ find_shifts_every_iter()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::find_shifts_every_iter ( )
protected

/brief Find shifts sigma which will be used for construction of the filtering polynomial for computing eigenvectors.

References apply_poly(), homo_bounds, lumo_bounds, maxit, SIGMA_HOMO_VEC, and SIGMA_LUMO_VEC.

Referenced by get_iterations_for_lumo_and_homo().

◆ gen_matlab_file_eigs()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::gen_matlab_file_eigs ( const char * filename) const

Create MATLAB .m file which plots the homo and lumo bounds in each recursive expansion iteration.

References do_output(), info, LOG_AREA_DENSFROMF, and LOG_CAT_INFO.

Referenced by GetDensFromFock::get_dens_from_fock_sparse(), and plot_results().

◆ gen_matlab_file_nnz()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::gen_matlab_file_nnz ( const char * filename) const

Create MATLAB .m file which plots the number of non-zero elements in matrices X_i and X_i^2 in each recursive expansion iteration.

References do_output(), info, LOG_AREA_DENSFROMF, and LOG_CAT_INFO.

Referenced by GetDensFromFock::get_dens_from_fock_sparse(), and plot_results().

◆ gen_matlab_file_norm_diff()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::gen_matlab_file_norm_diff ( const char * filename) const

Create MATLAB .m file which plots the idempotency error in each recursive expansion iteration.

References do_output(), mat::euclNorm, mat::frobNorm, info, LOG_AREA_DENSFROMF, LOG_CAT_INFO, mat::mixedNorm, normPuriStopCrit, and VecPoly.

Referenced by GetDensFromFock::get_dens_from_fock_sparse(), and plot_results().

◆ gen_matlab_file_threshold()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::gen_matlab_file_threshold ( const char * filename) const

Create MATLAB .m file which plots the actual introduced error after truncation of the matrix X_i in each recursive expansion iteration.

References do_output(), info, LOG_AREA_DENSFROMF, and LOG_CAT_INFO.

Referenced by GetDensFromFock::get_dens_from_fock_sparse(), and plot_results().

◆ gen_matlab_file_time()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::gen_matlab_file_time ( const char * filename) const

Create MATLAB .m file which creates a bar plot presenting time spent on various parts of the iteration (such as matrix square and computation of eigenvectors) in each recursive expansion iteration.

References do_output(), EIG_SQUARE_INT, eigenvectors_method, info, LOG_AREA_DENSFROMF, and LOG_CAT_INFO.

Referenced by GetDensFromFock::get_dens_from_fock_sparse(), and plot_results().

◆ get_eigenvalue_estimates()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::get_eigenvalue_estimates ( const VectorTypeReal & XmX2_norm_mixed,
const VectorTypeReal & XmX2_norm_frob,
const VectorTypeReal & XmX2_trace )
protected

Get homo and lumo bounds from traces and norms of Xi-Xi^2.

Used at the end of the recursive expansion. See article SIAM J. Sci. Comput., 36(2), B147–B170.

References estimate_homo_lumo().

Referenced by eigenvalue_bounds_estimation().

◆ get_eigenvalue_of_F_from_eigv_of_Xi()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::get_eigenvalue_of_F_from_eigv_of_Xi ( real & eigVal,
const VectorType & eigVec )
protected

◆ get_epsilon()

◆ get_est_number_of_puri_iterations()

template<typename MatrixType>
int PurificationGeneral< MatrixType >::get_est_number_of_puri_iterations ( )

References info.

◆ get_exact_number_of_puri_iterations()

template<typename MatrixType>
int PurificationGeneral< MatrixType >::get_exact_number_of_puri_iterations ( )

References info.

◆ get_go_back_X_iter_proj_method()

template<typename MatrixType>
int PurificationGeneral< MatrixType >::get_go_back_X_iter_proj_method ( ) const
inline

◆ get_int_eig_iter_method()

template<typename MatrixType>
int PurificationGeneral< MatrixType >::get_int_eig_iter_method ( string eigenvectors_iterative_method)
protected

◆ get_int_eig_method()

template<typename MatrixType>
int PurificationGeneral< MatrixType >::get_int_eig_method ( string eigenvectors_method)
protected

◆ get_iterations_for_lumo_and_homo()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::get_iterations_for_lumo_and_homo ( int & chosen_iter_lumo,
int & chosen_iter_homo )
protectedvirtual

Find the best iterations for computing eigenvectors.

The best iteration defined by both a small error in the eigenvector and a small number of iterations of an iterative method.

References apply_poly(), compute_derivative(), find_shifts_every_iter(), get_min_double(), good_iterations_homo, good_iterations_lumo, homo_bounds, lumo_bounds, maxit, SIGMA_HOMO_VEC, SIGMA_LUMO_VEC, and template_blas_fabs().

Referenced by determine_iteration_for_eigenvectors().

◆ get_jump_over_X_iter_proj_method()

◆ get_max_double()

template<typename MatrixType>
static real PurificationGeneral< MatrixType >::get_max_double ( )
inlinestatic

Get largest number.

◆ get_min_double()

template<typename MatrixType>
static real PurificationGeneral< MatrixType >::get_min_double ( )
inlinestatic

Get smallest number.

Referenced by get_iterations_for_lumo_and_homo().

◆ get_nnz_X() [1/2]

template<typename MatrixType>
double PurificationGeneral< MatrixType >::get_nnz_X ( )
inlineprotected

Get nnz of X in %.

◆ get_nnz_X() [2/2]

template<typename MatrixType>
double PurificationGeneral< MatrixType >::get_nnz_X ( size_t & nnzX)
inlineprotected

Get nnz of X in %.

Parameters
nnzXNumber of nz of X

Referenced by initialize(), and purification_process().

◆ get_nnz_Xsq() [1/2]

template<typename MatrixType>
double PurificationGeneral< MatrixType >::get_nnz_Xsq ( )
inlineprotected

Get nnz of X^2 in %.

◆ get_nnz_Xsq() [2/2]

template<typename MatrixType>
double PurificationGeneral< MatrixType >::get_nnz_Xsq ( size_t & nnzXsq)
inlineprotected

Get nnz of X^2 in %.

Parameters
nnzXsqNumber of nz of X^2

Referenced by purification_process().

◆ get_number_of_occ_eigenvectors_to_compute()

◆ get_number_of_unocc_eigenvectors_to_compute()

◆ get_spectrum_bounds()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::get_spectrum_bounds ( real & eigmin,
real & eigmax )

Get spectrum bounds.

Return spectrum bounds for the matrix F. If not computed before, compute them.

References compute_spectrum_bounds(), computed_spectrum_bounds, and spectrum_bounds.

◆ initialize()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::initialize ( const MatrixType & F_,
const IntervalType & lumo_bounds_,
const IntervalType & homo_bounds_,
int maxit_,
real error_sub_,
real error_eig_,
bool use_new_stopping_criterion_,
NormType norm_truncation,
NormType norm_stop_crit,
int nocc_ )
virtual

Set imporatant parameters for the recursive expansion.

Parameters
[in]F_Effective Hamiltonian matrix.
[in]lumo_bounds_Bounds for lumo eigenvalue.
[in]homo_bounds_Bounds for homo eigenvalue.
[in]maxit_Maximum number of recursive expansion iterations.
[in]error_sub_Allowed error in invariant subspaces.
[in]error_eig_Error in eigenvalues (used just in old stopping criterion).
[in]use_new_stopping_criterion_Set if want to use new stopping criterion.
[in]norm_truncationTruncation norm.
[in]norm_stop_critStopping criterion norm.
[in]nocc_Number of occupied orbitals.

References additional_iterations, check_stopping_criterion_iter, compute_eigenvectors_in_this_SCF_cycle, do_output(), enable_printf_output(), error_eig, error_sub, mat::euclNorm, mat::frobNorm, get_nnz_X(), homo_bounds_F, info, initialized_flag, LOG_AREA_DENSFROMF, LOG_CAT_INFO, lumo_bounds_F, maxit, mat::mixedNorm, nocc, normPuriStopCrit, normPuriTrunc, NUM_ADDITIONAL_ITERATIONS, set_init_params(), use_new_stopping_criterion, and X.

Referenced by GetDensFromFock::get_dens_from_fock_sparse(), main(), test1(), test2(), test3(), and test4().

◆ is_initialized()

template<typename MatrixType>
virtual bool PurificationGeneral< MatrixType >::is_initialized ( ) const
inlineprotectedvirtual

Check is function initialize() is already called.

Referenced by prepare_to_purification().

◆ map_bounds_to_0_1()

◆ output_norms_and_traces()

◆ output_separate_total_times()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::output_separate_total_times ( PuriInfo & info) const
protected

◆ output_time_WriteAndReadAll()

◆ prepare_to_purification()

◆ prepare_to_purification_eigenvectors()

◆ projection_method_one_puri_iter()

◆ puri_is_prepared()

template<typename MatrixType>
virtual bool PurificationGeneral< MatrixType >::puri_is_prepared ( ) const
inlineprotectedvirtual

Check is function prepare_to_purification() is already called.

Referenced by prepare_to_purification_eigenvectors(), and purification_process().

◆ purification_process()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::purification_process ( )
protectedvirtual

Run recursive expansion.

References additional_iterations, check_stopping_criterion_iter, compute_eigenvectors_in_this_SCF_cycle, compute_eigenvectors_without_diagonalization(), constant_C, IterationInfo::constantC, do_output(), eucl_acc, IterationInfo::eucl_diff_time, mat::euclNorm, IterationInfo::frob_diff_time, IterationInfo::gap, Util::TimeMeter::get_elapsed_wall_seconds(), get_nnz_X(), get_nnz_Xsq(), IterationInfo::homo_bound_low, IterationInfo::homo_bound_upp, homo_bounds, IterationInfo::inf_diff_time, info, IterationInfo::it, LOG_AREA_DENSFROMF, LOG_CAT_INFO, IterationInfo::lumo_bound_low, IterationInfo::lumo_bound_upp, lumo_bounds, maxit, mixed_acc, IterationInfo::mixed_diff_time, mat::mixedNorm, IterationInfo::nnz_time, IterationInfo::NNZ_X, IterationInfo::NNZ_X2, normPuriStopCrit, IterationInfo::order, output_current_memory_usage(), output_norms_and_traces(), output_separate_total_times(), output_time_WriteAndReadAll(), Util::TimeMeter::print(), puri_is_prepared(), purify_bounds(), IterationInfo::purify_time, purify_X(), save_matrix_now(), save_other_iter_info(), stopping_criterion(), IterationInfo::stopping_criterion_time, IterationInfo::threshold_X, total_subspace_error(), IterationInfo::total_time, IterationInfo::trace_diff_time, IterationInfo::trunc_time, truncate_matrix(), use_new_stopping_criterion, VecPoly, X, IterationInfo::XmX2_eucl, IterationInfo::XmX2_fro_norm, IterationInfo::XmX2_infty_norm, IterationInfo::XmX2_mixed_norm, IterationInfo::XmX2_trace, Xsq, and IterationInfo::Xsquare_time.

Referenced by PurificationStart().

◆ PurificationStart()

◆ purify_bounds()

template<typename MatrixType>
virtual void PurificationGeneral< MatrixType >::purify_bounds ( const int it)
protectedpure virtual

◆ purify_X()

template<typename MatrixType>
virtual void PurificationGeneral< MatrixType >::purify_X ( const int it)
protectedpure virtual

◆ readFromTmpFile()

◆ return_constant_C()

template<typename MatrixType>
virtual void PurificationGeneral< MatrixType >::return_constant_C ( const int it,
real & Cval )
protectedpure virtual

◆ save_matrix_A_now()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::save_matrix_A_now ( const MatrixType & A,
string str )
protected

References A, write_matrix_to_mtx(), and X.

Referenced by compute_eigenvector(), and save_matrix_now().

◆ save_matrix_now()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::save_matrix_now ( string str)
protected

References save_matrix_A_now(), and X.

Referenced by purification_process().

◆ save_other_iter_info()

template<typename MatrixType>
virtual void PurificationGeneral< MatrixType >::save_other_iter_info ( IterationInfo & iter_info,
int it )
protectedpure virtual

◆ save_selected_eigenvector_to_file()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::save_selected_eigenvector_to_file ( const VectorType & v,
int num,
bool is_homo,
int it = -1 )
protected

◆ set_compute_eigenvectors_in_each_iteration()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::set_compute_eigenvectors_in_each_iteration ( )
inline

◆ set_eigenvectors_params() [1/2]

template<typename MatrixType>
void PurificationGeneral< MatrixType >::set_eigenvectors_params ( string eigenvectors_method_,
string eigenvectors_iterative_method_,
real eigensolver_accuracy_,
int eigensolver_maxiter_,
int scf_step_,
bool try_eigv_on_next_iteration_if_fail_ )

Set parameters for computing eigenvectors.

References set_eigenvectors_params_basic().

Referenced by GetDensFromFock::get_dens_from_fock_sparse(), main(), test1(), test2(), test3(), and test4().

◆ set_eigenvectors_params() [2/2]

template<typename MatrixType>
void PurificationGeneral< MatrixType >::set_eigenvectors_params ( string eigenvectors_method_,
string eigenvectors_iterative_method_,
real eigensolver_accuracy_,
int eigensolver_maxiter_,
int scf_step_,
bool try_eigv_on_next_iteration_if_fail_,
bool use_prev_vector_as_initial_guess_,
const std::vector< VectorType > & eigVecOCCRef,
const std::vector< VectorType > & eigVecUNOCCRef )

◆ set_eigenvectors_params_basic()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::set_eigenvectors_params_basic ( string eigenvectors_method_,
string eigenvectors_iterative_method_,
real eigensolver_accuracy_,
int eigensolver_maxiter_,
int scf_step_,
bool try_eigv_on_next_iteration_if_fail_,
bool use_prev_vector_as_initial_guess_ )
protected

◆ set_go_back_X_iter_proj_method()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::set_go_back_X_iter_proj_method ( int val)
inline

◆ set_init_params()

template<typename MatrixType>
virtual void PurificationGeneral< MatrixType >::set_init_params ( )
protectedpure virtual

◆ set_jump_over_X_iter_proj_method()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::set_jump_over_X_iter_proj_method ( int val)
inline

◆ set_number_of_eigenvectors_to_compute()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::set_number_of_eigenvectors_to_compute ( const int occ,
const int unocc )
inline

◆ set_spectrum_bounds()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::set_spectrum_bounds ( real eigmin,
real eigmax )

Set spectrum bounds.

Used if we know spectrum bounds or want to compute them outside the class.

References computed_spectrum_bounds, and spectrum_bounds.

◆ set_truncation_parameters()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::set_truncation_parameters ( )
protectedvirtual

◆ stopping_criterion()

◆ total_subspace_error()

template<typename MatrixType>
PurificationGeneral< MatrixType >::real PurificationGeneral< MatrixType >::total_subspace_error ( int it)
virtual

References info, and VecGap.

Referenced by purification_process().

◆ truncate_matrix()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::truncate_matrix ( real & thresh,
int it )
protectedvirtual

◆ unset_compute_eigenvectors_in_each_iteration()

template<typename MatrixType>
void PurificationGeneral< MatrixType >::unset_compute_eigenvectors_in_each_iteration ( )
inline

◆ writeToTmpFile()

Member Data Documentation

◆ additional_iterations

◆ check_stopping_criterion_iter

◆ compute_eigenvectors_in_each_iteration

template<typename MatrixType>
bool PurificationGeneral< MatrixType >::compute_eigenvectors_in_each_iteration
protected

Compute homo and lumo eigenpairs in every iteration and save eigenvectors in txt files.

NOTE: if we are computing eigenvector in every iteration, we will save eigenvector computed in the last iteration, and it is most probably the wrong eigenvector.

Referenced by compute_eigenvectors_without_diagonalization(), and compute_eigenvectors_without_diagonalization_last_iter_proj().

◆ compute_eigenvectors_in_this_SCF_cycle

template<typename MatrixType>
bool PurificationGeneral< MatrixType >::compute_eigenvectors_in_this_SCF_cycle
protected

◆ computed_spectrum_bounds

template<typename MatrixType>
bool PurificationGeneral< MatrixType >::computed_spectrum_bounds
protected

◆ constant_C

template<typename MatrixType>
real PurificationGeneral< MatrixType >::constant_C
protected

Asymptotic constant C needed for the new stopping criterion.

Referenced by check_new_stopping_criterion(), and purification_process().

◆ EIG_ABS_GAP_HOMO_VEC

template<typename MatrixType>
VectorTypeReal PurificationGeneral< MatrixType >::EIG_ABS_GAP_HOMO_VEC
protected

(Eigenvectors) Absolute and relative gap in filter for lumo eigenvalue.

◆ EIG_ABS_GAP_LUMO_VEC

template<typename MatrixType>
VectorTypeReal PurificationGeneral< MatrixType >::EIG_ABS_GAP_LUMO_VEC
protected

◆ EIG_REL_GAP_HOMO_VEC

template<typename MatrixType>
VectorTypeReal PurificationGeneral< MatrixType >::EIG_REL_GAP_HOMO_VEC
protected

(Eigenvectors) Absolute and relative gap in filter for homo eigenvalue.

◆ EIG_REL_GAP_LUMO_VEC

template<typename MatrixType>
VectorTypeReal PurificationGeneral< MatrixType >::EIG_REL_GAP_LUMO_VEC
protected

◆ eigensolver_accuracy

template<typename MatrixType>
real PurificationGeneral< MatrixType >::eigensolver_accuracy
protected

Accuracy of the eigenvalue problem solver.

When residual is less then this value, stop.

Referenced by compute_eigenvector(), compute_eigenvectors_without_diagonalization_on_F(), and set_eigenvectors_params_basic().

◆ eigensolver_maxiter

template<typename MatrixType>
int PurificationGeneral< MatrixType >::eigensolver_maxiter
protected

Maximum number of iterations for eigensolver.

Referenced by compute_eigenvector(), compute_eigenvectors_without_diagonalization_on_F(), and set_eigenvectors_params_basic().

◆ eigenvectors_iterative_method

template<typename MatrixType>
int PurificationGeneral< MatrixType >::eigenvectors_iterative_method
protected

Chosen eigensolver.

Referenced by get_int_eig_iter_method(), and set_eigenvectors_params_basic().

◆ eigenvectors_iterative_method_str

template<typename MatrixType>
string PurificationGeneral< MatrixType >::eigenvectors_iterative_method_str
protected

◆ eigenvectors_method

◆ eigenvectors_method_str

template<typename MatrixType>
string PurificationGeneral< MatrixType >::eigenvectors_method_str
protected

◆ eigValHOMO

template<typename MatrixType>
real PurificationGeneral< MatrixType >::eigValHOMO
protected

◆ eigValLUMO

template<typename MatrixType>
real PurificationGeneral< MatrixType >::eigValLUMO
protected

◆ eigValOCC

template<typename MatrixType>
std::vector<real> PurificationGeneral< MatrixType >::eigValOCC
protected

Here we save eigenvalues corresponding to the occupied orbitals.

Referenced by compute_eigenvectors_without_diagonalization(), and projection_method_one_puri_iter().

◆ eigValUNOCC

template<typename MatrixType>
std::vector<real> PurificationGeneral< MatrixType >::eigValUNOCC
protected

Here we save eigenvalues corresponding to the unoccupied orbitals.

Referenced by compute_eigenvectors_without_diagonalization(), and projection_method_one_puri_iter().

◆ eigVecHOMORef

template<typename MatrixType>
VectorType PurificationGeneral< MatrixType >::eigVecHOMORef
protected

◆ eigVecLUMORef

template<typename MatrixType>
VectorType PurificationGeneral< MatrixType >::eigVecLUMORef
protected

◆ eigVecOCC

template<typename MatrixType>
std::vector<VectorType> PurificationGeneral< MatrixType >::eigVecOCC
protected

Here we save eigenvectors corresponding to the occupied orbitals.

Referenced by compute_eigenvectors_without_diagonalization(), discard_homo_eigenvector(), projection_method_one_puri_iter(), and set_eigenvectors_params_basic().

◆ eigVecUNOCC

template<typename MatrixType>
std::vector<VectorType> PurificationGeneral< MatrixType >::eigVecUNOCC
protected

Here we save eigenvectors corresponding to the unoccupied orbitals.

Referenced by compute_eigenvectors_without_diagonalization(), discard_lumo_eigenvector(), projection_method_one_puri_iter(), and set_eigenvectors_params_basic().

◆ error_eig

template<typename MatrixType>
real PurificationGeneral< MatrixType >::error_eig
protected

Error in eigenvalues (used just in old stopping criterion).

Referenced by check_standard_stopping_criterion(), and initialize().

◆ error_per_it

template<typename MatrixType>
real PurificationGeneral< MatrixType >::error_per_it
protected

Error allowed in each iteration due to truncation.

Referenced by set_truncation_parameters(), and truncate_matrix().

◆ error_sub

template<typename MatrixType>
real PurificationGeneral< MatrixType >::error_sub
protected

Allowed error in invariant subspaces.

Referenced by compute_eigenvector(), initialize(), and set_truncation_parameters().

◆ F

◆ gammaStopEstim

template<typename MatrixType>
real PurificationGeneral< MatrixType >::gammaStopEstim
protected

Used on the stopping criterion for estimation of eigenvalues from purification.

Referenced by estimate_homo_lumo(), Purification_sp2< MatrixType >::set_init_params(), and Purification_sp2acc< MatrixType >::set_init_params().

◆ go_back_X_iter_proj_method

template<typename MatrixType>
int PurificationGeneral< MatrixType >::go_back_X_iter_proj_method
protected

◆ good_iterations_homo

template<typename MatrixType>
VectorTypeInt PurificationGeneral< MatrixType >::good_iterations_homo
protected

Iterations where homo eigenvector can be computed.

Referenced by compute_eigenvectors_without_diagonalization(), and get_iterations_for_lumo_and_homo().

◆ good_iterations_lumo

template<typename MatrixType>
VectorTypeInt PurificationGeneral< MatrixType >::good_iterations_lumo
protected

Iterations where homo eigenvector can be computed.

Referenced by compute_eigenvectors_without_diagonalization(), and get_iterations_for_lumo_and_homo().

◆ homo_bounds

◆ homo_bounds_F

◆ homo_bounds_F_new

template<typename MatrixType>
IntervalType PurificationGeneral< MatrixType >::homo_bounds_F_new
protected

◆ homo_bounds_X0

template<typename MatrixType>
IntervalType PurificationGeneral< MatrixType >::homo_bounds_X0
protected

Initial lumo bounds for X.

Referenced by map_bounds_to_0_1().

◆ info

◆ initialized_flag

template<typename MatrixType>
bool PurificationGeneral< MatrixType >::initialized_flag
protected

Referenced by initialize().

◆ ITER_ERROR_VEC

template<typename MatrixType>
VectorTypeReal PurificationGeneral< MatrixType >::ITER_ERROR_VEC
protected

(Eigenvectors) Maximum error introduced in each iteration.

◆ iter_for_homo

◆ iter_for_lumo

◆ jump_over_X_iter_proj_method

template<typename MatrixType>
int PurificationGeneral< MatrixType >::jump_over_X_iter_proj_method
protected

◆ lumo_bounds

◆ lumo_bounds_F

◆ lumo_bounds_F_new

template<typename MatrixType>
IntervalType PurificationGeneral< MatrixType >::lumo_bounds_F_new
protected

◆ lumo_bounds_X0

template<typename MatrixType>
IntervalType PurificationGeneral< MatrixType >::lumo_bounds_X0
protected

Initial lumo bounds for X.

Referenced by map_bounds_to_0_1().

◆ maxit

◆ nocc

template<typename MatrixType>
int PurificationGeneral< MatrixType >::nocc
protected

◆ normPuriStopCrit

◆ normPuriTrunc

template<typename MatrixType>
NormType PurificationGeneral< MatrixType >::normPuriTrunc
protected

Norm used for the truncation of matrices.

Can be mat::frobNorm, mat::mixedNorm, or mat::euclNorm.

Referenced by initialize(), and truncate_matrix().

◆ number_of_occ_eigenvectors

template<typename MatrixType>
int PurificationGeneral< MatrixType >::number_of_occ_eigenvectors
protected

◆ number_of_unocc_eigenvectors

template<typename MatrixType>
int PurificationGeneral< MatrixType >::number_of_unocc_eigenvectors
protected

◆ puri_is_prepared_flag

template<typename MatrixType>
bool PurificationGeneral< MatrixType >::puri_is_prepared_flag
protected

Referenced by prepare_to_purification().

◆ really_good_iterations_homo

template<typename MatrixType>
VectorTypeInt PurificationGeneral< MatrixType >::really_good_iterations_homo
protected

Iterations where homo eigenvector is actually computed.

Referenced by compute_eigenvector().

◆ really_good_iterations_lumo

template<typename MatrixType>
VectorTypeInt PurificationGeneral< MatrixType >::really_good_iterations_lumo
protected

Iterations where lumo eigenvector is actually computed.

Referenced by compute_eigenvector().

◆ scf_step

template<typename MatrixType>
int PurificationGeneral< MatrixType >::scf_step
protected

◆ SIGMA_HOMO_VEC

◆ SIGMA_LUMO_VEC

template<typename MatrixType>
VectorTypeReal PurificationGeneral< MatrixType >::SIGMA_LUMO_VEC
protected

(Eigenvectors) Approximation of shifts in each iteration.

Referenced by compute_eigenvectors_without_diagonalization(), find_shifts_every_iter(), and get_iterations_for_lumo_and_homo().

◆ spectrum_bounds

template<typename MatrixType>
IntervalType PurificationGeneral< MatrixType >::spectrum_bounds
protected

◆ try_eigv_on_next_iteration_if_fail

template<typename MatrixType>
bool PurificationGeneral< MatrixType >::try_eigv_on_next_iteration_if_fail
protected

◆ use_new_stopping_criterion

template<typename MatrixType>
bool PurificationGeneral< MatrixType >::use_new_stopping_criterion
protected

True for new stopping criterion.

Referenced by initialize(), purification_process(), and stopping_criterion().

◆ use_prev_vector_as_initial_guess

template<typename MatrixType>
bool PurificationGeneral< MatrixType >::use_prev_vector_as_initial_guess
protected

◆ vec_matrices_Xi

template<typename MatrixType>
std::vector<MatrixType> PurificationGeneral< MatrixType >::vec_matrices_Xi
protected

Save matrices Xi in each iteration (if used projection method for computing eigenvectors).

If ergo input file mat.write_to_file=1 than matrices are saved to the file to save memory.

Referenced by compute_eigenvectors_without_diagonalization(), and projection_method_one_puri_iter().

◆ VecGap

◆ VecPoly

◆ X

◆ Xsq


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