Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
415b55f
update small places in charge_mixing_residual.cpp
mohanchen Sep 26, 2025
1156f21
update charge_mixing_preconditioner
mohanchen Sep 26, 2025
8d8803b
add timers and remove some PARAM.inp.nspin
mohanchen Sep 26, 2025
91b9ceb
fix problems
mohanchen Sep 26, 2025
a7f6294
add timers
mohanchen Sep 26, 2025
9f95733
small fix
mohanchen Sep 26, 2025
f7f156d
fix a potential memory leak
mohanchen Sep 26, 2025
94e5780
fix bug
mohanchen Sep 27, 2025
8fed198
Merge branch 'develop' of https://github.com/mohanchen/abacus-mc into…
mohanchen Sep 27, 2025
8616ac3
add ctrl_output_pw files but cannot run now
mohanchen Sep 27, 2025
bbe4c3f
add some interfaces in ctrl_output_pw
mohanchen Sep 27, 2025
77ea800
keep fixing bugs
mohanchen Sep 27, 2025
5364e44
successfully compile the codes
mohanchen Sep 27, 2025
5534980
finally I understand Devicegit add ../source/source_base/module_devic…
mohanchen Sep 27, 2025
9a1c9fd
update function variables
mohanchen Sep 27, 2025
40fa9f0
one step further
mohanchen Sep 27, 2025
155c18d
move on
mohanchen Sep 27, 2025
9c1c376
update codes, done!
mohanchen Sep 27, 2025
e6623f1
fix bug
mohanchen Sep 28, 2025
c715622
Merge branch 'develop' of https://github.com/mohanchen/abacus-mc into…
mohanchen Sep 29, 2025
2cc87f9
add setup_pot
mohanchen Sep 29, 2025
5d2fc35
fix bugs
mohanchen Sep 30, 2025
632b1c6
update esolver_ks_pw, add setup_pot
mohanchen Sep 30, 2025
0e70265
update format of esolver_ks_pw.cpp
mohanchen Sep 30, 2025
e0eed86
update setup_pot for GPU version
mohanchen Oct 4, 2025
6f1657e
update esolver_ks_pw.cpp
mohanchen Oct 5, 2025
28ce5d6
add setup_estate_pw in source_estate
mohanchen Oct 5, 2025
af3955d
fix some bugs
mohanchen Oct 5, 2025
8030dd0
small update
mohanchen Oct 5, 2025
29776a6
Merge branch 'develop' into develop
mohanchen Oct 5, 2025
266555c
move teardown to deconstructor of ESolver
mohanchen Oct 5, 2025
cb1a21a
fix error in passing pointers
mohanchen Oct 5, 2025
9a4a462
move teardown function to the correct place
mohanchen Oct 5, 2025
4ffe19a
fix bugs
mohanchen Oct 5, 2025
c3c8174
update
mohanchen Oct 5, 2025
94c17c3
add two functions in module_pwdft
mohanchen Oct 5, 2025
8aaf32d
add setup_pwrho file, and update esolver_fp
mohanchen Oct 5, 2025
3268459
update esolver_fp
mohanchen Oct 5, 2025
38093a1
add teardown function in setup_pwrho
mohanchen Oct 5, 2025
440b690
update esolver
mohanchen Oct 5, 2025
d672bca
move the after_all_runners() function of the base class to the end
mohanchen Oct 5, 2025
16ba5d2
add TITLE for after_all_runners
mohanchen Oct 5, 2025
8516477
update esolver_fp, move teardown to desconstructor
mohanchen Oct 5, 2025
9713afb
Revert "update esolver_fp, move teardown to desconstructor"
mohanchen Oct 5, 2025
de9d3de
Revert "add TITLE for after_all_runners"
mohanchen Oct 5, 2025
2163ef5
Revert "move the after_all_runners() function of the base class to th…
mohanchen Oct 5, 2025
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 @@ -712,6 +712,7 @@ OBJS_SRCPW=H_Ewald_pw.o\
charge_mixing_rho.o\
charge_mixing_uspp.o\
fp_energy.o\
setup_pot.o\
forces.o\
forces_us.o\
forces_nl.o\
Expand Down
102 changes: 11 additions & 91 deletions source/source_esolver/esolver_ks_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
#include "source_pw/module_pwdft/onsite_projector.h"
#include "source_lcao/module_dftu/dftu.h"
#include "source_pw/module_pwdft/VSep_in_pw.h"
#include "source_pw/module_pwdft/forces.h"
#include "source_pw/module_pwdft/hamilt_pw.h"

