Skip to content

Commit 9d3b841

Browse files
committed
Merge branch 'hamilt' of https://github.com/ErjieWu/abacus-develop into hamilt
2 parents adaf075 + e003633 commit 9d3b841

File tree

105 files changed

+1194
-994
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1194
-994
lines changed

source/module_elecstate/elecstate_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void ElecStatePW<T, Device>::add_usrho(const psi::Psi<T, Device>& psi)
263263
// get |beta>
264264
if (this->ppcell->nkb > 0)
265265
{
266-
this->ppcell->getvnl(this->ctx, ik, this->vkb);
266+
this->ppcell->getvnl(this->ctx, *ucell,ik, this->vkb);
267267
}
268268

269269
// becp = <beta|psi>

source/module_elecstate/test/elecstate_pw_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,14 @@ std::complex<double>* pseudopot_cell_vnl::get_vkb_data<double>() const
115115
}
116116
template <>
117117
void pseudopot_cell_vnl::getvnl<float, base_device::DEVICE_CPU>(base_device::DEVICE_CPU*,
118+
const UnitCell&,
118119
int const&,
119120
std::complex<float>*) const
120121
{
121122
}
122123
template <>
123124
void pseudopot_cell_vnl::getvnl<double, base_device::DEVICE_CPU>(base_device::DEVICE_CPU*,
125+
const UnitCell&,
124126
int const&,
125127
std::complex<double>*) const
126128
{

source/module_esolver/esolver_fp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void ESolver_FP::before_scf(UnitCell& ucell, const int istep)
281281
this->pw_rhod->collect_uniqgg();
282282
}
283283

284-
this->p_locpp->init_vloc(this->pw_rhod);
284+
this->p_locpp->init_vloc(ucell,this->pw_rhod);
285285
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");
286286

287287
this->pelec->omega = ucell.omega;

source/module_esolver/esolver_gets.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ void ESolver_GetS::runner(UnitCell& ucell, const int istep)
136136
if (PARAM.inp.out_mat_r)
137137
{
138138
cal_r_overlap_R r_matrix;
139-
r_matrix.init(pv, orb_);
140-
r_matrix.out_rR(istep);
139+
r_matrix.init(ucell,pv, orb_);
140+
r_matrix.out_rR(ucell,istep);
141141
}
142142

143143
ModuleBase::timer::tick("ESolver_GetS", "runner");

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
197197
}
198198

199199
// 8) initialize ppcell
200-
this->ppcell.init_vloc(this->pw_rho);
200+
this->ppcell.init_vloc(ucell,this->pw_rho);
201201
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");
202202

203203
// 9) inititlize the charge density
@@ -920,6 +920,8 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
920920
PARAM.inp.out_dm1,
921921
false,
922922
PARAM.inp.out_app_flag,
923+
ucell.get_iat2iwt(),
924+
&ucell.nat,
923925
istep);
924926

925927
//! 4) write density matrix
@@ -1228,7 +1230,8 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
12281230
PARAM.inp.nnkpfile,
12291231
PARAM.inp.wannier_spin);
12301232

1231-
myWannier.calculate(this->pelec->ekb,
1233+
myWannier.calculate(ucell,
1234+
this->pelec->ekb,
12321235
this->pw_wfc,
12331236
this->pw_big,
12341237
this->sf,
@@ -1247,7 +1250,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
12471250
PARAM.inp.wannier_spin,
12481251
orb_);
12491252

1250-
myWannier.calculate(this->pelec->ekb, this->kv, *(this->psi), &(this->pv));
1253+
myWannier.calculate(ucell,this->pelec->ekb, this->kv, *(this->psi), &(this->pv));
12511254
}
12521255
std::cout << FmtCore::format(" >> Finish %s.\n * * * * * *\n", "Wave function to Wannier90");
12531256
}
@@ -1259,12 +1262,13 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
12591262
{
12601263
std::cout << FmtCore::format("\n * * * * * *\n << Start %s.\n", "Berry phase calculation");
12611264
berryphase bp(&(this->pv));
1262-
bp.lcao_init(this->kv,
1265+
bp.lcao_init(ucell,
1266+
this->kv,
12631267
this->GridT,
12641268
orb_); // additional step before calling
12651269
// macroscopic_polarization (why capitalize
12661270
// the function name?)
1267-
bp.Macroscopic_polarization(this->pw_wfc->npwk_max, this->psi, this->pw_rho, this->pw_wfc, this->kv);
1271+
bp.Macroscopic_polarization(ucell,this->pw_wfc->npwk_max, this->psi, this->pw_rho, this->pw_wfc, this->kv);
12681272
std::cout << FmtCore::format(" >> Finish %s.\n * * * * * *\n", "Berry phase calculation");
12691273
}
12701274
}

