Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions source/source_base/complexarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void ComplexArray::operator=(const std::complex < double> c){
const int size = this->getSize();
for (int i = 0; i < size; i++)
ptr[i] = c;}
ComplexArray ComplexArray::operator+(const ComplexArray &cd){
ComplexArray ComplexArray::operator+(const ComplexArray &cd) const{
const int size = this->getSize();
assert(size==cd.getSize());
ComplexArray cd2(*this);
Expand All @@ -98,7 +98,7 @@ void ComplexArray::operator+=(const ComplexArray & cd){
for (int i = 0; i < size; i++)
ptr[i] += cd.ptr[i];
}
ComplexArray ComplexArray::operator-(const ComplexArray &cd){
ComplexArray ComplexArray::operator-(const ComplexArray &cd) const{
const int size = this->getSize();
assert(size==cd.getSize());
ComplexArray cd2(*this);
Expand All @@ -123,7 +123,7 @@ ComplexArray operator*(const double r, const ComplexArray &cd){
for (int i = 0; i < size; i++)
cd2.ptr[i] *= r;
return cd2;}
ComplexArray ComplexArray::operator*(const double r){
ComplexArray ComplexArray::operator*(const double r) const{
ComplexArray cd2(*this);
const int size = this->getSize();
for (int i = 0; i < size; i++)
Expand All @@ -135,7 +135,7 @@ ComplexArray operator*(const std::complex < double> c, const ComplexArray &cd){
for (int i = 0; i < size; i++)
cd2.ptr[i] = c * cd.ptr[i];
return cd2;}
ComplexArray ComplexArray::operator*(const std::complex < double> c){
ComplexArray ComplexArray::operator*(const std::complex < double> c) const{
const int size = this->getSize();
ComplexArray cd(size);
for (int i = 0; i < size; i++)
Expand Down
8 changes: 4 additions & 4 deletions source/source_base/complexarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ class ComplexArray
/// Assignment of scalar: all entries set to c.
void operator=(std::complex <double> c);
/// Add two ComplexArray
ComplexArray operator+(const ComplexArray &cd);
ComplexArray operator+(const ComplexArray &cd) const;
/// Accumulate sum of ComplexArray
void operator+=(const ComplexArray &cd);
/// Subtract two ComplexArray
ComplexArray operator-(const ComplexArray &cd);
ComplexArray operator-(const ComplexArray &cd) const;
/// Accumulate difference of arrays
void operator-=(const ComplexArray &cd);
/// Scale a ComplexArray by real r
ComplexArray operator*(const double r);
ComplexArray operator*(const double r) const;
/// Scale a ComplexArray by a std::complex number c
ComplexArray operator*(const std::complex <double> c);
ComplexArray operator*(const std::complex <double> c) const;
/// Scale a ComplexArray by real number in place
void operator*=(const double r);
/// Scale a ComplexArray by std::complex c in place
Expand Down
2 changes: 1 addition & 1 deletion source/source_base/complexmatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ std::ostream & ComplexMatrix::print( std::ostream & os, const double threshold_a
return os;
}

bool ComplexMatrix::checkreal(void)
bool ComplexMatrix::checkreal(void) const
{
const double tiny = 1e-12;
for(int i=0;i<this->nr;i++)
Expand Down
2 changes: 1 addition & 1 deletion source/source_base/complexmatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ComplexMatrix
std::ostream & print( std::ostream & os, const double threshold_abs=0.0, const double threshold_imag=0.0 ) const; // Peize Lin add 2021.09.08

// check if all the elements are real
bool checkreal(void);
bool checkreal(void) const;

using type=std::complex<double>; // Peiae Lin add 2022.08.08 for template
};
Expand Down
2 changes: 1 addition & 1 deletion source/source_base/formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class FmtCore
*
* @return std::string
*/
const std::string& fmt() { return fmt_; }
const std::string& fmt() const { return fmt_; }
/**
* Python-style string functions will be implemented here as toolbox
*/
Expand Down
4 changes: 2 additions & 2 deletions source/source_base/opt_CG.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ class Opt_CG
int& ifPD // if postive definit
);

double get_residual()
double get_residual() const
{
return sqrt(this->gg_);
};
int get_iter()
int get_iter() const
{
return this->iter_;
}
Expand Down
2 changes: 1 addition & 1 deletion source/source_basis/module_nao/radial_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void RadialSet::indexing()
}
}

const NumericalRadial& RadialSet::chi(const int l, const int izeta)
const NumericalRadial& RadialSet::chi(const int l, const int izeta) const
{
int i = index_map_[l * nzeta_max_ + izeta];
#ifdef __DEBUG
Expand Down
2 changes: 1 addition & 1 deletion source/source_basis/module_nao/radial_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class RadialSet
int nzeta_max() const { return nzeta_max_; }
int nchi() const { return nchi_; }

const NumericalRadial& chi(const int l, const int izeta);
const NumericalRadial& chi(const int l, const int izeta) const;
const NumericalRadial* cbegin() const { return chi_; }
const NumericalRadial* cend() const { return chi_ + nchi_; }
///@}
Expand Down
8 changes: 4 additions & 4 deletions source/source_cell/pseudo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void pseudo::check_betar()
}
}

void pseudo::print_pseudo(std::ofstream& ofs)
void pseudo::print_pseudo(std::ofstream& ofs) const
{
print_pseudo_vl(ofs);
ofs << "\n pseudo : ";
Expand All @@ -50,7 +50,7 @@ void pseudo::print_pseudo(std::ofstream& ofs)
ofs << "\n ----------------------";
}

void pseudo::print_pseudo_atom(std::ofstream &ofs)
void pseudo::print_pseudo_atom(std::ofstream& ofs) const
{
print_pseudo_h(ofs);
ofs << "\n pseudo_atom : ";
Expand All @@ -66,15 +66,15 @@ void pseudo::print_pseudo_atom(std::ofstream &ofs)
}


void pseudo::print_pseudo_vl(std::ofstream &ofs)
void pseudo::print_pseudo_vl(std::ofstream& ofs) const
{
ofs << "\n pseudo_vl:";
print_pseudo_atom(ofs);
output::printr1_d(ofs, "vloc_at : ", vloc_at.data(), mesh);
ofs << "\n ----------------------------------- ";
}

void pseudo::print_pseudo_h(std::ofstream &ofs)
void pseudo::print_pseudo_h(std::ofstream& ofs) const
{
ofs << "\n pseudo_info :";
ofs << "\n nv " << nv;
Expand Down
8 changes: 4 additions & 4 deletions source/source_cell/pseudo.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ class pseudo
*/
void check_betar();

void print_pseudo_h(std::ofstream& ofs);
void print_pseudo_atom(std::ofstream& ofs);
void print_pseudo_vl(std::ofstream& ofs);
void print_pseudo(std::ofstream& ofs);
void print_pseudo_h(std::ofstream& ofs) const;
void print_pseudo_atom(std::ofstream& ofs) const;
void print_pseudo_vl(std::ofstream& ofs) const;
void print_pseudo(std::ofstream& ofs) const;
};

#endif // PSEUDO_H
4 changes: 2 additions & 2 deletions source/source_cell/sep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int SepPot::read_sep(std::ifstream& ifs)
return 0;
}

void SepPot::print_sep_info(std::ofstream& ofs)
void SepPot::print_sep_info(std::ofstream& ofs) const
{
ofs << "\n sep_vl:";
ofs << "\n sep_info:";
Expand All @@ -84,7 +84,7 @@ void SepPot::print_sep_info(std::ofstream& ofs)
ofs << "\n strip electron" << strip_elec;
}

void SepPot::print_sep_vsep(std::ofstream& ofs)
void SepPot::print_sep_vsep(std::ofstream& ofs) const
{
ofs << "\n mesh " << mesh;
output::printr1_d(ofs, " r : ", r, mesh);
Expand Down
4 changes: 2 additions & 2 deletions source/source_cell/sep.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class SepPot
double* rv = nullptr; /**< sep potential, but rV, unit: Ry */

int read_sep(std::ifstream& is);
void print_sep_info(std::ofstream& ofs);
void print_sep_vsep(std::ofstream& ofs);
void print_sep_info(std::ofstream& ofs) const;
void print_sep_vsep(std::ofstream& ofs) const;
#ifdef __MPI
void bcast_sep();
#endif /* ifdef __MPI */
Expand Down
2 changes: 1 addition & 1 deletion source/source_cell/test/support/mock_unitcell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ void UnitCell::setup(const std::string& latname_in,

void cal_nelec(const Atom* atoms, const int& ntype, double& nelec) {}

void UnitCell::compare_atom_labels(const std::string &label1, const std::string &label2) {}
void UnitCell::compare_atom_labels(const std::string &label1, const std::string &label2) const {}
2 changes: 1 addition & 1 deletion source/source_cell/unitcell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ void UnitCell::setup(const std::string& latname_in,
}


void UnitCell::compare_atom_labels(const std::string &label1, const std::string &label2)
void UnitCell::compare_atom_labels(const std::string& label1, const std::string& label2) const
{
if (label1!= label2) //'!( "Ag" == "Ag" || "47" == "47" || "Silver" == Silver" )'
{
Expand Down
2 changes: 1 addition & 1 deletion source/source_cell/unitcell.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class UnitCell {

/// @brief check consistency between two atom labels from STRU and pseudo or
/// orb file
void compare_atom_labels(const std::string &label1, const std::string &label2);
void compare_atom_labels(const std::string& label1, const std::string& label2) const;
/// @brief get atomCounts, which is a map from element type to atom number
std::map<int, int> get_atom_Counts() const;
/// @brief get orbitalCounts, which is a map from element type to orbital
Expand Down
4 changes: 2 additions & 2 deletions source/source_esolver/esolver_lj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void ESolver_LJ::runner(UnitCell& ucell, const int istep)
GlobalV::ofs_running << " --------------------------------------------\n\n" << std::endl;
}

double ESolver_LJ::LJ_energy(const double& d, const int& i, const int& j)
double ESolver_LJ::LJ_energy(const double& d, const int& i, const int& j) const
{
assert(d > 1e-6); // avoid atom overlap
const double r2 = d * d;
Expand All @@ -135,7 +135,7 @@ void ESolver_LJ::runner(UnitCell& ucell, const int istep)
return lj_c12(i, j) / (r6 * r6) - lj_c6(i, j) / r6;
}

ModuleBase::Vector3<double> ESolver_LJ::LJ_force(const ModuleBase::Vector3<double>& dr, const int& i, const int& j)
ModuleBase::Vector3<double> ESolver_LJ::LJ_force(const ModuleBase::Vector3<double>& dr, const int& i, const int& j) const
{
const double d = dr.norm();
assert(d > 1e-6); // avoid atom overlap
Expand Down
4 changes: 2 additions & 2 deletions source/source_esolver/esolver_lj.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ namespace ModuleESolver
void after_all_runners(UnitCell& ucell) override;

private:
double LJ_energy(const double& d, const int& i, const int& j);
double LJ_energy(const double& d, const int& i, const int& j) const;

ModuleBase::Vector3<double> LJ_force(const ModuleBase::Vector3<double>& dr, const int& i, const int& j);
ModuleBase::Vector3<double> LJ_force(const ModuleBase::Vector3<double>& dr, const int& i, const int& j) const;

void LJ_virial(const ModuleBase::Vector3<double>& force, const ModuleBase::Vector3<double>& dtau);

Expand Down
2 changes: 1 addition & 1 deletion source/source_esolver/esolver_of.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ESolver_OF : public ESolver_FP
void test_direction(double* dEdtheta, double** ptemp_phi, UnitCell& ucell);

// --------------------- interface to blas --------------------------
double inner_product(double* pa, double* pb, int length, double dV = 1)
double inner_product(double* pa, double* pb, int length, double dV = 1) const
{
double innerproduct = BlasConnector::dot(length, pa, 1, pb, 1);
innerproduct *= dV;
Expand Down
2 changes: 1 addition & 1 deletion source/source_hsolver/diago_cusolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DiagoCusolver
private:
#ifdef __MPI
// Function to check if ELPA handle needs to be created or reused in MPI settings
bool ifElpaHandle(const bool& newIteration, const bool& ifNSCF);
bool ifElpaHandle(const bool& newIteration, const bool& ifNSCF) const;
#endif
};

Expand Down
2 changes: 1 addition & 1 deletion source/source_hsolver/diago_elpa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void DiagoElpa<double>::diag_pool(hamilt::MatrixBlock<double>& h_mat,

#ifdef __MPI
template <typename T>
bool DiagoElpa<T>::ifElpaHandle(const bool& newIteration, const bool& ifNSCF) {
bool DiagoElpa<T>::ifElpaHandle(const bool& newIteration, const bool& ifNSCF) const {
int doHandle = false;
if (newIteration) {
doHandle = true;
Expand Down
2 changes: 1 addition & 1 deletion source/source_hsolver/diago_elpa.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DiagoElpa

private:
#ifdef __MPI
bool ifElpaHandle(const bool& newIteration, const bool& ifNSCF);
bool ifElpaHandle(const bool& newIteration, const bool& ifNSCF) const;
static int lastmpinum; // last using mpi;
#endif
};
Expand Down
10 changes: 5 additions & 5 deletions source/source_hsolver/parallel_k2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ class Parallel_K2D {
/// set the number of k-points
void set_kpar(int kpar);
/// get the number of k-points
int get_kpar() { return this->kpar_; }
int get_kpar() const { return this->kpar_; }
/// get my pool
int get_my_pool() { return this->MY_POOL; }
int get_my_pool() const { return this->MY_POOL; }
/// get pKpoints
Parallel_Kpoints* get_pKpoints() { return this->Pkpoints; }
Parallel_Kpoints* get_pKpoints() const { return this->Pkpoints; }
/// get p2D_global
Parallel_2D* get_p2D_global() { return this->P2D_global; }
Parallel_2D* get_p2D_global() const { return this->P2D_global; }
/// get p2D_pool
Parallel_2D* get_p2D_pool() { return this->P2D_pool; }
Parallel_2D* get_p2D_pool() const { return this->P2D_pool; }

/**
* the local Hk, Sk matrices in POOL_WORLD_K2D
Expand Down
2 changes: 1 addition & 1 deletion source/source_io/module_output/csr_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ SparseMatrix<T> csrFileReader<T>::getMatrix(int index) const

// function to get matrix using R coordinate
template <typename T>
SparseMatrix<T> csrFileReader<T>::getMatrix(int Rx, int Ry, int Rz)
SparseMatrix<T> csrFileReader<T>::getMatrix(int Rx, int Ry, int Rz) const
{
for (int i = 0; i < RCoordinates.size(); i++)
{
Expand Down
2 changes: 1 addition & 1 deletion source/source_io/module_output/csr_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class csrFileReader : public FileReader
int getNumberOfR() const;

// get sparse matrix of a specific R coordinate
SparseMatrix<T> getMatrix(int Rx, int Ry, int Rz);
SparseMatrix<T> getMatrix(int Rx, int Ry, int Rz) const;

// get matrix by using index
SparseMatrix<T> getMatrix(int index) const;
Expand Down
2 changes: 1 addition & 1 deletion source/source_io/module_unk/berryphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ void berryphase::Macroscopic_polarization(const UnitCell& ucell,

std::string berryphase::outFormat(const double polarization,
const double modulus,
const ModuleBase::Vector3<double> project)
const ModuleBase::Vector3<double> project) const
{
std::stringstream outStr;
outStr << std::setw(12) << std::fixed << std::setprecision(7) << polarization << " (mod ";
Expand Down
2 changes: 1 addition & 1 deletion source/source_io/module_unk/berryphase.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class berryphase
const ModulePW::PW_Basis_K* wfcpw,
const K_Vectors& kv);

std::string outFormat(const double polarization, const double modulus, const ModuleBase::Vector3<double> project);
std::string outFormat(const double polarization, const double modulus, const ModuleBase::Vector3<double> project) const;
};

#endif
4 changes: 2 additions & 2 deletions source/source_io/module_wf/get_wf_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,14 +589,14 @@ void Get_wf_lcao::prepare_get_wf(std::ofstream& ofs_running)
ofs_running << std::setprecision(6);
}

int Get_wf_lcao::globalIndex(int localindex, int nblk, int nprocs, int myproc)
int Get_wf_lcao::globalIndex(int localindex, int nblk, int nprocs, int myproc) const
{
const int iblock = localindex / nblk;
const int gIndex = (iblock * nprocs + myproc) * nblk + localindex % nblk;
return gIndex;
}

int Get_wf_lcao::localIndex(int globalindex, int nblk, int nprocs, int& myproc)
int Get_wf_lcao::localIndex(int globalindex, int nblk, int nprocs, int& myproc) const
{
myproc = int((globalindex % (nblk * nprocs)) / nblk);
return int(globalindex / (nblk * nprocs)) * nblk + globalindex % nblk;
Expand Down
4 changes: 2 additions & 2 deletions source/source_io/module_wf/get_wf_lcao.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class Get_wf_lcao
const double* const* const rho,
psi::Psi<std::complex<double>>& wfc_g);

int globalIndex(int localindex, int nblk, int nprocs, int myproc);
int globalIndex(int localindex, int nblk, int nprocs, int myproc) const;

int localIndex(int globalindex, int nblk, int nprocs, int& myproc);
int localIndex(int globalindex, int nblk, int nprocs, int& myproc) const;

#ifdef __MPI
template <typename T>
Expand Down
Loading
Loading