Skip to content

Commit fa46030

Browse files
committed
Feature: Provide default parameters for MPN and CPN5 KEDF.
1 parent 48bf3f2 commit fa46030

File tree

7 files changed

+123
-46
lines changed

7 files changed

+123
-46
lines changed

source/module_esolver/esolver_of.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ void ESolver_OF::after_opt(const int istep, UnitCell& ucell)
500500

501501
#ifdef __MLKEDF
502502
// Check the positivity of Pauli energy
503-
if (this->of_kinetic_ == "mpn" || this->of_kinetic_ == "ml")
503+
if (this->of_kinetic_ == "ml")
504504
{
505505
this->tf_->get_energy(this->pelec->charge->rho);
506506
std::cout << "ML Term = " << this->ml_->ml_energy << " Ry, TF Term = " << this->tf_->tf_energy << " Ry." << std::endl;

source/module_esolver/esolver_of_interface.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ void ESolver_OF::init_kedf(const Input_para& inp)
1616
if (this->of_kinetic_ == "tf"
1717
|| this->of_kinetic_ == "tf+"
1818
|| this->of_kinetic_ == "wt"
19-
|| this->of_kinetic_ == "ml"
20-
|| this->of_kinetic_ == "mpn")
19+
|| this->of_kinetic_ == "ml")
2120
{
2221
if (this->tf_ == nullptr)
2322
{
@@ -28,7 +27,7 @@ void ESolver_OF::init_kedf(const Input_para& inp)
2827

2928
//! vW, TF+, WT, and LKT KEDFs
3029
if (this->of_kinetic_ == "vw" || this->of_kinetic_ == "tf+" || this->of_kinetic_ == "wt"
31-
|| this->of_kinetic_ == "lkt" || this->of_kinetic_ == "ml" || this->of_kinetic_ == "mpn")
30+
|| this->of_kinetic_ == "lkt" || this->of_kinetic_ == "ml")
3231
{
3332
if (this->vw_ == nullptr)
3433
{
@@ -67,7 +66,7 @@ void ESolver_OF::init_kedf(const Input_para& inp)
6766
this->lkt_->set_para(this->dV_, inp.of_lkt_a);
6867
}
6968
#ifdef __MLKEDF
70-
if (this->of_kinetic_ == "ml" || this->of_kinetic_ == "mpn")
69+
if (this->of_kinetic_ == "ml")
7170
{
7271
if (this->ml_ == nullptr)
7372
this->ml_ = new KEDF_ML();
@@ -104,7 +103,7 @@ void ESolver_OF::kinetic_potential(double** prho, double** pphi, ModuleBase::mat
104103
this->lkt_->lkt_potential(prho, this->pw_rho, rpot);
105104
}
106105
#ifdef __MLKEDF
107-
if (this->of_kinetic_ == "ml" || this->of_kinetic_ == "mpn")
106+
if (this->of_kinetic_ == "ml")
108107
{
109108
this->ml_->ml_potential(prho, this->pw_rho, rpot);
110109
this->tf_->get_energy(prho); // temp
@@ -121,7 +120,7 @@ void ESolver_OF::kinetic_potential(double** prho, double** pphi, ModuleBase::mat
121120
}
122121

123122
if (this->of_kinetic_ == "vw" || this->of_kinetic_ == "tf+" || this->of_kinetic_ == "wt"
124-
|| this->of_kinetic_ == "lkt" || this->of_kinetic_ == "ml" || this->of_kinetic_ == "mpn")
123+
|| this->of_kinetic_ == "lkt" || this->of_kinetic_ == "ml")
125124
{
126125
this->vw_->vw_potential(pphi, this->pw_rho, rpot);
127126
}
@@ -143,7 +142,7 @@ double ESolver_OF::kinetic_energy()
143142
}
144143

145144
if (this->of_kinetic_ == "vw" || this->of_kinetic_ == "tf+" || this->of_kinetic_ == "wt"
146-
|| this->of_kinetic_ == "lkt" || this->of_kinetic_ == "ml" || this->of_kinetic_ == "mpn")
145+
|| this->of_kinetic_ == "lkt" || this->of_kinetic_ == "ml")
147146
{
148147
kinetic_energy += this->vw_->vw_energy;
149148
}
@@ -158,7 +157,7 @@ double ESolver_OF::kinetic_energy()
158157
kinetic_energy += this->lkt_->lkt_energy;
159158
}
160159
#ifdef __MLKEDF
161-
if (this->of_kinetic_ == "ml" || this->of_kinetic_ == "mpn")
160+
if (this->of_kinetic_ == "ml")
162161
{
163162
kinetic_energy += this->ml_->ml_energy;
164163
if (this->ml_->ml_energy >= this->tf_->tf_energy)
@@ -246,7 +245,7 @@ void ESolver_OF::kinetic_stress(ModuleBase::matrix& kinetic_stress_)
246245
this->lkt_->get_stress(pelec->charge->rho, this->pw_rho);
247246
kinetic_stress_ += this->lkt_->stress;
248247
}
249-
if (this->of_kinetic_ == "ml" || this->of_kinetic_ == "mpn")
248+
if (this->of_kinetic_ == "ml")
250249
{
251250
std::cout << "Sorry, the stress of MPN KEDF is not yet supported." << std::endl;
252251
}

