Skip to content

Commit 03b6bcd

Browse files
committed
Merge branch 'develop' of https://github.com/deepmodeling/abacus-develop into refactor
2 parents cddace7 + 68248c6 commit 03b6bcd

Some content is hidden

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

59 files changed

+383
-321
lines changed

source/driver.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ void Driver::init()
4343
// (4) close all of the running logs
4444
ModuleBase::Global_File::close_all_log(GlobalV::MY_RANK, PARAM.inp.out_alllog,PARAM.inp.calculation);
4545

46-
// (5) output the json file
47-
// Json::create_Json(&GlobalC::ucell.symm,GlobalC::ucell.atoms,&INPUT);
48-
Json::create_Json(&GlobalC::ucell, PARAM);
4946
}
5047

5148
void Driver::print_start_info()
@@ -180,7 +177,7 @@ void Driver::atomic_world()
180177
//--------------------------------------------------
181178

182179
// where the actual stuff is done
183-
this->driver_run(GlobalC::ucell);
180+
this->driver_run();
184181

185182
ModuleBase::timer::finish(GlobalV::ofs_running);
186183
ModuleBase::Memory::print_all(GlobalV::ofs_running);

source/driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Driver
3636
void atomic_world();
3737

3838
// the actual calculations
39-
void driver_run(UnitCell& ucell);
39+
void driver_run();
4040
};
4141

4242
#endif

