ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
lr_util.h File Reference
#include <cstddef>
#include <complex>
#include <vector>
#include <utility>
#include "source_base/matrix.h"
#include "source_base/complexmatrix.h"
#include "source_base/parallel_blkcyc.h"
#include "source_psi/psi.h"
#include <ATen/core/tensor.h>
#include <ATen/ops/linalg_op.h>
#include <set>
#include "lr_util.hpp"
Include dependency graph for lr_util.h:

Go to the source code of this file.

Classes

struct  ToComplex< double >
struct  ToComplex< std::complex< double > >
struct  ToComplex< float >
struct  ToComplex< std::complex< float > >
struct  LR_Util::MPIType< T >
 Struct to get MPI_traits for different data types. More...
struct  LR_Util::MPIType< int >
struct  LR_Util::MPIType< double >
struct  LR_Util::MPIType< std::complex< double > >

Namespaces

namespace  LR_Util

Macros

#define TO_COMPLEX_H

Functions

double LR_Util::hse_sigma_floor ()
 Existing HSE sigma floor (bohr^-8), shared by LR and the GS fallback.
int LR_Util::spin_population_difference (const ModuleBase::matrix &wg, int kpar, int rank_in_pool)
 Sum k-point spin populations before rounding; count each pool only once.
void LR_Util::check_force_pp (const UnitCell &cell, bool cal_force, const std::string &calculation)
 Reject unsupported NLCC force requests after pseudopotentials have been loaded.
const std::vector< double > & LR_Util::prepare_xc_sigma (const std::vector< double > &sigma, bool is_hse06, std::vector< double > &hse_buffer)
 Preserve signed sigma invariants except for the existing HSE06 stabilization.
const std::vector< double > & LR_Util::prepare_xc_sigma (const std::vector< double > &sigma, bool is_hse06, std::vector< double > &hse_buffer, std::vector< double > &jacobian)
 Prepare stabilized sigma and its componentwise derivative.
const std::set< std::string > & LR_Util::hybrid_xc_list ()
 the xc kernels that carry an exact-exchange (EXX) term
bool LR_Util::has_local_xc (const std::string &name)
 check if the xc functional has local xc kernel
template<typename TCell>
int LR_Util::cal_nelec (const TCell &ucell)
 calculate the number of electrons
int LR_Util::cal_nocc (int nelec)
 =================PHYSICS====================
int LR_Util::cal_nocc (double nelec, int nspin, int nupdown)
 Largest occupied spin channel; nelec already includes the charge correction.
int LR_Util::cal_nocc_window (int requested_nocc, int nocc_max)
 Retain a positive user window, otherwise use all occupied orbitals.
std::string LR_Util::force_window_warning (int basis_size, int gs_bands, int skipped_occupied, const std::vector< int > &x_virtual, const std::vector< int > &z_virtual)
 Diagnose resolved force windows without modifying X, Z or their energies.
std::pair< ModuleBase::matrix, std::vector< std::pair< int, int > > > LR_Util::set_ix_map_diagonal (bool mode, int nc, int nv)
 set the index map: ix to (ic, iv) and vice versa by diagonal traverse the c-v pairs leftdown -> rightup for mode 0, rightup -> leftdown for mode 1
double LR_Util::inner_product (const double *vec1, const double *vec2, const int &size)
 =================ALGORITHM====================
std::complex< double > LR_Util::inner_product (const std::complex< double > *vec1, const std::complex< double > *vec2, const int &size)
template<typename T>
void LR_Util::_deallocate_2order_nested_ptr (T **p2, size_t size)
 delete 2d pointer
template<typename T>
void LR_Util::_allocate_2order_nested_ptr (T **&p2, size_t size1, size_t size2)
 new 2d pointer
template<typename T>
ct::Tensor LR_Util::newTensor (const ct::TensorShape &shape)
template<typename T>
void LR_Util::matsym (const T *in, const int n, T *out)
template<typename T>
void LR_Util::matsym (T *inout, const int n)
 calculate (A+A^T)/2 (in-place version)
