diff --git a/source/module_base/intarray.h b/source/module_base/intarray.h index 484d017f97..7cffbaf4fd 100644 --- a/source/module_base/intarray.h +++ b/source/module_base/intarray.h @@ -141,9 +141,14 @@ class IntArray } private: - int size; - int dim; - int bound1, bound2, bound3, bound4, bound5, bound6; + int size=0; + int dim=0; + int bound1=0; + int bound2=0; + int bound3=0; + int bound4=0; + int bound5=0; + int bound6=0; static int arrayCount; void freemem(); }; diff --git a/source/module_base/inverse_matrix.h b/source/module_base/inverse_matrix.h index ef5f5acec2..d49e109e15 100644 --- a/source/module_base/inverse_matrix.h +++ b/source/module_base/inverse_matrix.h @@ -20,13 +20,13 @@ class Inverse_Matrix_Complex void init( const int &dim_in); private: - int dim; - double *e; - int lwork; - std::complex *work2; - double* rwork; - int info; - bool allocate; //mohan add 2012-04-02 + int dim=0; + double *e=nullptr; + int lwork=0; + std::complex *work2=nullptr; + double* rwork=nullptr; + int info=0; + bool allocate=false; //mohan add 2012-04-02 ModuleBase::ComplexMatrix EA; }; diff --git a/source/module_base/memory.cpp b/source/module_base/memory.cpp index fdb6195be6..8d67f9ea4c 100644 --- a/source/module_base/memory.cpp +++ b/source/module_base/memory.cpp @@ -436,6 +436,7 @@ void Memory::print_all(std::ofstream &ofs) #if defined(__CUDA) || defined(__ROCM) if(!init_flag_gpu) { + delete[] print_flag; return; } diff --git a/source/module_basis/module_ao/ORB_nonlocal.cpp b/source/module_basis/module_ao/ORB_nonlocal.cpp index ce710d844b..86ec82be22 100644 --- a/source/module_basis/module_ao/ORB_nonlocal.cpp +++ b/source/module_basis/module_ao/ORB_nonlocal.cpp @@ -7,6 +7,7 @@ Numerical_Nonlocal::Numerical_Nonlocal() //question remains this->type = 0; this->lmax = 0; + this->rcut_max = 0.0; this->Proj = new Numerical_Nonlocal_Lm[1]; this->nproj = -1; //zhengdy-soc, for optimize nonlocal part @@ -49,6 +50,7 @@ void Numerical_Nonlocal::set_type_info //---------------------------------------------------------- //only store radial function delete[] Proj; + this->Proj = nullptr; this->Proj = new Numerical_Nonlocal_Lm[this->nproj]; for (int p1=0; p1freemem(); } -void Numerical_Nonlocal_Lm::renew(void) +void Numerical_Nonlocal_Lm::renew() { assert(nr_uniform>0); assert(nr>0); @@ -55,7 +56,7 @@ void Numerical_Nonlocal_Lm::renew(void) ModuleBase::GlobalFunc::ZEROS(beta_k, nk); } -void Numerical_Nonlocal_Lm::freemem(void) +void Numerical_Nonlocal_Lm::freemem() { delete[] this->r_radial; delete[] this->rab; @@ -246,7 +247,7 @@ void Numerical_Nonlocal_Lm::extra_uniform(const double &dr_uniform_in) } */ -void Numerical_Nonlocal_Lm::get_kradial(void) +void Numerical_Nonlocal_Lm::get_kradial() { //ModuleBase::TITLE("Numerical_Nonlocal_Lm","get_kradial"); double *jl = new double[nr]; diff --git a/source/module_basis/module_ao/parallel_orbitals.cpp b/source/module_basis/module_ao/parallel_orbitals.cpp index 880c43656a..c25a12df77 100644 --- a/source/module_basis/module_ao/parallel_orbitals.cpp +++ b/source/module_basis/module_ao/parallel_orbitals.cpp @@ -6,12 +6,20 @@ Parallel_Orbitals::Parallel_Orbitals() { - loc_sizes = nullptr; - + this->loc_sizes = nullptr; // in multi-k, 2D-block-division variables for FT (R<->k) - nnr = 1; - nlocdim = nullptr; - nlocstart = nullptr; + this->nlocdim = nullptr; + this->nlocstart = nullptr; + this->nnr = 1; + this->ncol_bands = 0; + this->nrow_bands=0; + this->nloc_wfc=0; + this->nloc_Eij=0; + this->lastband_in_proc=0; + this->lastband_number=0; + this->loc_size=0; + this->nbands = 0; + } Parallel_Orbitals::~Parallel_Orbitals() diff --git a/source/module_basis/module_ao/parallel_orbitals.h b/source/module_basis/module_ao/parallel_orbitals.h index 03ae9b133e..fb052de4e0 100644 --- a/source/module_basis/module_ao/parallel_orbitals.h +++ b/source/module_basis/module_ao/parallel_orbitals.h @@ -29,7 +29,7 @@ class Parallel_Orbitals : public Parallel_2D /// number of elements(basis-pairs) in this processon /// on all adjacent atoms-pairs(2D division) ///--------------------------------------- - int nnr; + int nnr=1; int *nlocdim; int *nlocstart; @@ -80,7 +80,7 @@ class Parallel_Orbitals : public Parallel_2D int get_nbands() const; - int nbands = 0; + int nbands; /** * @brief gather global indexes of orbitals in this processor diff --git a/source/module_basis/module_pw/pw_basis_big.h b/source/module_basis/module_pw/pw_basis_big.h index ad254fb436..d3ac1a5165 100644 --- a/source/module_basis/module_pw/pw_basis_big.h +++ b/source/module_basis/module_pw/pw_basis_big.h @@ -34,10 +34,12 @@ class PW_Basis_Big : public PW_Basis_Sup bxyz = bx * by * bz; } int bx = 1, by = 1, bz = 1, bxyz = 1; - int nbx, nby, nbz; - int nbzp; - int nbxx; - int nbzp_start; + int nbx=0; + int nby=0; + int nbz=0; + int nbzp=0; + int nbxx=0; + int nbzp_start=0; void autoset_big_cell_size(int& b_size, const int& nc_size, const int nproc = 0) { diff --git a/source/module_basis/module_pw/pw_basis_k.h b/source/module_basis/module_pw/pw_basis_k.h index 83aa377e79..768c4df1fe 100644 --- a/source/module_basis/module_pw/pw_basis_k.h +++ b/source/module_basis/module_pw/pw_basis_k.h @@ -94,9 +94,9 @@ class PW_Basis_K : public PW_Basis double *gk2=nullptr; // modulus (G+K)^2 of G vectors [npwk_max*nks] // liuyu add 2023-09-06 - double erf_ecut; // the value of the constant energy cutoff - double erf_height; // the height of the energy step for reciprocal vectors - double erf_sigma; // the width of the energy step for reciprocal vectors + double erf_ecut=0.0; // the value of the constant energy cutoff + double erf_height=0.0; // the height of the energy step for reciprocal vectors + double erf_sigma=0.0; // the width of the energy step for reciprocal vectors //collect gdirect, gcar, gg void collect_local_pw(const double& erf_ecut_in = 0.0, diff --git a/source/module_basis/module_pw/pw_basis_k_big.h b/source/module_basis/module_pw/pw_basis_k_big.h index 52e2bfb220..d0bb475627 100644 --- a/source/module_basis/module_pw/pw_basis_k_big.h +++ b/source/module_basis/module_pw/pw_basis_k_big.h @@ -30,8 +30,13 @@ class PW_Basis_K_Big: public PW_Basis_K by = by_in; bz = bz_in; } - int bx,by,bz; - int nbx, nby, nbz; + int bx=0; + int by=0; + int bz=0; + int nbx=0; + int nby=0; + int nbz=0; + virtual void distribute_r() { bx = (bx == 0) ? 2 : bx; @@ -51,7 +56,8 @@ class PW_Basis_K_Big: public PW_Basis_K for(int ip = 0 ; ip < this->poolnproc ; ++ip) { this->numz[ip] = npbz*this->bz; - if(ip < modbz) this->numz[ip]+=this->bz; + if(ip < modbz) { this->numz[ip]+=this->bz; +} if(ip < this->poolnproc - 1) this->startz[ip+1] = this->startz[ip] + numz[ip]; if(ip == this->poolrank) { diff --git a/source/module_cell/klist.cpp b/source/module_cell/klist.cpp index d887de0c05..68a788c0eb 100644 --- a/source/module_cell/klist.cpp +++ b/source/module_cell/klist.cpp @@ -15,23 +15,11 @@ K_Vectors::K_Vectors() { -#ifdef _MCD_CHECK - FILE* out; - out = fopen("1_Memory", "w"); - if (out == NULL) - { - std::cout << "\n Can't open file!"; - ModuleBase::QUIT(); - } - _MCD_RealTimeLog(out); - _MCD_MemStatLog(out); -// showMemStats(); -#endif nspin = 0; // default spin. kc_done = false; kd_done = false; - + nkstot_full = 0; nks = 0; nkstot = 0; k_nkstot = 0; // LiuXh add 20180619 @@ -39,10 +27,6 @@ K_Vectors::K_Vectors() K_Vectors::~K_Vectors() { -// ModuleBase::TITLE("K_Vectors","~K_Vectors"); -#ifdef _MCD_CHECK - showMemStats(); -#endif } int K_Vectors::get_ik_global(const int& ik, const int& nkstot) @@ -963,7 +947,8 @@ void K_Vectors::ibz_kpoint(const ModuleSymmetry::Symmetry& symm, break; } } - if (exist_number != -1) break; + if (exist_number != -1) { break; +} } this->kstars[exist_number].insert(std::make_pair(isym, kvec_d[i])); } diff --git a/source/module_cell/klist.h b/source/module_cell/klist.h index 658544dbdd..b9af96bed7 100644 --- a/source/module_cell/klist.h +++ b/source/module_cell/klist.h @@ -19,7 +19,7 @@ class K_Vectors std::vector ngk; /// ngk, number of plane waves for each k point std::vector isk; /// distinguish spin up and down k points - int nmp[3]; /// Number of Monhorst-Pack + int nmp[3]={0}; /// Number of Monhorst-Pack std::vector kl_segids; /// index of kline segment /// @brief equal k points to each ibz-kpont, corresponding to a certain symmetry operations. @@ -163,7 +163,7 @@ class K_Vectors int nspin; bool kc_done; bool kd_done; - double koffset[3]; // used only in automatic k-points. + double koffset[3]={0.0}; // used only in automatic k-points. std::string k_kword; // LiuXh add 20180619 int k_nkstot; // LiuXh add 20180619 bool is_mp = false; // Monkhorst-Pack diff --git a/source/module_cell/module_neighbor/sltk_atom.cpp b/source/module_cell/module_neighbor/sltk_atom.cpp index bd62fe52ca..c6c847a9dd 100644 --- a/source/module_cell/module_neighbor/sltk_atom.cpp +++ b/source/module_cell/module_neighbor/sltk_atom.cpp @@ -9,4 +9,7 @@ FAtom::FAtom() z = 0.0; type = 0; natom = 0; + cell_x = 0; + cell_y = 0; + cell_z = 0; } diff --git a/source/module_cell/module_neighbor/sltk_grid.h b/source/module_cell/module_neighbor/sltk_grid.h index 7998aad63b..ac0194c116 100644 --- a/source/module_cell/module_neighbor/sltk_grid.h +++ b/source/module_cell/module_neighbor/sltk_grid.h @@ -26,24 +26,24 @@ class Grid void init(std::ofstream& ofs, const UnitCell& ucell, const double radius_in, const bool boundary = true); // Data - bool pbc; // When pbc is set to false, periodic boundary conditions are explicitly ignored. - double sradius2; // searching radius squared (unit:lat0) - double sradius; // searching radius (unit:lat0) + bool pbc=false; // When pbc is set to false, periodic boundary conditions are explicitly ignored. + double sradius2=0.0; // searching radius squared (unit:lat0) + double sradius=0.0; // searching radius (unit:lat0) // coordinate range of the input atom (unit:lat0) - double x_min; - double y_min; - double z_min; - double x_max; - double y_max; - double z_max; + double x_min=0.0; + double y_min=0.0; + double z_min=0.0; + double x_max=0.0; + double y_max=0.0; + double z_max=0.0; // The algorithm for searching neighboring atoms uses a "box" partitioning method. // Each box has an edge length of sradius, and the number of boxes in each direction is recorded here. - double box_edge_length; - int box_nx; - int box_ny; - int box_nz; + double box_edge_length=0.0; + int box_nx=0; + int box_ny=0; + int box_nz=0; void getBox(int& bx, int& by, int& bz, const double& x, const double& y, const double& z) { @@ -104,12 +104,12 @@ class Grid void Construct_Adjacent_final(const FAtom& fatom1, FAtom* fatom2); void Check_Expand_Condition(const UnitCell& ucell); - int glayerX; - int glayerX_minus; - int glayerY; - int glayerY_minus; - int glayerZ; - int glayerZ_minus; + int glayerX=0; + int glayerX_minus=0; + int glayerY=0; + int glayerY_minus=0; + int glayerZ=0; + int glayerZ_minus=0; }; #endif diff --git a/source/module_cell/module_paw/paw_element.cpp b/source/module_cell/module_paw/paw_element.cpp index 5c75418752..30419e2ae4 100644 --- a/source/module_cell/module_paw/paw_element.cpp +++ b/source/module_cell/module_paw/paw_element.cpp @@ -67,7 +67,7 @@ void Paw_Element::read_paw_xml(std::string filename) this->lstate[istate] = this->extract_int(line,"l="); lmax = std::max(lmax, lstate[istate]); - int pos = line.find("f="); + size_t pos = line.find("f="); if(pos!=std::string::npos) { this->lstate_occ[istate] = this->extract_double(line,"f="); @@ -178,7 +178,7 @@ std::string Paw_Element::scan_file(std::ifstream &ifs, std::string pattern) double Paw_Element::extract_double(std::string line, std::string key) { - int index = line.find(key); + size_t index = line.find(key); if (index != std::string::npos) { std::stringstream tmp; @@ -198,7 +198,7 @@ double Paw_Element::extract_double(std::string line, std::string key) std::string Paw_Element::extract_string(std::string line, std::string key) { - int index = line.find(key); + size_t index = line.find(key); if (index != std::string::npos) { std::stringstream tmp; @@ -218,7 +218,7 @@ std::string Paw_Element::extract_string(std::string line, std::string key) int Paw_Element::extract_int(std::string line, std::string key) { - int index = line.find(key); + size_t index = line.find(key); if (index != std::string::npos) { std::stringstream tmp; diff --git a/source/module_cell/module_symmetry/symmetry.h b/source/module_cell/module_symmetry/symmetry.h index 25f8a42206..e5f4ad7950 100644 --- a/source/module_cell/module_symmetry/symmetry.h +++ b/source/module_cell/module_symmetry/symmetry.h @@ -35,31 +35,31 @@ class Symmetry : public Symmetry_Basic ModuleBase::Vector3 a1, a2, a3; //primitive cell vectors(might be changed during the process of the program) ModuleBase::Vector3 p1, p2, p3; //primitive cell vectors - int ntype; //the number of atomic species - int nat; //the number of all atoms - int *na; //number of atoms for each species - int *istart; //start number of atom. - int itmin_type; //the type has smallest number of atoms - int itmin_start; + int ntype=0; //the number of atomic species + int nat =0; //the number of all atoms + int *na =nullptr;//number of atoms for each species + int *istart=nullptr; //start number of atom. + int itmin_type=0; //the type has smallest number of atoms + int itmin_start=0; // direct coordinates of atoms. - double *newpos; + double *newpos=nullptr; // positions of atoms after rotation. - double *rotpos; + double *rotpos=nullptr; std::vector> ptrans; // the translation vectors of the primitive cell in the input structure int ncell=1; //the number of primitive cells within one supercell - int *index; + int *index=nullptr; - double cel_const[6]; - double pcel_const[6]; //cel_const of primitive cell - double pre_const[6]; //cel_const of input configuration, first 3 is moduli of a1, a2, a3, last 3 is eular angle - - bool symflag_fft[48]; - int sym_test; - int pbrav; //ibrav of primitive cell - int real_brav; // the real ibrav for the cell pengfei Li 3-15-2022 + double cel_const[6]={0.0}; + double pcel_const[6]={0.0}; //cel_const of primitive cell + double pre_const[6]={0.0}; //cel_const of input configuration, first 3 is moduli of a1, a2, a3, last 3 is eular angle + + bool symflag_fft[48]={false}; + int sym_test=0; + int pbrav=0; //ibrav of primitive cell + int real_brav=0; // the real ibrav for the cell pengfei Li 3-15-2022 std::string ilattname; //the bravais lattice type of the supercell std::string plattname; //the bravais lattice type of the primitive cell @@ -68,12 +68,12 @@ class Symmetry : public Symmetry_Basic ModuleBase::Vector3 gtrans[48]; ModuleBase::Matrix3 symop[48]; //the rotation matrices for the pure bravais lattice - int nop; //the number of point group operations of the pure bravais lattice without basis - int nrot; //the number of pure point group rotations + int nop=0; //the number of point group operations of the pure bravais lattice without basis + int nrot=0; //the number of pure point group rotations int nrotk = -1; //the number of all space group operations, >0 means the nrotk has been analyzed int max_nrotk = -1; ///< record the maximum number of symmetry operations during cell-relax - int pgnumber; //the serial number of point group - int spgnumber; //the serial number of point group in space group + int pgnumber=0; //the serial number of point group + int spgnumber=0; //the serial number of point group in space group std::string pgname; //the Schoenflies name of the point group R in {R|0} std::string spgname; //the Schoenflies name of the point group R in the space group {R|t} diff --git a/source/module_cell/read_atoms.cpp b/source/module_cell/read_atoms.cpp index 9f369cd3f5..736a0aec06 100644 --- a/source/module_cell/read_atoms.cpp +++ b/source/module_cell/read_atoms.cpp @@ -716,10 +716,11 @@ bool UnitCell::read_atom_positions(std::ifstream &ifpos, std::ofstream &ofs_runn } //print only ia==0 && mag>0 to avoid too much output //print when ia!=0 && mag[ia] != mag[0] to avoid too much output - if(ia==0 || (ia!=0 - && (atoms[it].m_loc_[ia].x != atoms[it].m_loc_[0].x - || atoms[it].m_loc_[ia].y != atoms[it].m_loc_[0].y - || atoms[it].m_loc_[ia].z != atoms[it].m_loc_[0].z))) + // 'A || (!A && B)' is equivalent to 'A || B',so the following + // code is equivalent to 'ia==0 || (...)' + if(ia==0 || (atoms[it].m_loc_[ia].x != atoms[it].m_loc_[0].x + || atoms[it].m_loc_[ia].y != atoms[it].m_loc_[0].y + || atoms[it].m_loc_[ia].z != atoms[it].m_loc_[0].z)) { //use a stringstream to generate string: "concollinear magnetization of element it is:" std::stringstream ss; @@ -737,7 +738,7 @@ bool UnitCell::read_atom_positions(std::ifstream &ifpos, std::ofstream &ofs_runn atoms[it].mag[ia] = atoms[it].m_loc_[ia].z; //print only ia==0 && mag>0 to avoid too much output //print when ia!=0 && mag[ia] != mag[0] to avoid too much output - if(ia==0 || (ia!=0 && atoms[it].mag[ia] != atoms[it].mag[0])) + if(ia==0 || (atoms[it].mag[ia] != atoms[it].mag[0])) { //use a stringstream to generate string: "cocollinear magnetization of element it is:" std::stringstream ss; diff --git a/source/module_cell/read_pp_upf100.cpp b/source/module_cell/read_pp_upf100.cpp index 1f5d11d980..bfff72f3ca 100644 --- a/source/module_cell/read_pp_upf100.cpp +++ b/source/module_cell/read_pp_upf100.cpp @@ -468,8 +468,7 @@ void Pseudopot_upf::read_pseudo_rhoatom(std::ifstream &ifs, Atom_pseudo& pp) void Pseudopot_upf::read_pseudo_so(std::ifstream &ifs, Atom_pseudo& pp) { //read soc info from upf, added by zhengdy-soc - if(!pp.has_so) { return; -} + if(!pp.has_so) { return;} pp.nn = std::vector(pp.nchi, 0); pp.jchi = std::vector(pp.nchi, 0.0); pp.jjj = std::vector(pp.nbeta, 0.0); diff --git a/source/module_cell/read_pp_vwr.cpp b/source/module_cell/read_pp_vwr.cpp index ddc105d934..68ef04fd81 100644 --- a/source/module_cell/read_pp_vwr.cpp +++ b/source/module_cell/read_pp_vwr.cpp @@ -29,7 +29,7 @@ int Pseudopot_upf::read_pseudo_vwr(std::ifstream &ifs, Atom_pseudo& pp) // (1) read in mesh std::string value; - int length=0; + size_t length=0; ifs >> value; length = value.find(","); value.erase(length,1); pp.mesh = std::atoi( value.c_str() ); //the mesh should be odd, which is forced in Simpson integration diff --git a/source/module_cell/setup_nonlocal.cpp b/source/module_cell/setup_nonlocal.cpp index f62982db49..c31557e25e 100644 --- a/source/module_cell/setup_nonlocal.cpp +++ b/source/module_cell/setup_nonlocal.cpp @@ -143,7 +143,7 @@ void InfoNonlocal::Set_NonLocal(const int& it, if (PARAM.inp.out_element_info) { tmpBeta_lm[p1].plot(GlobalV::MY_RANK); -} + } delete[] beta_r; } diff --git a/source/module_elecstate/elecstate_energy.cpp b/source/module_elecstate/elecstate_energy.cpp index fae932bd27..21537dab5d 100644 --- a/source/module_elecstate/elecstate_energy.cpp +++ b/source/module_elecstate/elecstate_energy.cpp @@ -103,7 +103,8 @@ double ElecState::cal_delta_eband(const UnitCell& ucell) const const double* v_eff = this->pot->get_effective_v(0); const double* v_fixed = this->pot->get_fixed_v(); const double* v_ofk = nullptr; - + const bool v_ofk_flag =(get_xc_func_type() == 3 + || get_xc_func_type() == 5); #ifdef USE_PAW if(PARAM.inp.use_paw) { @@ -128,28 +129,39 @@ double ElecState::cal_delta_eband(const UnitCell& ucell) const if(!PARAM.inp.use_paw) { - if (get_xc_func_type() == 3 || get_xc_func_type() == 5) - { - v_ofk = this->pot->get_effective_vofk(0); - } - for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++) { deband_aux -= this->charge->rho[0][ir] * (v_eff[ir] - v_fixed[ir]); - if (get_xc_func_type() == 3 || get_xc_func_type() == 5) + } + if (v_ofk_flag) + { + v_ofk = this->pot->get_effective_vofk(0); + // cause in the get_effective_vofk, the func will return nullptr + if(v_ofk==nullptr && this->charge->rhopw->nrxx>0) + { + ModuleBase::WARNING_QUIT("ElecState::cal_delta_eband","v_ofk is nullptr"); + } + for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++) { deband_aux -= this->charge->kin_r[0][ir] * v_ofk[ir]; } } - + if (PARAM.inp.nspin == 2) { v_eff = this->pot->get_effective_v(1); - v_ofk = this->pot->get_effective_vofk(1); for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++) { deband_aux -= this->charge->rho[1][ir] * (v_eff[ir] - v_fixed[ir]); - if (get_xc_func_type() == 3 || get_xc_func_type() == 5) + } + if (v_ofk_flag) + { + v_ofk = this->pot->get_effective_vofk(1); + if(v_ofk==nullptr && this->charge->rhopw->nrxx>0) + { + ModuleBase::WARNING_QUIT("ElecState::cal_delta_eband","v_ofk is nullptr"); + } + for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++) { deband_aux -= this->charge->kin_r[1][ir] * v_ofk[ir]; } @@ -201,12 +213,13 @@ double ElecState::cal_delta_escf() const { v_ofk = this->pot->get_effective_vofk(0); } - for (int ir = 0; ir < this->charge->rhopw->nrxx; ir++) { descf -= (this->charge->rho[0][ir] - this->charge->rho_save[0][ir]) * (v_eff[ir] - v_fixed[ir]); if (get_xc_func_type() == 3 || get_xc_func_type() == 5) { + // cause in the get_effective_vofk, the func will return nullptr + assert(v_ofk!=nullptr); descf -= (this->charge->kin_r[0][ir] - this->charge->kin_r_save[0][ir]) * v_ofk[ir]; } } diff --git a/source/module_elecstate/magnetism.cpp b/source/module_elecstate/magnetism.cpp index 918f1c988c..80d4856fc1 100644 --- a/source/module_elecstate/magnetism.cpp +++ b/source/module_elecstate/magnetism.cpp @@ -5,14 +5,15 @@ Magnetism::Magnetism() { - this->tot_magnetization = 0.0; - this->abs_magnetization = 0.0; - this->start_magnetization = nullptr; + tot_magnetization = 0.0; + abs_magnetization = 0.0; + std::fill(tot_magnetization_nc, tot_magnetization_nc + 3, 0.0); + std::fill(ux_, ux_ + 3, 0.0); } Magnetism::~Magnetism() { - delete[] this->start_magnetization; + delete[] start_magnetization; } void Magnetism::compute_magnetization(const double& omega, @@ -56,20 +57,23 @@ void Magnetism::compute_magnetization(const double& omega, // noncolliear : else if(PARAM.inp.nspin==4) { - for(int i=0;i<3;i++)this->tot_magnetization_nc[i] = 0.00; + for(int i=0;i<3;i++) {this->tot_magnetization_nc[i] = 0.00; +} this->abs_magnetization = 0.00; for (int ir=0; irtot_magnetization_nc[i] += rho[i+1][ir]; + for(int i=0;i<3;i++) {this->tot_magnetization_nc[i] += rho[i+1][ir]; +} this->abs_magnetization += std::abs(diff); } #ifdef __MPI Parallel_Reduce::reduce_pool(this->tot_magnetization_nc, 3); Parallel_Reduce::reduce_pool(this->abs_magnetization); #endif - for(int i=0;i<3;i++)this->tot_magnetization_nc[i] *= omega/ nxyz; + for(int i=0;i<3;i++) {this->tot_magnetization_nc[i] *= omega/ nxyz; +} this->abs_magnetization *= omega/ nxyz; GlobalV::ofs_running<<"total magnetism (Bohr mag/cell)"<<'\t'<tot_magnetization_nc[0]<<'\t'<tot_magnetization_nc[1]<<'\t'<tot_magnetization_nc[2]<<'\n'; ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"absolute magnetism (Bohr mag/cell)",this->abs_magnetization); diff --git a/source/module_elecstate/magnetism.h b/source/module_elecstate/magnetism.h index bb4de6d28d..408ba9d039 100644 --- a/source/module_elecstate/magnetism.h +++ b/source/module_elecstate/magnetism.h @@ -14,11 +14,11 @@ class Magnetism ~Magnetism(); // notice : becast is done in unitcell - double *start_magnetization; + double *start_magnetization=nullptr; // tot_magnetization : majority spin - minority spin (nelup - neldw). double tot_magnetization; - double tot_magnetization_nc[3]; + double tot_magnetization_nc[3]={0.0}; double abs_magnetization; void compute_magnetization(const double& omega, @@ -28,12 +28,12 @@ class Magnetism double* nelec_spin = nullptr); - ModuleBase::Vector3 *m_loc_; //magnetization for each element along c-axis - double *angle1_; //angle between c-axis and real spin std::vector - double *angle2_; //angle between a-axis and real spin std::vector projection in ab-plane + ModuleBase::Vector3 *m_loc_=nullptr;//magnetization for each element along c-axis + double *angle1_=nullptr; //angle between c-axis and real spin std::vector + double *angle2_=nullptr; //angle between a-axis and real spin std::vector projection in ab-plane //void cal_ux(const int ntype); - double ux_[3]; - bool lsign_; + double ux_[3]={0.0}; + bool lsign_=false; private: bool judge_parallel(double a[3],ModuleBase::Vector3 b); diff --git a/source/module_elecstate/module_charge/charge.cpp b/source/module_elecstate/module_charge/charge.cpp index c3e23dd6c6..f152ca850e 100644 --- a/source/module_elecstate/module_charge/charge.cpp +++ b/source/module_elecstate/module_charge/charge.cpp @@ -326,9 +326,10 @@ void Charge::atomic_rho(const int spin_number_need, { // check the start magnetization const int startmag_type = [&]() -> int { - if (ucell.magnet.start_magnetization[it] != 0.0) { + if (ucell.magnet.start_magnetization[it] != 0.0) + { return 1; -} + } return 2; }(); ModuleBase::GlobalFunc::OUT(GlobalV::ofs_warning, "startmag_type", startmag_type); diff --git a/source/module_elecstate/module_charge/charge.h b/source/module_elecstate/module_charge/charge.h index e3bc33f901..0fe89f2dbb 100644 --- a/source/module_elecstate/module_charge/charge.h +++ b/source/module_elecstate/module_charge/charge.h @@ -144,10 +144,10 @@ class Charge void set_omega(double* omega_in){this->omega_ = omega_in;}; // mohan add 2021-02-20 - int nrxx; // number of r vectors in this processor - int nxyz; // total nuber of r vectors - int ngmc; // number of g vectors in this processor - int nspin; // number of spins + int nrxx=0; // number of r vectors in this processor + int nxyz=0; // total nuber of r vectors + int ngmc=0; // number of g vectors in this processor + int nspin=0; // number of spins ModulePW::PW_Basis* rhopw = nullptr;// When double_grid is used, rhopw = rhodpw (dense grid) bool cal_elf = false; // whether to calculate electron localization function (ELF) private: diff --git a/source/module_esolver/esolver_ks_lcao.cpp b/source/module_esolver/esolver_ks_lcao.cpp index e5e0684e9e..3ee810abc0 100644 --- a/source/module_esolver/esolver_ks_lcao.cpp +++ b/source/module_esolver/esolver_ks_lcao.cpp @@ -927,6 +927,7 @@ void ESolver_KS_LCAO::after_scf(UnitCell& ucell, const int istep) // 1) calculate the kinetic energy density tau, sunliang 2024-09-18 if (PARAM.inp.out_elf[0] > 0) { + assert(this->psi != nullptr); this->pelec->cal_tau(*(this->psi)); } diff --git a/source/module_esolver/esolver_ks_pw.cpp b/source/module_esolver/esolver_ks_pw.cpp index 5812eb903c..dca648f262 100644 --- a/source/module_esolver/esolver_ks_pw.cpp +++ b/source/module_esolver/esolver_ks_pw.cpp @@ -204,6 +204,7 @@ void ESolver_KS_PW::before_all_runners(UnitCell& ucell, const Input_p if (this->psi != nullptr) { delete this->psi; + this->psi = nullptr; } //! initalize local pseudopotential @@ -224,7 +225,8 @@ void ESolver_KS_PW::before_all_runners(UnitCell& ucell, const Input_p &this->sf, &this->ppcell, ucell); - + + assert(this->psi != nullptr); this->kspw_psi = PARAM.inp.device == "gpu" || PARAM.inp.precision == "single" ? new psi::Psi(this->psi[0]) : reinterpret_cast*>(this->psi); diff --git a/source/module_esolver/esolver_lj.h b/source/module_esolver/esolver_lj.h index 2b56e4825e..d8c5361649 100644 --- a/source/module_esolver/esolver_lj.h +++ b/source/module_esolver/esolver_lj.h @@ -49,7 +49,7 @@ namespace ModuleESolver ModuleBase::matrix lj_c6; ModuleBase::matrix en_shift; - double lj_potential; + double lj_potential=0.0; ModuleBase::matrix lj_force; ModuleBase::matrix lj_virial; //--------------------------------------------------- diff --git a/source/module_hamilt_general/module_vdw/vdwd2_parameters.h b/source/module_hamilt_general/module_vdw/vdwd2_parameters.h index 06d4a52793..2b4f2f0176 100644 --- a/source/module_hamilt_general/module_vdw/vdwd2_parameters.h +++ b/source/module_hamilt_general/module_vdw/vdwd2_parameters.h @@ -23,6 +23,9 @@ class Vdwd2Parameters : public VdwParameters { C6_ = C6_default_; R0_ = R0_default_; + damping_ = 0.0; + scaling_ = 1.0; + radius_ = 0.0; } ~Vdwd2Parameters() = default; diff --git a/source/module_hamilt_general/module_vdw/vdwd3_parameters.h b/source/module_hamilt_general/module_vdw/vdwd3_parameters.h index f671e6245e..75c5801eb3 100644 --- a/source/module_hamilt_general/module_vdw/vdwd3_parameters.h +++ b/source/module_hamilt_general/module_vdw/vdwd3_parameters.h @@ -56,13 +56,13 @@ class Vdwd3Parameters : public VdwParameters private: std::string version_; - bool abc_; // third-order term? - double rthr2_; // R^2 distance neglect threshold (important for speed in case of large systems) (a.u.) - double cn_thr2_; // R^2 distance to cutoff for CN_calculation (a.u.) - double s6_; - double rs6_; - double s18_; - double rs18_; + bool abc_=false; // third-order term? + double rthr2_=0.0; // R^2 distance neglect threshold (important for speed in case of large systems) (a.u.) + double cn_thr2_=0.0; // R^2 distance to cutoff for CN_calculation (a.u.) + double s6_=0.0; + double rs6_=0.0; + double s18_=0.0; + double rs18_=0.0; static constexpr size_t max_elem_ = 94; static constexpr double k1_ = 16.0, k2_ = 4.0 / 3.0, k3_ = -4.0; diff --git a/source/module_hamilt_general/module_xc/xc_functional_libxc.cpp b/source/module_hamilt_general/module_xc/xc_functional_libxc.cpp index 82151ebd80..ffd44e7989 100644 --- a/source/module_hamilt_general/module_xc/xc_functional_libxc.cpp +++ b/source/module_hamilt_general/module_xc/xc_functional_libxc.cpp @@ -74,7 +74,7 @@ std::pair> XC_Functional_Libxc::set_xc_type_libxc(std::stri // determine the id std::vector func_id; // libxc id of functional - int pos = 0; + size_t pos = 0; std::string delimiter = "+"; std::string token; while ((pos = xc_func_in.find(delimiter)) != std::string::npos) diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.cpp index 150df06946..302972abe4 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.cpp @@ -4,7 +4,7 @@ #include "module_cell/module_neighbor/sltk_grid_driver.h" #include "module_hamilt_pw/hamilt_pwdft/global.h" #include "module_parameter/parameter.h" -Record_adj::Record_adj() : iat2ca(nullptr) +Record_adj::Record_adj() { } Record_adj::~Record_adj() diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.h b/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.h index 441f1452f6..248f6eb611 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.h +++ b/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.h @@ -37,8 +37,8 @@ class Record_adj void delete_grid(); - int na_proc; - int* na_each; + int na_proc=0; + int* na_each=nullptr; //-------------------------------------------- // record sparse atom index in for_grid(const Grid_Technique >); @@ -53,12 +53,12 @@ class Record_adj // 1. iat2ca[iat] > 0 ? na_each[iat2ca[iat]] : 0 // 2. iat2ca[iat] > 0 ? info[iat2ca[iat]] : nullptr //-------------------------------------------- - int* iat2ca; + int* iat2ca=nullptr; //------------------------------------------------ // info will identify each atom in each unitcell. //------------------------------------------------ - int*** info; + int*** info=nullptr; private: }; diff --git a/source/module_hamilt_lcao/module_dftu/dftu_yukawa.cpp b/source/module_hamilt_lcao/module_dftu/dftu_yukawa.cpp index a2c3dd2973..7845fe9963 100644 --- a/source/module_hamilt_lcao/module_dftu/dftu_yukawa.cpp +++ b/source/module_hamilt_lcao/module_dftu/dftu_yukawa.cpp @@ -196,41 +196,53 @@ double DFTU::spherical_Bessel(const int k, const double r, const double lambda) { ModuleBase::TITLE("DFTU", "spherical_Bessel"); - double val; + double val=0.0; double x = r * lambda; if (k == 0) { - if (x < 1.0e-3) { + if (x < 1.0e-3) + { val = 1 + pow(x, 2) / 6.0; - } else { + } + else + { val = sinh(x) / x; -} + } } else if (k == 2) { - if (x < 1.0e-2) { + if (x < 1.0e-2) + { val = -pow(x, 2) / 15.0 - pow(x, 4) / 210.0 - pow(x, 6) / 7560.0; - } else { + } + else + { val = 3 * cosh(x) / pow(x, 2) + (-3 - pow(x, 2)) * sinh(x) / pow(x, 3); -} + } } else if (k == 4) { - if (x < 5.0e-1) { + if (x < 5.0e-1) + { val = pow(x, 4) / 945.0 + pow(x, 6) / 20790.0 + pow(x, 8) / 1081080.0 + pow(x, 10) / 97297200.0; - } else { + } + else + { val = -5 * (21 + 2 * pow(x, 2)) * cosh(x) / pow(x, 4) + (105 + 45 * pow(x, 2) + pow(x, 4)) * sinh(x) / pow(x, 5); -} + } } else if (k == 6) { - if (x < 9.0e-1) { + if (x < 9.0e-1) + { val = -pow(x, 6) / 135135.0 - pow(x, 8) / 4054050.0 - pow(x, 10) / 275675400.0; - } else { + } + else + { val = 21 * (495 + 60 * pow(x, 2) + pow(x, 4)) * cosh(x) / pow(x, 6) + (-10395 - 4725 * pow(x, 2) - 210 * pow(x, 4) - pow(x, 6)) * sinh(x) / pow(x, 7); -} + } } return val; } @@ -239,44 +251,56 @@ double DFTU::spherical_Hankel(const int k, const double r, const double lambda) { ModuleBase::TITLE("DFTU", "spherical_Bessel"); - double val; + double val=0.0; double x = r * lambda; if (k == 0) { - if (x < 1.0e-3) { + if (x < 1.0e-3) + { val = -1 / x + 1 - x / 2.0 + pow(x, 2) / 6.0; - } else { + } + else + { val = -exp(-x) / x; -} + } } else if (k == 2) { - if (x < 1.0e-2) { + if (x < 1.0e-2) + { val = 3 / pow(x, 3) - 1 / (2 * x) + x / 8 - pow(x, 2) / 15.0 + pow(x, 3) / 48.0; - } else { + } + else + { val = exp(-x) * (3 + 3 * x + pow(x, 2)) / pow(x, 3); -} + } } else if (k == 4) { - if (x < 5.0e-1) { + if (x < 5.0e-1) + { val = -105 / pow(x, 5) + 15 / (2 * pow(x, 3)) - 3 / (8 * x) + x / 48 - pow(x, 3) / 384.0 + pow(x, 4) / 945.0; - } else { + } + else + { val = -exp(-x) * (105 + 105 * x + 45 * pow(x, 2) + 10 * pow(x, 3) + pow(x, 4)) / pow(x, 5); -} + } } else if (k == 6) { - if (x < 9.0e-1) { + if (x < 9.0e-1) + { val = 10395 / pow(x, 7) - 945 / (2 * pow(x, 5)) + 105 / (8 * pow(x, 3)) - 5 / (16 * x) + x / 128.0 - pow(x, 3) / 3840.0 + pow(x, 5) / 46080.0 - pow(x, 6) / 135135.0; - } else { + } + else + { val = exp(-x) * (10395 + 10395 * x + 4725 * pow(x, 2) + 1260 * pow(x, 3) + 210 * pow(x, 4) + 21 * pow(x, 5) + pow(x, 6)) / pow(x, 7); -} + } } return val; } diff --git a/source/module_hamilt_lcao/module_gint/gint_tools.h b/source/module_hamilt_lcao/module_gint/gint_tools.h index 3dd69e173c..a2ea0a20c0 100644 --- a/source/module_hamilt_lcao/module_gint/gint_tools.h +++ b/source/module_hamilt_lcao/module_gint/gint_tools.h @@ -33,19 +33,19 @@ class Gint_inout { public: // input - double*** DM; - const double* vl; - const double* vofk; - bool isforce; - bool isstress; - int ispin; - int nspin_rho; // usually, but not always, equal to global nspin + double*** DM=nullptr; + const double* vl=nullptr; + const double* vofk=nullptr; + bool isforce=false; + bool isstress=false; + int ispin=0; + int nspin_rho=0; // usually, but not always, equal to global nspin bool if_symm = false; // if true, use dsymv in gint_kernel_rho; if false, use dgemv. // output - double** rho; - ModuleBase::matrix* fvl_dphi; - ModuleBase::matrix* svl_dphi; + double** rho=nullptr; + ModuleBase::matrix* fvl_dphi=nullptr; + ModuleBase::matrix* svl_dphi=nullptr; Gint_Tools::job_type job; // electron density and kin_r, multi-k diff --git a/source/module_hamilt_lcao/module_gint/grid_bigcell.h b/source/module_hamilt_lcao/module_gint/grid_bigcell.h index 87960e7e18..10f52a7419 100644 --- a/source/module_hamilt_lcao/module_gint/grid_bigcell.h +++ b/source/module_hamilt_lcao/module_gint/grid_bigcell.h @@ -12,7 +12,7 @@ class Grid_BigCell: public Grid_MeshCell Grid_BigCell(); ~Grid_BigCell(); // number atoms and type. - int nat; + int nat=0; // save the relative cartesian position // to bigcell of each atom. std::vector> tau_in_bigcell; diff --git a/source/module_hamilt_lcao/module_gint/grid_technique.h b/source/module_hamilt_lcao/module_gint/grid_technique.h index 55ff74e151..6c3c26aba9 100644 --- a/source/module_hamilt_lcao/module_gint/grid_technique.h +++ b/source/module_hamilt_lcao/module_gint/grid_technique.h @@ -29,9 +29,9 @@ class Grid_Technique : public Grid_MeshBall { // record how many atoms on each grid. std::vector how_many_atoms; // max atom on grid - int max_atom; + int max_atom=0; // sum of how_many_atoms - int total_atoms_on_grid; + int total_atoms_on_grid=0; std::vector start_ind; //------------------------------------ @@ -54,8 +54,8 @@ class Grid_Technique : public Grid_MeshBall { //------------------------------------ // 3: which atom on local grid. //------------------------------------ - int lnat; // local nat. - int lgd; // local grid dimension. lgd * lgd symmetry matrix. + int lnat=0; // local nat. + int lgd=0; // local grid dimension. lgd * lgd symmetry matrix. std::vector in_this_processor; std::vector trace_iat; std::vector trace_lo; // trace local orbital. @@ -68,23 +68,23 @@ class Grid_Technique : public Grid_MeshBall { int nnrg = 0; // UnitCell and LCAO_Obrbitals - const UnitCell* ucell; - const LCAO_Orbitals* orb; + const UnitCell* ucell=nullptr; + const LCAO_Orbitals* orb=nullptr; // UnitCell parameters - int nwmax; - int nr_max; - int ntype; + int nwmax=0; + int nr_max=0; + int ntype=0; // LCAO Orbitals - double dr_uniform; + double dr_uniform={0.0}; std::vector rcuts; std::vector> psi_u; std::vector> dpsi_u; std::vector> d2psi_u; // Determine whether the grid point integration is initialized. - bool init_malloced; + bool init_malloced=false; bool get_init_malloced() const { return init_malloced; } diff --git a/source/module_hamilt_pw/hamilt_pwdft/operator_pw/meta_pw.cpp b/source/module_hamilt_pw/hamilt_pwdft/operator_pw/meta_pw.cpp index 1046a90c9a..b0372109dc 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/operator_pw/meta_pw.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/operator_pw/meta_pw.cpp @@ -15,6 +15,10 @@ Meta>::Meta(Real tpiba_in, const int vk_col, const ModulePW::PW_Basis_K* wfcpw_in) { + if(isk_in == nullptr || tpiba_in < 1e-10 || wfcpw_in == nullptr) + { + ModuleBase::WARNING_QUIT("MetaPW", "Constuctor of Operator::MetaPW is failed, please check your code!"); + } this->classname = "Meta"; this->cal_type = calculation_type::pw_meta; this->isk = isk_in; @@ -24,10 +28,7 @@ Meta>::Meta(Real tpiba_in, this->vk_col = vk_col; this->wfcpw = wfcpw_in; resmem_complex_op()(this->ctx, this->porter, this->wfcpw->nmaxgr, "Meta::porter"); - if(this->isk == nullptr || this->tpiba < 1e-10 || this->wfcpw == nullptr) - { - ModuleBase::WARNING_QUIT("MetaPW", "Constuctor of Operator::MetaPW is failed, please check your code!"); - } + } template diff --git a/source/module_hamilt_pw/hamilt_pwdft/operator_pw/nonlocal_pw.cpp b/source/module_hamilt_pw/hamilt_pwdft/operator_pw/nonlocal_pw.cpp index b8d9a3f086..563e9d23a0 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/operator_pw/nonlocal_pw.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/operator_pw/nonlocal_pw.cpp @@ -17,6 +17,10 @@ Nonlocal>::Nonlocal(const int* isk_in, const UnitCell* ucell_in, const ModulePW::PW_Basis_K* wfc_basis) { + if( isk_in == nullptr || ppcell_in == nullptr || ucell_in == nullptr) + { + ModuleBase::WARNING_QUIT("NonlocalPW", "Constuctor of Operator::NonlocalPW is failed, please check your code!"); + } this->classname = "Nonlocal"; this->cal_type = calculation_type::pw_nonlocal; this->wfcpw = wfc_basis; @@ -26,10 +30,7 @@ Nonlocal>::Nonlocal(const int* isk_in, this->deeq = this->ppcell->template get_deeq_data(); this->deeq_nc = this->ppcell->template get_deeq_nc_data(); this->vkb = this->ppcell->template get_vkb_data(); - if( this->isk == nullptr || this->ppcell == nullptr || this->ucell == nullptr) - { - ModuleBase::WARNING_QUIT("NonlocalPW", "Constuctor of Operator::NonlocalPW is failed, please check your code!"); - } + } template diff --git a/source/module_hamilt_pw/hamilt_pwdft/operator_pw/veff_pw.cpp b/source/module_hamilt_pw/hamilt_pwdft/operator_pw/veff_pw.cpp index 63ead6d57f..2343ee7ecb 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/operator_pw/veff_pw.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/operator_pw/veff_pw.cpp @@ -12,6 +12,9 @@ Veff>::Veff(const int* isk_in, const int veff_col, const ModulePW::PW_Basis_K* wfcpw_in) { + if (isk_in == nullptr || wfcpw_in == nullptr) { + ModuleBase::WARNING_QUIT("VeffPW", "Constuctor of Operator::VeffPW is failed, please check your code!"); + } this->classname = "Veff"; this->cal_type = calculation_type::pw_veff; this->isk = isk_in; @@ -22,9 +25,7 @@ Veff>::Veff(const int* isk_in, this->wfcpw = wfcpw_in; resmem_complex_op()(this->ctx, this->porter, this->wfcpw->nmaxgr, "Veff::porter"); resmem_complex_op()(this->ctx, this->porter1, this->wfcpw->nmaxgr, "Veff::porter1"); - if (this->isk == nullptr || this->wfcpw == nullptr) { - ModuleBase::WARNING_QUIT("VeffPW", "Constuctor of Operator::VeffPW is failed, please check your code!"); - } + } template diff --git a/source/module_hamilt_pw/hamilt_pwdft/operator_pw/velocity_pw.cpp b/source/module_hamilt_pw/hamilt_pwdft/operator_pw/velocity_pw.cpp index 858e6b3fd5..412534df6a 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/operator_pw/velocity_pw.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/operator_pw/velocity_pw.cpp @@ -13,15 +13,15 @@ Velocity::Velocity const bool nonlocal_in ) { + if( wfcpw_in == nullptr || isk_in == nullptr || ppcell_in == nullptr || ucell_in == nullptr) + { + ModuleBase::WARNING_QUIT("Velocity", "Constuctor of Operator::Velocity is failed, please check your code!"); + } this->wfcpw = wfcpw_in; this->isk = isk_in; this->ppcell = ppcell_in; this->ucell = ucell_in; this->nonlocal = nonlocal_in; - if( this->wfcpw == nullptr || this->isk == nullptr || this->ppcell == nullptr || this->ucell == nullptr) - { - ModuleBase::WARNING_QUIT("Velocity", "Constuctor of Operator::Velocity is failed, please check your code!"); - } this->tpiba = ucell_in -> tpiba; if(this->nonlocal) this->ppcell->initgradq_vnl(*this->ucell); } diff --git a/source/module_hamilt_pw/hamilt_pwdft/operator_pw/velocity_pw.h b/source/module_hamilt_pw/hamilt_pwdft/operator_pw/velocity_pw.h index f423221cc2..a6752065b0 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/operator_pw/velocity_pw.h +++ b/source/module_hamilt_pw/hamilt_pwdft/operator_pw/velocity_pw.h @@ -50,9 +50,9 @@ class Velocity const UnitCell* ucell = nullptr; - int ik; + int ik=0; - double tpiba; + double tpiba=0.0; }; } #endif \ No newline at end of file diff --git a/source/module_hamilt_pw/hamilt_pwdft/parallel_grid.h b/source/module_hamilt_pw/hamilt_pwdft/parallel_grid.h index f6e4811c03..1da46fa394 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/parallel_grid.h +++ b/source/module_hamilt_pw/hamilt_pwdft/parallel_grid.h @@ -49,15 +49,15 @@ class Parallel_Grid int **startz = nullptr; int **whichpro = nullptr; - int ncx; - int ncy; - int ncz; - int ncxy; - int ncxyz; - int nczp; // number of z-layers (xy-planes) in each processor - int nrxx; - int nbz; - int bz; + int ncx=0; + int ncy=0; + int ncz=0; + int ncxy=0; + int ncxyz=0; + int nczp=0; // number of z-layers (xy-planes) in each processor + int nrxx=0; + int nbz=0; + int bz=0; bool allocate = false; bool allocate_final_scf = false; //LiuXh add 20180619 diff --git a/source/module_hamilt_pw/hamilt_pwdft/structure_factor.h b/source/module_hamilt_pw/hamilt_pwdft/structure_factor.h index b77a69adb5..2f3e1931c8 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/structure_factor.h +++ b/source/module_hamilt_pw/hamilt_pwdft/structure_factor.h @@ -19,7 +19,7 @@ class Structure_Factor // Part 4: G vectors in reciprocal FFT box //=============================================== public: - int nbspline; + int nbspline=0; // structure factor (ntype, ngmc) ModuleBase::ComplexMatrix strucFac; @@ -59,7 +59,7 @@ class Structure_Factor ModuleBase::Vector3 q); private: - const UnitCell* ucell; + const UnitCell* ucell=nullptr; std::complex * c_eigts1 = nullptr, * c_eigts2 = nullptr, * c_eigts3 = nullptr; std::complex * z_eigts1 = nullptr, * z_eigts2 = nullptr, * z_eigts3 = nullptr; const ModulePW::PW_Basis* rho_basis = nullptr; diff --git a/source/module_hamilt_pw/hamilt_stodft/sto_func.cpp b/source/module_hamilt_pw/hamilt_stodft/sto_func.cpp index 581e5ab7ef..f4f60b8555 100644 --- a/source/module_hamilt_pw/hamilt_stodft/sto_func.cpp +++ b/source/module_hamilt_pw/hamilt_stodft/sto_func.cpp @@ -7,6 +7,10 @@ template Sto_Func::Sto_Func() { this->tem = Occupy::gaussian_parameter; + this->mu = static_cast(0.0); + this->t = static_cast(0.0); + this->sigma = static_cast(0.0); + this->targ_e = static_cast(0.0); } template @@ -20,11 +24,12 @@ template REAL Sto_Func::root_fd(REAL e) { REAL e_mu = (e - mu) / this->tem; - if (e_mu > 72) + if (e_mu > 72) { return 0; - else + } else { return 1 / sqrt(1 + exp(e_mu)); } +} template REAL Sto_Func::nroot_fd(REAL e) @@ -32,21 +37,23 @@ REAL Sto_Func::nroot_fd(REAL e) REAL Ebar = (*Emin + *Emax) / 2; REAL DeltaE = (*Emax - *Emin) / 2; REAL ne_mu = (e * DeltaE + Ebar - mu) / this->tem; - if (ne_mu > 72) + if (ne_mu > 72) { return 0; - else + } else { return 1 / sqrt(1 + exp(ne_mu)); } +} template REAL Sto_Func::fd(REAL e) { REAL e_mu = (e - mu) / this->tem; - if (e_mu > 36) + if (e_mu > 36) { return 0; - else + } else { return 1 / (1 + exp(e_mu)); } +} template REAL Sto_Func::nfd(REAL e) @@ -54,11 +61,12 @@ REAL Sto_Func::nfd(REAL e) REAL Ebar = (*Emin + *Emax) / 2; REAL DeltaE = (*Emax - *Emin) / 2; REAL ne_mu = (e * DeltaE + Ebar - mu) / this->tem; - if (ne_mu > 36) + if (ne_mu > 36) { return 0; - else + } else { return 1 / (1 + exp(ne_mu)); } +} template REAL Sto_Func::nxfd(REAL rawe) @@ -67,27 +75,29 @@ REAL Sto_Func::nxfd(REAL rawe) REAL DeltaE = (*Emax - *Emin) / 2; REAL e = rawe * DeltaE + Ebar; REAL ne_mu = (e - mu) / this->tem; - if (ne_mu > 36) + if (ne_mu > 36) { return 0; - else + } else { return e / (1 + exp(ne_mu)); } +} template REAL Sto_Func::fdlnfd(REAL e) { REAL e_mu = (e - mu) / this->tem; - if (e_mu > 36) + if (e_mu > 36) { return 0; - else if (e_mu < -36) + } else if (e_mu < -36) { return 0; - else + } else { REAL f = 1 / (1 + exp(e_mu)); - if (f == 0 || f == 1) + if (f == 0 || f == 1) { return 0; - else + } else { return (f * log(f) + (1.0 - f) * log(1.0 - f)); +} } } @@ -97,17 +107,18 @@ REAL Sto_Func::nfdlnfd(REAL rawe) REAL Ebar = (*Emin + *Emax) / 2; REAL DeltaE = (*Emax - *Emin) / 2; REAL ne_mu = (rawe * DeltaE + Ebar - mu) / this->tem; - if (ne_mu > 36) + if (ne_mu > 36) { return 0; - else if (ne_mu < -36) + } else if (ne_mu < -36) { return 0; - else + } else { REAL f = 1 / (1 + exp(ne_mu)); - if (f == 0 || f == 1) + if (f == 0 || f == 1) { return 0; - else + } else { return f * log(f) + (1 - f) * log(1 - f); +} } } @@ -117,17 +128,18 @@ REAL Sto_Func::n_root_fdlnfd(REAL rawe) REAL Ebar = (*Emin + *Emax) / 2; REAL DeltaE = (*Emax - *Emin) / 2; REAL ne_mu = (rawe * DeltaE + Ebar - mu) / this->tem; - if (ne_mu > 36) + if (ne_mu > 36) { return 0; - else if (ne_mu < -36) + } else if (ne_mu < -36) { return 0; - else + } else { REAL f = 1 / (1 + exp(ne_mu)); - if (f == 0 || f == 1) + if (f == 0 || f == 1) { return 0; - else + } else { return sqrt(-f * log(f) - (1 - f) * log(1 - f)); +} } } @@ -137,11 +149,12 @@ REAL Sto_Func::nroot_mfd(REAL rawe) REAL Ebar = (*Emin + *Emax) / 2; REAL DeltaE = (*Emax - *Emin) / 2; REAL ne_mu = (rawe * DeltaE + Ebar - mu) / this->tem; - if (ne_mu < -72) + if (ne_mu < -72) { return 0; - else + } else { return 1 / sqrt(1 + exp(-ne_mu)); } +} template REAL Sto_Func::ncos(REAL rawe) @@ -174,11 +187,12 @@ template REAL Sto_Func::gauss(REAL e) { REAL a = pow((targ_e - e), 2) / 2.0 / pow(sigma, 2); - if (a > 72) + if (a > 72) { return 0; - else + } else { return exp(-a) / sqrt(TWOPI) / sigma; } +} template REAL Sto_Func::ngauss(REAL rawe) @@ -187,11 +201,12 @@ REAL Sto_Func::ngauss(REAL rawe) REAL DeltaE = (*Emax - *Emin) / 2; REAL e = rawe * DeltaE + Ebar; REAL a = pow((targ_e - e), 2) / 2.0 / pow(sigma, 2); - if (a > 72) + if (a > 72) { return 0; - else + } else { return exp(-a) / sqrt(TWOPI) / sigma; } +} template REAL Sto_Func::nroot_gauss(REAL rawe) @@ -200,11 +215,12 @@ REAL Sto_Func::nroot_gauss(REAL rawe) REAL DeltaE = (*Emax - *Emin) / 2; REAL e = rawe * DeltaE + Ebar; REAL a = pow((targ_e - e), 2) / 4.0 / pow(sigma, 2); - if (a > 72) + if (a > 72) { return 0; - else + } else { return exp(-a) / sqrt(sqrt(TWOPI) * sigma); } +} // we only have two examples: double and float. template class Sto_Func; diff --git a/source/module_hamilt_pw/hamilt_stodft/sto_iter.h b/source/module_hamilt_pw/hamilt_stodft/sto_iter.h index 76cff4a0d9..901b1311f3 100644 --- a/source/module_hamilt_pw/hamilt_stodft/sto_iter.h +++ b/source/module_hamilt_pw/hamilt_stodft/sto_iter.h @@ -121,15 +121,15 @@ class Stochastic_Iter double mu0; // chemical potential; unit in Ry bool change; - double targetne; + double targetne=0.0; Real* spolyv = nullptr; //[Device] coefficients of Chebyshev expansion Real* spolyv_cpu = nullptr; //[CPU] coefficients of Chebyshev expansion public: int* nchip = nullptr; bool check = false; - double th_ne; - double KS_ne; + double th_ne=0.0; + double KS_ne=0.0; public: int method; // different methods 1: slow, less memory 2: fast, more memory @@ -141,7 +141,7 @@ class Stochastic_Iter void calTnchi_ik(const int& ik, Stochastic_WF& stowf); private: - K_Vectors* pkv; + K_Vectors* pkv=nullptr; /** * @brief return cpu dot result * @param x [Device] diff --git a/source/module_hsolver/genelpa/elpa_new.cpp b/source/module_hsolver/genelpa/elpa_new.cpp index bcbf6e1ea6..c9475d2bdf 100644 --- a/source/module_hsolver/genelpa/elpa_new.cpp +++ b/source/module_hsolver/genelpa/elpa_new.cpp @@ -33,6 +33,10 @@ ELPA_Solver::ELPA_Solver(const bool isReal, this->nev = nev; this->narows = narows; this->nacols = nacols; + this->method = 0; + this->comm_f = 0; + this->mpi_comm_cols = 0; + this->mpi_comm_rows = 0; for (int i = 0; i < 9; ++i) this->desc[i] = desc[i]; cblacs_ctxt = desc[1]; @@ -111,6 +115,10 @@ ELPA_Solver::ELPA_Solver(const bool isReal, this->nev = nev; this->narows = narows; this->nacols = nacols; + this->method = 0; + this->comm_f = 0; + this->mpi_comm_cols = 0; + this->mpi_comm_rows = 0; for (int i = 0; i < 9; ++i) this->desc[i] = desc[i]; diff --git a/source/module_hsolver/module_pexsi/dist_ccs_matrix.h b/source/module_hsolver/module_pexsi/dist_ccs_matrix.h index a63a0dc16c..86bfddb966 100644 --- a/source/module_hsolver/module_pexsi/dist_ccs_matrix.h +++ b/source/module_hsolver/module_pexsi/dist_ccs_matrix.h @@ -65,8 +65,8 @@ class DistCCSMatrix MPI_Group group; // total number of processes and the processes with data in - int nprocs; - int nproc_data; + int nprocs = 0; + int nproc_data =0; MPI_Group group_data; MPI_Comm comm_data; @@ -83,7 +83,7 @@ class DistCCSMatrix int numColLocal; // the first column index in current process - int firstCol; + int firstCol=0; // Array stores the indices to the nonzero row indices in rowptrLocal and nzvalLocal int* colptrLocal; diff --git a/source/module_io/berryphase.h b/source/module_io/berryphase.h index 38029880f7..8c1285e37d 100644 --- a/source/module_io/berryphase.h +++ b/source/module_io/berryphase.h @@ -28,11 +28,11 @@ class berryphase const Parallel_Orbitals* paraV; #endif - int total_string; + int total_string=0; std::vector> k_index; - int nppstr; - int direction; - int occ_nbands; + int nppstr=0; + int direction=0; + int occ_nbands=0; int GDIR; void get_occupation_bands(); diff --git a/source/module_io/bessel_basis.h b/source/module_io/bessel_basis.h index 29207756c9..cf4c609b6e 100644 --- a/source/module_io/bessel_basis.h +++ b/source/module_io/bessel_basis.h @@ -71,24 +71,24 @@ class Bessel_Basis /// @brief get energy cutoff, which is used to truncate SBF Jlq. /// @param /// @return energy cutoff in Ry - const double &get_ecut(void) const {return ecut;} + const double &get_ecut() const {return ecut;} /// @brief cutoff radius of radial SBF Jlq. /// @param /// @return cutoff radius in a.u. - const double &get_rcut(void) const {return rcut;} + const double &get_rcut() const {return rcut;} - const double &get_tolerence(void) const {return tolerence;} + const double &get_tolerence() const {return tolerence;} /// @brief check if SBFs are smoothed (mohan add 2009-08-28) /// @attention in this case, the Jlq are not the true Jlq. /// @param /// @return boolean whether SBFs are smoothed - const bool &get_smooth(void) const {return smooth;} + const bool &get_smooth() const {return smooth;} /// @brief get sigma the stddev (standard deviation) used in smooth function (Gaussian function) /// @param /// @return stddev of smooth function - const double &get_sigma(void) const {return sigma;} + const double &get_sigma() const {return sigma;} private: /// @brief the most important array to calculate spillage, has dimension (ntype, lmax+1, max_n, nk) @@ -101,20 +101,20 @@ class Bessel_Basis ModuleBase::realArray TableOne; /// @brief mesh of k vector, k is in j_l(k*r) - int kmesh; + int kmesh=0; /// @brief grid of k double Dk; /// @brief number of q vector, q is in j_l(q*r) int Ecut_number; /// @brief Cutoff radius (in a.u.) of SBFs, for any SBF j_l(qr), r>=rcut, j_l(q*r) = 0 (if not smoothed) - double rcut; + double rcut=0.0; /// @brief energy cutoff for determining kmesh and number of SBFs - double ecut; - double tolerence; + double ecut=0.0; + double tolerence=0.0; /// @brief whether smooth SBFs around cutoff radius, resulting in non-zero values. For importance of smooth of SBFs, see J. Phys.: Condens. Matter 22 (2010) 445501, eqn 6. (mohan add 2009-01-18) - bool smooth; + bool smooth=false; /// @brief stddev of smooth function (Gaussian function, centered at rcut) - double sigma; + double sigma=0.0; /// @brief Allocate memory for C4 matrix and initialize all elements to one. /// @param ntype number of atom types @@ -146,7 +146,7 @@ class Bessel_Basis const UnitCell& ucell ); - void init_TableOne(void); + void init_TableOne(); /// @brief calculate F_{aln}(it, il, in, ik) = sum_{ie}{C4(it, il, in, ie)*TableOne(il, ie, ik)}, where TableOne is overlap integral between two spherical bessel functions (jle(r) and jlk(r)) /// @param ntype number of atomtype @@ -162,7 +162,7 @@ class Bessel_Basis ); /// @brief number of localized wave functions - int nwfc; + int nwfc=0; /// @brief calculate element value of TableOne matrix /// @details (be called in Bessel_Basis::init(), used for outputing overlap Q matrix) initialize the table whose matrix element is the result of integral int{dr r^2 jle(r)*jlk(r)}, TableOne has three subscript (l, ie, ik), the first runs over orbitals' angular momentum and ie, ik run over ecut_number and kmesh SBFs diff --git a/source/module_io/get_pchg_lcao.h b/source/module_io/get_pchg_lcao.h index 208c3f027c..99b4a38d7a 100644 --- a/source/module_io/get_pchg_lcao.h +++ b/source/module_io/get_pchg_lcao.h @@ -141,8 +141,8 @@ class IState_Charge #endif std::vector bands_picked_; - psi::Psi* psi_gamma; - psi::Psi>* psi_k; + psi::Psi* psi_gamma=nullptr; + psi::Psi>* psi_k=nullptr; const Parallel_Orbitals* ParaV; }; #endif diff --git a/source/module_io/input_conv.h b/source/module_io/input_conv.h index d4a9bf4f71..a756cc5499 100644 --- a/source/module_io/input_conv.h +++ b/source/module_io/input_conv.h @@ -101,7 +101,7 @@ void parse_expression(const std::string& fn, std::vector& vec) const size_t sub_nmatch = 1; if (regexec(&sub_reg, sub_str.c_str(), sub_nmatch, sub_pmatch, 0) == 0) { - int pos = sub_str.find("*"); + size_t pos = sub_str.find("*"); int num = stoi(sub_str.substr(0, pos)); T occ = stof(sub_str.substr(pos + 1, sub_str.size())); // std::vector ocp_temp(num, occ); diff --git a/source/module_io/json_output/json_node.h b/source/module_io/json_output/json_node.h index 3ac988e95f..f19bddcf78 100644 --- a/source/module_io/json_output/json_node.h +++ b/source/module_io/json_output/json_node.h @@ -12,7 +12,7 @@ namespace Json template jsonKeyNode(const char (&s)[N]): key(s) {}; - int i; + int i=0; std::string key; }; diff --git a/source/module_io/numerical_descriptor.cpp b/source/module_io/numerical_descriptor.cpp index aa879d40af..16236c63ea 100644 --- a/source/module_io/numerical_descriptor.cpp +++ b/source/module_io/numerical_descriptor.cpp @@ -13,6 +13,8 @@ Numerical_Descriptor::Numerical_Descriptor() this->init_label = false; this->lmax = -1; this->nmax = -1; + this->nlocal = 0; + this->mu_index = nullptr; } Numerical_Descriptor::~Numerical_Descriptor() diff --git a/source/module_io/to_wannier90.h b/source/module_io/to_wannier90.h index a004dfada6..4d93bcb2f9 100644 --- a/source/module_io/to_wannier90.h +++ b/source/module_io/to_wannier90.h @@ -48,15 +48,15 @@ class toWannier90 bool try_read_nnkp(const UnitCell& ucell, const K_Vectors& kv); // Parameters related to k point - int num_kpts; - int cal_num_kpts; + int num_kpts=0; + int cal_num_kpts=0; std::vector> nnlist; std::vector>> nncell; int nntot = 0; int start_k_index = 0; // Parameters related to trial orbitals - int num_wannier; // Number of Wannier orbits + int num_wannier=0; // Number of Wannier orbits ModuleBase::Vector3 *R_centre = nullptr; int *L = nullptr; int *m = nullptr; diff --git a/source/module_io/unk_overlap_lcao.h b/source/module_io/unk_overlap_lcao.h index c598a6b2a4..241ac3d775 100644 --- a/source/module_io/unk_overlap_lcao.h +++ b/source/module_io/unk_overlap_lcao.h @@ -29,9 +29,9 @@ class unkOverlap_lcao std::vector>> psi_psi; std::vector>>> psi_r_psi; bool allocate_flag; // translate: Used to initialize the array - int** cal_tag; // Used for parallel scheme + int** cal_tag=nullptr; // Used for parallel scheme - int kpoints_number; + int kpoints_number=0; std::vector rcut_orb_; // real space cutoffs of LCAO orbitals' radial functions diff --git a/source/module_md/fire.cpp b/source/module_md/fire.cpp index 98f294db19..bba8b3a150 100644 --- a/source/module_md/fire.cpp +++ b/source/module_md/fire.cpp @@ -18,6 +18,8 @@ FIRE::FIRE(const Parameter& param_in, UnitCell& unit_in) : MD_base(param_in, uni f_alpha = 0.99; n_min = 4; negative_count = 0; + max = 0.0; + force_thr = 1e-3; } FIRE::~FIRE() diff --git a/source/module_md/fire.h b/source/module_md/fire.h index 2528e44b20..d586f6399f 100644 --- a/source/module_md/fire.h +++ b/source/module_md/fire.h @@ -50,7 +50,7 @@ class FIRE : public MD_base int n_min; ///< n_min double dt_max; ///< dt_max int negative_count; ///< Negative count - double force_thr = 1.0e-3; ///< force convergence threshold in FIRE method + double force_thr; ///< force convergence threshold in FIRE method }; #endif diff --git a/source/module_md/md_base.h b/source/module_md/md_base.h index ca6eb0dcf7..c48afe10cc 100644 --- a/source/module_md/md_base.h +++ b/source/module_md/md_base.h @@ -82,13 +82,13 @@ class MD_base ModuleBase::Vector3* force; ///< force of each atom ModuleBase::matrix virial; ///< virial for this lattice ModuleBase::matrix stress; ///< stress for this lattice - double potential; ///< potential energy + double potential=0.0; ///< potential energy double kinetic; ///< kinetic energy protected: const MD_para& mdp; ///< input parameters used in md - UnitCell& ucell; ///< unitcell information - double energy_; ///< total energy of the system + UnitCell& ucell; ///< unitcell information + double energy_=0.0; ///< total energy of the system bool cal_stress; ///< whether calculate stress int my_rank; ///< MPI rank of the processor diff --git a/source/module_md/msst.cpp b/source/module_md/msst.cpp index faa9eada19..3ff8c7c6f9 100644 --- a/source/module_md/msst.cpp +++ b/source/module_md/msst.cpp @@ -22,7 +22,9 @@ MSST::MSST(const Parameter& param_in, UnitCell& unit_in) : MD_base(param_in, uni e0 = 0; v0 = 1; totmass = 0; - + lag_pos = 0; + vsum = 0; + for (int i = 0; i < ucell.nat; ++i) { totmass += allmass[i]; diff --git a/source/module_md/nhchain.h b/source/module_md/nhchain.h index b804d8784b..bdbcf08b2a 100644 --- a/source/module_md/nhchain.h +++ b/source/module_md/nhchain.h @@ -71,33 +71,33 @@ class Nose_Hoover : public MD_base const static int nys = 7; ///< the number of scale evolution operator double w[nys]; ///< scale evolution operator - int tdof; ///< particle degree of freedom - double t_target; ///< target temperature - double* mass_eta; ///< mass of thermostats coupled with particles - double* eta; ///< position of thermostats coupled with particles - double* v_eta; ///< velocity of thermostats coupled with particles - double* g_eta; ///< acceleration of thermostats coupled with particles + int tdof; ///< particle degree of freedom + double t_target=0.0;///< target temperature + double* mass_eta; ///< mass of thermostats coupled with particles + double* eta; ///< position of thermostats coupled with particles + double* v_eta; ///< velocity of thermostats coupled with particles + double* g_eta; ///< acceleration of thermostats coupled with particles - int npt_flag; ///< whether NPT ensemble - double mass_omega[6]; ///< mass of lattice component - double v_omega[6]; ///< velocity of lattice component - double pstart[6]; ///< initial stress components - double pstop[6]; ///< final stress components - double pfreq[6]; ///< Oscillation frequency, used to determine qmass of thermostats coupled with barostat - int pflag[6]; ///< control stress components - int pdim; ///< pdim = pflag[0] + pflag[1] + pflag[2], number of barostatted dims - double p_target[6]; ///< target stress components - double p_hydro; ///< target hydrostatic target pressure - double p_current[6]; ///< current stress after coupled - double* mass_peta; ///< mass of thermostats coupled with barostat - double* peta; ///< position of thermostats coupled with barostat - double* v_peta; ///< velocity of thermostats coupled with barostat - double* g_peta; ///< acceleration of thermostats coupled with barostat - double mtk_term; ///< mtk correction - double md_tfreq; ///< Oscillation frequency, used to determine qmass of thermostats coupled with particles - double md_pfirst; ///< Initial pressure - double md_plast; ///< Final pressure - double md_pfreq; ///< Oscillation frequency, used to determine qmass of thermostats coupled with barostat + int npt_flag; ///< whether NPT ensemble + double mass_omega[6]; ///< mass of lattice component + double v_omega[6]; ///< velocity of lattice component + double pstart[6]; ///< initial stress components + double pstop[6]; ///< final stress components + double pfreq[6]; ///< Oscillation frequency, used to determine qmass of thermostats coupled with barostat + int pflag[6]; ///< control stress components + int pdim; ///< pdim = pflag[0] + pflag[1] + pflag[2], number of barostatted dims + double p_target[6]; ///< target stress components + double p_hydro = 0.0; ///< target hydrostatic target pressure + double p_current[6] = {0.0}; ///< current stress after coupled + double* mass_peta; ///< mass of thermostats coupled with barostat + double* peta; ///< position of thermostats coupled with barostat + double* v_peta; ///< velocity of thermostats coupled with barostat + double* g_peta; ///< acceleration of thermostats coupled with barostat + double mtk_term=0; ///< mtk correction + double md_tfreq; ///< Oscillation frequency, used to determine qmass of thermostats coupled with particles + double md_pfirst; ///< Initial pressure + double md_plast; ///< Final pressure + double md_pfreq; ///< Oscillation frequency, used to determine qmass of thermostats coupled with barostat }; #endif \ No newline at end of file diff --git a/source/module_relax/relax_old/bfgs_basic.h b/source/module_relax/relax_old/bfgs_basic.h index 52227e7509..2e0a130a37 100644 --- a/source/module_relax/relax_old/bfgs_basic.h +++ b/source/module_relax/relax_old/bfgs_basic.h @@ -39,15 +39,15 @@ class BFGS_Basic static double relax_bfgs_w2; // fixed: parameters for Wolfe conditions. protected: - bool save_flag; - bool tr_min_hit; //.TRUE. if the trust_radius has already been set + bool save_flag=false; + bool tr_min_hit=false; //.TRUE. if the trust_radius has already been set // to the minimum value at the previous step // mohan add 2010-07-27 double check_move(const double& lat0, const double& pos, const double& pos_p); private: - bool wolfe_flag; + bool wolfe_flag=false; ModuleBase::matrix inv_hess; int bfgs_ndim; diff --git a/source/module_relax/relax_old/ions_move_cg.h b/source/module_relax/relax_old/ions_move_cg.h index cf61e5c2dc..59ed3b63c1 100644 --- a/source/module_relax/relax_old/ions_move_cg.h +++ b/source/module_relax/relax_old/ions_move_cg.h @@ -13,15 +13,15 @@ class Ions_Move_CG void start(UnitCell &ucell, const ModuleBase::matrix &force, const double &etot); static double RELAX_CG_THR; - int sd_step; - int cg_step; + int sd_step=0; + int cg_step=0; private: double *pos0; double *grad0; double *cg_grad0; double *move0; - double e0; + double e0=0.0; // setup gradients. void setup_cg_grad(double *grad, const double *grad0, diff --git a/source/module_relax/relax_old/lattice_change_cg.h b/source/module_relax/relax_old/lattice_change_cg.h index 74a78af080..bbaa012919 100644 --- a/source/module_relax/relax_old/lattice_change_cg.h +++ b/source/module_relax/relax_old/lattice_change_cg.h @@ -18,7 +18,7 @@ class Lattice_Change_CG double *grad0; double *cg_grad0; double *move0; - double e0; + double e0=0.0; // setup gradients. void setup_cg_grad(double *grad,