source/module_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,16 @@ void ESolver_KS_LCAO_TDDFT::after_scf(UnitCell& ucell, const int istep)
287287
{
288288
std::stringstream ss_dipole;
289289
ss_dipole << PARAM.globalv.global_out_dir << "SPIN" << is + 1 << "_DIPOLE";
290-
ModuleIO::write_dipole(pelec->charge->rho_save[is], pelec->charge->rhopw, is, istep, ss_dipole.str());
290+
ModuleIO::write_dipole(ucell,pelec->charge->rho_save[is], pelec->charge->rhopw, is, istep, ss_dipole.str());
291291
}
292292
}
293293
if (TD_Velocity::out_current == true)
294294
{
295295
elecstate::DensityMatrix<std::complex<double>, double>* tmp_DM
296296
= dynamic_cast<elecstate::ElecStateLCAO<std::complex<double>>*>(this->pelec)->get_DM();
297297

298-
ModuleIO::write_current(istep,
298+
ModuleIO::write_current(ucell,
299+
istep,
299300
this->psi,
300301
pelec,
301302
kv,

source/module_esolver/esolver_ks_lcaopw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ namespace ModuleESolver
6262
}
6363

6464
template <typename T>
65-
void ESolver_KS_LIP<T>::allocate_hamilt()
65+
void ESolver_KS_LIP<T>::allocate_hamilt(const UnitCell& ucell)
6666
{
67-
this->p_hamilt = new hamilt::HamiltLIP<T>(this->pelec->pot, this->pw_wfc, &this->kv, &this->ppcell
67+
this->p_hamilt = new hamilt::HamiltLIP<T>(this->pelec->pot, this->pw_wfc, &this->kv, &this->ppcell, &ucell
6868
#ifdef __EXX
6969
, *this->exx_lip
7070
#endif

source/module_esolver/esolver_ks_lcaopw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace ModuleESolver
3333
const int iter,
3434
const double ethr) override;
3535

36-
virtual void allocate_hamilt() override;
36+
virtual void allocate_hamilt(const UnitCell& ucell) override;
3737
virtual void deallocate_hamilt() override;
3838

3939
#ifdef __EXX

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ ESolver_KS_PW<T, Device>::~ESolver_KS_PW()
115115
}
116116

117117
template <typename T, typename Device>
118-
void ESolver_KS_PW<T, Device>::allocate_hamilt()
118+
void ESolver_KS_PW<T, Device>::allocate_hamilt(const UnitCell& ucell)
119119
{
120-
this->p_hamilt = new hamilt::HamiltPW<T, Device>(this->pelec->pot, this->pw_wfc, &this->kv, &this->ppcell);
120+
this->p_hamilt = new hamilt::HamiltPW<T, Device>(this->pelec->pot, this->pw_wfc, &this->kv, &this->ppcell, &ucell);
121121
}
122122
template <typename T, typename Device>
123123
void ESolver_KS_PW<T, Device>::deallocate_hamilt()
@@ -202,10 +202,10 @@ void ESolver_KS_PW<T, Device>::before_all_runners(UnitCell& ucell, const Input_p
202202
}
203203

204204
//! init pseudopotential
205-
this->ppcell.init(ucell.ntype, &this->sf, this->pw_wfc);
205+
this->ppcell.init(ucell,&this->sf, this->pw_wfc);
206206

207207
//! initalize local pseudopotential
208-
this->ppcell.init_vloc(this->pw_rhod);
208+
this->ppcell.init_vloc(ucell,this->pw_rhod);
209209
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");
210210

211211
//! Initalize non-local pseudopotential
@@ -279,7 +279,7 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
279279
this->deallocate_hamilt();
280280

281281
// allocate HamiltPW
282-
this->allocate_hamilt();
282+
this->allocate_hamilt(ucell);
283283

284284
//----------------------------------------------------------
285285
// about vdw, jiyy add vdwd3 and linpz add vdwd2
@@ -585,8 +585,8 @@ void ESolver_KS_PW<T, Device>::after_scf(UnitCell& ucell, const int istep)
585585
PARAM.inp.out_wannier_wvfn_formatted,
586586
PARAM.inp.nnkpfile,
587587
PARAM.inp.wannier_spin);
588-
589-
wan.calculate(this->pelec->ekb, this->pw_wfc, this->pw_big, this->kv, this->psi);
588+
wan.set_tpiba_omega(ucell.tpiba, ucell.omega);
589+
wan.calculate(ucell,this->pelec->ekb, this->pw_wfc, this->pw_big, this->kv, this->psi);
590590
std::cout << FmtCore::format(" >> Finish %s.\n * * * * * *\n", "Wannier functions calculation");
591591
}
592592

@@ -595,7 +595,7 @@ void ESolver_KS_PW<T, Device>::after_scf(UnitCell& ucell, const int istep)
595595
{
596596
std::cout << FmtCore::format("\n * * * * * *\n << Start %s.\n", "Berry phase polarization");
597597
berryphase bp;
598-
bp.Macroscopic_polarization(this->pw_wfc->npwk_max, this->psi, this->pw_rho, this->pw_wfc, this->kv);
598+
bp.Macroscopic_polarization(ucell,this->pw_wfc->npwk_max, this->psi, this->pw_rho, this->pw_wfc, this->kv);
599599
std::cout << FmtCore::format(" >> Finish %s.\n * * * * * *\n", "Berry phase polarization");
600600
}
601601
}
@@ -621,7 +621,8 @@ void ESolver_KS_PW<T, Device>::cal_force(UnitCell& ucell, ModuleBase::matrix& fo
621621
: reinterpret_cast<psi::Psi<std::complex<double>, Device>*>(this->kspw_psi);
622622

623623
// Calculate forces
624-
ff.cal_force(force,
624+
ff.cal_force(ucell,
625+
force,
625626
*this->pelec,
626627
this->pw_rhod,
627628
&ucell.symm,
@@ -782,7 +783,7 @@ void ESolver_KS_PW<T, Device>::after_all_runners(UnitCell& ucell)
782783
//! 6) Print out electronic wave functions in real space
783784
if (PARAM.inp.out_wfc_r == 1) // Peize Lin add 2021.11.21
784785
{
785-
ModuleIO::write_psi_r_1(this->psi[0], this->pw_wfc, "wfc_realspace", true, this->kv);
786+
ModuleIO::write_psi_r_1(ucell,this->psi[0], this->pw_wfc, "wfc_realspace", true, this->kv);
786787
}
787788

788789
//! 7) Use Kubo-Greenwood method to compute conductivities

source/module_esolver/esolver_ks_pw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ESolver_KS_PW : public ESolver_KS<T, Device>
4646

4747
virtual void hamilt2density_single(UnitCell& ucell, const int istep, const int iter, const double ethr) override;
4848

49-
virtual void allocate_hamilt();
49+
virtual void allocate_hamilt(const UnitCell& ucell);
5050
virtual void deallocate_hamilt();
5151

5252
//! hide the psi in ESolver_KS for tmp use

0 commit comments

Comments
 (0)