Skip to content
Open
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
2 changes: 1 addition & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ target_link_libraries(
cell
parameter
psi_overall_init
psi_initializer
psi_init
psi
dftu
deltaspin
Expand Down
2 changes: 1 addition & 1 deletion source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ OBJS_ORBITAL=ORB_atomic.o\

OBJS_PSI=psi.o\

OBJS_PSI_INITIALIZER=psi_initializer.o\
OBJS_PSI_INITIALIZER=psi_base.o\
psi_init_random.o\
psi_init_file.o\
psi_init_atomic.o\
Expand Down
2 changes: 1 addition & 1 deletion source/source_cell/test/klist_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pseudopot_cell_vnl::pseudopot_cell_vnl()
pseudopot_cell_vnl::~pseudopot_cell_vnl()
{
}
Soc::~Soc()
SocBase::~SocBase()
{
}
Fcoef::~Fcoef()
Expand Down
2 changes: 1 addition & 1 deletion source/source_cell/test/klist_test_para.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pseudopot_cell_vnl::pseudopot_cell_vnl()
pseudopot_cell_vnl::~pseudopot_cell_vnl()
{
}
Soc::~Soc()
SocBase::~SocBase()
{
}
Fcoef::~Fcoef()
Expand Down
26 changes: 23 additions & 3 deletions source/source_esolver/esolver_ks_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void ESolver_KS_PW<T, Device>::before_all_runners(UnitCell& ucell, const Input_p
this->locpp, this->ppcell, this->vsep_cell, this->pw_wfc, this->pw_rho,
this->pw_rhod, this->pw_big, this->solvent, inp);

this->stp.before_runner(ucell, this->kv, this->sf, *this->pw_wfc, this->ppcell, PARAM.inp);
this->stp.before_runner(ucell, this->kv, this->sf, *this->pw_wfc, this->ppcell.lmaxkb, PARAM.inp);

ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT BASIS");

Expand Down Expand Up @@ -143,7 +143,18 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)

if (ucell.cell_parameter_updated)
{
this->stp.p_psi_init->prepare_init(PARAM.inp.pw_seed);
this->stp.p_psi_init->prepare_init(PARAM.inp.pw_seed,
PARAM.globalv.nbands_l,
PARAM.inp.nspin,
PARAM.globalv.nqx,
PARAM.globalv.dq,
PARAM.globalv.domag,
PARAM.globalv.domag_z,
PARAM.inp.pseudo_mesh,
PARAM.inp.orbital_dir,
PARAM.globalv.global_readin_dir,
PARAM.globalv.ks_run,
PARAM.globalv.npol);
}

//! Init Hamiltonian (cell changed)
Expand All @@ -168,7 +179,16 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
this->pw_wfc, this->pw_rhod, PARAM.globalv.global_out_dir, PARAM.inp);

// setup psi (electronic wave functions)
this->stp.init(this->p_hamilt);
this->stp.init(this->p_hamilt,
PARAM.inp.device,
PARAM.inp.precision,
PARAM.inp.ks_solver,
PARAM.inp.bndpar,
PARAM.inp.use_k_continuity,
PARAM.inp.calculation,
PARAM.inp.mem_saver,
PARAM.globalv.npol,
PARAM.globalv.ks_run);

//! Setup EXX helper for Hamiltonian and psi
exx_helper->before_scf(this->p_hamilt, this->stp.template get_psi_t<T, Device>(), PARAM.inp);
Expand Down
4 changes: 2 additions & 2 deletions source/source_estate/test/elecstate_pw_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "source_hamilt/module_xc/xc_functional.h"
#include "source_pw/module_pwdft/vl_pw.h"
#include "source_pw/module_pwdft/vnl_pw.h"
#include "source_pw/module_pwdft/soc.h"
#include "source_psi/soc_base.h"
#include "source_io/module_parameter/parameter.h"
// mock functions for testing
int XC_Functional::func_type = 1;
Expand Down Expand Up @@ -115,7 +115,7 @@ void pseudopot_cell_vnl::getvnl<double, base_device::DEVICE_CPU>(base_device::DE
std::complex<double>*) const
{
}
Soc::~Soc()
SocBase::~SocBase()
{
}
Fcoef::~Fcoef()
Expand Down
4 changes: 3 additions & 1 deletion source/source_io/module_ctrl/ctrl_output_pw.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include "source_base/module_device/device.h" // use Device
#include "source_psi/psi.h" // define psi
#include "source_estate/elecstate_lcao.h" // use pelec
#include "source_psi/setup_psi_pw.h" // use Setup_Psi class
#include "source_psi/setup_psi_pw.h" // use Setup_Psi class

class pseudopot_cell_vnl;

namespace ModuleIO
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ void ReadInput::item_postprocess()

In the future lcao_in_pw will have its own ESolver.

