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
1 change: 1 addition & 0 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ OBJS_SRCPW=h_ewald_pw.o\
dftu_base.o\
dftu_base_io.o\
dftu_base_io_read.o\
dftu_base_io_write.o\
dftu_pw.o\
dftu_pw_tools.o\
yukawa_screening.o\
Expand Down
20 changes: 6 additions & 14 deletions source/source_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,6 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int&
// Read globalv values once into locals so the repeated DFT+U call sites
// below do not each re-enter the global dependency surface.
const std::string& global_out_dir = PARAM.globalv.global_out_dir;
const int npol = PARAM.globalv.npol;
const bool gamma_only_local = PARAM.globalv.gamma_only_local;
finish_dftu_lcao<TK>(conv_esolver,
this->inp_->dft_plus_u,
Expand All @@ -690,7 +689,6 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int&
hamilt_lcao,
global_out_dir,
this->inp_->nspin,
npol,
gamma_only_local,
istep,
iter,
Expand Down Expand Up @@ -720,15 +718,14 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int&
// overwrite occ_mat.txt with the latest occupation matrix and the
// actual charge-density residual; ESolver_KS::iter_finish() above has
// computed drho for this electronic step.
const DFTU_BASE::OccmatStepInfo occmat_step{istep,
iter,
this->scf_thr,
this->drho};
DFTU_BASE::write_latest_occmat(*this->dftu_,
ucell,
global_out_dir,
this->inp_->nspin,
npol,
istep,
iter,
this->scf_thr,
this->drho,
occmat_step,
occmat_cfg,
DFTU_BASE::SOC_LAYOUT_SPIN_BASIS_REAL);

Expand All @@ -738,14 +735,9 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int&
DFTU_BASE::append_ion_step_snapshot(*this->dftu_,
ucell,
global_out_dir,
this->inp_->nspin,
npol,
istep,
iter,
occmat_step,
conv_esolver,
true,
this->scf_thr,
this->drho,
occmat_cfg,
DFTU_BASE::SOC_LAYOUT_SPIN_BASIS_REAL);

Expand Down
22 changes: 7 additions & 15 deletions source/source_esolver/esolver_ks_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ void ESolver_KS_PW<T, Device>::iter_init(UnitCell& ucell, const int istep, const
init_occmat_cfg,
this->kv.isk.data(),
this->inp_->nspin,
this->inp_->kpar,
PARAM.globalv.npol);
this->inp_->kpar);

// mohan add 2025-11: push DFT+U energy from Plus_U instance to ElecState
if (this->inp_->dft_plus_u)
Expand Down Expand Up @@ -380,22 +379,20 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
this->inp_->scf_nmax,
this->inp_->out_occ_mat,
this->inp_->dft_plus_u};
const DFTU_BASE::OccmatStepInfo occmat_step{istep,
iter,
this->scf_thr,
this->drho};
// Read globalv values once into locals so the repeated DFT+U call sites
// below do not each re-enter the global dependency surface.
const std::string& global_out_dir = PARAM.globalv.global_out_dir;
const int npol = PARAM.globalv.npol;
const bool latest_ready = (iter > 1 || istep > 0);
if (latest_ready)
{
DFTU_BASE::write_latest_occmat(*this->dftu_,
ucell,
global_out_dir,
this->inp_->nspin,
npol,
istep,
iter,
this->scf_thr,
this->drho,
occmat_step,
occmat_cfg,
DFTU_BASE::SOC_LAYOUT_PAULI);
}
Expand All @@ -408,14 +405,9 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
DFTU_BASE::append_ion_step_snapshot(*this->dftu_,
ucell,
global_out_dir,
this->inp_->nspin,
npol,
istep,
iter,
occmat_step,
conv_esolver,
occmat_ready,
this->scf_thr,
this->drho,
occmat_cfg,
DFTU_BASE::SOC_LAYOUT_PAULI);