source/module_esolver/esolver_of_tool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void ESolver_OF::print_info()
448448
energies_Ry.push_back(this->tf_->tf_energy);
449449
}
450450
if (this->of_kinetic_ == "vw" || this->of_kinetic_ == "tf+" || this->of_kinetic_ == "wt"
451-
|| this->of_kinetic_ == "lkt" || this->of_kinetic_ == "ml" || this->of_kinetic_ == "mpn")
451+
|| this->of_kinetic_ == "lkt" || this->of_kinetic_ == "ml")
452452
{
453453
titles.push_back("vW KEDF");
454454
energies_Ry.push_back(this->vw_->vw_energy);
@@ -464,7 +464,7 @@ void ESolver_OF::print_info()
464464
energies_Ry.push_back(this->lkt_->lkt_energy);
465465
}
466466
#ifdef __MLKEDF
467-
if (this->of_kinetic_ == "ml" || this->of_kinetic_ == "mpn")
467+
if (this->of_kinetic_ == "ml")
468468
{
469469
titles.push_back("MPN KEDF");
470470
energies_Ry.push_back(this->ml_->ml_energy);

source/module_io/read_input_item_ofdft.cpp

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,84 @@ void ReadInput::item_ofdft()
1010
{
1111
Input_Item item("of_kinetic");
1212
item.annotation = "kinetic energy functional, such as tf, vw, wt";
13+
item.check_value = [](const Input_Item& item, const Parameter& para) {
14+
#ifndef __MLKEDF
15+
if (para.input.of_kinetic == "ml" || para.input.of_kinetic == "mpn" || para.input.of_kinetic == "cpn5")
16+
{
17+
ModuleBase::WARNING_QUIT("ReadInput", "ML KEDF is not supported.");
18+
}
19+
#endif
20+
if (para.input.of_kinetic != "tf" && para.input.of_kinetic != "vw" && para.input.of_kinetic != "wt"
21+
&& para.input.of_kinetic != "lkt" && para.input.of_kinetic != "tf+"
22+
&& para.input.of_kinetic != "ml" && para.input.of_kinetic != "mpn" && para.input.of_kinetic != "cpn5")
23+
{
24+
ModuleBase::WARNING_QUIT("ReadInput", "of_kinetic must be tf, vw, tf+, wt, lkt, ml, mpn, or cpn5");
25+
}
26+
};
27+
item.reset_value = [](const Input_Item& item, Parameter& para) {
28+
// Set the default parameters for MPN or CPN5 KEDF
29+
if (para.input.of_kinetic == "mpn")
30+
{
31+
para.input.of_kinetic = "ml";
32+
33+
para.input.of_ml_feg = 3;
34+
para.input.of_ml_nkernel = 1;
35+
para.input.of_ml_kernel = {1};
36+
para.input.of_ml_kernel_scaling = {1.0};
37+
para.input.of_ml_yukawa_alpha = {1.0};
38+
para.input.of_ml_gamma = false;
39+
para.input.of_ml_p = false;
40+
para.input.of_ml_q = false;
41+
para.input.of_ml_tanhp = true;
42+
para.input.of_ml_tanhq = false;
43+
para.input.of_ml_chi_p = 0.2;
44+
para.input.of_ml_chi_q = 0.1;
45+
para.input.of_ml_gammanl = {0};
46+
para.input.of_ml_pnl = {0};
47+
para.input.of_ml_qnl = {0};
48+
para.input.of_ml_xi = {0};
49+
para.input.of_ml_tanhxi = {1};
50+
para.input.of_ml_tanhxi_nl = {1};
51+
para.input.of_ml_tanh_pnl = {0};
52+
para.input.of_ml_tanh_qnl = {0};
53+
para.input.of_ml_tanhp_nl = {1};
54+
para.input.of_ml_tanhq_nl = {0};
55+
para.input.of_ml_chi_xi = {1.0};
56+
para.input.of_ml_chi_pnl = {0.2};
57+
para.input.of_ml_chi_qnl = {0.1};
58+
}
59+
60+
if (para.input.of_kinetic == "cpn5")
61+
{
62+
para.input.of_kinetic = "ml";
63+
64+
para.input.of_ml_feg = 3;
65+
para.input.of_ml_nkernel = 5;
66+
para.input.of_ml_kernel = {1, 1, 1, 1, 1};
67+
para.input.of_ml_kernel_scaling = {2.0, 1.5, 1.0, 0.75, 0.5};
68+
para.input.of_ml_yukawa_alpha = {1.0, 1.0, 1.0, 1.0, 1.0};
69+
para.input.of_ml_gamma = false;
70+
para.input.of_ml_p = false;
71+
para.input.of_ml_q = false;
72+
para.input.of_ml_tanhp = true;
73+
para.input.of_ml_tanhq = false;
74+
para.input.of_ml_chi_p = 0.2;
75+
para.input.of_ml_chi_q = 0.1;
76+
para.input.of_ml_gammanl = {0, 0, 0, 0, 0};
77+
para.input.of_ml_pnl = {0, 0, 0, 0, 0};
78+
para.input.of_ml_qnl = {0, 0, 0, 0, 0};
79+
para.input.of_ml_xi = {0, 0, 0, 0, 0};
80+
para.input.of_ml_tanhxi = {1, 1, 1, 1, 1};
81+
para.input.of_ml_tanhxi_nl = {1, 1, 1, 1, 1};
82+
para.input.of_ml_tanh_pnl = {0, 0, 0, 0, 0};
83+
para.input.of_ml_tanh_qnl = {0, 0, 0, 0, 0};
84+
para.input.of_ml_tanhp_nl = {1, 1, 1, 1, 1};
85+
para.input.of_ml_tanhq_nl = {0, 0, 0, 0, 0};
86+
para.input.of_ml_chi_xi = {0.6, 0.8, 1.0, 1.5, 3.0};
87+
para.input.of_ml_chi_pnl = {0.2, 0.2, 0.2, 0.2, 0.2};
88+
para.input.of_ml_chi_qnl = {0.1, 0.1, 0.1, 0.1, 0.1};
89+
}
90+
};
1391
read_sync_string(input.of_kinetic);
1492
this->add_item(item);
1593
}

tests/integrate/902_OF_KE_CPN5/INPUT

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@ ecutwfc 20
1414
scf_nmax 200
1515

1616
#OFDFT
17-
of_kinetic ml
17+
of_kinetic cpn5
1818
of_method tn
1919
of_conv energy
2020
of_tole 2e-6
2121
of_full_pw 1
2222
of_full_pw_dim 0
23-
of_ml_feg 3
2423

2524
#Parameters (3.Basis)
2625
basis_type pw
27-
of_ml_nkernel 5
28-
of_ml_chi_xi 0.6 0.8 1 1.5 3
29-
of_ml_chi_p 0.2
30-
of_ml_chi_q 0.1
31-
of_ml_chi_pnl 0.2 0.2 0.2 0.2 0.2
32-
of_ml_chi_qnl 0.1 0.1 0.1 0.1 0.1
33-
of_ml_kernel 1 1 1 1 1
34-
of_ml_yukawa_alpha 1 1 1 1 1
35-
of_ml_kernel_scaling 2.0 1.5 1.0 0.75 0.5
36-
of_ml_tanhxi 1 1 1 1 1
37-
of_ml_tanhxi_nl 1 1 1 1 1
38-
of_ml_tanhp 1
39-
of_ml_tanhp_nl 1 1 1 1 1
40-
of_ml_nnode 100
41-
of_ml_nlayer 3
4226
of_ml_device cpu
27+
# of_ml_feg 3
28+
# of_ml_nkernel 5
29+
# of_ml_chi_xi 0.6 0.8 1.0 1.5 3.0
30+
# of_ml_chi_p 0.2
31+
# of_ml_chi_q 0.1
32+
# of_ml_chi_pnl 0.2 0.2 0.2 0.2 0.2
33+
# of_ml_chi_qnl 0.1 0.1 0.1 0.1 0.1
34+
# of_ml_kernel 1 1 1 1 1
35+
# of_ml_yukawa_alpha 1 1 1 1 1
36+
# of_ml_kernel_scaling 2.0 1.5 1.0 0.75 0.5
37+
# of_ml_tanhxi 1 1 1 1 1
38+
# of_ml_tanhxi_nl 1 1 1 1 1
39+
# of_ml_tanhp 1
40+
# of_ml_tanhp_nl 1 1 1 1 1
41+
# of_ml_nnode 100
42+
# of_ml_nlayer 3
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
etotref -218.1572352870448
2-
etotperatomref -109.0786176435
1+
etotref -218.1572355140357
2+
etotperatomref -109.0786177570
33
pointgroupref T_d
44
spacegroupref O_h
55
nksibzref 1
6-
totaltimeref 28.48
6+
totaltimeref 28.35

tests/integrate/902_OF_KE_MPN/INPUT

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ dft_functional XC_GGA_X_PBE+XC_GGA_C_PBE
1818
basis_type pw
1919

2020
#OFDFT
21-
of_kinetic ml
21+
of_kinetic mpn
2222
of_ml_device cpu
2323

24-
of_ml_chi_xi 1
25-
of_ml_chi_p 0.2
26-
of_ml_chi_q 0.1
27-
of_ml_chi_pnl 0.2
28-
of_ml_chi_qnl 0.1
29-
30-
of_ml_tanhxi 1
31-
of_ml_tanhxi_nl 1
32-
of_ml_tanhp 1
33-
of_ml_tanhp_nl 1
34-
of_ml_feg 3
35-
of_ml_nnode 10
36-
of_ml_nlayer 3
24+
#of_ml_chi_xi 1
25+
#of_ml_chi_p 0.2
26+
#of_ml_chi_q 0.1
27+
#of_ml_chi_pnl 0.2
28+
#of_ml_chi_qnl 0.1
29+
#
30+
#of_ml_tanhxi 1
31+
#of_ml_tanhxi_nl 1
32+
#of_ml_tanhp 1
33+
#of_ml_tanhp_nl 1
34+
#of_ml_feg 3
35+
#of_ml_nnode 10
36+
#of_ml_nlayer 3

0 commit comments

Comments
 (0)