Skip to content

Commit

Permalink
Refactor: remove lcao_fun.cpp (#5481)
Browse files Browse the repository at this point in the history
* Refactor: remove lcao_fun.cpp

* use original format
  • Loading branch information
YuLiu98 authored Nov 14, 2024
1 parent d3aa439 commit b0503e4
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 251 deletions.
1 change: 0 additions & 1 deletion source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ OBJS_ESOLVER_LCAO=esolver_ks_lcao.o\
lcao_gets.o\
lcao_others.o\
lcao_init_after_vc.o\
lcao_fun.o\

OBJS_GINT=gint.o\
gint_gamma_env.o\
Expand Down
1 change: 0 additions & 1 deletion source/module_esolver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ if(ENABLE_LCAO)
lcao_gets.cpp
lcao_others.cpp
lcao_init_after_vc.cpp
lcao_fun.cpp
)
endif()

Expand Down
22 changes: 18 additions & 4 deletions source/module_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "module_io/nscf_band.h"
#include "module_io/output_dmk.h"
#include "module_io/output_log.h"
#include "module_io/output_mat_sparse.h"
#include "module_io/output_mulliken.h"
#include "module_io/output_sk.h"
#include "module_io/to_qo.h"
Expand Down Expand Up @@ -1132,14 +1133,27 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
}
}

// 14) write md related
if (!md_skip_out(PARAM.inp.calculation, istep, PARAM.inp.out_interval))
// 14) output sparse matrix
if (PARAM.inp.calculation != "md" || istep % PARAM.inp.out_interval == 0)
{
this->create_Output_Mat_Sparse(istep).write();
ModuleIO::output_mat_sparse(PARAM.inp.out_mat_hs2,
PARAM.inp.out_mat_dh,
PARAM.inp.out_mat_t,
PARAM.inp.out_mat_r,
istep,
this->pelec->pot->get_effective_v(),
this->pv,
this->GK, // mohan add 2024-04-01
two_center_bundle_,
orb_,
GlobalC::ucell,
GlobalC::GridD, // mohan add 2024-04-06
this->kv,
this->p_hamilt);
// mulliken charge analysis
if (PARAM.inp.out_mul)
{
this->cal_mag(istep, true);
ModuleIO::cal_mag(&(this->pv), this->p_hamilt, this->kv, this->pelec, GlobalC::ucell, istep, true);
}
}

