Skip to content

Commit 287b4ae

Browse files
author
root
committed
Merge branch 'develop' of https://github.com/deepmodeling/abacus-develop into diag
2 parents 200a9cf + a6d0ba1 commit 287b4ae

File tree

272 files changed

+3623
-4691
lines changed

Some content is hidden

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

272 files changed

+3623
-4691
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@
424424
- [pexsi\_zero\_thr](#pexsi_zero_thr)
425425
- [Linear Response TDDFT](#linear-response-tddft)
426426
- [xc\_kernel](#xc_kernel)
427+
- [lr\_init\_xc\_kernel](#lr_init_xc_kernel)
427428
- [lr\_solver](#lr_solver)
428429
- [lr\_thr](#lr_thr)
429430
- [nocc](#nocc)
@@ -2937,7 +2938,7 @@ These variables are used to control DFT+U correlated parameters
29372938

29382939
- where $\gamma$ is a parameter that adjusts the relative weight of the error function to the derivative error function.
29392940
- **Unit**: Bohr
2940-
- **Default**: 5.0
2941+
- **Default**: 3.0
29412942

29422943
[back to top](#full-list-of-input-keywords)
29432944

@@ -3955,6 +3956,15 @@ These parameters are used to solve the excited states using. e.g. LR-TDDFT.
39553956
Currently supported: `RPA`, `LDA`, `PBE`, `HSE`, `HF`.
39563957
- **Default**: LDA
39573958

3959+
### lr_init_xc_kernel
3960+
3961+
- **Type**: String
3962+
- **Description**: The method to initalize the xc kernel.
3963+
- "default": Calculate xc kerenel ($f_\text{xc}$) from the ground-state charge density.
3964+
- "file": Read the xc kernel $f_\text{xc}$ on grid from the provided files. The following words should be the paths of ".cube" files, where the first 1 (*[nspin](#nspin)==1*) or 3 (*[nspin](#nspin)==2*, namely spin-aa, spin-ab and spin-bb) will be read in. The parameter [xc_kernel](#xc_kernel) will be invalid. Now only LDA-type kernel is supproted as the potential will be calculated by directly multiplying the transition density.
3965+
- "from_charge_file": Calculate fxc from the charge density read from the provided files. The following words should be the paths of ".cube" files, where the first [nspin]($nspin) files will be read in.
3966+
- **Default**: "default"
3967+
39583968
### lr_solver
39593969

39603970
- **Type**: String

examples/bsse/water/result.ref

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-13.31798074740440
2-
E_H2O: -466.1225988776397
3-
E_O: -427.6271689751553
4-
E_H1: -12.58872469295076
5-
E_H2: -12.58872446212924
1+
-13.49968292248493
2+
E_H2O: -466.1225988772539
3+
E_O: -427.5222287307378
4+
E_H1: -12.55034372743879
5+
E_H2: -12.55034349659238

examples/scf/lcao_Cu/INPUT

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ orbital_dir ../../../tests/PP_ORB
44
nbands 10
55

66
calculation scf
7-
ecutwfc 100
87
ecutwfc 100 ###Energy cutoff needs to be tested to ensure your calculation is reliable.[1]
98
scf_thr 1.0e-8
109
scf_nmax 100

source/Makefile.Objects

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ OBJS_ESOLVER=esolver.o\
245245
esolver_of.o\
246246
esolver_of_tool.o\
247247
esolver_of_interface.o\
248-
pw_init_after_vc.o\
249248
pw_init_globalc.o\
250249
pw_others.o\
251250

@@ -256,7 +255,6 @@ OBJS_ESOLVER_LCAO=esolver_ks_lcao.o\
256255
lcao_before_scf.o\
257256
esolver_gets.o\
258257
lcao_others.o\
259-
lcao_init_after_vc.o\
260258

261259
OBJS_GINT=gint.o\
262260
gint_gamma_env.o\
@@ -317,7 +315,7 @@ OBJS_HAMILT_LCAO=hamilt_lcao.o\
317315
op_dftu_lcao.o\
318316
deepks_lcao.o\
319317
op_exx_lcao.o\
320-
sc_lambda_lcao.o\
318+
dspin_lcao.o\
321319
dftu_lcao.o\
322320

323321
OBJS_HCONTAINER=base_matrix.o\
@@ -696,14 +694,11 @@ OBJS_DFTU=dftu.o\
696694
dftu_hamilt.o
697695

698696
OBJS_DELTASPIN=basic_funcs.o\
699-
cal_h_lambda.o\
700697
cal_mw_from_lambda.o\
701-
cal_mw_helper.o\
702698
cal_mw.o\
703699
init_sc.o\
704700
lambda_loop_helper.o\
705701
lambda_loop.o\
706-
sc_parse_json.o\
707702
spin_constrain.o\
708703
template_helpers.o\
709704

@@ -730,7 +725,7 @@ OBJS_TENSOR=tensor.o\
730725
dmr_complex.o\
731726
operator_lr_hxc.o\
732727
operator_lr_exx.o\
733-
kernel_xc.o\
728+
xc_kernel.o\
734729
pot_hxc_lrtd.o\
735730
lr_spectrum.o\
736731
hamilt_casida.o\

source/module_base/module_mixing/mixing_data.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Base_Mixing
44
{
55

6-
Mixing_Data::Mixing_Data(const int& ndim, const int& length, const size_t& type_size)
6+
Mixing_Data::Mixing_Data(const int& ndim, const std::size_t& length, const size_t& type_size)
77
{
88
this->ndim_tot = ndim;
99
this->length = length;
@@ -15,16 +15,18 @@ Mixing_Data::Mixing_Data(const int& ndim, const int& length, const size_t& type_
1515

1616
Mixing_Data::~Mixing_Data()
1717
{
18-
if (this->data != nullptr)
18+
if (this->data != nullptr) {
1919
free(this->data);
2020
}
21+
}
2122

22-
void Mixing_Data::resize(const int& ndim, const int& length, const size_t& type_size)
23+
void Mixing_Data::resize(const int& ndim, const std::size_t& length, const size_t& type_size)
2324
{
2425
this->ndim_tot = ndim;
2526
this->length = length;
26-
if (this->data != nullptr)
27+
if (this->data != nullptr) {
2728
free(this->data);
29+
}
2830
if (ndim * length > 0)
2931
{
3032
this->data = malloc(ndim * length * type_size);

source/module_base/module_mixing/mixing_data.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Mixing_Data
2222
* @param type_size size of type
2323
*
2424
*/
25-
Mixing_Data(const int& ndim, const int& length, const size_t& type_size);
25+
Mixing_Data(const int& ndim, const std::size_t& length, const size_t& type_size);
2626

2727
/**
2828
* @brief Destroy the Mixing_Data object
@@ -38,7 +38,7 @@ class Mixing_Data
3838
* @param type_size size of type
3939
*
4040
*/
41-
void resize(const int& ndim, const int& length, const size_t& type_size);
41+
void resize(const int& ndim, const std::size_t& length, const size_t& type_size);
4242

4343
/**
4444
* @brief push data to the tensor
@@ -54,7 +54,7 @@ class Mixing_Data
5454
#ifdef _OPENMP
5555
#pragma omp parallel for schedule(static, 4096/sizeof(FPTYPE))
5656
#endif
57-
for (int i = 0; i < length; ++i)
57+
for (std::size_t i = 0; i < length; ++i)
5858
{
5959
FP_startdata[i] = data_in[i];
6060
}
@@ -86,7 +86,7 @@ class Mixing_Data
8686
// the number of vectors for mixing
8787
int ndim_tot = 0;
8888
// the length of each vector
89-
int length = 0;
89+
std::size_t length = 0;
9090
// the start index for vector: start = this->index_move(0)
9191
int start = -1;
9292
// the number of used vectors for mixing

source/module_base/module_mixing/pulay_mixing.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ void Pulay_Mixing::tem_push_data(Mixing_Data& mdata,
2828
std::function<void(FPTYPE*, const FPTYPE*, const FPTYPE*)> mix,
2929
const bool& need_calcoef)
3030
{
31-
const size_t length = mdata.length;
31+
const std::size_t length = mdata.length;
3232
std::vector<FPTYPE> F_tmp(length);
3333

3434
#ifdef _OPENMP
3535
#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE))
3636
#endif
37-
for (int i = 0; i < length; ++i)
37+
for (std::size_t i = 0; i < length; ++i)
3838
{
3939
F_tmp[i] = data_out[i] - data_in[i];
4040
}
@@ -69,7 +69,7 @@ void Pulay_Mixing::tem_push_data(Mixing_Data& mdata,
6969
#ifdef _OPENMP
7070
#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE))
7171
#endif
72-
for (int i = 0; i < length; ++i)
72+
for (std::size_t i = 0; i < length; ++i)
7373
{
7474
FP_F[i] = F_tmp[i];
7575
}
@@ -81,7 +81,7 @@ void Pulay_Mixing::tem_push_data(Mixing_Data& mdata,
8181
#ifdef _OPENMP
8282
#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE))
8383
#endif
84-
for (int i = 0; i < length; ++i)
84+
for (std::size_t i = 0; i < length; ++i)
8585
{
8686
FP_startF[i] = F_tmp[i];
8787
}
@@ -103,7 +103,7 @@ void Pulay_Mixing::tem_cal_coef(const Mixing_Data& mdata, std::function<double(F
103103
ModuleBase::WARNING_QUIT(
104104
"Pulay_mixing",
105105
"One Pulay_Mixing object can only bind one Mixing_Data object to calculate coefficients");
106-
const int length = mdata.length;
106+
const std::size_t length = mdata.length;
107107
FPTYPE* FP_F = static_cast<FPTYPE*>(F);
108108

109109
if (mdata.ndim_use > 1)

source/module_cell/atom_spec.cpp

Lines changed: 25 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13,55 +13,20 @@ Atom::Atom()
1313
type = 0;
1414
stapos_wf = 0;
1515
mass = 0.0;
16-
tau = new ModuleBase::Vector3<double>[1];
17-
dis = new ModuleBase::Vector3<double>[1];
18-
taud = new ModuleBase::Vector3<double>[1];
19-
vel = new ModuleBase::Vector3<double>[1];
20-
mag = new double[1];
21-
angle1 = new double[1];
22-
angle2 = new double[1];
23-
m_loc_ = new ModuleBase::Vector3<double>[1];
24-
l_nchi = new int[1];
25-
iw2l = new int[1];
26-
iw2n = new int[1];
27-
iw2m = new int[1];
28-
iw2_ylm = new int[1];
29-
iw2_new = new bool[1];
30-
mbl = new ModuleBase::Vector3<int>[1];
3116
}
3217

3318
Atom::~Atom()
3419
{
35-
delete[] tau;
36-
delete[] dis;
37-
delete[] taud;
38-
delete[] vel;
39-
delete[] mag;
40-
delete[] angle1;
41-
delete[] angle2;
42-
delete[] m_loc_;
43-
delete[] l_nchi;
44-
delete[] iw2l;
45-
delete[] iw2n;
46-
delete[] iw2m;
47-
delete[] iw2_ylm;
48-
delete[] iw2_new;
49-
delete[] mbl;
5020
}
5121

5222
void Atom::set_index(void)
5323
{
5424
assert(nw != 0);
55-
delete[] iw2l;
56-
delete[] iw2n;
57-
delete[] iw2m;
58-
delete[] iw2_ylm;
59-
delete[] iw2_new;
60-
iw2l = new int[nw];
61-
iw2n = new int[nw];
62-
iw2m = new int[nw];
63-
iw2_ylm = new int[nw];
64-
iw2_new = new bool[nw];
25+
this->iw2l.resize(nw, 0);
26+
this->iw2n.resize(nw, 0);
27+
this->iw2m.resize(nw, 0);
28+
this->iw2_ylm.resize(nw, 0);
29+
this->iw2_new.resize(nw, false); // bool array to check if the local orbital is new
6530

6631
int index = 0;
6732
for (int L = 0; L <= nwl; L++)
@@ -103,7 +68,7 @@ void Atom::print_Atom(std::ofstream& ofs)
10368
ModuleBase::GlobalFunc::OUT(ofs, "mass", mass);
10469
ofs << std::endl;
10570

106-
output::printv31_d(ofs, "atom_position(cartesian)", tau, na);
71+
output::printv31_d(ofs, "atom_position(cartesian)", tau.data(), na);
10772
/*
10873
for (int i = 0;i < na;i++)
10974
{
@@ -131,34 +96,26 @@ void Atom::bcast_atom(void)
13196
Parallel_Common::bcast_bool(coulomb_potential);
13297
if (GlobalV::MY_RANK != 0)
13398
{
134-
delete[] l_nchi;
135-
l_nchi = new int[nwl + 1];
99+
this->l_nchi.resize(nwl + 1, 0);
136100
}
137-
Parallel_Common::bcast_int(l_nchi, nwl + 1);
101+
Parallel_Common::bcast_int(l_nchi.data(), nwl + 1);
138102
Parallel_Common::bcast_bool(this->flag_empty_element);
139103
Parallel_Common::bcast_double(mass);
140104

141105
if (GlobalV::MY_RANK != 0)
142106
{
143107
assert(na != 0);
144-
delete[] tau;
145-
delete[] dis;
146-
delete[] taud;
147-
delete[] vel;
148-
delete[] mag;
149-
delete[] angle1;
150-
delete[] angle2;
151-
delete[] m_loc_;
152-
delete[] mbl;
153-
tau = new ModuleBase::Vector3<double>[na];
154-
dis = new ModuleBase::Vector3<double>[na];
155-
taud = new ModuleBase::Vector3<double>[na];
156-
vel = new ModuleBase::Vector3<double>[na];
157-
mag = new double[na];
158-
angle1 = new double[na];
159-
angle2 = new double[na];
160-
m_loc_ = new ModuleBase::Vector3<double>[na];
161-
mbl = new ModuleBase::Vector3<int>[na];
108+
this->tau.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
109+
this->dis.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
110+
this->taud.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
111+
this->vel.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
112+
this->mag.resize(na, 0);
113+
this->angle1.resize(na, 0);
114+
this->angle2.resize(na, 0);
115+
this->m_loc_.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
116+
this->mbl.resize(na, ModuleBase::Vector3<int>(0, 0, 0));
117+
this->lambda.resize(na, ModuleBase::Vector3<double>(0, 0, 0));
118+
this->constrain.resize(na, ModuleBase::Vector3<int>(0, 0, 0));
162119
}
163120

164121
for (int i = 0; i < na; i++)
@@ -184,6 +141,12 @@ void Atom::bcast_atom(void)
184141
Parallel_Common::bcast_int(mbl[i].x);
185142
Parallel_Common::bcast_int(mbl[i].y);
186143
Parallel_Common::bcast_int(mbl[i].z);
144+
Parallel_Common::bcast_double(lambda[i].x);
145+
Parallel_Common::bcast_double(lambda[i].y);
146+
Parallel_Common::bcast_double(lambda[i].z);
147+
Parallel_Common::bcast_int(constrain[i].x);
148+
Parallel_Common::bcast_int(constrain[i].y);
149+
Parallel_Common::bcast_int(constrain[i].z);
187150
}
188151

189152
return;

source/module_cell/atom_spec.h

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ class Atom
1313

1414
Atom_pseudo ncpp;
1515
double mass; // the mass of atom
16-
ModuleBase::Vector3<int> *mbl; // whether the atoms can move or not
16+
std::vector<ModuleBase::Vector3<int>> mbl; // whether the atoms can move or not
1717
bool flag_empty_element = false; // whether is the empty element for bsse. Peize Lin add 2021.04.07
1818

19-
int *iw2m; // use iw to find m
20-
int *iw2n; // use iw to find n
21-
int *iw2l; // use iw to find L
22-
int *iw2_ylm;
23-
bool *iw2_new;
19+
std::vector<int> iw2m; // use iw to find m
20+
std::vector<int> iw2n; // use iw to find n
21+
std::vector<int> iw2l; // use iw to find L
22+
std::vector<int> iw2_ylm;
23+
std::vector<bool> iw2_new;
2424
int nw; // number of local orbitals (l,n,m) of this type
2525

2626
void set_index(void);
@@ -30,21 +30,23 @@ class Atom
3030

3131
int nwl; // max L(Angular momentum) (for local basis)
3232
double Rcut; //pengfei Li 16-2-29
33-
int *l_nchi; // number of chi for each L
33+
std::vector<int> l_nchi; // number of chi for each L
3434
int stapos_wf; // start position of wave functions
3535

3636
std::string label; // atomic symbol
37-
ModuleBase::Vector3<double> *tau;// Cartesian coordinates of each atom in this type.
38-
ModuleBase::Vector3<double> *dis;// direct displacements of each atom in this type in current step liuyu modift 2023-03-22
39-
ModuleBase::Vector3<double> *taud;// Direct coordinates of each atom in this type.
40-
ModuleBase::Vector3<double> *vel;// velocities of each atom in this type.
41-
ModuleBase::Vector3<double> *force; // force acting on each atom in this type.
37+
std::vector<ModuleBase::Vector3<double>> tau;// Cartesian coordinates of each atom in this type.
38+
std::vector<ModuleBase::Vector3<double>> dis;// direct displacements of each atom in this type in current step liuyu modift 2023-03-22
39+
std::vector<ModuleBase::Vector3<double>> taud;// Direct coordinates of each atom in this type.
40+
std::vector<ModuleBase::Vector3<double>> vel;// velocities of each atom in this type.
41+
std::vector<ModuleBase::Vector3<double>> force; // force acting on each atom in this type.
42+
std::vector<ModuleBase::Vector3<double>> lambda; // Lagrange multiplier for each atom in this type. used in deltaspin
43+
std::vector<ModuleBase::Vector3<int>> constrain; // constrain for each atom in this type. used in deltaspin
4244
std::string label_orb; // atomic Element symbol in the orbital file of lcao
4345

44-
double* mag;
45-
double* angle1;//spin angle, added by zhengdy-soc
46-
double* angle2;
47-
ModuleBase::Vector3<double> *m_loc_;
46+
std::vector<double> mag;
47+
std::vector<double> angle1;//spin angle, added by zhengdy-soc
48+
std::vector<double> angle2;
49+
std::vector<ModuleBase::Vector3<double>> m_loc_;
4850
// Coulomb potential v(r) = z/r
4951
// It is a local potentail, and has no non-local potential parts.
5052
bool coulomb_potential = false;

0 commit comments

Comments
 (0)