template<typename T>
void LR_Util::matsym (const T *in, const int n, const Parallel_Blkcyclic &pmat, T *out)
template<typename T>
void LR_Util::matsym (T *inout, const int n, const Parallel_Blkcyclic &pmat)
template<typename T>
void LR_Util::mattrans (const T *in, const int n, const Parallel_Blkcyclic &pmat, T *out)
template<typename T>
void LR_Util::mattrans (T *inout, const int n, const Parallel_Blkcyclic &pmat)
template<typename T>
void LR_Util::matantisym (T *inout, const int n, const Parallel_Blkcyclic &pmat)
template<typename T>
bool LR_Util::is_hermitian (const T *mat, const Parallel_Blkcyclic &pmat, const double threshold, const int my_rank)
template<typename T>
bool LR_Util::is_symmetric (const T *mat, const Parallel_Blkcyclic &pmat, const double threshold, const int my_rank)
template<typename T, typename Device>
psi::Psi< T, Device > LR_Util::k1_to_bfirst_wrapper (const psi::Psi< T, Device > &psi_kfirst, int nk_in, int nbasis_in)
 psi(nk=1, nbands=nb, nk * nbasis) -> psi(nb, nk, nbasis) without memory copy
template<typename T, typename Device>
psi::Psi< T, Device > LR_Util::bfirst_to_k1_wrapper (const psi::Psi< T, Device > &psi_bfirst)
 psi(nb, nk, nbasis) -> psi(nk=1, nbands=nb, nk * nbasis) without memory copy
void LR_Util::setup_2d_division (Parallel_Blkcyclic &pv, int nb, int gr, int gc)
 =================2D-block Parallel===============
template<typename T>
void LR_Util::global2local_X (T *local_X, const T *global_X, const int nband, const int nk, const std::vector< int > &nocc, const std::vector< int > &nvirt, const std::vector< Parallel_Blkcyclic > &pX, const bool openshell)
 assign global X to 2d-matrix, its col is band(excition state), and row is { spin, k-point, occ, virt }
void LR_Util::setup_2d_division (Parallel_Blkcyclic &pv, int nb, int gr, int gc, const int &blacs_ctxt_in)
template<typename T>
void LR_Util::pA2pX (T *X_pX, const T *X_pA, const int nband, const int nk, const std::vector< int > &nocc, const std::vector< int > &nvirt, const std::vector< Parallel_Blkcyclic > &pX, const Parallel_Blkcyclic &pA, const int row_offset, const int col_offset, const bool openshell, const int my_rank, const int nproc)
 assign X in pA to X in pX
template<typename T>
void LR_Util::gather_2d_to_full (const Parallel_Blkcyclic &pv, const T *submat, T *fullmat, const bool row_major, const std::size_t global_nrow, const std::size_t global_ncol)
 gather 2d matrix to full matrix the defination of row and col is consistent with setup_2d_division
template<typename T>
void LR_Util::scatter_full_to_2d (const Parallel_Blkcyclic &pv, const T *fullmat, T *submat, const bool col_first=false)
 scatter full matrix to 2d block-cyclic distributed matrix
template<typename T>
void LR_Util::diag_lapack (const int &n, T *mat, double *eig)
 diagonalize a hermitian matrix
template<typename T>
void LR_Util::diag_lapack_nh (const int &n, T *mat, std::complex< double > *eig)
 diagonalize a general matrix
template<typename T>
int LR_Util::lapack_linear_solver (const T *A, T *x, const T *b, const int n, const int nrhs)
 solve linear equations Ax=b using LAPACK
std::string LR_Util::tolower (const std::string &str)
 =================string option====================
std::string LR_Util::toupper (const std::string &str)
template<typename T>
std::vector< T > operator+ (const std::vector< T > &a, const std::vector< T > &b)
 =================operators======================= (should ot in namespace LR_Util)

Macro Definition Documentation

◆ TO_COMPLEX_H

#define TO_COMPLEX_H

Function Documentation

◆ operator+()

template<typename T>
std::vector< T > operator+ ( const std::vector< T > & a,
const std::vector< T > & b )

=================operators======================= (should ot in namespace LR_Util)