Skip to content

Commit 208f494

Browse files
author
zxy.monado
committed
Merge upstream develop into source_base coverage branch
2 parents ca6e17b + c2fa3ac commit 208f494

254 files changed

Lines changed: 20518 additions & 6052 deletions

File tree

Some content is hidden

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

.github/workflows/build_test_cmake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
- tag: gnu
2626
external_toolchain_args: ""
27-
build_args: "-DENABLE_LIBXC=ON -DENABLE_MLALGO=ON -DENABLE_LIBRI=ON -DENABLE_DFTD4=ON"
27+
build_args: "-DENABLE_LIBXC=ON -DENABLE_MLALGO=ON -DENABLE_LIBRI=ON -DENABLE_DFTD4=ON -DENABLE_PEXSI=ON"
2828
name: "Build extra components with GNU toolchain"
2929
- tag: intel
3030
external_toolchain_args: "--with-intel"

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767
-DENABLE_RAPIDJSON=ON \
6868
-DENABLE_FLOAT_FFTW=ON \
6969
-DENABLE_DFTD4=ON \
70+
-DENABLE_PEXSI=ON \
7071
-Werror=dev
7172
7273
# Temporarily removed because no one maintains this now.

AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ rules. Read the complete governance document before making or reviewing changes:
103103
- Member -> free function: inventory `this->` reads; pass as params (const
104104
for config, ref for mutable state); move only when body is `this`-free;
105105
keep thin wrapper; compile each step.
106+
- Extract a base-class nested-vector member in three steps (hold + forward,
107+
switch writers, delete legacy) so no commit mixes old-storage writes with
108+
new-storage reads.
106109

107110
## Local Commands
108111

