Skip to content

Commit 988db11

Browse files
committed
add parameter out_mat_xc2 and update tests
1 parent daab36c commit 988db11

File tree

9 files changed

+56
-21
lines changed

9 files changed

+56
-21
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
- [out\_mat\_t](#out_mat_t)
154154
- [out\_mat\_dh](#out_mat_dh)
155155
- [out\_mat\_xc](#out_mat_xc)
156+
- [out\_mat\_xc2](#out_mat_xc2)
156157
- [out\_eband\_terms](#out_eband_terms)
157158
- [out\_hr\_npz/out\_dm\_npz](#out_hr_npzout_dm_npz)
158159
- [dm\_to\_rho](#dm_to_rho)
@@ -1799,6 +1800,13 @@ These variables are used to control the output of properties.
17991800
The band (KS orbital) energy for each (k-point, spin, band) will be printed in the file `OUT.${suffix}/vxc_out.dat`. If EXX is calculated, the local and EXX part of band energy will also be printed in `OUT.${suffix}/vxc_local_out.dat`and `OUT.${suffix}/vxc_exx_out.dat`, respectively. All the `vxc*_out.dat` files contains 3 integers (nk, nspin, nband) followed by nk\*nspin\*nband lines of energy Hartree and eV.
18001801
- **Default**: False
18011802

1803+
### out_mat_xc2
1804+
1805+
- **Type**: Boolean
1806+
- **Availability**: Numerical atomic orbital (NAO) basis
1807+
- **Description**: Whether to print the exchange-correlation matrices in **numerical orbital representation** (unit: Ry): $\braket{\phi_i|V_\text{xc}^\text{(semi-)local}+V_\text{exx}+V_\text{DFTU}|\phi_j}(\mathbf{R})$ in CSR format (the same format as [out_mat_hs2](../elec_properties/hs_matrix.md#out_mat_hs2)) in the directory `OUT.${suffix}`. (Note that currently DeePKS term is not included. ) The files are named `Vxc_R_spin$s`.
1808+
- **Default**: False
1809+
18021810
### out_eband_terms
18031811

18041812
- **Type**: Boolean

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -489,30 +489,32 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
489489
if (PARAM.inp.out_mat_xc)
490490
{
491491
ModuleIO::write_Vxc<TK, TR>(PARAM.inp.nspin,
492-
PARAM.globalv.nlocal,
493-
GlobalV::DRANK,
494-
&this->pv,
495-
*this->psi,
496-
ucell,
497-
this->sf,
498-
this->solvent,
499-
*this->pw_rho,
500-
*this->pw_rhod,
501-
this->locpp.vloc,
502-
this->chr,
503-
this->GG,
504-
this->GK,
505-
this->kv,
506-
orb_.cutoffs(),
507-
this->pelec->wg,
508-
this->gd
492+
PARAM.globalv.nlocal,
493+
GlobalV::DRANK,
494+
&this->pv,
495+
*this->psi,
496+
ucell,
497+
this->sf,
498+
this->solvent,
499+
*this->pw_rho,
500+
*this->pw_rhod,
501+
this->locpp.vloc,
502+
this->chr,
503+
this->GG,
504+
this->GK,
505+
this->kv,
506+
orb_.cutoffs(),
507+
this->pelec->wg,
508+
this->gd
509509
#ifdef __EXX
510-
,
511-
this->exx_lri_double ? &this->exx_lri_double->Hexxs : nullptr,
512-
this->exx_lri_complex ? &this->exx_lri_complex->Hexxs : nullptr
510+
,
511+
this->exx_lri_double ? &this->exx_lri_double->Hexxs : nullptr,
512+
this->exx_lri_complex ? &this->exx_lri_complex->Hexxs : nullptr
513513
#endif
514514
);
515-
515+
}
516+
if (PARAM.inp.out_mat_xc2)
517+
{
516518
ModuleIO::write_Vxc_R<TK, TR>(PARAM.inp.nspin,
517519
&this->pv,
518520
ucell,

source/module_io/read_input_item_output.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ void ReadInput::item_output()
298298
read_sync_bool(input.out_mat_xc);
299299
this->add_item(item);
300300
}
301+
{
302+
Input_Item item("out_mat_xc2");
303+
item.annotation = "output exchange-correlation matrix in NAO representation";
304+
read_sync_bool(input.out_mat_xc2);
305+
this->add_item(item);
306+
}
301307
{
302308
Input_Item item("out_eband_terms");
303309
item.annotation = "output the band energy terms separately";

source/module_io/test/read_input_ptest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ TEST_F(InputParaTest, ParaRead)
208208
EXPECT_EQ(param.inp.out_mat_hs[1], 8);
209209
EXPECT_EQ(param.inp.out_mat_hs2, 0);
210210
EXPECT_FALSE(param.inp.out_mat_xc);
211+
EXPECT_FALSE(param.inp.out_mat_xc2);
211212
EXPECT_FALSE(param.inp.out_eband_terms);
212213
EXPECT_EQ(param.inp.out_interval, 1);
213214
EXPECT_EQ(param.inp.out_app_flag, 0);

source/module_parameter/input_parameter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ struct Input_para
376376
bool out_mat_dh = false;
377377
bool out_mat_xc = false; ///< output exchange-correlation matrix in
378378
///< KS-orbital representation.
379+
bool out_mat_xc2 = false; ///< output exchange-correlation matrix Vxc(R) in NAO representation.
379380
bool out_eband_terms = false; ///< output the band energy terms separately
380381
bool out_hr_npz = false; ///< output exchange-correlation matrix in
381382
///< KS-orbital representation.

tests/integrate/307_NO_GO_OXC/INPUT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ smearing_method gauss
2323
smearing_sigma 0.002
2424

2525
out_mat_xc 1
26+
out_mat_xc2 1
2627
out_eband_terms 1
2728

2829
#Parameters (5.Mixing)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
STEP: 0
2+
Matrix Dimension of Vxc_R_spin0(R): 26
3+
Matrix number of Vxc_R_spin0(R): 1
4+
0 0 0 132
5+
-6.99425500e-01 1.54630627e-01 -2.02590600e-02 -9.98372482e-02 1.54630627e-01 -3.63859528e-01 -9.98178110e-02 -1.36032667e-01 -6.10221093e-01 -2.05221537e-01 4.84073458e-03 3.86425460e-02 -6.54685745e-02 1.71711614e-02 -6.10221093e-01 -2.05221537e-01 4.84073458e-03 3.86425460e-02 -6.54685745e-02 1.71711614e-02 -6.10221093e-01 -2.05221537e-01 4.84073458e-03 3.86425460e-02 -6.54685745e-02 1.71711614e-02 -2.05221537e-01 -4.39113944e-01 -1.04968231e-03 -6.55024474e-02 2.36444413e-02 -6.86923692e-02 -2.05221537e-01 -4.39113944e-01 -1.04968231e-03 -6.55024474e-02 2.36444413e-02 -6.86923692e-02 -2.05221537e-01 -4.39113944e-01 -1.04968231e-03 -6.55024474e-02 2.36444413e-02 -6.86923692e-02 -6.98160574e-01 -4.48366310e-03 4.84073458e-03 -1.04968231e-03 -6.99822165e-01 -1.71459508e-02 6.86343042e-02 -3.03794506e-04 4.84073458e-03 -1.04968231e-03 -6.99822165e-01 -1.71459508e-02 6.86343042e-02 -3.03794506e-04 -6.98160574e-01 -4.48366310e-03 4.84073458e-03 -1.04968231e-03 -6.99822165e-01 -1.71459508e-02 6.86343042e-02 -3.03794506e-04 -2.02590600e-02 -9.98178110e-02 -6.99426855e-01 1.54629055e-01 -9.98372482e-02 -1.36032667e-01 1.54629055e-01 -3.63863991e-01 3.86425460e-02 -6.55024474e-02 -1.71459508e-02 -6.10223512e-01 -2.05219163e-01 -4.84033739e-03 3.86425460e-02 -6.55024474e-02 -1.71459508e-02 -6.10223512e-01 -2.05219163e-01 -4.84033739e-03 3.86425460e-02 -6.55024474e-02 -1.71459508e-02 -6.10223512e-01 -2.05219163e-01 -4.84033739e-03 -6.54685745e-02 2.36444413e-02 6.86343042e-02 -2.05219163e-01 -4.39128101e-01 1.04971294e-03 -6.54685745e-02 2.36444413e-02 6.86343042e-02 -2.05219163e-01 -4.39128101e-01 1.04971294e-03 -6.54685745e-02 2.36444413e-02 6.86343042e-02 -2.05219163e-01 -4.39128101e-01 1.04971294e-03 -4.48366310e-03 -6.98168157e-01 1.71711614e-02 -6.86923692e-02 -3.03794506e-04 -4.84033739e-03 1.04971294e-03 -6.99823286e-01 1.71711614e-02 -6.86923692e-02 -3.03794506e-04 -4.84033739e-03 1.04971294e-03 -6.99823286e-01 -4.48366310e-03 -6.98168157e-01 1.71711614e-02 -6.86923692e-02 -3.03794506e-04 -4.84033739e-03 1.04971294e-03 -6.99823286e-01
6+
0 1 13 14 0 1 13 14 2 5 12 15 18 25 3 6 10 16 19 23 4 7 9 17 20 22 2 5 12 15 18 25 3 6 10 16 19 23 4 7 9 17 20 22 8 21 4 7 9 17 20 22 3 6 10 16 19 23 11 24 2 5 12 15 18 25 0 1 13 14 0 1 13 14 2 5 12 15 18 25 3 6 10 16 19 23 4 7 9 17 20 22 2 5 12 15 18 25 3 6 10 16 19 23 4 7 9 17 20 22 8 21 4 7 9 17 20 22 3 6 10 16 19 23 11 24 2 5 12 15 18 25
7+
0 4 8 14 20 26 32 38 44 46 52 58 60 66 70 74 80 86 92 98 104 110 112 118 124 126 132

tests/integrate/307_NO_GO_OXC/result.ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
etotref -204.1062806122546
22
etotperatomref -102.0531403061
33
CompareVXC_pass 0
4+
CompareVXC_R_pass 0
45
CompareOrbXC_pass 0
56
CompareOrbKinetic_pass 0
67
CompareOrbVL_pass 0

tests/integrate/tools/catch_properties.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ has_cond=$(get_input_key_value "cal_cond" "INPUT")
4242
has_hs=$(get_input_key_value "out_mat_hs" "INPUT")
4343
has_hs2=$(get_input_key_value "out_mat_hs2" "INPUT")
4444
has_xc=$(get_input_key_value "out_mat_xc" "INPUT")
45+
has_xc2=$(get_input_key_value "out_mat_xc2" "INPUT")
4546
has_eband_separate=$(get_input_key_value "out_eband_terms" "INPUT")
4647
has_r=$(get_input_key_value "out_mat_r" "INPUT")
4748
deepks_out_labels=$(get_input_key_value "deepks_out_labels" "INPUT")
@@ -257,6 +258,13 @@ if ! test -z "$has_xc" && [ $has_xc == 1 ]; then
257258
echo "CompareOrbXC_pass $?" >>$1
258259
fi
259260

261+
if ! test -z "$has_xc2" && [ $has_xc2 == 1 ]; then
262+
xc2ref=Vxc_R_spin0.ref
263+
xc2cal=OUT.autotest/Vxc_R_spin0.csr
264+
python3 ../tools/CompareFile.py $xc2ref $xc2cal 8
265+
echo "CompareVXC_R_pass $?" >>$1
266+
fi
267+
260268
if ! test -z "$has_eband_separate" && [ $has_eband_separate == 1 ]; then
261269
ekref=kinetic_out.ref
262270
ekcal=OUT.autotest/kinetic_out.dat

0 commit comments

Comments
 (0)