#include "source_pw/module_pwdft/forces.h"
#include "source_pw/module_pwdft/stress_pw.h"

#include <iostream>
Expand All @@ -33,6 +34,7 @@

#include <chrono>

#include "source_pw/module_pwdft/setup_pot.h" // mohan add 20250929
#include "source_io/ctrl_output_pw.h" // mohan add 20250927

namespace ModuleESolver
Expand Down Expand Up @@ -251,96 +253,14 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
this->allocate_hamilt(ucell);

//----------------------------------------------------------
//! 4) DFT-1/2 calculations, sep potential need to generate before effective potential calculation
//----------------------------------------------------------
if (PARAM.inp.dfthalf_type > 0)
{
this->vsep_cell->generate_vsep_r(this->pw_rhod[0], this->sf.strucFac, ucell.sep_cell);
}

//----------------------------------------------------------
//! 5) Renew local pseudopotential
//----------------------------------------------------------
this->pelec
->init_scf(istep, ucell, this->Pgrid, this->sf.strucFac, this->locpp.numeric, ucell.symm, (void*)this->pw_wfc);

//----------------------------------------------------------
//! 6) Symmetrize the charge density (rho)
//----------------------------------------------------------

//! Symmetry_rho should behind init_scf, because charge should be
//! initialized first. liuyu comment: Symmetry_rho should be
//! located between init_rho and v_of_rho?
Symmetry_rho srho;
for (int is = 0; is < PARAM.inp.nspin; is++)
{
srho.begin(is, this->chr, this->pw_rhod, ucell.symm);
}

//----------------------------------------------------------
//! 7) Calculate the effective potential with rho
// 4) setup potentials (local, non-local, sc, +U, DFT-1/2)
//----------------------------------------------------------
//! liuyu move here 2023-10-09
//! D in uspp need vloc, thus behind init_scf()
//! calculate the effective coefficient matrix
//! for non-local pseudopotential projectors
ModuleBase::matrix veff = this->pelec->pot->get_effective_v();

this->ppcell.cal_effective_D(veff, this->pw_rhod, ucell);

//----------------------------------------------------------
//! 8) Onsite projectors
//----------------------------------------------------------
if (PARAM.inp.onsite_radius > 0)
{
auto* onsite_p = projectors::OnsiteProjector<double, Device>::get_instance();
onsite_p->init(PARAM.inp.orbital_dir,
&ucell,
*(this->kspw_psi),
this->kv,
*(this->pw_wfc),
this->sf,
PARAM.inp.onsite_radius,
PARAM.globalv.nqx,
PARAM.globalv.dq,
this->pelec->wg,
this->pelec->ekb);
}

//----------------------------------------------------------
//! 9) Spin-constrained algorithms
//----------------------------------------------------------
if (PARAM.inp.sc_mag_switch)
{
spinconstrain::SpinConstrain<std::complex<double>>& sc
= spinconstrain::SpinConstrain<std::complex<double>>::getScInstance();
sc.init_sc(PARAM.inp.sc_thr,
PARAM.inp.nsc,
PARAM.inp.nsc_min,
PARAM.inp.alpha_trial,
PARAM.inp.sccut,
PARAM.inp.sc_drop_thr,
ucell,
nullptr,
PARAM.inp.nspin,
this->kv,
this->p_hamilt,
this->kspw_psi,
this->pelec,
this->pw_wfc);
}

