Skip to content

Commit

Permalink
Refactor: move io_npz to ModuleIO (#5475)
Browse files Browse the repository at this point in the history
  • Loading branch information
YuLiu98 authored Nov 13, 2024
1 parent 3354927 commit dcff74d
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 131 deletions.
2 changes: 1 addition & 1 deletion source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ OBJS_ESOLVER_LCAO=esolver_ks_lcao.o\
esolver_ks_lcao_tddft.o\
dpks_cal_e_delta_band.o\
dftu_cal_occup_m.o\
io_npz.o\
set_matrix_grid.o\
lcao_before_scf.o\
lcao_gets.o\
Expand Down Expand Up @@ -557,6 +556,7 @@ OBJS_IO_LCAO=cal_r_overlap_R.o\
output_mulliken.o\
output_sk.o\
output_dmk.o\
io_npz.o\

OBJS_LCAO=evolve_elec.o\
evolve_psi.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 @@ -19,7 +19,6 @@ if(ENABLE_LCAO)
esolver_ks_lcao.cpp
esolver_ks_lcao_tddft.cpp
dpks_cal_e_delta_band.cpp
io_npz.cpp
set_matrix_grid.cpp
dftu_cal_occup_m.cpp
lcao_before_scf.cpp
Expand Down
18 changes: 9 additions & 9 deletions source/module_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
#include "module_base/global_variable.h"
#include "module_base/tool_title.h"
#include "module_elecstate/module_dm/cal_dm_psi.h"
#include "module_hamilt_lcao/module_deltaspin/spin_constrain.h"
#include "module_io/berryphase.h"
#include "module_io/cube_io.h"
#include "module_io/dos_nao.h"
#include "module_io/io_dmk.h"
#include "module_io/io_npz.h"
#include "module_io/nscf_band.h"
#include "module_io/output_dmk.h"
#include "module_io/output_log.h"
Expand All @@ -16,11 +19,13 @@
#include "module_io/to_wannier90_lcao.h"
#include "module_io/to_wannier90_lcao_in_pw.h"
#include "module_io/write_HS.h"
#include "module_io/write_dmr.h"
#include "module_io/write_eband_terms.hpp"
#include "module_io/write_elecstat_pot.h"
#include "module_io/write_istate_info.h"
#include "module_io/write_proj_band_lcao.h"
#include "module_io/write_vxc.hpp"
#include "module_io/write_wfc_nao.h"
#include "module_parameter/parameter.h"

//--------------temporary----------------------------
Expand Down Expand Up @@ -55,11 +60,6 @@
// #include "module_elecstate/cal_dm.h"
//---------------------------------------------------

#include "module_hamilt_lcao/module_deltaspin/spin_constrain.h"
#include "module_io/io_dmk.h"
#include "module_io/write_dmr.h"
#include "module_io/write_wfc_nao.h"

namespace ModuleESolver
{

Expand Down Expand Up @@ -1105,15 +1105,15 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
hamilt::HamiltLCAO<std::complex<double>, double>* p_ham_lcao
= dynamic_cast<hamilt::HamiltLCAO<std::complex<double>, double>*>(this->p_hamilt);
std::string zipname = "output_HR0.npz";
this->output_mat_npz(zipname, *(p_ham_lcao->getHR()));
ModuleIO::output_mat_npz(GlobalC::ucell, zipname, *(p_ham_lcao->getHR()));

if (PARAM.inp.nspin == 2)
{
this->p_hamilt->updateHk(this->kv.get_nks() / 2); // the other half of k points, down spin
hamilt::HamiltLCAO<std::complex<double>, double>* p_ham_lcao
= dynamic_cast<hamilt::HamiltLCAO<std::complex<double>, double>*>(this->p_hamilt);
zipname = "output_HR1.npz";
this->output_mat_npz(zipname, *(p_ham_lcao->getHR()));
ModuleIO::output_mat_npz(GlobalC::ucell, zipname, *(p_ham_lcao->getHR()));
}
}

Expand All @@ -1123,12 +1123,12 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
const elecstate::DensityMatrix<TK, double>* dm
= dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM();
std::string zipname = "output_DM0.npz";
this->output_mat_npz(zipname, *(dm->get_DMR_pointer(1)));
ModuleIO::output_mat_npz(GlobalC::ucell, zipname, *(dm->get_DMR_pointer(1)));

if (PARAM.inp.nspin == 2)
{
zipname = "output_DM1.npz";
this->output_mat_npz(zipname, *(dm->get_DMR_pointer(2)));
ModuleIO::output_mat_npz(GlobalC::ucell, zipname, *(dm->get_DMR_pointer(2)));
}
}

Expand Down
4 changes: 0 additions & 4 deletions source/module_esolver/esolver_ks_lcao.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ class ESolver_KS_LCAO : public ESolver_KS<TK> {
/// density matrix of H, S, T, r
ModuleIO::Output_Mat_Sparse<TK> create_Output_Mat_Sparse(int istep);

void read_mat_npz(std::string& zipname, hamilt::HContainer<double>& hR);
void output_mat_npz(std::string& zipname,
const hamilt::HContainer<double>& hR);

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

Expand Down
5 changes: 3 additions & 2 deletions source/module_esolver/lcao_before_scf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "module_io/berryphase.h"
#include "module_io/get_pchg_lcao.h"
#include "module_io/get_wf_lcao.h"
#include "module_io/io_npz.h"
#include "module_io/to_wannier90_lcao.h"
#include "module_io/to_wannier90_lcao_in_pw.h"
#include "module_io/write_HS_R.h"
Expand Down Expand Up @@ -279,11 +280,11 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(const int istep)
std::string zipname = "output_DM0.npz";
elecstate::DensityMatrix<TK, double>* dm
= dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM();
this->read_mat_npz(zipname, *(dm->get_DMR_pointer(1)));
ModuleIO::read_mat_npz(&(this->pv), GlobalC::ucell, zipname, *(dm->get_DMR_pointer(1)));
if (PARAM.inp.nspin == 2)
{
zipname = "output_DM1.npz";
this->read_mat_npz(zipname, *(dm->get_DMR_pointer(2)));
ModuleIO::read_mat_npz(&(this->pv), GlobalC::ucell, zipname, *(dm->get_DMR_pointer(2)));
}

this->pelec->calculate_weights();
Expand Down
1 change: 1 addition & 0 deletions source/module_io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ if(ENABLE_LCAO)
output_sk.cpp
output_dmk.cpp
output_mulliken.cpp
io_npz.cpp
)
list(APPEND objects_advanced
unk_overlap_lcao.cpp
Expand Down
Loading

0 comments on commit dcff74d

Please sign in to comment.