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
29 changes: 0 additions & 29 deletions source/source_base/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,35 +323,6 @@ double matrix::trace_on(void) const
return tr;
}

//this function is wrong, and there is no file use this function.
// void matrix::get_extreme_eigen_values(double &ev_lower, double &ev_upper)const
// {
// double *a = new double[nr];
// double *b = new double[nr];
// for (int i = 0; i < nr; ++i)
// {
// double sum = 0.0;
// for(int j = 0; j < nc; ++j)
// {
// sum += fabs(c[i * nc + j]);
// }
// sum -= fabs(c[i * nc + i]);
// a[i] = c[i * nc + i] - sum;
// b[i] = c[i * nc + i] + sum;
// }

// ev_lower = a[0];
// ev_upper = b[0];

// for (int i = 1; i < nr; ++i)
// {
// if (a[i] < ev_lower) ev_lower = a[i];
// if (b[i] > ev_upper) ev_upper = b[i];
// }
// delete[] a;
// delete[] b;
// }

// Peize Lin add 2017-05-27
void matrix::reshape( const int nr_new, const int nc_new, const bool flag_zero )
{
Expand Down
4 changes: 2 additions & 2 deletions source/source_base/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <ostream>
#include<cassert>

#include<fstream>// test
#include <fstream> // test

namespace ModuleBase
{
Expand Down Expand Up @@ -80,7 +80,7 @@ class matrix

std::ostream & print( std::ostream & os, const double threshold=0.0 ) const; // Peize Lin add 2021.09.08

using type=double; // Peiae Lin add 2022.08.08 for template
using type=double; // Peize Lin add 2022.08.08 for template
};


Expand Down
41 changes: 20 additions & 21 deletions source/source_cell/cell_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "source_base/name_angular.h"
#include "source_base/tool_quit.h"
#include <stdexcept>

CellIndex::CellIndex(const std::vector<std::string>& atomLabels_in,
const std::vector<int>& atomCounts_in,
Expand All @@ -18,12 +17,12 @@ CellIndex::CellIndex(const std::vector<std::string>& atomLabels_in,
this->cal_orbitalCounts();
}

int CellIndex::get_ntype()
int CellIndex::get_ntype() const
{
return this->atomCounts.size();
}

int CellIndex::get_nat()
int CellIndex::get_nat() const
{
int nat = 0;
for (int it = 0; it < this->atomCounts.size(); ++it)
Expand All @@ -33,12 +32,12 @@ int CellIndex::get_nat()
return nat;
}

int CellIndex::get_nat(int it)
int CellIndex::get_nat(int it) const
{
return this->atomCounts[it];
}

int CellIndex::get_nw()
int CellIndex::get_nw() const
{
int nw = 0;
for (int it = 0; it < this->orbitalCounts.size(); ++it)
Expand All @@ -48,13 +47,13 @@ int CellIndex::get_nw()
return nw;
}

int CellIndex::get_nw(int iat)
int CellIndex::get_nw(int iat) const
{
int it = this->iat2it(iat);
return this->orbitalCounts[it];
}

int CellIndex::get_iwt(int iat, int orbital_index)
int CellIndex::get_iwt(int iat, int orbital_index) const
{
if (iat < 0 || iat >= this->get_nat())
{
Expand Down Expand Up @@ -83,14 +82,14 @@ int CellIndex::get_iwt(int iat, int orbital_index)
return iwt;
}

int CellIndex::get_maxL(int iat)
int CellIndex::get_maxL(int iat) const
{
int it = this->iat2it(iat);
return this->lnchiCounts[it].size() - 1;
}

/// @brief get nchi
int CellIndex::get_nchi(int iat, int L)
int CellIndex::get_nchi(int iat, int L) const
{
int it = this->iat2it(iat);
if (L < 0 || L >= this->lnchiCounts[it].size())
Expand Down Expand Up @@ -119,7 +118,7 @@ void CellIndex::check_atomCounts()
}
}

std::string CellIndex::get_atom_label(int iat, bool order)
std::string CellIndex::get_atom_label(int iat, bool order) const
{
int it = this->iat2it(iat);
int ia = this->iat2ia(iat);
Expand All @@ -129,7 +128,7 @@ std::string CellIndex::get_atom_label(int iat, bool order)
return atomType;
}

int CellIndex::iat2it(int iat)
int CellIndex::iat2it(int iat) const
{
int running_iat = 0;
int it = -1; // Tracks the index of the atom in atomLabels
Expand All @@ -151,7 +150,7 @@ int CellIndex::iat2it(int iat)
return it;
}

int CellIndex::iat2ia(int iat)
int CellIndex::iat2ia(int iat) const
{
int it = this->iat2it(iat);
// sum of atoms of previous types
Expand All @@ -163,7 +162,7 @@ int CellIndex::iat2ia(int iat)
return iat - running_iat;
}

int CellIndex::iw2l(int iat, int iw)
int CellIndex::iw2l(int iat, int iw) const
{
int it = this->iat2it(iat);
int maxL = this->lnchiCounts[it].size() - 1;
Expand All @@ -185,10 +184,10 @@ int CellIndex::iw2l(int iat, int iw)
{
ModuleBase::WARNING_QUIT("CellIndex::iw2l", "localized wave funciton index out of range [0, nw)");
}
throw std::out_of_range(std::string(__FILE__)+" line "+std::to_string(__LINE__));
ModuleBase::WARNING_QUIT("CellIndex::iw2l", "unreachable code reached");
}

int CellIndex::iw2z(int iat, int iw)
int CellIndex::iw2z(int iat, int iw) const
{
int it = this->iat2it(iat);
int maxL = this->lnchiCounts[it].size() - 1;
Expand All @@ -208,12 +207,12 @@ int CellIndex::iw2z(int iat, int iw)
}
if (iw >= 0)
{
ModuleBase::WARNING_QUIT("CellIndex::iw2l", "localized wave funciton index out of range [0, nw)");
ModuleBase::WARNING_QUIT("CellIndex::iw2z", "localized wave funciton index out of range [0, nw)");
}
throw std::out_of_range(std::string(__FILE__)+" line "+std::to_string(__LINE__));
ModuleBase::WARNING_QUIT("CellIndex::iw2z", "unreachable code reached");
}

int CellIndex::iw2m(int iat, int iw)
int CellIndex::iw2m(int iat, int iw) const
{
int it = this->iat2it(iat);
int maxL = this->lnchiCounts[it].size() - 1;
Expand All @@ -233,9 +232,9 @@ int CellIndex::iw2m(int iat, int iw)
}
if (iw >= 0)
{
ModuleBase::WARNING_QUIT("CellIndex::iw2l", "localized wave funciton index out of range [0, nw)");
ModuleBase::WARNING_QUIT("CellIndex::iw2m", "localized wave funciton index out of range [0, nw)");
}
throw std::out_of_range(std::string(__FILE__)+" line "+std::to_string(__LINE__));
ModuleBase::WARNING_QUIT("CellIndex::iw2m", "unreachable code reached");
}

