Skip to content

Commit d98b754

Browse files
author
abacus_fixer
committed
update fix bugs
1 parent 5ac06b9 commit d98b754

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

source/source_estate/read_pseudo.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ void read_pseudo(std::ofstream& ofs, UnitCell& ucell,
159159
basis_type, smearing_method,
160160
ks_solver, bndpar);
161161

162+
// Set PARAM values from the calculated atoms_info
163+
ParamUpdater::update_from_atoms_info(atoms_info);
164+
162165
// setup nlocal
163166
// nlocal is calculated by CalAtomsInfo::cal_atoms_info() above
164167
cal_nwfc(ofs, ucell, ucell.atoms, nspin, atoms_info.nlocal, npol,
@@ -387,4 +390,14 @@ void print_unitcell_pseudo(const std::string& fn, UnitCell& ucell)
387390
return;
388391
}
389392

393+
void ParamUpdater::update_from_atoms_info(const AtomsInfoResult& atoms_info)
394+
{
395+
PARAM.input.nelec = atoms_info.nelec;
396+
PARAM.input.nbands = atoms_info.nbands;
397+
PARAM.input.nupdown = atoms_info.nupdown;
398+
PARAM.sys.use_uspp = atoms_info.use_uspp;
399+
PARAM.sys.nbands_l = atoms_info.nbands_l;
400+
PARAM.sys.ks_run = atoms_info.ks_run;
401+
}
402+
390403
}

source/source_estate/read_pseudo.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define READ_PSEUDO_H
33

44
#include "source_cell/unitcell.h"
5+
#include "source_cell/cal_atoms_info.h"
56

67
namespace elecstate {
78

@@ -58,6 +59,12 @@ namespace elecstate {
5859
// atoms[].na
5960
//=========================
6061
void cal_natomwfc(std::ofstream& log,int& natomwfc,const int ntype,const Atom* atoms,const int nspin);
62+
63+
class ParamUpdater {
64+
public:
65+
static void update_from_atoms_info(const AtomsInfoResult& atoms_info);
66+
};
67+
6168
}
6269

6370
#endif

source/source_io/module_parameter/parameter.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
#include "system_parameter.h"
55
namespace ModuleIO
66
{
7-
class ReadInput;
7+
class ReadInput;
88
}
99

10-
class CalAtomInfo;
10+
namespace elecstate
11+
{
12+
class ParamUpdater;
13+
}
1114

1215
class Parameter
1316
{
@@ -35,11 +38,10 @@ class Parameter
3538
// Set the start time
3639
void set_start_time(const std::time_t& start_time);
3740
private:
38-
// Only ReadInput and CalAtomInfo can modify the value of Parameter.
41+
// Only ReadInput and ParamUpdater can modify the value of Parameter.
3942
// Do not add extra friend class here!!!
4043
friend class ModuleIO::ReadInput; // ReadInput read INPUT file and give the value to Parameter
41-
friend class CalAtomsInfo; // CalAtomInfo calculate the atom information from pseudopotential and give the value to
42-
// Parameter
44+
friend class elecstate::ParamUpdater; // ParamUpdater updates Parameter values from atoms_info
4345

4446
// INPUT parameters
4547
Input_para input;

0 commit comments

Comments
 (0)