2023/12/22 use new psi_initializer to expand numerical
2023/12/22 use new psi_base to expand numerical
atomic orbitals, ykhuang
*/
if (para.input.towannier90 && para.input.basis_type == "lcao_in_pw")
Expand Down
7 changes: 4 additions & 3 deletions source/source_io/module_wannier/to_wannier90_lcao_in_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ void toWannier90_LCAO_IN_PW::calculate(
{
this->ParaV = pv;

Structure_Factor* sf_ptr = const_cast<Structure_Factor*>(&sf);
ModulePW::PW_Basis_K* wfcpw_ptr = const_cast<ModulePW::PW_Basis_K*>(wfcpw);
delete this->psi_initer_;
this->psi_initer_ = new psi_init_nao<std::complex<double>>();
this->psi_initer_->initialize(sf_ptr, wfcpw_ptr, &ucell, &kv, 1, nullptr, GlobalV::MY_RANK);
psi_init_nao<std::complex<double>>* nao_initer = new psi_init_nao<std::complex<double>>();
nao_initer->prepare_params(PARAM.globalv.nqx, PARAM.globalv.dq, PARAM.inp.nspin, PARAM.inp.orbital_dir, sf);
this->psi_initer_ = nao_initer;
this->psi_initer_->initialize(wfcpw_ptr, &ucell, kv.ik2iktot, kv.get_nkstot(), 1, 0, GlobalV::MY_RANK, PARAM.globalv.npol, PARAM.inp.nbands);
this->psi_initer_->tabulate();
delete this->psi;
const int nks_psi = (PARAM.inp.calculation == "nscf" && PARAM.inp.mem_saver == 1)? 1 : wfcpw->nks;
Expand Down
4 changes: 2 additions & 2 deletions source/source_io/module_wannier/to_wannier90_lcao_in_pw.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#ifdef __LCAO
#include "source_basis/module_ao/parallel_orbitals.h"
#include "source_psi/psi_initializer.h"
#include "source_psi/psi_base.h"

class toWannier90_LCAO_IN_PW : public toWannier90_PW
{
Expand Down Expand Up @@ -59,7 +59,7 @@ class toWannier90_LCAO_IN_PW : public toWannier90_PW
protected:
const Parallel_Orbitals* ParaV = nullptr;
/// @brief psi initializer for expanding nao in planewave basis
psi_initializer<std::complex<double>>* psi_initer_ = nullptr;
psi_base<std::complex<double>>* psi_initer_ = nullptr;

psi::Psi<std::complex<double>, base_device::DEVICE_CPU>* psi = nullptr;

Expand Down
2 changes: 1 addition & 1 deletion source/source_io/test/for_testing_input_conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pseudopot_cell_vnl::pseudopot_cell_vnl()
pseudopot_cell_vnl::~pseudopot_cell_vnl()
{
}
Soc::~Soc()
SocBase::~SocBase()
{
}
Fcoef::~Fcoef()
Expand Down
2 changes: 1 addition & 1 deletion source/source_io/test/for_testing_klist.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pseudopot_cell_vl::pseudopot_cell_vl(){}
pseudopot_cell_vl::~pseudopot_cell_vl(){}
pseudopot_cell_vnl::pseudopot_cell_vnl(){}
pseudopot_cell_vnl::~pseudopot_cell_vnl(){}
Soc::~Soc()
SocBase::~SocBase()
{
}
Fcoef::~Fcoef()
Expand Down
1 change: 0 additions & 1 deletion source/source_lcao/module_deepks/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ set(DEEPKS_UNIT_COMMON_SOURCES
../../../source_cell/read_pp_blps.cpp
../../../source_cell/sep.cpp
../../../source_cell/sep_cell.cpp
../../../source_pw/module_pwdft/soc.cpp
../../../source_io/module_output/sparse_matrix.cpp
../../../source_cell/read_pseudo.cpp
../../../source_estate/param_update.cpp
Expand Down
2 changes: 1 addition & 1 deletion source/source_lcao/module_rdmft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif()

# if(ENABLE_COVERAGE)
# add_coverage(psi)
# add_coverage(psi_initializer)
# add_coverage(psi_init)
# endif()

# if (BUILD_TESTING)
Expand Down
2 changes: 1 addition & 1 deletion source/source_lcao/module_ri/exx_lip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "source_estate/elecstate.h"
#include "source_basis/module_pw/pw_basis_k.h"
#include "source_cell/module_symmetry/symmetry.h"
#include "source_psi/psi_initializer.h"
#include "source_psi/psi_base.h"
#include "source_pw/module_pwdft/structure_factor.h"
#include "source_base/tool_title.h"
#include "source_base/timer.h"
Expand Down
2 changes: 1 addition & 1 deletion source/source_lcao/module_rt/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ AddTest(
../../../source_io/module_hs/cal_r_overlap_R.cpp
../../../source_io/module_hs/single_R_io.cpp
../../../source_io/module_hs/rr_sparse_writer.cpp
../../../source_pw/module_pwdft/soc.cpp
../../../source_psi/soc_base.cpp
)
4 changes: 2 additions & 2 deletions source/source_lcao/setup_nonlocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "source_io/module_parameter/parameter.h"

#ifdef __LCAO
#include "source_pw/module_pwdft/soc.h"
#include "source_psi/soc_base.h"
// mohan add 2013-08-02
// In order to get rid of the read in file .NONLOCAL.

Expand Down Expand Up @@ -53,7 +53,7 @@ void InfoNonlocal::Set_NonLocal(const int& it,
{
lmaxkb = std::max(lmaxkb, atom->ncpp.lll[ibeta]);
}
Soc soc;
SocBase soc;
if (atom->ncpp.has_so)
{
soc.rot_ylm(lmaxkb);
Expand Down
7 changes: 4 additions & 3 deletions source/source_psi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ add_library(
psi
OBJECT
psi.cpp
soc_base.cpp
)

add_library(
Expand All @@ -13,9 +14,9 @@ add_library(
)

add_library(
psi_initializer
psi_init
OBJECT
psi_initializer.cpp
psi_base.cpp
psi_init_random.cpp
psi_init_file.cpp
psi_init_atomic.cpp
Expand All @@ -27,7 +28,7 @@ add_library(

if(ENABLE_COVERAGE)
add_coverage(psi)
add_coverage(psi_initializer)
add_coverage(psi_init)
endif()

if (BUILD_TESTING)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#include "psi_initializer.h"
#include "psi_base.h"

#include <vector>
#include <cassert>
#include <cstdlib>

#include "source_cell/unitcell.h"
#include "source_basis/module_pw/pw_basis_k.h"
#include "source_base/parallel_global.h"
// basic functions support
#include "source_base/timer.h"
Expand All @@ -13,38 +19,42 @@
#endif

template <typename T>
void psi_initializer<T>::initialize(const Structure_Factor* sf,
const ModulePW::PW_Basis_K* pw_wfc,
void psi_base<T>::initialize(const ModulePW::PW_Basis_K* pw_wfc,
const UnitCell* p_ucell,
const K_Vectors* p_kv_in,
const std::vector<int>& ik2iktot,
const int& nkstot,
const int& random_seed,
const pseudopot_cell_vnl* p_pspot_nl,
const int& rank)
const int& lmaxkb,
const int& rank,
const int& npol,
const int& nbands)
{
this->sf_ = sf;
this->pw_wfc_ = pw_wfc;
this->p_ucell_ = p_ucell;
this->p_kv = p_kv_in;
this->ik2iktot_ = ik2iktot;
this->nkstot_ = nkstot;
this->random_seed_ = random_seed;
this->p_pspot_nl_ = p_pspot_nl;
this->lmaxkb_ = lmaxkb;
this->npol_ = npol;
this->nbands_ = nbands;
}

template <typename T>
void psi_initializer<T>::random_t(T* psi, const int iw_start, const int iw_end, const int ik, const int mode)
void psi_base<T>::random_t(T* psi, const int iw_start, const int iw_end, const int ik, const int mode)
{
ModuleBase::timer::start("psi_init", "random_t");
assert(mode <= 1);
assert(iw_start >= 0);
const int ng = this->pw_wfc_->npwk[ik];
const int npwk_max = this->pw_wfc_->npwk_max;
const int npol = PARAM.globalv.npol;
const int npol = this->npol_;

// If random seed is specified, then generate random wavefunction satisfying that
// it can generate the same results using different number of processors.
if (this->random_seed_ > 0) // qianrui add 2021-8-13
{
#ifdef __MPI
srand(unsigned(this->random_seed_ + this->p_kv->ik2iktot[ik]));
srand(unsigned(this->random_seed_ + this->ik2iktot_[ik]));
#else
srand(unsigned(this->random_seed_ + ik));
#endif
Expand Down Expand Up @@ -184,7 +194,7 @@ void psi_initializer<T>::random_t(T* psi, const int iw_start, const int iw_end,

#ifdef __MPI
template <typename T>
void psi_initializer<T>::stick_to_pool(Real* stick, const int& ir, Real* out) const
void psi_base<T>::stick_to_pool(Real* stick, const int& ir, Real* out) const
{
ModuleBase::timer::start("psi_init", "stick_to_pool");
MPI_Status ierror;
Expand All @@ -211,7 +221,7 @@ void psi_initializer<T>::stick_to_pool(Real* stick, const int& ir, Real* out) co
}
else
{
ModuleBase::WARNING_QUIT("psi_initializer", "stick_to_pool: Real type not supported");
ModuleBase::WARNING_QUIT("psi_base", "stick_to_pool: Real type not supported");
}
for (int iz = 0; iz < nz; iz++)
{
Expand All @@ -230,7 +240,7 @@ void psi_initializer<T>::stick_to_pool(Real* stick, const int& ir, Real* out) co
}
else
{
ModuleBase::WARNING_QUIT("psi_initializer", "stick_to_pool: Real type not supported");
ModuleBase::WARNING_QUIT("psi_base", "stick_to_pool: Real type not supported");
}
}

Expand All @@ -240,8 +250,8 @@ void psi_initializer<T>::stick_to_pool(Real* stick, const int& ir, Real* out) co
#endif

// explicit instantiation
template class psi_initializer<std::complex<double>>;
template class psi_initializer<std::complex<float>>;
template class psi_base<std::complex<double>>;
template class psi_base<std::complex<float>>;
// gamma point calculation
template class psi_initializer<double>;
template class psi_initializer<float>;
template class psi_base<double>;
template class psi_base<float>;
Loading
Loading