Skip to content

Commit bde70e2

Browse files
authored
Merge branch 'develop' into subspace-dug
2 parents ad1d463 + a2ec5d1 commit bde70e2

File tree

173 files changed

+1825
-3721
lines changed

Some content is hidden

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

173 files changed

+1825
-3721
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
- [kpar](#kpar)
1212
- [bndpar](#bndpar)
1313
- [latname](#latname)
14-
- [psi\_initializer](#psi_initializer)
1514
- [init\_wfc](#init_wfc)
1615
- [init\_chg](#init_chg)
1716
- [init\_vel](#init_vel)
@@ -93,6 +92,7 @@
9392
- [scf\_os\_stop](#scf_os_stop)
9493
- [scf\_os\_thr](#scf_os_thr)
9594
- [scf\_os\_ndim](#scf_os_ndim)
95+
- [sc\_os\_ndim](#sc_os_ndim)
9696
- [chg\_extrap](#chg_extrap)
9797
- [lspinorb](#lspinorb)
9898
- [noncolin](#noncolin)
@@ -467,7 +467,7 @@
467467
- [abs\_broadening](#abs_broadening)
468468
- [ri\_hartree\_benchmark](#ri_hartree_benchmark)
469469
- [aims\_nbasis](#aims_nbasis)
470-
- [Reduced Density Matrix Functional Theory](#Reduced-Density-Matrix-Functional-Theory)
470+
- [Reduced Density Matrix Functional Theory](#reduced-density-matrix-functional-theory)
471471
- [rdmft](#rdmft)
472472
- [rdmft\_power\_alpha](#rdmft_power_alpha)
473473

@@ -580,17 +580,6 @@ These variables are used to control general system parameters.
580580
- triclinic: triclinic (14)
581581
- **Default**: none
582582

583-
### psi_initializer
584-
585-
- **Type**: Integer
586-
- **Description**: enable the experimental feature psi_initializer, to support use numerical atomic orbitals initialize wavefunction (`basis_type pw` case).
587-
588-
NOTE: this feature is not well-implemented for `nspin 4` case (closed presently), and cannot use with `calculation nscf`/`esolver_type sdft` cases.
589-
Available options are:
590-
- 0: disable psi_initializer
591-
- 1: enable psi_initializer
592-
- **Default**: 0
593-
594583
### init_wfc
595584

596585
- **Type**: String
@@ -602,8 +591,6 @@ These variables are used to control general system parameters.
602591
- atomic+random: add small random numbers on atomic pseudo-wavefunctions
603592
- file: from binary files `WAVEFUNC*.dat`, which are output by setting [out_wfc_pw](#out_wfc_pw) to `2`.
604593
- random: random numbers
605-
606-
with `psi_initializer 1`, two more options are supported:
607594
- nao: from numerical atomic orbitals. If they are not enough, other wave functions are initialized with random numbers.
608595
- nao+random: add small random numbers on numerical atomic orbitals
609596
- **Default**: atomic

source/Makefile.Objects

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ OBJS_PSI=psi.o\
398398

399399
OBJS_PSI_INITIALIZER=psi_initializer.o\
400400
psi_initializer_random.o\
401+
psi_initializer_file.o\
401402
psi_initializer_atomic.o\
402403
psi_initializer_atomic_random.o\
403404
psi_initializer_nao.o\
@@ -494,6 +495,7 @@ OBJS_IO=input_conv.o\
494495
to_wannier90_lcao.o\
495496
fR_overlap.o\
496497
unk_overlap_pw.o\
498+
write_pao.o\
497499
write_wfc_pw.o\
498500
winput.o\
499501
write_cube.o\
@@ -669,8 +671,6 @@ OBJS_SRCPW=H_Ewald_pw.o\
669671
of_stress_pw.o\
670672
symmetry_rho.o\
671673
symmetry_rhog.o\
672-
wavefunc.o\
673-
wf_atomic.o\
674674
psi_init.o\
675675
elecond.o\
676676
sto_tool.o\

source/driver_run.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ void Driver::driver_run()
4040
// the life of ucell should begin here, mohan 2024-05-12
4141
UnitCell ucell;
4242
ucell.setup(PARAM.inp.latname,
43-
PARAM.inp.ntype,
44-
PARAM.inp.lmaxmax,
45-
PARAM.inp.init_vel,
46-
PARAM.inp.fixed_axes);
43+
PARAM.inp.ntype,
44+
PARAM.inp.lmaxmax,
45+
PARAM.inp.init_vel,
46+
PARAM.inp.fixed_axes);
4747

4848
ucell.setup_cell(PARAM.globalv.global_in_stru, GlobalV::ofs_running);
4949
Check_Atomic_Stru::check_atomic_stru(ucell, PARAM.inp.min_dist_coef);

source/module_basis/module_ao/test/ORB_unittest.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ void test_orb::TearDown()
2828
}
2929
ooo.clear_after_ions(OGT, ORB, 0, nproj);
3030
delete[] nproj;
31-
delete[] orbital_fn;
3231
return;
3332
}
3433

@@ -75,7 +74,7 @@ void test_orb::set_orbs()
7574
ORB.init(ofs_running,
7675
ntype_read,
7776
"./",
78-
orbital_fn,
77+
orbital_fn.data(),
7978
descriptor_file,
8079
lmax,
8180
lcao_ecut,
@@ -114,7 +113,7 @@ void test_orb::set_files()
114113

115114
ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "NUMERICAL_ORBITAL");
116115

117-
orbital_fn = new std::string[ntype_read];
116+
orbital_fn.resize(ntype_read);
118117

119118
for (int it = 0; it < ntype_read; it++)
120119
{

source/module_basis/module_ao/test/ORB_unittest.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class test_orb : public testing::Test
5151
double randr(double Rmax);
5252
void gen_table_center2();
5353

54-
bool force_flag = 0;
54+
bool force_flag = false;
5555
int my_rank = 0;
5656
int ntype_read;
5757

@@ -66,7 +66,7 @@ class test_orb : public testing::Test
6666
int lmax = 1;
6767
double lat0 = 1.0;
6868
std::string case_dir = "./GaAs/";
69-
std::string* orbital_fn;
69+
std::vector<std::string> orbital_fn;
7070
std::string descriptor_file;
7171
};
7272
#endif

source/module_basis/module_pw/pw_basis_k.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ PW_Basis_K::~PW_Basis_K()
2222
delete[] igl2isz_k;
2323
delete[] igl2ig_k;
2424
delete[] gk2;
25-
delete[] ig2ixyz_k_;
2625
#if defined(__CUDA) || defined(__ROCM)
2726
if (this->device == "gpu") {
2827
if (this->precision == "single") {
@@ -169,6 +168,7 @@ void PW_Basis_K::setupIndGk()
169168
syncmem_int_h2d_op()(gpu_ctx, cpu_ctx, this->d_igl2isz_k, this->igl2isz_k, this->npwk_max * this->nks);
170169
}
171170
#endif
171+
this->get_ig2ixyz_k();
172172
return;
173173
}
174174

@@ -334,8 +334,12 @@ int& PW_Basis_K::getigl2ig(const int ik, const int igl) const
334334

335335
void PW_Basis_K::get_ig2ixyz_k()
336336
{
337-
delete[] this->ig2ixyz_k_;
338-
this->ig2ixyz_k_ = new int [this->npwk_max * this->nks];
337+
if (this->device != "gpu")
338+
{
339+
//only GPU need to get ig2ixyz_k
340+
return;
341+
}
342+
int * ig2ixyz_k_cpu = new int [this->npwk_max * this->nks];
339343
ModuleBase::Memory::record("PW_B_K::ig2ixyz", sizeof(int) * this->npwk_max * this->nks);
340344
assert(gamma_only == false); //We only finish non-gamma_only fft on GPU temperarily.
341345
for(int ik = 0; ik < this->nks; ++ik)
@@ -348,15 +352,12 @@ void PW_Basis_K::get_ig2ixyz_k()
348352
int ixy = this->is2fftixy[is];
349353
int iy = ixy % this->ny;
350354
int ix = ixy / this->ny;
351-
ig2ixyz_k_[igl + ik * npwk_max] = iz + iy * nz + ix * ny * nz;
355+
ig2ixyz_k_cpu[igl + ik * npwk_max] = iz + iy * nz + ix * ny * nz;
352356
}
353357
}
354-
#if defined(__CUDA) || defined(__ROCM)
355-
if (this->device == "gpu") {
356-
resmem_int_op()(gpu_ctx, ig2ixyz_k, this->npwk_max * this->nks);
357-
syncmem_int_h2d_op()(gpu_ctx, cpu_ctx, this->ig2ixyz_k, this->ig2ixyz_k_, this->npwk_max * this->nks);
358-
}
359-
#endif
358+
resmem_int_op()(gpu_ctx, ig2ixyz_k, this->npwk_max * this->nks);
359+
syncmem_int_h2d_op()(gpu_ctx, cpu_ctx, this->ig2ixyz_k, ig2ixyz_k_cpu, this->npwk_max * this->nks);
360+
delete[] ig2ixyz_k_cpu;
360361
}
361362

362363
std::vector<int> PW_Basis_K::get_ig2ix(const int ik) const

source/module_basis/module_pw/pw_basis_k.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ class PW_Basis_K : public PW_Basis
7171
const bool xprime_in = true
7272
);
7373

74-
void get_ig2ixyz_k();
75-
7674
public:
7775
int nks=0;//number of k points in this pool
7876
ModuleBase::Vector3<double> *kvec_d=nullptr; // Direct coordinates of k points
@@ -88,8 +86,7 @@ class PW_Basis_K : public PW_Basis
8886

8987
int *igl2isz_k=nullptr, * d_igl2isz_k = nullptr; //[npwk_max*nks] map (igl,ik) to (is,iz)
9088
int *igl2ig_k=nullptr;//[npwk_max*nks] map (igl,ik) to ig
91-
int *ig2ixyz_k=nullptr;
92-
int *ig2ixyz_k_=nullptr;
89+
int *ig2ixyz_k=nullptr; ///< [npw] map ig to ixyz
9390

9491
double *gk2=nullptr; // modulus (G+K)^2 of G vectors [npwk_max*nks]
9592

@@ -108,6 +105,8 @@ class PW_Basis_K : public PW_Basis
108105
double * d_gk2 = nullptr; // modulus (G+K)^2 of G vectors [npwk_max*nks]
109106
//create igl2isz_k map array for fft
110107
void setupIndGk();
108+
// get ig2ixyz_k
109+
void get_ig2ixyz_k();
111110
//calculate G+K, it is a private function
112111
ModuleBase::Vector3<double> cal_GplusK_cartesian(const int ik, const int ig) const;
113112

source/module_basis/module_pw/test/test4-4.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,6 @@ TEST_F(PWTEST,test4_4)
213213
}
214214
}
215215

216-
//check getig2ixyz_k
217-
pwtest.get_ig2ixyz_k();
218-
for(int igl = 0; igl < npwk ; ++igl)
219-
{
220-
EXPECT_GE(pwtest.ig2ixyz_k_[igl + ik * pwtest.npwk_max], 0);
221-
}
222-
223216
}
224217
delete []tmp;
225218
delete [] rhor;

source/module_cell/bcast_cell.cpp

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#include "unitcell.h"
2-
2+
#include "module_base/parallel_common.h"
3+
#include "module_parameter/parameter.h"
4+
#ifdef __EXX
5+
#include "module_ri/serialization_cereal.h"
6+
#include "module_hamilt_pw/hamilt_pwdft/global.h"
7+
#endif
38
namespace unitcell
49
{
510
void bcast_atoms_tau(Atom* atoms,
@@ -12,4 +17,105 @@ namespace unitcell
1217
}
1318
#endif
1419
}
20+
21+
void bcast_atoms_pseudo(Atom* atoms,
22+
const int ntype)
23+
{
24+
#ifdef __MPI
25+
MPI_Barrier(MPI_COMM_WORLD);
26+
for (int i = 0; i < ntype; i++)
27+
{
28+
atoms[i].bcast_atom2();
29+
}
30+
#endif
31+
}
32+
33+
void bcast_Lattice(Lattice& lat)
34+
{
35+
#ifdef __MPI
36+
MPI_Barrier(MPI_COMM_WORLD);
37+
// distribute lattice parameters.
38+
ModuleBase::Matrix3& latvec = lat.latvec;
39+
ModuleBase::Matrix3& latvec_supercell = lat.latvec_supercell;
40+
Parallel_Common::bcast_string(lat.Coordinate);
41+
Parallel_Common::bcast_double(lat.lat0);
42+
Parallel_Common::bcast_double(lat.lat0_angstrom);
43+
Parallel_Common::bcast_double(lat.tpiba);
44+
Parallel_Common::bcast_double(lat.tpiba2);
45+
Parallel_Common::bcast_double(lat.omega);
46+
Parallel_Common::bcast_string(lat.latName);
47+
48+
// distribute lattice vectors.
49+
Parallel_Common::bcast_double(latvec.e11);
50+
Parallel_Common::bcast_double(latvec.e12);
51+
Parallel_Common::bcast_double(latvec.e13);
52+
Parallel_Common::bcast_double(latvec.e21);
53+
Parallel_Common::bcast_double(latvec.e22);
54+
Parallel_Common::bcast_double(latvec.e23);
55+
Parallel_Common::bcast_double(latvec.e31);
56+
Parallel_Common::bcast_double(latvec.e32);
57+
Parallel_Common::bcast_double(latvec.e33);
58+
59+
// distribute lattice vectors.
60+
for (int i = 0; i < 3; i++)
61+
{
62+
Parallel_Common::bcast_double(lat.a1[i]);
63+
Parallel_Common::bcast_double(lat.a2[i]);
64+
Parallel_Common::bcast_double(lat.a3[i]);
65+
Parallel_Common::bcast_double(lat.latcenter[i]);
66+
Parallel_Common::bcast_int(lat.lc[i]);
67+
}
68+
69+
// distribute superlattice vectors.
70+
Parallel_Common::bcast_double(latvec_supercell.e11);
71+
Parallel_Common::bcast_double(latvec_supercell.e12);
72+
Parallel_Common::bcast_double(latvec_supercell.e13);
73+
Parallel_Common::bcast_double(latvec_supercell.e21);
74+
Parallel_Common::bcast_double(latvec_supercell.e22);
75+
Parallel_Common::bcast_double(latvec_supercell.e23);
76+
Parallel_Common::bcast_double(latvec_supercell.e31);
77+
Parallel_Common::bcast_double(latvec_supercell.e32);
78+
Parallel_Common::bcast_double(latvec_supercell.e33);
79+
80+
// distribute Change the lattice vectors or not
81+
#endif
82+
}
83+
84+
void bcast_magnetism(Magnetism& magnet, const int ntype)
85+
{
86+
#ifdef __MPI
87+
MPI_Barrier(MPI_COMM_WORLD);
88+
Parallel_Common::bcast_double(magnet.start_magnetization, ntype);
89+
if (PARAM.inp.nspin == 4)
90+
{
91+
Parallel_Common::bcast_double(magnet.ux_[0]);
92+
Parallel_Common::bcast_double(magnet.ux_[1]);
93+
Parallel_Common::bcast_double(magnet.ux_[2]);
94+
}
95+
#endif
96+
}
97+
98+
void bcast_unitcell(UnitCell& ucell)
99+
{
100+
#ifdef __MPI
101+
const int ntype = ucell.ntype;
102+
Parallel_Common::bcast_int(ucell.nat);
103+
104+
bcast_Lattice(ucell.lat);
105+
bcast_magnetism(ucell.magnet,ntype);
106+
bcast_atoms_tau(ucell.atoms,ntype);
107+
108+
for (int i = 0; i < ntype; i++)
109+
{
110+
Parallel_Common::bcast_string(ucell.orbital_fn[i]);
111+
}
112+
113+
#ifdef __EXX
114+
ModuleBase::bcast_data_cereal(GlobalC::exx_info.info_ri.files_abfs,
115+
MPI_COMM_WORLD,
116+
0);
117+
#endif
118+
return;
119+
#endif
120+
}
15121
}

source/module_cell/bcast_cell.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,50 @@
11
#ifndef BCAST_CELL_H
22
#define BCAST_CELL_H
33

4+
#include "module_cell/unitcell.h"
45
namespace unitcell
56
{
7+
/**
8+
* @brief broadcast the tau array of the atoms
9+
*
10+
* @param atoms: the atoms to be broadcasted [in/out]
11+
* @param ntype: the number of types of the atoms [in]
12+
*/
613
void bcast_atoms_tau(Atom* atoms,
14+
const int ntype);
15+
16+
/**
17+
* @brief broadcast the pseduo of the atoms
18+
*
19+
* @param atoms: the atoms to be broadcasted [in/out]
20+
* @param ntype: the number of types of the atoms [in]
21+
*/
22+
void bcast_atoms_pseudo(Atom* atoms,
23+
const int ntype);
24+
/**
25+
* @brief broadcast the lattice
26+
*
27+
* @param lat: the lattice to be broadcasted [in/out]
28+
*/
29+
void bcast_Lattice(Lattice& lat);
30+
31+
/**
32+
* @brief broadcast the magnetism
33+
*
34+
* @param magnet: the magnetism to be broadcasted [in/out]
35+
* @param nytpe: the number of types of the atoms [in]
36+
*/
37+
void bcast_magnetism(Magnetism& magnet,
738
const int ntype);
39+
40+
/**
41+
* @brief broadcast the unitcell
42+
*
43+
* @param ucell: the unitcell to be broadcasted [in/out]
44+
*/
45+
void bcast_unitcell(UnitCell& ucell);
46+
47+
848
}
949

1050
#endif // BCAST_CELL_H

0 commit comments

Comments
 (0)