Skip to content

Commit 002786e

Browse files
Wuming-HUSTdependabot[bot]Critsium-xywangtianxiangzgn-26714
authored
Feature: add DFT-1/2 and shell DFT-1/2, only support PW esolvers_ks_pw. (#6490)
* Feature: add DFT-1/2 and shell DFT-1/2, currently only support PW esolver_ks_pw. * Added Sep, Sep_Cell, and VSep to organize the self-energy potential of DFT-1/2 * Added a new effective potential pot_sep for calculating the self-energy potential * Added initialization of the self-energy potential in the esolver_ks_pw control flow * Added the keyword SEP_FILES in the STRU file for reading self-energy potential files * Added the dfthalf_type keyword in INPUT to enable DFT-1/2 and shell DFT-1/2 * Fix: Compilation error in DeepKS unit tests after adding DFT-1/2 * Fix: Add the additional files to Makefile.Objects * Build(deps): Bump actions/setup-python from 5 to 6 (#6492) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5 to 6. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](actions/setup-python@v5...v6) --- updated-dependencies: - dependency-name: actions/setup-python dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * [Refactor] Move hardware initializer out from esolver code (#6494) * Move hardware initializer out from esolver * Remove useless codes * Remove finalize code out * Feature: support NVTX profiling via timer_enable_nvtx flag (#6495) * Feature: support NVTX profiling via timer_enable_nvtx flag Signed-off-by:Tianxiang Wang<[email protected]>, Contributed under MetaX Integrated Circuits (Shanghai) Co., Ltd. * Add timer_enable_nvtx section in markdown Signed-off-by:Tianxiang Wang<[email protected]>, Contributed under MetaX Integrated Circuits (Shanghai) Co., Ltd. * Fix: Use __USE_NVTX macro to avoid NVTX linking errors in tests. Clarify in docs that timer_enable_nvtx parameter only takes effect on CUDA platforms. Signed-off-by:Tianxiang Wang<[email protected]>, Contributed under MetaX Integrated Circuits (Shanghai) Co., Ltd. * Perf: Optimize Davidson by fusing operators, offloading CPU computation to GPU, and reducing memory transfers (#6493) * Perf: Optimize Diago_DavSubspace with GPU operators by adding and fusing custom kernels. Signed-off-by:Tianxiang Wang<[email protected]>, Contributed under MetaX Integrated Circuits (Shanghai) Co., Ltd. * Perf: reduce memory allocation and copy in Diago_DavSubspace::diag_zhegvx Signed-off-by:Tianxiang Wang<[email protected]>, Contributed under MetaX Integrated Circuits (Shanghai) Co., Ltd. * Perf: Replace loop-based 2D copy and memset with memcpy_2d_op, memset_2d_op Signed-off-by:Tianxiang Wang<[email protected]>, Contributed under MetaX Integrated Circuits (Shanghai) Co., Ltd. * Perf: use warp reduce instead of shared memory for better efficiency Signed-off-by:Tianxiang Wang<[email protected]>, Contributed under MetaX Integrated Circuits (Shanghai) Co., Ltd. * Fix compilation error Signed-off-by:Tianxiang Wang<[email protected]>, Contributed under MetaX Integrated Circuits (Shanghai) Co., Ltd. * Fix: resolve compile error with USE_ELPA=OFF + BUILD_TESTING=ON and switch to nvtx3 headers when CUDA_VERSION >= 12090 (#6497) * Fix: switch to nvtx3 headers when CUDA_VERSION >= 12090 Signed-off-by:Tianxiang Wang<[email protected]>, Contributed under MetaX Integrated Circuits (Shanghai) Co., Ltd. * Fix: resolve compile error with USE_ELPA=OFF + BUILD_TESTING=ON Signed-off-by:Tianxiang Wang<[email protected]>, Contributed under MetaX Integrated Circuits (Shanghai) Co., Ltd. * Fix dsp compilation problem (#6499) * Fix: Fix crash in Debug build with multi-GPU due to forced cudaSetDevice(0) (#6498) Signed-off-by:Tianxiang Wang<[email protected]>, Contributed under MetaX Integrated Circuits (Shanghai) Co., Ltd. * Removed the temporary variable DMRGint_full when transitioning from 2D block parallelism to serial in Hcontainer(develop) (#6489) * delete tem Hcontainer to reduce memory usage * simplify the compute code * change DM2D_tmp to dm2d_tmp, use vector instead of new * Update version to 3.9.0.14 (#6504) * Refactor: Remove the GlobalC from sep_cell and vsep_cell * Removed GlobalC::sep_cell and GlobalC::vsep_cell from GlobalC * Integrated sep_cell into UnitCell * Integrated vsep_cell into esolver_ks_pw * Added empty constructors and destructors for Sep_Pot and Sep_Cell to facilitate unit testing compilation --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Critsium <[email protected]> Co-authored-by: Tianxiang Wang <[email protected]> Co-authored-by: zgn-26714 <[email protected]> Co-authored-by: Erjie Wu <[email protected]> Co-authored-by: Mohan Chen <[email protected]>
1 parent 99720fe commit 002786e

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

+3580
-168
lines changed

source/Makefile.Objects

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ OBJS_CELL=atom_pseudo.o\
202202
bcast_cell.o\
203203
read_stru.o\
204204
read_atom_species.o\
205+
sep.o\
206+
sep_cell.o\
205207

206208
OBJS_DEEPKS=LCAO_deepks.o\
207209
deepks_basic.o\
@@ -220,7 +222,7 @@ OBJS_DEEPKS=LCAO_deepks.o\
220222
deepks_phialpha.o\
221223
LCAO_deepks_io.o\
222224
LCAO_deepks_interface.o\
223-
225+
224226

225227
OBJS_ELECSTAT=elecstate.o\
226228
elecstate_energy_terms.o\
@@ -246,6 +248,7 @@ OBJS_ELECSTAT=elecstate.o\
246248
cal_nelec_nband.o\
247249
read_pseudo.o\
248250
cal_wfc.o\
251+
pot_sep.o\
249252

250253
OBJS_ELECSTAT_LCAO=elecstate_lcao.o\
251254
elecstate_lcao_cal_tau.o\
@@ -397,7 +400,7 @@ OBJS_HSOLVER=diago_cg.o\
397400
diag_const_nums.o\
398401
diag_hs_para.o\
399402
diago_pxxxgvx.o\
400-
403+
401404
OBJS_HSOLVER_LCAO=hsolver_lcao.o\
402405
diago_scalapack.o\
403406
diago_lapack.o\
@@ -415,7 +418,7 @@ OBJS_HSOLVER_PEXSI=diago_pexsi.o\
415418
dist_bcd_matrix.o\
416419
dist_ccs_matrix.o\
417420
dist_matrix_transformer.o\
418-
421+
419422
OBJS_MD=fire.o\
420423
langevin.o\
421424
md_base.o\
@@ -490,7 +493,7 @@ OBJS_RELAXATION=bfgs_basic.o\
490493
lbfgs.o\
491494
matrix_methods.o\
492495
line_search.o\
493-
496+
494497

495498
OBJS_SURCHEM=surchem.o\
496499
H_correction_pw.o\
@@ -690,7 +693,7 @@ OBJS_PARALLEL=parallel_common.o\
690693
parallel_kpoints.o\
691694
parallel_reduce.o\
692695
parallel_device.o
693-
696+
694697
OBJS_SRCPW=H_Ewald_pw.o\
695698
dnrm2.o\
696699
VL_in_pw.o\
@@ -754,7 +757,8 @@ OBJS_SRCPW=H_Ewald_pw.o\
754757
sto_elecond.o\
755758
sto_dos.o\
756759
onsite_projector.o\
757-
onsite_proj_tools.o
760+
onsite_proj_tools.o\
761+
VSep_in_pw.o
758762

759763
OBJS_VDW=vdw.o\
760764
vdwd2_parameters.o\

source/source_cell/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ add_library(
2626
print_cell.cpp
2727
read_atom_species.cpp
2828
k_vector_utils.cpp
29+
sep.cpp
30+
sep_cell.cpp
2931
)
3032

3133
if(ENABLE_COVERAGE)

source/source_cell/module_symmetry/test/symmetry_test_analysis.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
* 1-1. test if the bravis lattice analysis is right;
77
* 1-2. check if matrix-type and vector3-type;
88
* input and optimized lattice vectors are right;
9-
* 1-3. double-check for if `gtrans_convert`
9+
* 1-3. double-check for if `gtrans_convert`
1010
* gives the same results as `veccon`;
1111
* 1-4. check `invmap` function gives the right result;
1212
* 1-5 test if `gmatrix_convert` and `gmatrix_convert_int`
1313
* gives the right result;
1414
* 2. function: `atom_ordering_new:
1515
* test the new atom-sort algorithm gives the right result;
1616
*3. function: `pricell`:
17-
* test if the number of primitive cells are right,
17+
* test if the number of primitive cells are right,
1818
* using cases whose space group
1919
* is different from its point group.
2020
***********************************************/
@@ -34,6 +34,10 @@ UnitCell::UnitCell(){}
3434
UnitCell::~UnitCell(){}
3535
Magnetism::Magnetism(){}
3636
Magnetism::~Magnetism() {}
37+
SepPot::SepPot(){}
38+
SepPot::~SepPot(){}
39+
Sep_Cell::Sep_Cell() noexcept {}
40+
Sep_Cell::~Sep_Cell() noexcept {}
3741

3842
TEST_F(SymmetryTest, AnalySys)
3943
{
@@ -50,8 +54,8 @@ TEST_F(SymmetryTest, AnalySys)
5054
int cal_ibrav = symm.real_brav;
5155
EXPECT_EQ(cal_ibrav, ref_ibrav);
5256
EXPECT_EQ(cal_point_group, ref_point_group) << "ibrav=" << stru_lib[stru].ibrav;
53-
54-
//2. input and optimized lattice, gtrans_convert and veccon
57+
58+
//2. input and optimized lattice, gtrans_convert and veccon
5559
//input lattice
5660
EXPECT_EQ(symm.s1, ucell.a1);
5761
EXPECT_EQ(symm.s2, ucell.a2);
@@ -73,7 +77,7 @@ TEST_F(SymmetryTest, AnalySys)
7377
symm.gtrans_convert(symm.gtrans, gtrans_optconf.data(), symm.nrotk, ucell.latvec, symm.optlat);
7478
symm.veccon(gtrans_veccon, gtrans_optconf_veccon, symm.nrotk, symm.s1, symm.s2, symm.s3, symm.a1, symm.a2, symm.a3);
7579
for(int i=0;i<symm.nrotk;++i)
76-
EXPECT_EQ(gtrans_optconf[i], ModuleBase::Vector3<double>(gtrans_optconf_veccon[i*3],
80+
EXPECT_EQ(gtrans_optconf[i], ModuleBase::Vector3<double>(gtrans_optconf_veccon[i*3],
7781
gtrans_optconf_veccon[i*3+1], gtrans_optconf_veccon[i*3+2]));
7882
delete[] gtrans_veccon;
7983
delete[] gtrans_optconf_veccon;
@@ -108,7 +112,7 @@ TEST_F(SymmetryTest, AnalySys)
108112
symm.gmatrix_convert_int(symm.gmatrix, gmatrix_opt, symm.nrotk, ucell.latvec, symm.optlat); //1->2
109113
symm.gmatrix_convert_int(gmatrix_opt, gmatrix_input_back, symm.nrotk, symm.optlat, ucell.latvec); //2->3
110114
symm.gmatrix_convert_int(gmatrix_input_back, gmatrix_opt_back, symm.nrotk, ucell.latvec, symm.optlat); //3->4
111-
115+
112116
symm.gmatrix_convert(symm.gmatrix, kgmatrix_nonint, symm.nrotk, ucell.latvec, ucell.G);
113117
for (int i=0;i<symm.nrotk;++i)
114118
{
@@ -130,7 +134,7 @@ TEST_F(SymmetryTest, AnalySys)
130134
EXPECT_NEAR(gmatrix_opt[i].e31, gmatrix_opt_back[i].e31, DOUBLETHRESHOLD);
131135
EXPECT_NEAR(gmatrix_opt[i].e23, gmatrix_opt_back[i].e23, DOUBLETHRESHOLD);
132136
EXPECT_NEAR(gmatrix_opt[i].e32, gmatrix_opt_back[i].e32, DOUBLETHRESHOLD);
133-
137+
134138
ModuleBase::Matrix3 tmpA=symm.optlat.Inverse()*gmatrix_opt[i]*symm.optlat; //A^-1*SA*A
135139
ModuleBase::Matrix3 tmpB=ucell.latvec.Inverse()*symm.gmatrix[i]*ucell.latvec;//B^-1*SB*B
136140
ModuleBase::Matrix3 tmpG_int=ucell.G.Inverse()*symm.kgmatrix[i]*ucell.G;//G^-1*SG*G
@@ -168,7 +172,7 @@ TEST_F(SymmetryTest, AnalySys)
168172
EXPECT_NEAR(tmpA.e23, tmpG.e23, DOUBLETHRESHOLD);
169173
EXPECT_NEAR(tmpA.e32, tmpG.e32, DOUBLETHRESHOLD);
170174
}
171-
175+
172176
delete[] gmatrix_input_back;
173177
delete[] gmatrix_opt;
174178
delete[] gmatrix_opt_back;
@@ -180,7 +184,7 @@ TEST_F(SymmetryTest, AnalySys)
180184

181185
TEST_F(SymmetryTest, AtomOrderingNew)
182186
{
183-
// the old function `atom_ordering` has bugs
187+
// the old function `atom_ordering` has bugs
184188
// so here I do not compare with its results
185189
ModuleSymmetry::Symmetry symm;
186190
symm.epsilon=1e-5;
@@ -199,7 +203,7 @@ TEST_F(SymmetryTest, AtomOrderingNew)
199203
}
200204
//ordering
201205
symm.test_atom_ordering(new_pos, nat, subindex);
202-
//check
206+
//check
203207
for (int i=0;i<nat-1;++i)
204208
{
205209
//x[i]<=x[i+1]
@@ -250,7 +254,7 @@ TEST_F(SymmetryTest, SG_Pricell)
250254
std::string cal_point_group = symm.pgname;
251255
std::string ref_space_group = supercell_lib[stru].space_group;
252256
std::string cal_space_group = symm.spgname;
253-
257+
254258
int ref_ncells = supercell_lib[stru].ibrav;
255259
EXPECT_EQ(symm.ncell, ref_ncells);
256260
EXPECT_EQ(cal_point_group, ref_point_group);

source/source_cell/module_symmetry/test/symmetry_test_symtrz.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ UnitCell::UnitCell() {}
1919
UnitCell::~UnitCell() {}
2020
Magnetism::Magnetism() {}
2121
Magnetism::~Magnetism() {}
22+
SepPot::SepPot(){}
23+
SepPot::~SepPot(){}
24+
Sep_Cell::Sep_Cell() noexcept {}
25+
Sep_Cell::~Sep_Cell() noexcept {}
2226

2327
inline std::vector<double> allocate_pos(ModuleSymmetry::Symmetry& symm, UnitCell& ucell)
2428
{
@@ -46,7 +50,7 @@ TEST_F(SymmetryTest, ForceSymmetry)
4650
{
4751
auto check_force = [](stru_& conf, ModuleBase::matrix& force)
4852
{
49-
// 1. check zeros
53+
// 1. check zeros
5054
for (auto iat : conf.force_zero_iat)
5155
for (int j = 0; j < 3; ++j)
5256
EXPECT_NEAR(force(iat, j), 0.0, DOUBLETHRESHOLD);

source/source_cell/sep.cpp

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#include "sep.h"
2+
3+
#include "source_base/global_variable.h"
4+
#include "source_base/parallel_common.h"
5+
#include "source_base/tool_title.h"
6+
#include "source_io/output.h"
7+
8+
#include <fstream>
9+
#include <sstream>
10+
#include <string>
11+
12+
SepPot::SepPot()
13+
{
14+
}
15+
16+
SepPot::~SepPot()
17+
{
18+
delete[] r;
19+
r = nullptr;
20+
delete[] rv;
21+
rv = nullptr;
22+
}
23+
24+
int SepPot::read_sep(std::ifstream& ifs)
25+
{
26+
std::string line;
27+
while (std::getline(ifs, line))
28+
{
29+
std::istringstream iss(line);
30+
std::string key;
31+
iss >> key;
32+
33+
if (key == "Sep.Element")
34+
{
35+
iss >> label;
36+
}
37+
else if (key == "Sep.XcType")
38+
{
39+
iss >> xc_type;
40+
}
41+
else if (key == "Sep.Orbital")
42+
{
43+
iss >> orbital;
44+
}
45+
else if (key == "Sep.Points")
46+
{
47+
iss >> mesh;
48+
delete[] r;
49+
r = new double[mesh];
50+
delete[] rv;
51+
rv = new double[mesh];
52+
}
53+
else if (key == "Sep.StripAmount")
54+
{
55+
iss >> strip_elec;
56+
}
57+
else if (key == "<Sep.Potential")
58+
{
59+
double r_val, rv_val;
60+
int idx = 0;
61+
while (std::getline(ifs, line) && line != "Sep.Potential>")
62+
{
63+
std::istringstream data_line(line);
64+
if (data_line >> r_val >> rv_val)
65+
{
66+
r[idx] = r_val;
67+
rv[idx] = rv_val;
68+
idx++;
69+
}
70+
}
71+
break;
72+
}
73+
}
74+
return 0;
75+
}
76+
77+
void SepPot::print_sep_info(std::ofstream& ofs)
78+
{
79+
ofs << "\n sep_vl:";
80+
ofs << "\n sep_info:";
81+
ofs << "\n label " << label;
82+
ofs << "\n xc " << xc_type;
83+
ofs << "\n orbital " << orbital;
84+
ofs << "\n strip electron" << strip_elec;
85+
}
86+
87+
void SepPot::print_sep_vsep(std::ofstream& ofs)
88+
{
89+
ofs << "\n mesh " << mesh;
90+
output::printr1_d(ofs, " r : ", r, mesh);
91+
output::printr1_d(ofs, " vsep : ", rv, mesh);
92+
ofs << "\n -----------------------------";
93+
}
94+
95+
#ifdef __MPI
96+
97+
void SepPot::bcast_sep()
98+
{
99+
ModuleBase::TITLE("SepPot", "bcast_sep");
100+
Parallel_Common::bcast_bool(is_enable);
101+
Parallel_Common::bcast_double(r_in);
102+
Parallel_Common::bcast_double(r_out);
103+
Parallel_Common::bcast_double(r_power);
104+
Parallel_Common::bcast_double(enhence_a);
105+
Parallel_Common::bcast_string(label);
106+
Parallel_Common::bcast_string(xc_type);
107+
Parallel_Common::bcast_string(orbital);
108+
Parallel_Common::bcast_int(strip_elec);
109+
Parallel_Common::bcast_int(mesh);
110+
111+
if (GlobalV::MY_RANK != 0 && mesh > 0)
112+
{
113+
r = new double[mesh];
114+
rv = new double[mesh];
115+
}
116+
117+
Parallel_Common::bcast_double(r, mesh);
118+
Parallel_Common::bcast_double(rv, mesh);
119+
120+
return;
121+
}
122+
#endif // __MPI

source/source_cell/sep.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef SEP_H
2+
#define SEP_H
3+
4+
#include <fstream>
5+
#include <string>
6+
7+
/**
8+
* Sep Potential for DFT-1/2 etc.
9+
*
10+
* Sep Potential
11+
*/
12+
class SepPot
13+
{
14+
public:
15+
SepPot();
16+
~SepPot();
17+
18+
bool is_enable = false;
19+
double r_in = 0.0; /**< cut-off radius inner */
20+
double r_out = 0.0; /**< cut-off radius outter */
21+
double r_power = 20.0; /**< shell function exp factor */
22+
double enhence_a = 1.0; /**< scale sep potential */
23+
std::string label; /**< element nameof sep */
24+
std::string xc_type; /**< Exch-Corr type */
25+
std::string orbital; /** atomic angular moment s,p,d,f */
26+
int mesh = 0; /**< number of points in radial mesh */
27+
int strip_elec = 0; /**< strip electron amount 1->0.01 50->0.5 */
28+
double* r = nullptr; /**< ridial mesh */
29+
double* rv = nullptr; /**< sep potential, but rV, unit: Ry */
30+
31+
int read_sep(std::ifstream& is);
32+
void print_sep_info(std::ofstream& ofs);
33+
void print_sep_vsep(std::ofstream& ofs);
34+
#ifdef __MPI
35+
void bcast_sep();
36+
#endif /* ifdef __MPI */
37+
};
38+
39+
#endif /* ifndef SEP_H */

0 commit comments

Comments
 (0)