Expand Down
11 changes: 1 addition & 10 deletions source/module_esolver/esolver_ks_lcao.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ class ESolver_KS_LCAO : public ESolver_KS<TK> {

void get_S();

void cal_mag(const int istep, const bool print = false);

protected:
virtual void before_scf(const int istep) override;

Expand Down Expand Up @@ -89,14 +87,7 @@ class ESolver_KS_LCAO : public ESolver_KS<TK> {
void set_matrix_grid(Record_adj& ra);

void beforesolver(const int istep);
//----------------------------------------------------------------------

/// @brief create ModuleIO::Output_Mat_Sparse object to output sparse
/// density matrix of H, S, T, r
ModuleIO::Output_Mat_Sparse<TK> create_Output_Mat_Sparse(int istep);

/// @brief check if skip the corresponding output in md calculation
bool md_skip_out(std::string calculation, int istep, int interval);
//---------------------------------------------------------------------

#ifdef __EXX
std::shared_ptr<Exx_LRI_Interface<TK, double>> exd = nullptr;
Expand Down
129 changes: 0 additions & 129 deletions source/module_esolver/lcao_fun.cpp

This file was deleted.

100 changes: 48 additions & 52 deletions source/module_io/output_mat_sparse.cpp
Original file line number Diff line number Diff line change
@@ -1,93 +1,89 @@
#include "output_mat_sparse.h"

#include "cal_r_overlap_R.h"
#include "module_hamilt_pw/hamilt_pwdft/global.h" // for ucell
#include "write_HS_R.h"
#include "module_io/cal_r_overlap_R.h"
#include "module_io/write_HS_R.h"

namespace ModuleIO
{

template <typename T>
Output_Mat_Sparse<T>::Output_Mat_Sparse(int out_mat_hsR,
int out_mat_dh,
int out_mat_t,
int out_mat_r,
int istep,
const ModuleBase::matrix& v_eff,
const Parallel_Orbitals& pv,
Gint_k& gint_k, // mohan add 2024-04-01
const TwoCenterBundle& two_center_bundle,
const LCAO_Orbitals& orb,
Grid_Driver& grid, // mohan add 2024-04-06
const K_Vectors& kv,
hamilt::Hamilt<T>* p_ham)
: _out_mat_hsR(out_mat_hsR), _out_mat_dh(out_mat_dh), _out_mat_t(out_mat_t), _out_mat_r(out_mat_r), _istep(istep),
_v_eff(v_eff), _pv(pv), orb_(orb), _gint_k(gint_k), // mohan add 2024-04-01
two_center_bundle_(two_center_bundle), _grid(grid), // mohan add 2024-04-06
_kv(kv), _p_ham(p_ham) {}

template <>
void Output_Mat_Sparse<double>::write()
void output_mat_sparse(const bool& out_mat_hsR,
const bool& out_mat_dh,
const bool& out_mat_t,
const bool& out_mat_r,
const int& istep,
const ModuleBase::matrix& v_eff,
const Parallel_Orbitals& pv,
Gint_k& gint_k,
const TwoCenterBundle& two_center_bundle,
const LCAO_Orbitals& orb,
UnitCell& ucell,
Grid_Driver& grid,
const K_Vectors& kv,
hamilt::Hamilt<double>* p_ham)
{
}

template <>
void Output_Mat_Sparse<std::complex<double>>::write()
void output_mat_sparse(const bool& out_mat_hsR,
const bool& out_mat_dh,
const bool& out_mat_t,
const bool& out_mat_r,
const int& istep,
const ModuleBase::matrix& v_eff,
const Parallel_Orbitals& pv,
Gint_k& gint_k,
const TwoCenterBundle& two_center_bundle,
const LCAO_Orbitals& orb,
UnitCell& ucell,
Grid_Driver& grid,
const K_Vectors& kv,
hamilt::Hamilt<std::complex<double>>* p_ham)
{
LCAO_HS_Arrays HS_Arrays; // store sparse arrays

//! generate a file containing the Hamiltonian and S(overlap) matrices
if (_out_mat_hsR)
if (out_mat_hsR)
{
output_HSR(_istep, this->_v_eff, this->_pv, HS_Arrays, this->_grid, _kv, _p_ham);
output_HSR(istep, v_eff, pv, HS_Arrays, grid, kv, p_ham);
}

//! generate a file containing the kinetic energy matrix
if (_out_mat_t)
if (out_mat_t)
{
output_TR(_istep,
GlobalC::ucell,
this->_pv,
HS_Arrays,
this->_grid,
two_center_bundle_,
orb_
); // LiuXh add 2019-07-15
output_TR(istep, ucell, pv, HS_Arrays, grid, two_center_bundle, orb);
}

//! generate a file containing the derivatives of the Hamiltonian matrix (in Ry/Bohr)
if (_out_mat_dh)
if (out_mat_dh)
{
output_dHR(_istep,
this->_v_eff,
this->_gint_k, // mohan add 2024-04-01
this->_pv,
output_dHR(istep,
v_eff,
gint_k, // mohan add 2024-04-01
pv,
HS_Arrays,
this->_grid, // mohan add 2024-04-06
two_center_bundle_,
orb_,
_kv); // LiuXh add 2019-07-15
grid, // mohan add 2024-04-06
two_center_bundle,
orb,
kv); // LiuXh add 2019-07-15
}

// add by jingan for out r_R matrix 2019.8.14
if (_out_mat_r)
if (out_mat_r)
{
cal_r_overlap_R r_matrix;
r_matrix.init(this->_pv, orb_);
if (_out_mat_hsR)
r_matrix.init(pv, orb);
if (out_mat_hsR)
{
r_matrix.out_rR_other(_istep, HS_Arrays.output_R_coor);
r_matrix.out_rR_other(istep, HS_Arrays.output_R_coor);
}
else
{
r_matrix.out_rR(_istep);
r_matrix.out_rR(istep);
}
}

return;
}

template class Output_Mat_Sparse<double>;
template class Output_Mat_Sparse<std::complex<double>>;

} // namespace ModuleIO
Loading

0 comments on commit b0503e4

Please sign in to comment.