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
41 changes: 41 additions & 0 deletions source/module_esolver/esolver_ks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "module_base/timer.h"
#include "module_cell/cal_atoms_info.h"
#include "module_io/cube_io.h"
#include "module_io/json_output/init_info.h"
#include "module_io/json_output/output_info.h"
#include "module_io/output_log.h"
Expand Down Expand Up @@ -679,6 +680,46 @@ void ESolver_KS<T, Device>::iter_finish(UnitCell& ucell, const int istep, int& i
this->p_chgmix->mixing_restart_last = iter;
std::cout << " SCF restart after this step!" << std::endl;
}

//! output charge density and density matrix
if (this->out_freq_elec && iter % this->out_freq_elec == 0)
{
for (int is = 0; is < PARAM.inp.nspin; is++)
{
double* data = nullptr;
if (PARAM.inp.dm_to_rho)
{
data = this->pelec->charge->rho[is];
}
else
{
data = this->pelec->charge->rho_save[is];
}
std::string fn = PARAM.globalv.global_out_dir + "/tmp_SPIN" + std::to_string(is + 1) + "_CHG.cube";
ModuleIO::write_vdata_palgrid(GlobalC::Pgrid,
data,
is,
PARAM.inp.nspin,
0,
fn,
this->pelec->eferm.get_efval(is),
&(ucell),
3,
1);
if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
{
fn = PARAM.globalv.global_out_dir + "/tmp_SPIN" + std::to_string(is + 1) + "_TAU.cube";
ModuleIO::write_vdata_palgrid(GlobalC::Pgrid,
this->pelec->charge->kin_r_save[is],
is,
PARAM.inp.nspin,
0,
fn,
this->pelec->eferm.get_efval(is),
&(ucell));
}
}
}
}

//! Something to do after SCF iterations when SCF is converged or comes to the max iter step.
Expand Down
40 changes: 0 additions & 40 deletions source/module_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,46 +939,6 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int&
}
#endif

// 4) output charge density and density matrix
if (this->out_freq_elec && iter % this->out_freq_elec == 0)
{
for (int is = 0; is < PARAM.inp.nspin; is++)
{
double* data = nullptr;
if (PARAM.inp.dm_to_rho)
{
data = this->pelec->charge->rho[is];
}
else
{
data = this->pelec->charge->rho_save[is];
}
std::string fn = PARAM.globalv.global_out_dir + "/tmp_SPIN" + std::to_string(is + 1) + "_CHG.cube";
ModuleIO::write_vdata_palgrid(GlobalC::Pgrid,
data,
is,
PARAM.inp.nspin,
0,
fn,
this->pelec->eferm.get_efval(is),
&(ucell),
3,
1);
if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
{
fn = PARAM.globalv.global_out_dir + "/tmp_SPIN" + std::to_string(is + 1) + "_TAU.cube";
ModuleIO::write_vdata_palgrid(GlobalC::Pgrid,
this->pelec->charge->kin_r_save[is],
is,
PARAM.inp.nspin,
0,
fn,
this->pelec->eferm.get_efval(is),
&(ucell));
}
}
}

// 6) use the converged occupation matrix for next MD/Relax SCF calculation
if (PARAM.inp.dft_plus_u && this->conv_esolver)
{
Expand Down
40 changes: 0 additions & 40 deletions source/module_esolver/esolver_ks_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,48 +502,8 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
GlobalC::ppcell.cal_effective_D(veff, this->pw_rhod, ucell);
}

// 3) Print out charge density
if (this->out_freq_elec && iter % this->out_freq_elec == 0)
{
if (PARAM.inp.out_chg[0] > 0)
{
for (int is = 0; is < PARAM.inp.nspin; is++)
{
double* data = nullptr;
if (PARAM.inp.dm_to_rho)
{
data = this->pelec->charge->rho[is];
}
else
{
data = this->pelec->charge->rho_save[is];
}
std::string fn = PARAM.globalv.global_out_dir + "/tmp_SPIN" + std::to_string(is + 1) + "_CHG.cube";
ModuleIO::write_vdata_palgrid(GlobalC::Pgrid,
data,
is,
PARAM.inp.nspin,
0,
fn,
this->pelec->eferm.get_efval(is),
&(ucell),
3,
1);
if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
{
fn = PARAM.globalv.global_out_dir + "/tmp_SPIN" + std::to_string(is + 1) + "_TAU.cube";
ModuleIO::write_vdata_palgrid(GlobalC::Pgrid,
this->pelec->charge->kin_r_save[is],
is,
PARAM.inp.nspin,
0,
fn,
this->pelec->eferm.get_efval(is),
&(ucell));
}
}
}

// 4) Print out electronic wavefunctions
if (PARAM.inp.out_wfc_pw == 1 || PARAM.inp.out_wfc_pw == 2)
{
Expand Down
Loading