Skip to content

Commit b5b66d6

Browse files
committed
reduce the charge mixing code in esolver_ks_lcao
1 parent 4d89de7 commit b5b66d6

File tree

3 files changed

+9
-55
lines changed

3 files changed

+9
-55
lines changed

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@
6363

6464
// test RDMFT
6565
#include "source_lcao/module_rdmft/rdmft.h"
66-
6766
#include "source_lcao/module_gint/temp_gint/gint_info.h"
6867

69-
#include <iostream>
68+
#include "source_estate/module_charge/chgmixing.h" // use charge mixing, mohan add 20251006
69+
7070

7171
namespace ModuleESolver
7272
{
@@ -526,52 +526,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
526526
elecstate::DensityMatrix<TK, double>* dm
527527
= dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM();
528528

529-
if (iter == 1)
530-
{
531-
this->p_chgmix->mix_reset(); // init mixing
532-
this->p_chgmix->mixing_restart_step = PARAM.inp.scf_nmax + 1;
533-
this->p_chgmix->mixing_restart_count = 0;
534-
// this output will be removed once the feeature is stable
535-
if (GlobalC::dftu.uramping > 0.01)
536-
{
537-
std::cout << " U-Ramping! Current U = ";
538-
for (int i = 0; i < GlobalC::dftu.U0.size(); i++)
539-
{
540-
std::cout << GlobalC::dftu.U[i] * ModuleBase::Ry_to_eV << " ";
541-
}
542-
std::cout << " eV " << std::endl;
543-
}
544-
}
545-
546-
// for mixing restart
547-
if (iter == this->p_chgmix->mixing_restart_step && PARAM.inp.mixing_restart > 0.0)
548-
{
549-
this->p_chgmix->init_mixing();
550-
this->p_chgmix->mixing_restart_count++;
551-
if (PARAM.inp.dft_plus_u)
552-
{
553-
GlobalC::dftu.uramping_update(); // update U by uramping if uramping > 0.01
554-
if (GlobalC::dftu.uramping > 0.01)
555-
{
556-
std::cout << " U-Ramping! Current U = ";
557-
for (int i = 0; i < GlobalC::dftu.U0.size(); i++)
558-
{
559-
std::cout << GlobalC::dftu.U[i] * ModuleBase::Ry_to_eV << " ";
560-
}
561-
std::cout << " eV " << std::endl;
562-
}
563-
if (GlobalC::dftu.uramping > 0.01 && !GlobalC::dftu.u_converged())
564-
{
565-
this->p_chgmix->mixing_restart_step = PARAM.inp.scf_nmax + 1;
566-
}
567-
}
568-
if (PARAM.inp.mixing_dmr) // for mixing_dmr
569-
{
570-
// allocate memory for dmr_mdata
571-
int nnr_tmp = dm->get_DMR_pointer(1)->get_nnr();
572-
this->p_chgmix->allocate_mixing_dmr(nnr_tmp);
573-
}
574-
}
529+
module_charge::chgmixing_ks_lcao(iter, this->p_chgmix, dm->get_DMR_pointer(1)->get_nnr(), PARAM.inp);
575530

576531
// mohan update 2012-06-05
577532
this->pelec->f_en.deband_harris = this->pelec->cal_delta_eband(ucell);

source/source_estate/module_charge/chgmixing.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ void module_charge::chgmixing_ks_pw(const int iter, // scf iteration number
5656
return;
5757
}
5858

59-
/*
6059
void module_charge::chgmixing_ks_lcao(const int iter, // scf iteration number
6160
Charge_Mixing* p_chgmix, // charge mixing class
61+
const int nnr, // dimension of density matrix
6262
const Input_para& inp) // input parameters
6363
{
6464
ModuleBase::TITLE("module_charge", "chgmixing_ks_lcao");
@@ -105,11 +105,7 @@ void module_charge::chgmixing_ks_lcao(const int iter, // scf iteration number
105105
if (inp.mixing_dmr) // for mixing_dmr
106106
{
107107
// allocate memory for dmr_mdata
108-
const elecstate::DensityMatrix<TK, double>* dm
109-
= dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM();
110-
int nnr_tmp = dm->get_DMR_pointer(1)->get_nnr();
111-
p_chgmix->allocate_mixing_dmr(nnr_tmp);
108+
p_chgmix->allocate_mixing_dmr(nnr);
112109
}
113110
}
114111
}
115-
*/

source/source_estate/module_charge/chgmixing.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ void chgmixing_ks_pw(const int iter,
1111
Charge_Mixing* p_chgmix,
1212
const Input_para& inp); // input parameters
1313

14-
//void chgmixing_ks_lcao();
14+
void chgmixing_ks_lcao(const int iter, // scf iteration number
15+
Charge_Mixing* p_chgmix, // charge mixing class
16+
const int nnr, // dimension of density matrix
17+
const Input_para& inp); // input parameters
1518

1619
}
1720

0 commit comments

Comments
 (0)