Expand Down
2 changes: 2 additions & 0 deletions source/source_lcao/module_dftu/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ if(ENABLE_MPI)
../../../source_pw/module_pwdft/dftu_base.cpp
../../../source_pw/module_pwdft/dftu_base_io.cpp
../../../source_pw/module_pwdft/dftu_base_io_read.cpp
../../../source_pw/module_pwdft/dftu_base_io_write.cpp
../../../source_pw/module_pwdft/yukawa_screening.cpp
../../../source_estate/occ_matrix.cpp
../../../source_estate/occ_mixer.cpp
Expand Down Expand Up @@ -213,6 +214,7 @@ if(ENABLE_MPI)
../../../source_pw/module_pwdft/dftu_base.cpp
../../../source_pw/module_pwdft/dftu_base_io.cpp
../../../source_pw/module_pwdft/dftu_base_io_read.cpp
../../../source_pw/module_pwdft/dftu_base_io_write.cpp
../../../source_pw/module_pwdft/yukawa_screening.cpp
../../../source_estate/occ_matrix.cpp
../../../source_estate/occ_mixer.cpp
Expand Down
6 changes: 1 addition & 5 deletions source/source_lcao/setup_dftu_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ void finish_dftu_lcao(const bool conv_esolver,
void* hamilt_lcao,
const std::string& global_out_dir,
int nspin,
int npol,
const bool gamma_only_local,
int istep,
int iter,
Expand Down Expand Up @@ -82,8 +81,7 @@ void finish_dftu_lcao(const bool conv_esolver,
DFTU_LCAO::cal_energy_correction(*dftu_ptr, ucell, PARAM.inp.nspin);
}
}
DFTU_BASE::output(*dftu_ptr, ucell, global_out_dir, nspin, npol,
istep, iter, occmat_cfg, DFTU_BASE::SOC_LAYOUT_SPIN_BASIS_REAL);
DFTU_BASE::prepare_ion_step_output(global_out_dir, istep, iter, occmat_cfg);

/// use the converged occupation matrix for next MD/Relax SCF calculation
if (conv_esolver)
Expand All @@ -103,7 +101,6 @@ template void finish_dftu_lcao<double>(const bool conv_esolver,
void* hamilt_lcao,
const std::string& global_out_dir,
int nspin,
int npol,
const bool gamma_only_local,
int istep,
int iter,
Expand All @@ -119,7 +116,6 @@ template void finish_dftu_lcao<std::complex<double>>(const bool conv_esolver,
void* hamilt_lcao,
const std::string& global_out_dir,
int nspin,
int npol,
const bool gamma_only_local,
int istep,
int iter,
Expand Down
2 changes: 0 additions & 2 deletions source/source_lcao/setup_dftu_lcao.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ void init_dftu_lcao(int dft_plus_u,
* @param hamilt_lcao Hamiltonian LCAO object
* @param global_out_dir Output directory for occ_mat.txt and occ_matg{#}.txt
* @param nspin Number of spin channels (1, 2, or 4)
* @param npol Number of polarizations
* @param gamma_only_local Whether only the Gamma point is used for LCAO
* @param istep Ionic-step index, starting from 0
* @param iter Electronic-iteration index, starting from 1
Expand All @@ -74,7 +73,6 @@ void finish_dftu_lcao(const bool conv_esolver,
void* hamilt_lcao,
const std::string& global_out_dir,
int nspin,
int npol,
const bool gamma_only_local,
int istep,
int iter,
Expand Down
1 change: 1 addition & 0 deletions source/source_pw/module_pwdft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ list(
dftu_base.cpp
dftu_base_io.cpp
dftu_base_io_read.cpp
dftu_base_io_write.cpp
dftu_pw.cpp
dftu_pw_tools.cpp
yukawa_screening.cpp
Expand Down
4 changes: 2 additions & 2 deletions source/source_pw/module_pwdft/dftu_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void Plus_U_Base::init_base(UnitCell& cell,
DFTU_BASE::read_occup_m(cell, this->occmat_, this->l_channel,
readin_fn, nspin, npol, soc_layout);
#ifdef __MPI
DFTU_BASE::local_occup_bcast(cell, this->occmat_, this->l_channel, nspin, npol);
DFTU_BASE::local_occup_bcast(cell, this->occmat_, this->l_channel);
#endif

this->set_occmat_ready();
Expand Down Expand Up @@ -216,7 +216,7 @@ void Plus_U_Base::init_base(UnitCell& cell,
DFTU_BASE::read_occup_m(cell, this->occmat_, this->l_channel,
readin_fn, nspin, npol, soc_layout);
#ifdef __MPI
DFTU_BASE::local_occup_bcast(cell, this->occmat_, this->l_channel, nspin, npol);
DFTU_BASE::local_occup_bcast(cell, this->occmat_, this->l_channel);
#endif
this->set_occmat_ready();
}
Expand Down
Loading
Loading