bool CellIndex::check_nspin(int nspin)
Expand All @@ -262,7 +261,7 @@ void CellIndex::cal_orbitalCounts()
}
}

void CellIndex::write_orb_info(std::string out_dir)
void CellIndex::write_orb_info(const std::string& out_dir) const
{
std::stringstream os;
os << out_dir << "Orbital";
Expand Down
30 changes: 15 additions & 15 deletions source/source_cell/cell_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@ class CellIndex

public:
/// @brief the total number of atoms
int get_nat();
int get_nat() const;
/// @brief the total number of atoms of a given type
int get_nat(int it);
int get_nat(int it) const;
/// @brief get ntype
int get_ntype();
int get_ntype() const;
/// @brief get nw
int get_nw();
int get_nw() const;
/// @brief get nw of a given type
int get_nw(int iat);
int get_nw(int iat) const;
/// @brief get iwt
int get_iwt(int iat, int orbital_index);
int get_iwt(int iat, int orbital_index) const;
/// @brief get maximum L of a given atom
int get_maxL(int iat);
int get_maxL(int iat) const;
/// @brief get nchi of a given atom and a give L
int get_nchi(int iat, int L);
int get_nchi(int iat, int L) const;
/// @brief get atom label of a given atom
std::string get_atom_label(int iat, bool order = false);
std::string get_atom_label(int iat, bool order = false) const;
/// @brief write orbital info into file
void write_orb_info(std::string out_dir);
void write_orb_info(const std::string& out_dir) const;

private:
/// atomCounts is a vector used to store the number of atoms for each type
Expand All @@ -66,15 +66,15 @@ class CellIndex
/// check if atomCounts is set ok
void check_atomCounts();
/// get type of atom from total order
int iat2it(int iat);
int iat2it(int iat) const;
/// get index of atom in the same type
int iat2ia(int iat);
int iat2ia(int iat) const;
/// get L from iw
int iw2l(int iat, int iw);
int iw2l(int iat, int iw) const;
/// get Z from iw
int iw2z(int iat, int iw);
int iw2z(int iat, int iw) const;
/// get m from iw
int iw2m(int iat, int iw);
int iw2m(int iat, int iw) const;
};

