Skip to content

Commit 9441396

Browse files
committed
split update_pot in rt-TDDFT into two functions, one is the original update_pot, which is replaced by update_pot function in estate, the other is save2 function used in after_iter
1 parent 242184c commit 9441396

File tree

12 files changed

+22
-17
lines changed

12 files changed

+22
-17
lines changed

source/Makefile.Objects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ OBJS_ELECSTAT=elecstate.o\
250250
read_pseudo.o\
251251
cal_wfc.o\
252252
setup_estate_pw.o\
253+
update_pot.o\
253254

254255
OBJS_ELECSTAT_LCAO=elecstate_lcao.o\
255256
elecstate_lcao_cal_tau.o\

source/source_esolver/esolver_ks.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ void ESolver_KS<T, Device>::iter_finish(UnitCell& ucell, const int istep, int& i
375375
if (this->scf_ene_thr > 0.0)
376376
{
377377
// calculate energy of output charge density
378-
elecstate::update_pot(ucell, istep, iter, conv_esolver);
378+
elecstate::update_pot(ucell, this->pelec, this->chr, conv_esolver);
379379
this->pelec->cal_energies(2); // 2 means Kohn-Sham functional
380380
// now, etot_old is the energy of input density, while etot is the energy of output density
381381
this->pelec->f_en.etot_delta = this->pelec->f_en.etot - this->pelec->f_en.etot_old;
@@ -433,7 +433,7 @@ void ESolver_KS<T, Device>::iter_finish(UnitCell& ucell, const int istep, int& i
433433
#endif
434434

435435
// 4) Update potentials (should be done every SF iter)
436-
this->update_pot(ucell, istep, iter, conv_esolver);
436+
elecstate::update_pot(ucell, this->pelec, this->chr, conv_esolver);
437437

438438
// 5) calculate energies
439439
// 1 means Harris-Foulkes functional

source/source_esolver/esolver_ks.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ class ESolver_KS : public ESolver_FP
4646
//! Something to do after SCF iterations when SCF is converged or comes to the max iter step.
4747
virtual void after_scf(UnitCell& ucell, const int istep, const bool conv_esolver) override;
4848

49-
//! <Temporary> It should be replaced by a function in Hamilt Class
50-
virtual void update_pot(UnitCell& ucell, const int istep, const int iter, const bool conv_esolver){};
51-
5249
//! Hamiltonian
5350
hamilt::Hamilt<T, Device>* p_hamilt = nullptr;
5451

source/source_esolver/esolver_ks_lcao.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ class ESolver_KS_LCAO : public ESolver_KS<TK>
5252

5353
virtual void hamilt2rho_single(UnitCell& ucell, const int istep, const int iter, const double ethr) override;
5454

55-
virtual void update_pot(UnitCell& ucell, const int istep, const int iter, const bool conv_esolver) override;
56-
5755
virtual void iter_finish(UnitCell& ucell, const int istep, int& iter, bool& conv_esolver) override;
5856

5957
virtual void after_scf(UnitCell& ucell, const int istep, const bool conv_esolver) override;

source/source_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,16 +336,19 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::iter_finish(
336336
GlobalV::ofs_running << std::endl;
337337
}
338338

339+
this->save2(ucell, istep, iter, conv_esolver);
340+
339341
ESolver_KS_LCAO<std::complex<double>, TR>::iter_finish(ucell, istep, iter, conv_esolver);
340342
}
341343

342344
template <typename TR, typename Device>
343-
void ESolver_KS_LCAO_TDDFT<TR, Device>::update_pot(UnitCell& ucell,
345+
void ESolver_KS_LCAO_TDDFT<TR, Device>::save2(UnitCell& ucell,
344346
const int istep,
345347
const int iter,
346348
const bool conv_esolver)
347349
{
348350
// Calculate new potential according to new Charge Density
351+
/*
349352
if (!conv_esolver)
350353
{
351354
elecstate::cal_ux(ucell);
@@ -356,6 +359,7 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::update_pot(UnitCell& ucell,
356359
{
357360
this->pelec->cal_converged();
358361
}
362+
*/
359363

360364
const int nloc = this->pv.nloc;
361365
const int ncol_nbands = this->pv.ncol_bands;

source/source_esolver/esolver_ks_lcao_tddft.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ class ESolver_KS_LCAO_TDDFT : public ESolver_KS_LCAO<std::complex<double>, TR>
6464

6565
virtual void hamilt2rho_single(UnitCell& ucell, const int istep, const int iter, const double ethr) override;
6666

67-
virtual void update_pot(UnitCell& ucell, const int istep, const int iter, const bool conv_esolver) override;
67+
// mohan change update_pot to save2, 2025-10-17
68+
virtual void save2(UnitCell& ucell, const int istep, const int iter, const bool conv_esolver);
6869

6970
virtual void iter_finish(UnitCell& ucell, const int istep, int& iter, bool& conv_esolver) override;
7071

source/source_esolver/esolver_ks_pw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
326326
<< std::endl;
327327
exx_helper.op_exx->first_iter = false;
328328
XC_Functional::set_xc_type(ucell.atoms[0].ncpp.xc_func);
329-
elecstate::update_pot(ucell, istep, iter, conv_esolver);
330-
exx_helper.iter_inc();
329+
elecstate::update_pot(ucell, this->pelec, this->chr, conv_esolver);
330+
exx_helper.iter_inc();
331331
}
332332
}
333333
}

source/source_esolver/esolver_ks_pw.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ class ESolver_KS_PW : public ESolver_KS<T, Device>
4141

4242
virtual void iter_init(UnitCell& ucell, const int istep, const int iter) override;
4343

44-
virtual void update_pot(UnitCell& ucell, const int istep, const int iter, const bool conv_esolver) override;
45-
4644
virtual void iter_finish(UnitCell& ucell, const int istep, int& iter, bool& conv_esolver) override;
4745

4846
virtual void after_scf(UnitCell& ucell, const int istep, const bool conv_esolver) override;

source/source_esolver/rho_restart.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "rho_restart.h"
22

3+
/*
34
void ModuleESolver::rho_restart(const Input_para& inp,
45
const UnitCell& ucell,
56
const elecstate::ElecState& elec,
@@ -145,3 +146,4 @@ void ModuleESolver::rho_restart(const Input_para& inp,
145146
#endif
146147
147148
}
149+
*/

source/source_estate/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ list(APPEND objects
3939
read_pseudo.cpp
4040
cal_wfc.cpp
4141
setup_estate_pw.cpp
42+
update_pot.cpp
4243
)
4344

4445
if(ENABLE_LCAO)

0 commit comments

Comments
 (0)