Skip to content

Commit aa8dde3

Browse files
committed
Merge branch 'develop' of github.com:deepmodeling/abacus-develop into HSolver
2 parents c2f57de + ec6b8ae commit aa8dde3

Some content is hidden

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

66 files changed

+580
-1174
lines changed

docs/input-main.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868

6969
- [Variables useful for debugging](#variables-useful-for-debugging)
7070

71-
[nurse](#nurse) | [t_in_h](#t_in_h) | [vl_in_h](#vl_in_h) | [vnl_in_h](#vnl_in_h) | [test_force](#test_force) | [test_stress](#test_stress) | [colour](#colour) | [test_just_neighbor](#test_just_neighbor)
71+
[nurse](#nurse) | [t_in_h](#t_in_h) | [vl_in_h](#vl_in_h) | [vnl_in_h](#vnl_in_h) | [test_force](#test_force) | [test_stress](#test_stress) | [colour](#colour)
7272

7373
- [DeePKS](#deepks)
7474

@@ -148,6 +148,9 @@ This part of variables are used to control general system parameters.
148148
- *md*: molecular dynamics
149149
- *sto-scf*: do self-consistent electronic structure calculation with [stochastic DFT](#electronic-structure-sdft)
150150
- *sto-md*: molecular dynamics with [stochastic DFT](#electronic-structure-sdft)
151+
- *test_memory* : checks memory required for the calculation. The number is not quite reliable, please use with care
152+
- *test_neighbour* : only performs neighbouring atom search
153+
- *gen_jle* : generates projectors for DeePKS; see also deepks_lmax_descriptor
151154

152155
> Note: *istate* and *ienvelope* only work for LCAO basis set and are not working right now.
153156
- **Default**: scf
@@ -969,8 +972,8 @@ Warning: this function is not robust enough for the current version. Please try
969972
#### deepks_descriptor_lmax
970973
971974
- **Type**: Integer
972-
- **Description**: control the max angular momentum of descriptor basis.
973-
- **Default**: 0
975+
- **Description**: when generating projectors, this variable controls the max angular momentum of descriptor basis.
976+
- **Default**: 2
974977
975978
#### deepks_scf
976979
@@ -1590,12 +1593,6 @@ This part of variables are used to control berry phase and wannier90 interfacae
15901593
- **Description**: If set to 1, output to terminal will have some color.
15911594
- **Default**: 0
15921595
1593-
#### test_just_neighbor
1594-
1595-
- **Type**: Boolean
1596-
- **Description**: If set to 1, then only perform the neighboring atoms search.
1597-
- **Default**: 0
1598-
15991596
### Electronic conductivities
16001597
16011598
Frequency-dependent electronic conductivities can be calculated with Kubo-Greenwood formula[Phys. Rev. B 83, 235120 (2011)].

source/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ add_library(
2626
driver
2727
OBJECT
2828
driver.cpp
29+
driver_run.cpp
2930
input.cpp
3031
input_conv.cpp
3132
input_update.cpp
32-
run_lcao.cpp
33-
run_pw.cpp
3433
)

source/Makefile.Objects

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ ORB_gen_tables.o\
138138
local_orbital_wfc.o\
139139
local_orbital_charge.o\
140140
ELEC_evolve.o\
141-
LOOP_cell.o\
142-
LOOP_ions.o\
143141
run_md_lcao.o\
144142
DM_gamma.o\
145143
DM_k.o\
@@ -340,7 +338,6 @@ write_dm.o\
340338
write_wfc_realspace.o\
341339
magnetism.o\
342340
optical.o\
343-
Cell_PW.o\
344341
run_md_pw.o\
345342
ions.o \
346343
ions_move_methods.o\

source/driver.cpp

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
#include "input.h"
44
#include "input_conv.h"
5-
#include "run_pw.h"
65
#include "src_pw/global.h"
76
#ifdef __LCAO
8-
#include "run_lcao.h"
97
#include "src_lcao/global_fp.h"
108
#endif
119
#include "module_base/memory.h"
@@ -41,7 +39,6 @@ void Driver::init()
4139
Print_Info::print_time(time_start, time_finish);
4240

4341
// (4) close all of the running logs
44-
4542
INPUT.close_log();
4643

4744
return;
@@ -93,34 +90,11 @@ void Driver::atomic_world(void)
9390
// lcao_in_pw: LCAO expaned by plane wave basis set
9491
// lcao: linear combination of atomic orbitals
9592
//--------------------------------------------------
96-
string use_ensol;
97-
ModuleESolver::ESolver *p_esolver = nullptr;
98-
if (GlobalV::BASIS_TYPE == "pw" || GlobalV::BASIS_TYPE == "lcao_in_pw")
99-
{
100-
if (GlobalV::CALCULATION.substr(0, 3) == "sto")
101-
use_ensol = "sdft_pw";
102-
else
103-
use_ensol = "ksdft_pw";
104-
// We set it temporarily
105-
// Finally, we have ksdft_pw, ksdft_lcao, sdft_pw, ofdft, lj, eam, etc.
106-
ModuleESolver::init_esolver(p_esolver, use_ensol);
107-
Run_pw::plane_wave_line(p_esolver);
108-
ModuleESolver::clean_esolver(p_esolver);
109-
}
110-
#ifdef __LCAO
111-
else if (GlobalV::BASIS_TYPE == "lcao")
112-
{
113-
use_ensol = "ksdft_lcao";
114-
if (INPUT.tddft == 1)
115-
use_ensol = "ksdft_lcao_tddft";
116-
ModuleESolver::init_esolver(p_esolver, use_ensol);
117-
Run_lcao::lcao_line(p_esolver);
118-
ModuleESolver::clean_esolver(p_esolver);
119-
}
120-
#endif
12193

122-
ModuleBase::timer::finish(GlobalV::ofs_running);
94+
// where the actual stuff is done
95+
this->driver_run();
12396

97+
ModuleBase::timer::finish(GlobalV::ofs_running);
12498
ModuleBase::Memory::print_all(GlobalV::ofs_running);
12599

126100
return;

source/driver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class Driver
1818
// do stuff, have fun!
1919
void atomic_world();
2020

21+
// interface to the actual calculations
22+
void driver_run();
2123

2224
};
2325

source/driver_run.cpp

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#include "driver.h"
2+
#include "src_pw/global.h"
3+
#include "input.h"
4+
#include "src_io/winput.h"
5+
#include "module_neighbor/sltk_atom_arrange.h"
6+
#include "src_io/print_info.h"
7+
#include "src_lcao/run_md_lcao.h"
8+
#include "src_pw/run_md_pw.h"
9+
10+
// This is the driver function which defines the workflow of ABACUS calculations
11+
// It relies on the class Esolver, which is a class that organizes workflows of single point calculations.
12+
// For calculations involving change of configuration (lattice parameter & ionic motion),
13+
// this driver calls Esolver::Run and the configuration-changing subroutine
14+
// in a alternating manner.
15+
// Information is passed between the two subroutines by class UnitCell_Pseudo
16+
// Esolver::Run takes in a configuration and provides force and stress,
17+
// the configuration-changing subroutine takes force and stress and updates the configuration
18+
void Driver::driver_run()
19+
{
20+
ModuleBase::TITLE("Driver", "driver_line");
21+
ModuleBase::timer::tick("Driver", "driver_line");
22+
23+
// 1. Initialzie type of Esolver
24+
ModuleESolver::ESolver *p_esolver = nullptr;
25+
ModuleESolver::init_esolver(p_esolver);
26+
27+
// 2. Setup cell and atom information
28+
#ifdef __LCAO
29+
GlobalC::ucell.setup_cell(GlobalC::ORB, GlobalV::global_pseudo_dir, GlobalV::stru_file, GlobalV::ofs_running);
30+
#else
31+
if(GlobalV::BASIS_TYPE == "lcao_in_pw" || GlobalV::BASIS_TYPE == "lcao")
32+
{
33+
ModuleBase::WARNING_QUIT("driver","to use LCAO basis, compile with __LCAO");
34+
}
35+
GlobalC::ucell.setup_cell(GlobalV::global_pseudo_dir, GlobalV::stru_file, GlobalV::ofs_running);
36+
#endif
37+
38+
// 3. For these two types of calculations
39+
// nothing else need to be initialized
40+
if(GlobalV::CALCULATION == "test_neighbour" || GlobalV::CALCULATION == "test_memory")
41+
{
42+
p_esolver->Run(0, GlobalC::ucell);
43+
ModuleBase::QUIT();
44+
}
45+
46+
// 4. Initialize Esolver
47+
p_esolver->Init(INPUT, GlobalC::ucell);
48+
49+
//------------------------------------------------------------
50+
// This part onward needs to be refactored.
51+
//---------------------------MD/Relax------------------
52+
if(GlobalV::CALCULATION == "md" && GlobalV::BASIS_TYPE=="lcao")
53+
{
54+
Run_MD_LCAO run_md_lcao;
55+
run_md_lcao.opt_ions(p_esolver);
56+
}
57+
else if(GlobalV::CALCULATION == "md" || GlobalV::CALCULATION == "sto-md")
58+
{
59+
Run_MD_PW run_md_pw;
60+
run_md_pw.md_ions_pw(p_esolver);
61+
}
62+
else // scf; cell relaxation; nscf; etc
63+
{
64+
Ions ions;
65+
ions.opt_ions(p_esolver);
66+
}
67+
//---------------------------MD/Relax------------------
68+
69+
// 6. clean up esolver
70+
p_esolver->postprocess();
71+
ModuleESolver::clean_esolver(p_esolver);
72+
73+
ModuleBase::timer::tick("Driver", "driver_line");
74+
return;
75+
}

source/input.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2514,10 +2514,22 @@ void Input::Check(void)
25142514
if (!this->relax_nmax)
25152515
this->relax_nmax = 50;
25162516
}
2517-
else if (calculation == "test")
2517+
else if (calculation == "test_memory")
25182518
{
25192519
this->relax_nmax = 1;
25202520
}
2521+
else if(calculation == "test_neighbour")
2522+
{
2523+
this->relax_nmax = 1;
2524+
}
2525+
else if(calculation == "gen_jle")
2526+
{
2527+
this->relax_nmax = 1;
2528+
if(basis_type != "pw")
2529+
{
2530+
ModuleBase::WARNING_QUIT("Input","to generate descriptors, please use pw basis");
2531+
}
2532+
}
25212533
else
25222534
{
25232535
ModuleBase::WARNING_QUIT("Input", "check 'calculation' !");

source/input_conv.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ void Input_Conv::Convert(void)
8989
Force_Stress_LCAO::force_invalid_threshold_ev = INPUT.force_thr_ev2;
9090
#endif
9191

92+
if((INPUT.calculation=="relax" || INPUT.calculation=="cell-relax") && INPUT.chg_extrap!="atomic")
93+
{
94+
std::cout << " For relaxation, charge extrapolation is set to atomic." << std::endl;
95+
INPUT.chg_extrap="atomic";
96+
}
97+
9298
BFGS_Basic::relax_bfgs_w1 = INPUT.relax_bfgs_w1;
9399
BFGS_Basic::relax_bfgs_w2 = INPUT.relax_bfgs_w2;
94100

@@ -454,6 +460,10 @@ void Input_Conv::Convert(void)
454460
{
455461
elecstate::ElecStateLCAO::need_psi_grid = false;
456462
}
463+
if(INPUT.calculation == "test_neighbour" && GlobalV::NPROC>1)
464+
{
465+
ModuleBase::WARNING_QUIT("Input_conv", "test_neighbour must be done with 1 processor");
466+
}
457467
#endif
458468

459469
GlobalC::en.dos_emin_ev = INPUT.dos_emin_ev;

source/module_cell/atom_spec.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ class Atom: public Atom_pseudo
3434
ModuleBase::Vector3<double> *tau_original;// Cartesian coordinates of each atom in this type, but without periodic adjustment.
3535
ModuleBase::Vector3<double> *taud;// Direct coordinates of each atom in this type.
3636
ModuleBase::Vector3<double> *vel;// velocities of each atom in this type.
37+
ModuleBase::Vector3<double> *force; // force acting on each atom in this type.
3738

3839
double* mag;
3940
double* angle1;//spin angle, added by zhengdy-soc
4041
double* angle2;
4142
ModuleBase::Vector3<double> *m_loc_;
4243

43-
4444
void print_Atom(std::ofstream &ofs);
45+
void update_force(ModuleBase::matrix &fcs);
4546
#ifdef __MPI
4647
void bcast_atom(void);
4748
void bcast_atom2(void);

source/module_cell/unitcell.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ class UnitCell
7474
ModuleBase::Matrix3 GGT0;
7575
ModuleBase::Matrix3 invGGT0;
7676

77+
//I'm doing a bad thing here! Will change later
78+
bool ionic_position_updated = false; //whether the ionic position has been updated
79+
80+
private:
81+
ModuleBase::Matrix3 stress; //calculate stress on the cell
82+
7783
public:
7884
UnitCell();
7985
~UnitCell();
@@ -93,7 +99,8 @@ class UnitCell
9399
void save_cartesian_position_original(ModuleBase::Vector3<double>* pos)const;
94100
bool judge_big_cell(void)const;
95101

96-
102+
void update_stress(ModuleBase::matrix &scs); //updates stress
103+
void update_force(ModuleBase::matrix &fcs); //updates force in Atom
97104

98105
double *atom_mass;
99106
std::string *atom_label;

0 commit comments

Comments
 (0)