Skip to content

Commit 168c3c2

Browse files
authored
Merge branch 'develop' into modularize_1
2 parents 59902c3 + 6742c15 commit 168c3c2

File tree

151 files changed

+34674
-21662
lines changed

Some content is hidden

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

151 files changed

+34674
-21662
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
- [nupdown](#nupdown)
6666
- [dft\_functional](#dft_functional)
6767
- [xc\_temperature](#xc_temperature)
68+
- [xc\_exch\_ext](#xc_exch_ext)
69+
- [xc\_corr\_ext](#xc_corr_ext)
6870
- [pseudo\_rcut](#pseudo_rcut)
6971
- [pseudo\_mesh](#pseudo_mesh)
7072
- [nspin](#nspin)
@@ -1060,6 +1062,26 @@ calculations.
10601062
- **Default**: 0.0
10611063
- **Unit**: Ry
10621064

1065+
### xc_exch_ext
1066+
1067+
- **Type**: Integer Real ...
1068+
- **Description**: Customized parameterization on the exchange part of XC functional. The first value should be the LibXC ID of the original functional, and latter values are external parameters. Default values are those of Perdew-Burke-Ernzerhof (PBE) functional. For more information on LibXC ID of functionals, please refer to [LibXC](https://libxc.gitlab.io/functionals/). For parameters of functionals of interest, please refer to the source code of LibXC, such as PBE functional interface in LibXC: [gga_x_pbe.c](https://gitlab.com/libxc/libxc/-/blob/7.0.0/src/gga_x_pbe.c).
1069+
- **Default**: 101 0.8040 0.2195149727645171
1070+
- **Note**:
1071+
1. Solely setting this keyword will take no effect on XC functionals. One should also set `dft_functional` to corresponding functional to apply the customized parameterization. For example, if you want to use the PBE functional with customized parameters, you should set `dft_functional` to `GGA_X_PBE+GGA_C_PBE` and `xc_exch_ext` to `101 0.8040 0.2195149727645171`.
1072+
2. For functionals that do not have separate exchange and correlation parts, such as HSE06 whose corresponding LibXC notation is `HYB_GGA_XC_HSE06` and LibXC id is 428, you can set either `xc_exch_ext` or `xc_corr_ext` to `428 0.25 0.11 0.11` (which means 25% Hartree-Fock fraction, 0.11 as range-seperation) and leave the other one unset.
1073+
3. Presently this feature can only support parameterization on **one** exchange functional.
1074+
1075+
### xc_corr_ext
1076+
1077+
- **Type**: Integer Real ...
1078+
- **Description**: Customized parameterization on the correlation part of XC functional. The first value should be the LibXC ID of the original functional, and latter values are external parameters. Default values are those of Perdew-Burke-Ernzerhof (PBE) functional. For more information on LibXC ID of functionals, please refer to [LibXC](https://libxc.gitlab.io/functionals/). For parameters of functionals of interest, please refer to the source code of LibXC, such as PBE functional interface in LibXC: [gga_c_pbe.c](https://gitlab.com/libxc/libxc/-/blob/7.0.0/src/gga_c_pbe.c).
1079+
- **Default**: 130 0.06672455060314922 0.031090690869654895034 1.0
1080+
- **Note**:
1081+
1. Solely setting this keyword will take no effect on XC functionals. One should also set `dft_functional` to corresponding functional to apply the customized parameterization. For example, if you want to use the PBE functional with customized parameters, you should set `dft_functional` to `GGA_X_PBE+GGA_C_PBE` and `xc_corr_ext` to `130 0.06672455060314922 0.031090690869654895034 1.0`.
1082+
2. For functionals that do not have separate exchange and correlation parts, such as HSE06 whose corresponding LibXC notation is `HYB_GGA_XC_HSE06` and LibXC id is 428, you can set either `xc_exch_ext` or `xc_corr_ext` to `428 0.25 0.11 0.11` (which means 25% Hartree-Fock fraction, 0.11 as range-seperation) and leave the other one unset.
1083+
3. Presently this feature can only support parameterization on **one** correlation functional.
1084+
10631085
### pseudo_rcut
10641086

10651087
- **Type**: Real
@@ -2378,8 +2400,29 @@ Warning: this function is not robust enough for the current version. Please try
23782400
### of_ml_gene_data
23792401

23802402
- **Type**: Boolean
2381-
- **Availability**: OFDFT
2382-
- **Description**: Generate training data or not.
2403+
- **Availability**: Used only for KSDFT with plane wave basis
2404+
- **Description**: Controls the generation of machine learning training data. When enabled, training data in `.npy` format will be saved in the directory `OUT.${suffix}/MLKEDF_Descriptors/`. The generated descriptors are categorized as follows:
2405+
- Local/Semilocal Descriptors. Files are named as `{var}.npy`, where `{var}` corresponds to the descriptor type:
2406+
- `gamma`: Enabled by [of_ml_gamma](#of_ml_gamma)
2407+
- `p`: Enabled by [of_ml_p](#of_ml_p)
2408+
- `q`: Enabled by [of_ml_q](#of_ml_q)
2409+
- `tanhp`: Enabled by [of_ml_tanhp](#of_ml_tanhp)
2410+
- `tanhq`: Enabled by [of_ml_tanhq](#of_ml_tanhq)
2411+
- Nonlocal Descriptors generated using kernels configured via [of_ml_nkernel](#of_ml_nkernel), [of_ml_kernel](#of_ml_kernel), and [of_ml_kernel_scaling](#of_ml_kernel_scaling). Files follow the naming convention `{var}_{kernel_type}_{kernel_scaling}.npy`, where `{kernel_type}` and `{kernel_scaling}` are specified by [of_ml_kernel](#of_ml_kernel), and [of_ml_kernel_scaling](#of_ml_kernel_scaling), respectively, and `{val}` denotes the kind of the descriptor, including
2412+
- `gammanl`: Enabled by [of_ml_gammanl](#of_ml_gammanl)
2413+
- `pnl`: Enabled by [of_ml_pnl](#of_ml_pnl)
2414+
- `qnl`: Enabled by [of_ml_qnl](#of_ml_qnl)
2415+
- `xi`: Enabled by [of_ml_xi](#of_ml_xi)
2416+
- `tanhxi`: Enabled by [of_ml_tanhxi](#of_ml_tanhxi)
2417+
- `tanhxi_nl`: Enabled by [of_ml_tanhxi_nl](#of_ml_tanhxi_nl)
2418+
- `tanh_pnl`: Enabled by [of_ml_tanh_pnl](#of_ml_tanh_pnl)
2419+
- `tanh_qnl`: Enabled by [of_ml_tanh_qnl](#of_ml_tanh_qnl)
2420+
- `tanhp_nl`: Enabled by [of_ml_tanhp_nl](#of_ml_tanhp_nl)
2421+
- `tanhq_nl`: Enabled by [of_ml_tanhq_nl](#of_ml_tanhq_nl)
2422+
- Training Targets, including key quantum mechanical quantities:
2423+
- `enhancement.npy`: Pauli energy enhancement factor $T_\theta/T_{\rm{TF}}$, where $T_{\rm{TF}}$ is the Thomas-Fermi functional
2424+
- `pauli.npy`: Pauli potential $V_\theta$
2425+
- `veff.npy`: Effective potential
23832426
- **Default**: False
23842427

23852428
### of_ml_device

source/Makefile.Objects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ OBJS_CELL=atom_pseudo.o\
202202

203203
OBJS_DEEPKS=LCAO_deepks.o\
204204
deepks_basic.o\
205+
deepks_check.o\
205206
deepks_descriptor.o\
206207
deepks_force.o\
207208
deepks_fpre.o\

source/module_base/global_file.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,47 @@ void ModuleBase::Global_File::make_dir_out(
153153
#endif
154154
}
155155

156+
if(PARAM.inp.of_ml_gene_data == 1)
157+
{
158+
int make_dir_descrip = 0;
159+
std::string command1 = "test -d " + PARAM.globalv.global_mlkedf_descriptor_dir + " || mkdir " + PARAM.globalv.global_mlkedf_descriptor_dir;
160+
161+
times = 0;
162+
while(times<GlobalV::NPROC)
163+
{
164+
if(rank==times)
165+
{
166+
if ( system( command1.c_str() ) == 0 )
167+
{
168+
std::cout << " MAKE THE MLKEDF DESCRIPTOR DIR : " << PARAM.globalv.global_mlkedf_descriptor_dir << std::endl;
169+
make_dir_descrip = 1;
170+
}
171+
else
172+
{
173+
std::cout << " PROC " << rank << " CAN NOT MAKE THE MLKEDF DESCRIPTOR DIR !!! " << std::endl;
174+
make_dir_descrip = 0;
175+
}
176+
}
177+
#ifdef __MPI
178+
Parallel_Reduce::reduce_all(make_dir_descrip);
179+
#endif
180+
if(make_dir_descrip > 0)
181+
{
182+
break;
183+
}
184+
++times;
185+
}
186+
187+
#ifdef __MPI
188+
if(make_dir_descrip == 0)
189+
{
190+
std::cout << " CAN NOT MAKE THE MLKEDF DESCRIPTOR DIR......." << std::endl;
191+
ModuleBase::QUIT();
192+
}
193+
MPI_Barrier(MPI_COMM_WORLD);
194+
#endif
195+
}
196+
156197
// mohan add 2010-09-12
157198
if(out_alllog)
158199
{

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include <iostream>
3838

3939
#ifdef __MLALGO
40-
#include "module_hamilt_pw/hamilt_ofdft/ml_data.h"
40+
#include "module_io/write_mlkedf_descriptors.h"
4141
#endif
4242

4343
#include <ATen/kernels/blas.h>
@@ -1003,30 +1003,31 @@ void ESolver_KS_PW<T, Device>::after_all_runners(UnitCell& ucell)
10031003
{
10041004
this->pelec->pot->update_from_charge(&this->chr, &ucell);
10051005

1006-
ML_data ml_data;
1007-
ml_data.set_para(this->chr.nrxx,
1008-
PARAM.inp.nelec,
1009-
PARAM.inp.of_tf_weight,
1010-
PARAM.inp.of_vw_weight,
1011-
PARAM.inp.of_ml_chi_p,
1012-
PARAM.inp.of_ml_chi_q,
1013-
PARAM.inp.of_ml_chi_xi,
1014-
PARAM.inp.of_ml_chi_pnl,
1015-
PARAM.inp.of_ml_chi_qnl,
1016-
PARAM.inp.of_ml_nkernel,
1017-
PARAM.inp.of_ml_kernel,
1018-
PARAM.inp.of_ml_kernel_scaling,
1019-
PARAM.inp.of_ml_yukawa_alpha,
1020-
PARAM.inp.of_ml_kernel_file,
1021-
ucell.omega,
1022-
this->pw_rho);
1023-
1024-
ml_data.generateTrainData_KS(this->kspw_psi,
1025-
this->pelec,
1026-
this->pw_wfc,
1027-
this->pw_rho,
1028-
ucell,
1029-
this->pelec->pot->get_effective_v(0));
1006+
ModuleIO::Write_MLKEDF_Descriptors write_mlkedf_desc;
1007+
write_mlkedf_desc.cal_tool->set_para(this->chr.nrxx,
1008+
PARAM.inp.nelec,
1009+
PARAM.inp.of_tf_weight,
1010+
PARAM.inp.of_vw_weight,
1011+
PARAM.inp.of_ml_chi_p,
1012+
PARAM.inp.of_ml_chi_q,
1013+
PARAM.inp.of_ml_chi_xi,
1014+
PARAM.inp.of_ml_chi_pnl,
1015+
PARAM.inp.of_ml_chi_qnl,
1016+
PARAM.inp.of_ml_nkernel,
1017+
PARAM.inp.of_ml_kernel,
1018+
PARAM.inp.of_ml_kernel_scaling,
1019+
PARAM.inp.of_ml_yukawa_alpha,
1020+
PARAM.inp.of_ml_kernel_file,
1021+
ucell.omega,
1022+
this->pw_rho);
1023+
1024+
write_mlkedf_desc.generateTrainData_KS(PARAM.globalv.global_mlkedf_descriptor_dir,
1025+
this->kspw_psi,
1026+
this->pelec,
1027+
this->pw_wfc,
1028+
this->pw_rho,
1029+
ucell,
1030+
this->pelec->pot->get_effective_v(0));
10301031
}
10311032
#endif
10321033
}

0 commit comments

Comments
 (0)