Skip to content

Commit b0503e4

Browse files
authored
Refactor: remove lcao_fun.cpp (#5481)
* Refactor: remove lcao_fun.cpp * use original format
1 parent d3aa439 commit b0503e4

File tree

8 files changed

+115
-251
lines changed

8 files changed

+115
-251
lines changed

source/Makefile.Objects

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ OBJS_ESOLVER_LCAO=esolver_ks_lcao.o\
259259
lcao_gets.o\
260260
lcao_others.o\
261261
lcao_init_after_vc.o\
262-
lcao_fun.o\
263262

264263
OBJS_GINT=gint.o\
265264
gint_gamma_env.o\

source/module_esolver/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ if(ENABLE_LCAO)
2525
lcao_gets.cpp
2626
lcao_others.cpp
2727
lcao_init_after_vc.cpp
28-
lcao_fun.cpp
2928
)
3029
endif()
3130

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "module_io/nscf_band.h"
1414
#include "module_io/output_dmk.h"
1515
#include "module_io/output_log.h"
16+
#include "module_io/output_mat_sparse.h"
1617
#include "module_io/output_mulliken.h"
1718
#include "module_io/output_sk.h"
1819
#include "module_io/to_qo.h"
@@ -1132,14 +1133,27 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
11321133
}
11331134
}
11341135

1135-
// 14) write md related
1136-
if (!md_skip_out(PARAM.inp.calculation, istep, PARAM.inp.out_interval))
1136+
// 14) output sparse matrix
1137+
if (PARAM.inp.calculation != "md" || istep % PARAM.inp.out_interval == 0)
11371138
{
1138-
this->create_Output_Mat_Sparse(istep).write();
1139+
ModuleIO::output_mat_sparse(PARAM.inp.out_mat_hs2,
1140+
PARAM.inp.out_mat_dh,
1141+
PARAM.inp.out_mat_t,
1142+
PARAM.inp.out_mat_r,
1143+
istep,
1144+
this->pelec->pot->get_effective_v(),
1145+
this->pv,
1146+
this->GK, // mohan add 2024-04-01
1147+
two_center_bundle_,
1148+
orb_,
1149+
GlobalC::ucell,
1150+
GlobalC::GridD, // mohan add 2024-04-06
1151+
this->kv,
1152+
this->p_hamilt);
11391153
// mulliken charge analysis
11401154
if (PARAM.inp.out_mul)
11411155
{
1142-
this->cal_mag(istep, true);
1156+
ModuleIO::cal_mag(&(this->pv), this->p_hamilt, this->kv, this->pelec, GlobalC::ucell, istep, true);
11431157
}
11441158
}
11451159