source/driver_run.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@
2424
* the configuration-changing subroutine takes force and stress and updates the
2525
* configuration
2626
*/
27-
void Driver::driver_run(UnitCell& ucell)
27+
void Driver::driver_run()
2828
{
2929
ModuleBase::TITLE("Driver", "driver_line");
3030
ModuleBase::timer::tick("Driver", "driver_line");
3131

3232
//! 1: setup cell and atom information
33-
3433
// this warning should not be here, mohan 2024-05-22
3534
#ifndef __LCAO
3635
if (PARAM.inp.basis_type == "lcao_in_pw" || PARAM.inp.basis_type == "lcao") {
@@ -40,6 +39,13 @@ void Driver::driver_run(UnitCell& ucell)
4039
#endif
4140

4241
// the life of ucell should begin here, mohan 2024-05-12
42+
UnitCell ucell;
43+
ucell.setup(PARAM.inp.latname,
44+
PARAM.inp.ntype,
45+
PARAM.inp.lmaxmax,
46+
PARAM.inp.init_vel,
47+
PARAM.inp.fixed_axes);
48+
4349
ucell.setup_cell(PARAM.globalv.global_in_stru, GlobalV::ofs_running);
4450
Check_Atomic_Stru::check_atomic_stru(ucell, PARAM.inp.min_dist_coef);
4551

@@ -86,6 +92,8 @@ void Driver::driver_run(UnitCell& ucell)
8692

8793
ModuleESolver::clean_esolver(p_esolver);
8894

95+
//! 6: output the json file
96+
Json::create_Json(&ucell, PARAM);
8997
ModuleBase::timer::tick("Driver", "driver_line");
9098
return;
9199
}

source/module_elecstate/elecstate.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ void ElecState::calEBand()
208208

209209
void ElecState::init_scf(const int istep,
210210
const UnitCell& ucell,
211+
const Parallel_Grid& pgrid,
211212
const ModuleBase::ComplexMatrix& strucfac,
212213
const bool* numeric,
213214
ModuleSymmetry::Symmetry& symm,
@@ -227,7 +228,7 @@ void ElecState::init_scf(const int istep,
227228
// choose charge density from ionic step 0.
228229
if (istep == 0)
229230
{
230-
this->charge->init_rho(this->eferm,ucell, strucfac, symm, (const void*)this->klist, wfcpw);
231+
this->charge->init_rho(this->eferm,ucell, pgrid, strucfac, symm, (const void*)this->klist, wfcpw);
231232
this->charge->check_rho(); // check the rho
232233
}
233234

source/module_elecstate/elecstate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class ElecState
111111
*/
112112
void init_scf(const int istep,
113113
const UnitCell& ucell,
114+
const Parallel_Grid& pgrid,
114115
const ModuleBase::ComplexMatrix& strucfac,
115116
const bool* numeric,
116117
ModuleSymmetry::Symmetry& symm,

source/module_elecstate/module_charge/charge.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
#include "module_base/global_variable.h"
77
#include "module_base/parallel_global.h"
88
#include "module_basis/module_pw/pw_basis.h"
9-
#include "module_elecstate/fp_energy.h"
109
#include "module_cell/module_symmetry/symmetry.h"
10+
#include "module_elecstate/fp_energy.h"
11+
#include "module_hamilt_pw/hamilt_pwdft/parallel_grid.h"
1112

1213
//a forward declaration of UnitCell
1314
class UnitCell;
@@ -43,6 +44,7 @@ class Charge
4344
double **kin_r = nullptr; // kinetic energy density in real space, for meta-GGA
4445
double **kin_r_save = nullptr; // kinetic energy density in real space, for meta-GGA
4546
// wenfei 2021-07-28
47+
const Parallel_Grid* pgrid = nullptr;
4648
private:
4749
//temporary
4850
double *_space_rho = nullptr, *_space_rho_save = nullptr;
@@ -73,6 +75,7 @@ class Charge
7375
*/
7476
void init_rho(elecstate::efermi& eferm_iout,
7577
const UnitCell& ucell,
78+
const Parallel_Grid& pgrid,
7679
const ModuleBase::ComplexMatrix& strucFac,
7780
ModuleSymmetry::Symmetry& symm,
7881
const void* klist = nullptr,

source/module_elecstate/module_charge/charge_extra.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ void Charge_Extra::Init_CE(const int& nspin, const int& natom, const int& nrxx,
7575
}
7676

7777
void Charge_Extra::extrapolate_charge(
78-
#ifdef __MPI
7978
Parallel_Grid* Pgrid,
80-
#endif
8179
UnitCell& ucell,
8280
Charge* chr,
8381
Structure_Factor* sf,
@@ -109,7 +107,7 @@ void Charge_Extra::extrapolate_charge(
109107
rho_extr = std::min(istep, pot_order);
110108
if(rho_extr == 0)
111109
{
112-
sf->setup_structure_factor(&ucell, chr->rhopw);
110+
sf->setup_structure_factor(&ucell, *Pgrid, chr->rhopw);
113111
ofs_running << " charge density from previous step !" << std::endl;
114112
return;
115113
}
@@ -171,7 +169,7 @@ void Charge_Extra::extrapolate_charge(
171169
}
172170
}
173171

174-
sf->setup_structure_factor(&ucell, chr->rhopw);
172+
sf->setup_structure_factor(&ucell, *Pgrid, chr->rhopw);
175173
double** rho_atom = new double*[this->nspin];
176174
for (int is = 0; is < this->nspin; is++)
177175
{

source/module_elecstate/module_charge/charge_extra.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ class Charge_Extra
6363
* @param ofs_warning the output stream
6464
*/
6565
void extrapolate_charge(
66-
#ifdef __MPI
6766
Parallel_Grid* Pgrid,
68-
#endif
6967
UnitCell& ucell,
7068
Charge* chr,
7169
Structure_Factor* sf,

source/module_elecstate/module_charge/charge_init.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
void Charge::init_rho(elecstate::efermi& eferm_iout,
2525
const UnitCell& ucell,
26+
const Parallel_Grid& pgrid,
2627
const ModuleBase::ComplexMatrix& strucFac,
2728
ModuleSymmetry::Symmetry& symm,
2829
const void* klist,
@@ -33,7 +34,8 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
3334
std::cout << " START CHARGE : " << PARAM.inp.init_chg << std::endl;
3435
//here we need to set the omega for the charge density
3536
set_omega(&ucell.omega);
36-
37+
this->pgrid = &pgrid;
38+
3739
bool read_error = false;
3840
if (PARAM.inp.init_chg == "file" || PARAM.inp.init_chg == "auto")
3941
{
@@ -57,7 +59,7 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
5759
{
5860
std::stringstream ssc;
5961
ssc << PARAM.globalv.global_readin_dir << "SPIN" << is + 1 << "_CHG.cube";
60-
if (ModuleIO::read_vdata_palgrid(GlobalC::Pgrid,
62+
if (ModuleIO::read_vdata_palgrid(pgrid,
6163
(PARAM.inp.esolver_type == "sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK),
6264
GlobalV::ofs_running,
6365
ssc.str(),
@@ -107,7 +109,7 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
107109
GlobalV::ofs_running << " try to read kinetic energy density from file : " << ssc.str()
108110
<< std::endl;
109111
// mohan update 2012-02-10, sunliang update 2023-03-09
110-
if (ModuleIO::read_vdata_palgrid(GlobalC::Pgrid,
112+
if (ModuleIO::read_vdata_palgrid(pgrid,
111113
(PARAM.inp.esolver_type == "sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK),
112114
GlobalV::ofs_running,
113115
ssc.str(),
@@ -170,7 +172,7 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
170172
// try to load from the output of `out_chg`
171173
std::stringstream ssc;
172174
ssc << PARAM.globalv.global_readin_dir << "SPIN" << is + 1 << "_CHG.cube";
173-
if (ModuleIO::read_vdata_palgrid(GlobalC::Pgrid,
175+
if (ModuleIO::read_vdata_palgrid(pgrid,
174176
(PARAM.inp.esolver_type == "sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK),
175177
GlobalV::ofs_running,
176178
ssc.str(),

source/module_elecstate/potentials/pot_surchem.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class PotSurChem : public PotBase
4040
}
4141

4242
v_eff += this->surchem_->v_correction(*ucell,
43+
*chg->pgrid,
4344
const_cast<ModulePW::PW_Basis*>(this->rho_basis_),
4445
v_eff.nr,
4546
chg->rho,

0 commit comments

Comments
 (0)