Skip to content

Commit 731d7ee

Browse files
authored
Merge branch 'develop' into fft14
2 parents 480681d + 15835bd commit 731d7ee

Some content is hidden

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

68 files changed

+1269
-26254
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
- [dos\_emax\_ev](#dos_emax_ev)
178178
- [dos\_nche](#dos_nche)
179179
- [stm\_bias](#stm_bias)
180+
- [ldos\_line](#ldos_line)
180181
- [NAOs](#naos)
181182
- [bessel\_nao\_ecut](#bessel_nao_ecut)
182183
- [bessel\_nao\_tolerence](#bessel_nao_tolerence)
@@ -1705,9 +1706,13 @@ These variables are used to control the output of properties.
17051706

17061707
### out_ldos
17071708

1708-
- **Type**: Boolean
1709-
- **Description**: Whether to output the local density of states for given bias in cube file format, which is controlled by [stm_bias](#stm_bias).
1710-
- **Default**: False
1709+
- **Type**: Integer
1710+
- **Description**: Whether to output the local density of states (LDOS), optionally output precision can be set by a second parameter, default is 3.
1711+
- 0: no output
1712+
- 1: output the partial charge density for given bias (controlled by [stm_bias](#stm_bias)) in cube file format, which can be used to plot scanning tunneling spectroscopys to mimick STM images using the Python script [plot.py](../../../tools/stm/plot.py).
1713+
- 2: output LDOS along a line in real space (controlled by [ldos_line](#ldos_line)). Parameters used to control DOS output are also valid for LDOS.
1714+
- 3: output both two LDOS modes above.
1715+
- **Default**: 0
17111716

17121717
### out_band
17131718

@@ -1986,6 +1991,13 @@ These variables are used to control the calculation of DOS. [Detailed introducti
19861991
- **Default**: 1.0
19871992
- **Unit**: V
19881993

1994+
### ldos_line
1995+
1996+
- **Type**: Real*6 Integer(optional)
1997+
- **Description**: Specify the path of the three-dimensional space and display LDOS in the form of a two-dimensional color chart, see details in [out_ldos](#out_ldos). The first three paramenters are the direct coordinates of the start point, the next three paramenters are the direct coordinates of the end point, and the final one is the number of points along the path, whose default is 100.
1998+
- **Default**: 0.0 0.0 0.0 0.0 0.0 1.0 100
1999+
2000+
19892001
[back to top](#full-list-of-input-keywords)
19902002

19912003
## NAOs

source/module_base/blas_connector.cpp

Lines changed: 264 additions & 44 deletions
Large diffs are not rendered by default.

source/module_base/blas_connector.h

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ extern "C"
6565
void cgemv_(const char *trans, const int *m, const int *n, const std::complex<float> *alpha,
6666
const std::complex<float> *a, const int *lda, const std::complex<float> *x, const int *incx,
6767
const std::complex<float> *beta, std::complex<float> *y, const int *incy);
68-
68+
6969
void zgemv_(const char *trans, const int *m, const int *n, const std::complex<double> *alpha,
7070
const std::complex<double> *a, const int *lda, const std::complex<double> *x, const int *incx,
7171
const std::complex<double> *beta, std::complex<double> *y, const int *incy);
@@ -180,11 +180,36 @@ class BlasConnector
180180
// Peize Lin add 2017-10-27
181181
// d=x*y
182182
static
183-
float dot( const int n, const float *X, const int incX, const float *Y, const int incY, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
183+
float dot( const int n, const float*const X, const int incX, const float*const Y, const int incY, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
184+
185+
static
186+
double dot( const int n, const double*const X, const int incX, const double*const Y, const int incY, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
187+
188+
// d=x*y
189+
static
190+
float dotu( const int n, const float*const X, const int incX, const float*const Y, const int incY, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
191+
192+
static
193+
double dotu( const int n, const double*const X, const int incX, const double*const Y, const int incY, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
194+
195+
static
196+
std::complex<float> dotu( const int n, const std::complex<float>*const X, const int incX, const std::complex<float>*const Y, const int incY, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
197+
198+
static
199+
std::complex<double> dotu( const int n, const std::complex<double>*const X, const int incX, const std::complex<double>*const Y, const int incY, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
200+
201+
// d=x.conj()*y
202+
static
203+
float dotc( const int n, const float*const X, const int incX, const float*const Y, const int incY, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
204+
205+
static
206+
double dotc( const int n, const double*const X, const int incX, const double*const Y, const int incY, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
184207

185208
static
186-
double dot( const int n, const double *X, const int incX, const double *Y, const int incY, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
209+
std::complex<float> dotc( const int n, const std::complex<float>*const X, const int incX, const std::complex<float>*const Y, const int incY, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
187210

211+
static
212+
std::complex<double> dotc( const int n, const std::complex<double>*const X, const int incX, const std::complex<double>*const Y, const int incY, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
188213

189214
// Peize Lin add 2017-10-27, fix bug trans 2019-01-17
190215
// C = a * A.? * B.? + b * C
@@ -231,6 +256,9 @@ class BlasConnector
231256
const std::complex<double> alpha, const std::complex<double> *a, const int lda, const std::complex<double> *b, const int ldb,
232257
const std::complex<double> beta, std::complex<double> *c, const int ldc, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
233258

259+
// side=='L': C = a * A * B + b * C.
260+
// side=='R': C = a * B * A + b * C.
261+
// A == A^T
234262
// Because you cannot pack symm or hemm into a row-major kernel by exchanging parameters, so only col-major functions are provided.
235263
static
236264
void symm_cm(const char side, const char uplo, const int m, const int n,
@@ -252,6 +280,19 @@ class BlasConnector
252280
const std::complex<double> alpha, const std::complex<double> *a, const int lda, const std::complex<double> *b, const int ldb,
253281
const std::complex<double> beta, std::complex<double> *c, const int ldc, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
254282

283+
// side=='L': C = a * A * B + b * C.
284+
// side=='R': C = a * B * A + b * C.
285+
// A == A^H
286+
static
287+
void hemm_cm(const char side, const char uplo, const int m, const int n,
288+
const float alpha, const float *a, const int lda, const float *b, const int ldb,
289+
const float beta, float *c, const int ldc, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
290+
291+
static
292+
void hemm_cm(const char side, const char uplo, const int m, const int n,
293+
const double alpha, const double *a, const int lda, const double *b, const int ldb,
294+
const double beta, double *c, const int ldc, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
295+
255296
static
256297
void hemm_cm(char side, char uplo, int m, int n,
257298
std::complex<float> alpha, std::complex<float> *a, int lda, std::complex<float> *b, int ldb,
@@ -263,7 +304,6 @@ class BlasConnector
263304
std::complex<double> beta, std::complex<double> *c, int ldc, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
264305

265306
// y = A*x + beta*y
266-
267307
static
268308
void gemv(const char trans, const int m, const int n,
269309
const float alpha, const float* A, const int lda, const float* X, const int incx,
@@ -283,7 +323,6 @@ class BlasConnector
283323
void gemv(const char trans, const int m, const int n,
284324
const std::complex<double> alpha, const std::complex<double> *A, const int lda, const std::complex<double> *X, const int incx,
285325
const std::complex<double> beta, std::complex<double> *Y, const int incy, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
286-
287326

288327
// Peize Lin add 2018-06-12
289328
// out = ||x||_2

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -690,11 +690,11 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
690690
{
691691
this->p_hamilt->refresh();
692692
}
693-
if (iter == 1 && istep == 0)
694-
{
695-
// initialize DMR
696-
this->ld.init_DMR(ucell, orb_, this->pv, this->gd);
697-
}
693+
// if (iter == 1 && istep == 0)
694+
// {
695+
// // initialize DMR
696+
// this->ld.init_DMR(ucell, orb_, this->pv, this->gd);
697+
// }
698698
#endif
699699

700700
if (PARAM.inp.vl_in_h)

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -947,11 +947,10 @@ void ESolver_KS_PW<T, Device>::after_all_runners(UnitCell& ucell)
947947
//----------------------------------------------------------
948948
if (PARAM.inp.out_ldos[0])
949949
{
950-
ModuleIO::Cal_ldos<std::complex<double>>::cal_ldos_pw(
951-
reinterpret_cast<elecstate::ElecStatePW<std::complex<double>>*>(this->pelec),
952-
this->psi[0],
953-
this->Pgrid,
954-
ucell);
950+
ModuleIO::cal_ldos_pw(reinterpret_cast<elecstate::ElecStatePW<std::complex<double>>*>(this->pelec),
951+
this->psi[0],
952+
this->Pgrid,
953+
ucell);
955954
}
956955

957956
//----------------------------------------------------------

source/module_esolver/lcao_before_scf.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
243243
->get_DM()
244244
->init_DMR(*(dynamic_cast<hamilt::HamiltLCAO<TK, TR>*>(this->p_hamilt)->getHR()));
245245

246+
#ifdef __DEEPKS
247+
// initialize DMR of DeePKS
248+
this->ld.init_DMR(ucell, orb_, this->pv, this->gd);
249+
#endif
250+
246251
// 15) two cases are considered:
247252
// 1. DMK in DensityMatrix is not empty (istep > 0), then DMR is initialized by DMK
248253
// 2. DMK in DensityMatrix is empty (istep == 0), then DMR is initialized by zeros

source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/td_ekinetic_lcao.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ void TDEkinetic<OperatorLCAO<TK, TR>>::init_td()
244244

245245
// mohan update 2025-04-20
246246
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Cartesian vector potential Ax(t)", cart_At[0]);
247-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Cartesian vector potential Ax(t)", cart_At[1]);
248-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Cartesian vector potential Ax(t)", cart_At[2]);
247+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Cartesian vector potential Ay(t)", cart_At[1]);
248+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Cartesian vector potential Az(t)", cart_At[2]);
249249
}
250250

251251
template <typename TK, typename TR>

source/module_hamilt_lcao/module_gint/temp_gint/gint_atom.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,5 +203,6 @@ void GintAtom::set_phi_dphi(
203203

204204
// explicit instantiation
205205
template void GintAtom::set_phi(const std::vector<Vec3d>& coords, const int stride, double* phi) const;
206+
template void GintAtom::set_phi(const std::vector<Vec3d>& coords, const int stride, std::complex<double>* phi) const;
206207
template void GintAtom::set_phi_dphi(const std::vector<Vec3d>& coords, const int stride, double* phi, double* dphi_x, double* dphi_y, double* dphi_z) const;
207208
}

source/module_hamilt_lcao/module_gint/temp_gint/gint_common.cpp

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void compose_hr_gint(std::shared_ptr<HContainer<double>> hr_gint)
2323
assert(upper_ap != nullptr);
2424
#endif
2525
for (int ir = 0; ir < ap.get_R_size(); ir++)
26-
{
26+
{
2727
auto R_index = ap.get_R_index(ir);
2828
auto upper_mat = upper_ap->find_matrix(-R_index);
2929
auto lower_mat = lower_ap->find_matrix(R_index);
@@ -36,7 +36,7 @@ void compose_hr_gint(std::shared_ptr<HContainer<double>> hr_gint)
3636
}
3737
}
3838
}
39-
}
39+
}
4040
}
4141

4242
void compose_hr_gint(std::vector<std::shared_ptr<HContainer<double>>> hr_gint_part,
@@ -54,7 +54,7 @@ void compose_hr_gint(std::vector<std::shared_ptr<HContainer<double>>> hr_gint_pa
5454
const hamilt::AtomPair<double>* ap_nspin_0 = hr_gint_part[0]->find_pair(iat1, iat2);
5555
const hamilt::AtomPair<double>* ap_nspin_3 = hr_gint_part[3]->find_pair(iat1, iat2);
5656
for (int ir = 0; ir < upper_ap->get_R_size(); ir++)
57-
{
57+
{
5858
const auto R_index = upper_ap->get_R_index(ir);
5959
auto upper_mat = upper_ap->find_matrix(R_index);
6060
auto mat_nspin_0 = ap_nspin_0->find_matrix(R_index);
@@ -124,10 +124,11 @@ void transfer_hr_gint_to_hR(std::shared_ptr<const HContainer<T>> hr_gint, HConta
124124

125125
// gint_info should not have been a parameter, but it was added to initialize dm_gint_full
126126
// In the future, we might try to remove the gint_info parameter
127+
template<typename T>
127128
void transfer_dm_2d_to_gint(
128129
std::shared_ptr<const GintInfo> gint_info,
129-
std::vector<HContainer<double>*> dm,
130-
std::vector<std::shared_ptr<HContainer<double>>> dm_gint)
130+
std::vector<HContainer<T>*> dm,
131+
std::vector<std::shared_ptr<HContainer<T>>> dm_gint)
131132
{
132133
// To check whether input parameter dm_2d has been initialized
133134
#ifdef __DEBUG
@@ -150,12 +151,12 @@ void transfer_dm_2d_to_gint(
150151
{
151152
#ifdef __MPI
152153
const int npol = 2;
153-
std::shared_ptr<HContainer<double>> dm_full = gint_info->get_hr<double>(npol);
154+
std::shared_ptr<HContainer<T>> dm_full = gint_info->get_hr<T>(npol);
154155
hamilt::transferParallels2Serials(*dm[0], dm_full.get());
155156
#else
156-
HContainer<double>* dm_full = dm[0];
157+
HContainer<T>* dm_full = dm[0];
157158
#endif
158-
std::vector<double*> tmp_pointer(4, nullptr);
159+
std::vector<T*> tmp_pointer(4, nullptr);
159160
for (int iap = 0; iap < dm_full->size_atom_pairs(); iap++)
160161
{
161162
auto& ap = dm_full->get_atom_pair(iap);
@@ -166,10 +167,10 @@ void transfer_dm_2d_to_gint(
166167
const ModuleBase::Vector3<int> r_index = ap.get_R_index(ir);
167168
for (int is = 0; is < 4; is++)
168169
{
169-
tmp_pointer[is] =
170+
tmp_pointer[is] =
170171
dm_gint[is]->find_matrix(iat1, iat2, r_index)->get_pointer();
171172
}
172-
double* data_full = ap.get_pointer(ir);
173+
T* data_full = ap.get_pointer(ir);
173174
for (int irow = 0; irow < ap.get_row_size(); irow += 2)
174175
{
175176
for (int icol = 0; icol < ap.get_col_size(); icol += 2)
@@ -191,6 +192,18 @@ void transfer_dm_2d_to_gint(
191192
}
192193

193194

194-
template void transfer_hr_gint_to_hR(std::shared_ptr<const HContainer<double>> hr_gint, HContainer<double>* hR);
195-
template void transfer_hr_gint_to_hR(std::shared_ptr<const HContainer<std::complex<double>>> hr_gint, HContainer<std::complex<double>>* hR);
195+
template void transfer_hr_gint_to_hR(
196+
std::shared_ptr<const HContainer<double>> hr_gint,
197+
HContainer<double>* hR);
198+
template void transfer_hr_gint_to_hR(
199+
std::shared_ptr<const HContainer<std::complex<double>>> hr_gint,
200+
HContainer<std::complex<double>>* hR);
201+
template void transfer_dm_2d_to_gint(
202+
std::shared_ptr<const GintInfo> gint_info,
203+
std::vector<HContainer<double>*> dm,
204+
std::vector<std::shared_ptr<HContainer<double>>> dm_gint);
205+
template void transfer_dm_2d_to_gint(
206+
std::shared_ptr<const GintInfo> gint_info,
207+
std::vector<HContainer<std::complex<double>>*> dm,
208+
std::vector<std::shared_ptr<HContainer<std::complex<double>>>> dm_gint);
196209
}

source/module_hamilt_lcao/module_gint/temp_gint/gint_common.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ namespace ModuleGint
1313
template <typename T>
1414
void transfer_hr_gint_to_hR(std::shared_ptr<const HContainer<T>> hr_gint, HContainer<T>* hR);
1515

16+
template<typename T>
1617
void transfer_dm_2d_to_gint(
1718
std::shared_ptr<const GintInfo> gint_info,
18-
std::vector<HContainer<double>*> dm,
19-
std::vector<std::shared_ptr<HContainer<double>>> dm_gint);
19+
std::vector<HContainer<T>*> dm,
20+
std::vector<std::shared_ptr<HContainer<T>>> dm_gint);
2021

2122
}

0 commit comments

Comments
 (0)