source/module_esolver/esolver_ks_lcao.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ class ESolver_KS_LCAO : public ESolver_KS<TK> {
4141

4242
void get_S();
4343

44-
void cal_mag(const int istep, const bool print = false);
45-
4644
protected:
4745
virtual void before_scf(const int istep) override;
4846

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

9189
void beforesolver(const int istep);
92-
//----------------------------------------------------------------------
93-
94-
/// @brief create ModuleIO::Output_Mat_Sparse object to output sparse
95-
/// density matrix of H, S, T, r
96-
ModuleIO::Output_Mat_Sparse<TK> create_Output_Mat_Sparse(int istep);
97-
98-
/// @brief check if skip the corresponding output in md calculation
99-
bool md_skip_out(std::string calculation, int istep, int interval);
90+
//---------------------------------------------------------------------
10091

10192
#ifdef __EXX
10293
std::shared_ptr<Exx_LRI_Interface<TK, double>> exd = nullptr;

source/module_esolver/lcao_fun.cpp

Lines changed: 0 additions & 129 deletions
This file was deleted.
Lines changed: 48 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,89 @@
11
#include "output_mat_sparse.h"
22

3-
#include "cal_r_overlap_R.h"
4-
#include "module_hamilt_pw/hamilt_pwdft/global.h" // for ucell
5-
#include "write_HS_R.h"
3+
#include "module_io/cal_r_overlap_R.h"
4+
#include "module_io/write_HS_R.h"
65

76
namespace ModuleIO
87
{
98

10-
template <typename T>
11-
Output_Mat_Sparse<T>::Output_Mat_Sparse(int out_mat_hsR,
12-
int out_mat_dh,
13-
int out_mat_t,
14-
int out_mat_r,
15-
int istep,
16-
const ModuleBase::matrix& v_eff,
17-
const Parallel_Orbitals& pv,
18-
Gint_k& gint_k, // mohan add 2024-04-01
19-
const TwoCenterBundle& two_center_bundle,
20-
const LCAO_Orbitals& orb,
21-
Grid_Driver& grid, // mohan add 2024-04-06
22-
const K_Vectors& kv,
23-
hamilt::Hamilt<T>* p_ham)
24-
: _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),
25-
_v_eff(v_eff), _pv(pv), orb_(orb), _gint_k(gint_k), // mohan add 2024-04-01
26-
two_center_bundle_(two_center_bundle), _grid(grid), // mohan add 2024-04-06
27-
_kv(kv), _p_ham(p_ham) {}
28-
299
template <>
30-
void Output_Mat_Sparse<double>::write()
10+
void output_mat_sparse(const bool& out_mat_hsR,
11+
const bool& out_mat_dh,
12+
const bool& out_mat_t,
13+
const bool& out_mat_r,
14+
const int& istep,
15+
const ModuleBase::matrix& v_eff,
16+
const Parallel_Orbitals& pv,
17+
Gint_k& gint_k,
18+
const TwoCenterBundle& two_center_bundle,
19+
const LCAO_Orbitals& orb,
20+
UnitCell& ucell,
21+
Grid_Driver& grid,
22+
const K_Vectors& kv,
23+
hamilt::Hamilt<double>* p_ham)
3124
{
3225
}
3326

3427
template <>
35-
void Output_Mat_Sparse<std::complex<double>>::write()
28+
void output_mat_sparse(const bool& out_mat_hsR,
29+
const bool& out_mat_dh,
30+
const bool& out_mat_t,
31+
const bool& out_mat_r,
32+
const int& istep,
33+
const ModuleBase::matrix& v_eff,
34+
const Parallel_Orbitals& pv,
35+
Gint_k& gint_k,
36+
const TwoCenterBundle& two_center_bundle,
37+
const LCAO_Orbitals& orb,
38+
UnitCell& ucell,
39+
Grid_Driver& grid,
40+
const K_Vectors& kv,
41+
hamilt::Hamilt<std::complex<double>>* p_ham)
3642
{
3743
LCAO_HS_Arrays HS_Arrays; // store sparse arrays
3844

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

4551
//! generate a file containing the kinetic energy matrix
46-
if (_out_mat_t)
52+
if (out_mat_t)
4753
{
48-
output_TR(_istep,
49-
GlobalC::ucell,
50-
this->_pv,
51-
HS_Arrays,
52-
this->_grid,
53-
two_center_bundle_,
54-
orb_
55-
); // LiuXh add 2019-07-15
54+
output_TR(istep, ucell, pv, HS_Arrays, grid, two_center_bundle, orb);
5655
}
5756

5857
//! generate a file containing the derivatives of the Hamiltonian matrix (in Ry/Bohr)
59-
if (_out_mat_dh)
58+
if (out_mat_dh)
6059
{
61-
output_dHR(_istep,
62-
this->_v_eff,
63-
this->_gint_k, // mohan add 2024-04-01
64-
this->_pv,
60+
output_dHR(istep,
61+
v_eff,
62+
gint_k, // mohan add 2024-04-01
63+
pv,
6564
HS_Arrays,
66-
this->_grid, // mohan add 2024-04-06
67-
two_center_bundle_,
68-
orb_,
69-
_kv); // LiuXh add 2019-07-15
65+
grid, // mohan add 2024-04-06
66+
two_center_bundle,
67+
orb,
68+
kv); // LiuXh add 2019-07-15
7069
}
7170

7271
// add by jingan for out r_R matrix 2019.8.14
73-
if (_out_mat_r)
72+
if (out_mat_r)
7473
{
7574
cal_r_overlap_R r_matrix;
76-
r_matrix.init(this->_pv, orb_);
77-
if (_out_mat_hsR)
75+
r_matrix.init(pv, orb);
76+
if (out_mat_hsR)
7877
{
79-
r_matrix.out_rR_other(_istep, HS_Arrays.output_R_coor);
78+
r_matrix.out_rR_other(istep, HS_Arrays.output_R_coor);
8079
}
8180
else
8281
{
83-
r_matrix.out_rR(_istep);
82+
r_matrix.out_rR(istep);
8483
}
8584
}
8685

8786
return;
8887
}
8988

90-
template class Output_Mat_Sparse<double>;
91-
template class Output_Mat_Sparse<std::complex<double>>;
92-
9389
} // namespace ModuleIO

0 commit comments

Comments
 (0)