//----------------------------------------------------------
//! 10) DFT+U algorithm
//----------------------------------------------------------
if (PARAM.inp.dft_plus_u)
{
auto* dftu = ModuleDFTU::DFTU::get_instance();
dftu->init(ucell, nullptr, this->kv.get_nks());
}
pw::setup_pot(istep, ucell, this->kv, this->sf, this->pelec, this->Pgrid,
this->chr, this->locpp, this->ppcell, this->vsep_cell,
this->kspw_psi, this->p_hamilt, this->pw_wfc, this->pw_rhod, PARAM.inp);

//----------------------------------------------------------
//! 10) Initialize wave functions
//! 5) Initialize wave functions
//----------------------------------------------------------
if (!this->already_initpsi)
{
Expand All @@ -349,10 +269,10 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
}

//----------------------------------------------------------
//! 11) Exx calculations
//! 6) Exx calculations
//----------------------------------------------------------
if (PARAM.inp.calculation == "scf" || PARAM.inp.calculation == "relax" || PARAM.inp.calculation == "cell-relax"
|| PARAM.inp.calculation == "md")
if (PARAM.inp.calculation == "scf" || PARAM.inp.calculation == "relax"
|| PARAM.inp.calculation == "cell-relax" || PARAM.inp.calculation == "md")
{
if (GlobalC::exx_info.info_global.cal_exx && PARAM.inp.basis_type == "pw")
{
Expand Down
4 changes: 2 additions & 2 deletions source/source_lcao/module_deltaspin/init_sc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void spinconstrain::SpinConstrain<FPTYPE>::init_sc(double sc_thr_in,
const UnitCell& ucell,
Parallel_Orbitals* ParaV_in,
int nspin_in,
K_Vectors& kv_in,
const K_Vectors& kv_in,
void* p_hamilt_in,
void* psi_in,
elecstate::ElecState* pelec_in,
Expand All @@ -34,4 +34,4 @@ void spinconstrain::SpinConstrain<FPTYPE>::init_sc(double sc_thr_in,
}

template class spinconstrain::SpinConstrain<std::complex<double>>;
template class spinconstrain::SpinConstrain<double>;
template class spinconstrain::SpinConstrain<double>;
4 changes: 2 additions & 2 deletions source/source_lcao/module_deltaspin/spin_constrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ double SpinConstrain<FPTYPE>::get_sc_drop_thr()
}

template <typename FPTYPE>
void SpinConstrain<FPTYPE>::set_solver_parameters(K_Vectors& kv_in,
void SpinConstrain<FPTYPE>::set_solver_parameters(const K_Vectors& kv_in,
void* p_hamilt_in,
void* psi_in,
elecstate::ElecState* pelec_in)
Expand Down Expand Up @@ -603,4 +603,4 @@ void SpinConstrain<FPTYPE>::print_Mag_Force(std::ofstream& ofs_running)
template class SpinConstrain<std::complex<double>>;
template class SpinConstrain<double>;

} // namespace spinconstrain
} // namespace spinconstrain
4 changes: 2 additions & 2 deletions source/source_lcao/module_deltaspin/spin_constrain.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SpinConstrain
const UnitCell& ucell,
Parallel_Orbitals* ParaV_in,
int nspin_in,
K_Vectors& kv_in,
const K_Vectors& kv_in,
void* p_hamilt_in,
void* psi_in,
elecstate::ElecState* pelec_in,
Expand Down Expand Up @@ -201,7 +201,7 @@ class SpinConstrain
/// @brief set orbital parallel info
void set_ParaV(Parallel_Orbitals* ParaV_in);
/// @brief set parameters for solver
void set_solver_parameters(K_Vectors& kv_in,
void set_solver_parameters(const K_Vectors& kv_in,
void* p_hamilt_in,
void* psi_in,
elecstate::ElecState* pelec_in);
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 @@ -12,6 +12,7 @@ list(APPEND objects
operator_pw/op_exx_pw.cpp
operator_pw/exx_pw_ace.cpp
operator_pw/exx_pw_pot.cpp
setup_pot.cpp
forces_nl.cpp
forces_cc.cpp
forces_scc.cpp
Expand Down
Loading
Loading