docs/advanced/input_files/input-main.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,14 @@
589589
- [Reduced Density Matrix Functional Theory](#reduced-density-matrix-functional-theory)
590590
- [rdmft](#rdmft)
591591
- [rdmft\_power\_alpha](#rdmft_power_alpha)
592+
- [Density functional perturbation theory](#density-functional-perturbation-theory)
593+
- [dfpt\_qmesh](#dfpt_qmesh)
594+
- [dfpt\_qfile](#dfpt_qfile)
595+
- [dfpt\_compute\_q0](#dfpt_compute_q0)
596+
- [dfpt\_loto](#dfpt_loto)
597+
- [dfpt\_conv\_thr](#dfpt_conv_thr)
598+
- [dfpt\_max\_iter](#dfpt_max_iter)
599+
- [dfpt\_mix\_beta](#dfpt_mix_beta)
592600

593601
## System variables
594602

@@ -643,6 +651,7 @@
643651
- nep: Neuroevolution Potential
644652
- ks-lr: Kohn-Sham density functional theory + LR-TDDFT (Under Development Feature)
645653
- lr: LR-TDDFT with given KS orbitals (Under Development Feature)
654+
- dfpt: density functional perturbation theory (Under Development Feature)
646655
- **Default**: ksdft
647656

648657
### symmetry
@@ -5192,3 +5201,49 @@
51925201
- **Default**: 0.656
51935202

51945203
[back to top](#full-list-of-input-keywords)
5204+
5205+
## Density functional perturbation theory
5206+
5207+
### dfpt_qmesh
5208+
5209+
- **Type**: Vector of Int (1 or 3 values)
5210+
- **Description**: Set the Monkhorst-Pack q mesh (gamma-centered) for DFPT phonon calculations. The q mesh must be commensurate with the ground-state k mesh: k + q must be a point of the k list (modulo a reciprocal lattice vector). For example, a 4x4x4 KPT mesh is commensurate with dfpt_qmesh values of 1, 2, or 4 along each direction. This parameter is ignored when dfpt_qfile is set.
5211+
- **Default**: 1 1 1
5212+
5213+
### dfpt_qfile
5214+
5215+
- **Type**: String
5216+
- **Description**: Set the file containing the q points for DFPT, in the same format as the KPT file (Q_POINTS card: Gamma/Monkhorst-Pack mesh, or an explicit Direct/Cartesian list; symmetry reduction is not applied to file q lists). When set, it overrides dfpt_qmesh. Each q point must still be commensurate with the ground-state k mesh.
5217+
- **Default**: ""
5218+
5219+
### dfpt_compute_q0
5220+
5221+
- **Type**: Boolean
5222+
- **Description**: Whether to compute the macroscopic dielectric tensor (epsilon_inf) and the Born effective charges at q = 0 within the same DFPT run. Requires a q point at Gamma (the default dfpt_qmesh 1 1 1).
5223+
- **Default**: false
5224+
5225+
### dfpt_loto
5226+
5227+
- **Type**: Boolean
5228+
- **Description**: Whether to apply the Lyddane-Sachs-Teller non-analytic correction to the Gamma-point dynamical matrix, which splits the longitudinal and transverse optical modes. Requires dfpt_compute_q0 to be true, since the correction is built from epsilon_inf and the Born effective charges.
5229+
- **Default**: false
5230+
5231+
### dfpt_conv_thr
5232+
5233+
- **Type**: Real
5234+
- **Description**: Set the convergence threshold of the self-consistent DFPT cycle: the iteration stops when the relative residual of the first-order density ||drho_out - drho_in|| / ||drho_out|| drops below this value for every displacement.
5235+
- **Default**: 1.0e-8
5236+
5237+
### dfpt_max_iter
5238+
5239+
- **Type**: Integer
5240+
- **Description**: Set the maximum number of self-consistent DFPT iterations for each atomic displacement.
5241+
- **Default**: 100
5242+
5243+
### dfpt_mix_beta
5244+
5245+
- **Type**: Real
5246+
- **Description**: Set the plain-mixing coefficient of the first-order density in the self-consistent DFPT cycle. The response Jacobian has strongly negative eigenvalues on the smallest-G shells (Coulomb stiffness), so beta must stay below 2 / (1 + |lambda_min|); the default 0.4 keeps margin up to |lambda_min| ~ 3. A larger value accelerates convergence for weakly screened systems but may diverge.
5247+
- **Default**: 0.4
5248+
5249+
[back to top](#full-list-of-input-keywords)

docs/parameters.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ parameters:
6161
* nep: Neuroevolution Potential
6262
* ks-lr: Kohn-Sham density functional theory + LR-TDDFT (Under Development Feature)
6363
* lr: LR-TDDFT with given KS orbitals (Under Development Feature)
64+
* dfpt: density functional perturbation theory (Under Development Feature)
6465
default_value: ksdft
6566
unit: ""
6667
availability: ""
@@ -3046,6 +3047,62 @@ parameters:
30463047
default_value: "-1 2 -1 2"
30473048
unit: primitive cells
30483049
availability: "lr_solver==plot and exciton_plot_format in [slice, both]"
3050+
- name: dfpt_qmesh
3051+
category: Density functional perturbation theory
3052+
type: Vector of Int (1 or 3 values)
3053+
description: |
3054+
Set the Monkhorst-Pack q mesh (gamma-centered) for DFPT phonon calculations. The q mesh must be commensurate with the ground-state k mesh: k + q must be a point of the k list (modulo a reciprocal lattice vector). For example, a 4x4x4 KPT mesh is commensurate with dfpt_qmesh values of 1, 2, or 4 along each direction. This parameter is ignored when dfpt_qfile is set.
3055+
default_value: 1 1 1
3056+
unit: ""
3057+
availability: ""
3058+
- name: dfpt_qfile
3059+
category: Density functional perturbation theory
3060+
type: String
3061+
description: |
3062+
Set the file containing the q points for DFPT, in the same format as the KPT file (Q_POINTS card: Gamma/Monkhorst-Pack mesh, or an explicit Direct/Cartesian list; symmetry reduction is not applied to file q lists). When set, it overrides dfpt_qmesh. Each q point must still be commensurate with the ground-state k mesh.
3063+
default_value: "\"\""
3064+
unit: ""
3065+
availability: ""
3066+
- name: dfpt_compute_q0
3067+
category: Density functional perturbation theory
3068+
type: Boolean
3069+
description: |
3070+
Whether to compute the macroscopic dielectric tensor (epsilon_inf) and the Born effective charges at q = 0 within the same DFPT run. Requires a q point at Gamma (the default dfpt_qmesh 1 1 1).
3071+
default_value: "false"
3072+
unit: ""
3073+
availability: ""
3074+
- name: dfpt_loto
3075+
category: Density functional perturbation theory
3076+
type: Boolean
3077+
description: |
3078+
Whether to apply the Lyddane-Sachs-Teller non-analytic correction to the Gamma-point dynamical matrix, which splits the longitudinal and transverse optical modes. Requires dfpt_compute_q0 to be true, since the correction is built from epsilon_inf and the Born effective charges.
3079+
default_value: "false"
3080+
unit: ""
3081+
availability: ""
3082+
- name: dfpt_conv_thr
3083+
category: Density functional perturbation theory
3084+
type: Real
3085+
description: |
3086+
Set the convergence threshold of the self-consistent DFPT cycle: the iteration stops when the relative residual of the first-order density ||drho_out - drho_in|| / ||drho_out|| drops below this value for every displacement.
3087+
default_value: "1.0e-8"
3088+
unit: ""
3089+
availability: ""
3090+
- name: dfpt_max_iter
3091+
category: Density functional perturbation theory
3092+
type: Integer
3093+
description: |
3094+
Set the maximum number of self-consistent DFPT iterations for each atomic displacement.
3095+
default_value: "100"
3096+
unit: ""
3097+
availability: ""
3098+
- name: dfpt_mix_beta
3099+
category: Density functional perturbation theory
3100+
type: Real
3101+
description: |
3102+
Set the plain-mixing coefficient of the first-order density in the self-consistent DFPT cycle. The response Jacobian has strongly negative eigenvalues on the smallest-G shells (Coulomb stiffness), so beta must stay below 2 / (1 + |lambda_min|); the default 0.4 keeps margin up to |lambda_min| ~ 3. A larger value accelerates convergence for weakly screened systems but may diverge.
3103+
default_value: "0.4"
3104+
unit: ""
3105+
availability: ""
30493106
- name: out_freq_ion
30503107
category: Output information
30513108
type: Integer

source/Makefile.Objects

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ OBJS_CELL=atom_pseudo.o\
211211
print_cell.o\
212212
setup_nonlocal.o\
213213
klist.o\
214-
k_vector_utils.o\
214+
reciprocal_grid.o\
215215
cell_index.o\
216216
cell_tools.o\
217217
check_atomic_stru.o\
@@ -281,6 +281,7 @@ OBJS_ELECSTAT=elecstate.o\
281281
read_orb.o\
282282
setup_estate_pw.o\
283283
update_pot.o\
284+
occ_matrix.o
284285

285286
OBJS_ELECSTAT_LCAO=elecstate_lcao.o\
286287
init_dm.o\
@@ -373,12 +374,23 @@ OBJS_HAMILT_OF=kedf_tf.o\
373374
kedf_manager.o\
374375
evolve_ofdft.o\
375376

376-
OBJS_DFPT=dfpt_metal.o\
377+
OBJS_DFPT=dfpt_hamilt_shift.o\
378+
dfpt_kq_basis.o\
379+
dfpt_metal.o\
377380
dfpt_pert.o\
381+
dfpt_pert_nl.o\
382+
dfpt_pert_vkb.o\
378383
dfpt_phon.o\
384+
dfpt_phon_elec.o\
385+
dfpt_phon_ewald.o\
379386
dfpt_pw.o\
380387
dfpt_pw_data.o\
388+
dfpt_pw_init.o\
389+
dfpt_pw_q0.o\
390+
dfpt_pw_run.o\
391+
dfpt_pw_solve.o\
381392
dfpt_q0.o\
393+
dfpt_q0_pos.o\
382394
dfpt_rho.o\
383395
dfpt_stern.o
384396

@@ -399,13 +411,12 @@ OBJS_HAMILT_LCAO=hamilt_lcao.o\
399411
veff_lcao.o\
400412
veff_dh.o\
401413
meta_lcao.o\
402-
dftu_lcao_op.o\
414+
dftu_nao_op.o\
403415
deepks_lcao.o\
404416
op_exx_lcao.o\
405417
dspin_lcao.o\
406418
dspin_fs.o\
407419
setup_dftu_lcao.o\
408-
dftu_fs.o\
409420
operator_fs_utils.o\
410421

411422
OBJS_HCONTAINER=base_matrix.o\
@@ -564,6 +575,7 @@ OBJS_SYMMETRY=symm_other.o\
564575
symm_magnetic.o\
565576
symm_pricell.o\
566577
symm_rho.o\
578+
little_group.o\
567579
symmetry.o\
568580

569581
OBJS_XC=xc_functional.o\
@@ -674,6 +686,7 @@ OBJS_IO=module_parameter/input_conv.o\
674686
module_parameter/read_inp_model.o\
675687
module_parameter/read_inp_postproc.o\
676688
module_parameter/read_inp_exx_dftu.o\
689+
module_parameter/read_inp_dfpt.o\
677690
module_parameter/read_inp_other.o\
678691
module_parameter/read_inp_out.o\
679692
module_parameter/read_set_globalv.o\
@@ -808,12 +821,12 @@ OBJS_SRCPW=h_ewald_pw.o\
808821
setup_pwwfc.o\
809822
update_cell_pw.o\
810823
dftu_base.o\
811-
dftu_output.o\
812-
dftu_tools_pw.o\
813-
dftu_cal_occ_pw.o\
824+
dftu_base_io.o\
825+
dftu_base_occ.o\
826+
dftu_base_tools.o\
827+
yukawa_screening.o\
814828
setup_dftu_pw.o\
815829
deltaspin_pw.o\
816-
deltaspin_pw_impl.o\
817830
force_pw.o\
818831
force_pw_us.o\
819832
force_pw_nl.o\
@@ -885,25 +898,29 @@ OBJS_VDW=vdw.o\
885898
vdwd3_autoset_xcname.o\
886899
vdwd3_auto_xcpar.o
887900

888-
OBJS_DFTU=dftu_lcao.o\
889-
dftu_force.o\
890-
dftu_yukawa.o\
891-
dftu_folding.o\
892-
dftu_lcao_pots.o\
893-
dftu_lcao_energy.o\
894-
dftu_lcao_op_legacy.o\
895-
dftu_lcao_occ.o\
901+
OBJS_DFTU=dftu_nao.o\
902+
dftu_nao_fs_k.o\
903+
dftu_nao_for_r.o\
904+
dftu_nao_fs_r.o\
905+
dftu_nao_str_r.o\
906+
dftu_nao_folding.o\
907+
dftu_nao_pots.o\
908+
dftu_nao_energy.o\
909+
dftu_nao_op_legacy.o\
910+
dftu_nao_occ.o\
896911
dftu_hamilt.o
897912

898913
OBJS_DELTASPIN=basic_funcs.o\
899914
cal_mw_from_lambda.o\
900915
cal_mw.o\
901-
init_sc.o\
916+
deltaspin_init.o\
902917
lambda_loop_helper.o\
903918
lambda_loop.o\
904919
spin_constrain.o\
905-
cal_mw_helper.o\
906920
deltaspin_lcao.o\
921+
deltaspin_lcao_mi.o\
922+
deltaspin_state.o\
923+
deltaspin_pw_mi.o\
907924
mi_tools.o\
908925
template_helpers.o\
909926

source/source_base/module_container/ATen/core/tensor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ bool Tensor::AllocateFrom(const Tensor& other, const TensorShape& shape) {
295295

296296
void Tensor::sync(const Tensor& rhs) {
297297
REQUIRES_OK(this->data_type_ == rhs.data_type_
298-
&& this->device_ == rhs.device_)
298+
&& this->device_ == rhs.device_,
299+
"sync: data_type and device must match between tensors")
299300

300301
if (this->shape_ == rhs.shape_) {
301302
TEMPLATE_ALL_2(data_type_, device_,

source/source_base/module_container/ATen/kernels/memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct synchronize_memory_stride {
8181
const std::vector<int64_t>& out_size,
8282
const std::vector<int64_t>& in_size)
8383
{
84-
REQUIRES_OK(in_size.size() == out_size.size() && in_size.size() <= 2);
84+
REQUIRES_OK(in_size.size() == out_size.size() && in_size.size() <= 2, "rank mismatch: in_size and out_size must have the same rank <= 2");
8585
if (in_size.size() == 1) {
8686
synchronize_memory<T, Device_out, Device_in>()(arr_out, arr_in, in_size[0]);
8787
}

source/source_base/module_container/base/macros/macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
__func__, \
7171
__FILE__, \
7272
static_cast<uint32_t>(__LINE__), \
73-
CHECK_MSG(expr, ##__VA_ARGS__)); \
73+
CHECK_MSG(expr, __VA_ARGS__)); \
7474
}
7575

7676
// The macro TEMPLATE_1() expands to a switch statement conditioned on

source/source_base/parallel_cell.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
namespace ModuleBase
44
{
5-
CommunicationDomain::CommunicationDomain()
6-
{
7-
}
8-
95
#ifdef __MPI
10-
CommunicationDomain::CommunicationDomain(MPI_Comm communicator) : communicator_(communicator)
6+
void CommunicationDomain::initialize(MPI_Comm communicator)
117
{
8+
communicator_ = communicator;
9+
rank_ = 0;
1210
if (communicator_ != MPI_COMM_NULL)
1311
{
1412
MPI_Comm_rank(communicator_, &rank_);
@@ -28,10 +26,10 @@ int CommunicationDomain::rank() const
2826

2927
CommunicationDomain world_communication_domain()
3028
{
29+
CommunicationDomain communication_domain;
3130
#ifdef __MPI
32-
return CommunicationDomain(MPI_COMM_WORLD);
33-
#else
34-
return CommunicationDomain();
31+
communication_domain.initialize(MPI_COMM_WORLD);
3532
#endif
33+
return communication_domain;
3634
}
3735
} // namespace ModuleBase

0 commit comments

Comments
 (0)