#endif // CELL_INDEX_H
3 changes: 2 additions & 1 deletion source/source_estate/module_dm/density_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "source_base/memory.h"
#include "source_base/timer.h"
#include "source_base/tool_title.h"
#include "source_base/tool_quit.h"
#include "source_base/constants.h"
#include "source_cell/klist.h"

Expand Down Expand Up @@ -612,7 +613,7 @@ void DensityMatrix<TK, TR>::switch_dmr(const int mode)
}
break;
default:
throw std::string("Unknown mode in switch_dmr");
ModuleBase::WARNING_QUIT("density_matrix.cpp", "Unknown mode in switch_dmr");
}
ModuleBase::timer::tick("DensityMatrix", "switch_dmr");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace ModuleSymmetry
{
std::string mat3_fmt(const ModuleBase::Matrix3& m)
{
auto s = [](auto x) { return std::to_string(x); };
auto s = [](double x) { return std::to_string(x); };
return s(m.e11) + " " + s(m.e12) + " " + s(m.e13) + "\n" +
s(m.e21) + " " + s(m.e22) + " " + s(m.e23) + "\n" +
s(m.e31) + " " + s(m.e32) + " " + s(m.e33);
Expand Down
2 changes: 1 addition & 1 deletion source/source_md/md_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void MD_base::setup(ModuleESolver::ESolver* p_esolver, const std::string& global

// mohan add 2026-01-04
const int stress_step = 0;
const int force_step = 0;
const int force_step = 0;
const int istep_print = step_ + step_rst_ + 1;

ModuleIO::print_screen(stress_step, force_step, istep_print);
Expand Down
24 changes: 12 additions & 12 deletions source/source_md/md_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,18 @@ void init_vel(const UnitCell& unit_in,
ModuleBase::Vector3<int> frozen;
get_mass_mbl(unit_in, allmass, frozen, ionmbl);
frozen_freedom = frozen.x + frozen.y + frozen.z;
if (frozen.x == 0)
{
++frozen_freedom;
}
if (frozen.y == 0)
{
++frozen_freedom;
}
if (frozen.z == 0)
{
++frozen_freedom;
}
if (frozen.x == 0)
{
++frozen_freedom;
}
if (frozen.y == 0)
{
++frozen_freedom;
}
if (frozen.z == 0)
{
++frozen_freedom;
}

if (unit_in.init_vel)
{
Expand Down
4 changes: 2 additions & 2 deletions source/source_md/run_md.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void md_line(UnitCell& unit_in, ModuleESolver::ESolver* p_esolver, const Paramet
}
else
{
// mohan add 2026-01-04
const int stress_step = 0;
// mohan add 2026-01-04
const int stress_step = 0;
const int force_step = 0;
const int istep_print = mdrun->step_ + mdrun->step_rst_ + 1;
ModuleIO::print_screen(stress_step, force_step, istep_print);
Expand Down
Loading