Skip to content

Commit 9263c66

Browse files
committed
update out_dm and out_dm1 parameters and documents
1 parent 7771d88 commit 9263c66

File tree

16 files changed

+49
-41
lines changed

16 files changed

+49
-41
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,21 +1643,22 @@ These variables are used to control the output of properties.
16431643

16441644
- **Type**: Boolean
16451645
- **Availability**: Numerical atomic orbital basis
1646-
- **Description**: Whether to output the density matrix of localized orbitals into files in the folder `OUT.${suffix}`. The files are named as:
1646+
- **Description**: Whether to output the density matrix for each k-point into files in the folder `OUT.${suffix}`. The files are named as:
16471647
- For gamma only case:
1648-
- nspin = 1: SPIN1_DM;
1649-
- nspin = 2: SPIN1_DM, and SPIN2_DM.
1648+
- nspin = 1: `dms1_nao.csr`;
1649+
- nspin = 2: `dms1_nao.csr` and `dms2_nao.csr` for the two spin channels.
16501650
- For multi-k points case:
1651-
- SPIN\*_K\*_DM, where \* stands for index of spin and kpoints;
1651+
- nspin = 1: `dms1k1_nao.csr`, `dms1k2_nao.csr`, ...;
1652+
- nspin = 2: `dms1k1_nao.csr`... and `dms2k1_nao.csr`... for the two spin channels.
16521653
- **Default**: False
16531654

16541655
### out_dm1
16551656

16561657
- **Type**: Boolean
16571658
- **Availability**: Numerical atomic orbital basis (multi-k points)
1658-
- **Description**: Whether to output the density matrix of localized orbitals into files in the folder `OUT.${suffix}`. The density matrices are written in the format of sparse matrices, as mentioned in [out_mat_hs2](#out_mat_hs2). The files are named as:
1659-
- nspin = 1: data-DMR-sparse_SPIN0.csr;
1660-
- nspin = 2: data-DMR-sparse_SPIN0.csr, and data-DMR-sparse_SPIN1.csr.
1659+
- **Description**: Whether to output the density matrix with Bravias lattice vector R, labelled as DM(R), into files in the folder `OUT.${suffix}`. The files are named as `dmr{s}{spin index}{g}{geometry index}{_nao} + {".csr"}`. Here, 's' refers to spin, where s1 means spin up channel while s2 means spin down channel, and the sparse matrix format 'csr' is mentioned in [out_mat_hs2](#out_mat_hs2). Finally, if [out_app_flag](#out_app_flag) is set to false, the file name contains the optinal 'g' index for each ionic step that may have different geometries, and if [out_app_flag](#out_app_flag) is set to true, the density matrix with respect to Bravias lattice vector R accumulates during ionic steps:
1660+
- nspin = 1: `dmrs1_nao.csr`;
1661+
- nspin = 2: `dmrs1_nao.csr` and `dmrs2_nao.csr` for the two spin channels.
16611662
- **Default**: False
16621663

16631664
### out_wfc_pw

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "module_io/to_wannier90_lcao.h"
2727
#include "module_io/to_wannier90_lcao_in_pw.h"
2828
#include "module_io/write_HS.h"
29-
#include "module_io/write_dmr.h"
3029
#include "module_io/write_elecstat_pot.h"
3130
#include "module_io/write_istate_info.h"
3231
#include "module_io/write_proj_band_lcao.h"

source/module_io/io_dmk.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ std::string ModuleIO::dmk_gen_fname(const bool gamma_only, const int ispin, cons
5959
{
6060
if (gamma_only)
6161
{
62-
return "SPIN" + std::to_string(ispin + 1) + "_DM";
62+
return std::string("dm") + "s" + std::to_string(ispin + 1) + "_nao.txt";
6363
}
6464
else
6565
{
66-
return "SPIN" + std::to_string(ispin + 1) + "_K" + std::to_string(ik + 1) + "_DM";
66+
// mohan update 2025-05-25, the index of 'ik' should be the correct 'ik' without spin
67+
return std::string("dm") + "s" + std::to_string(ispin + 1)
68+
+ "k" + std::to_string(ik + 1) + "_nao.txt";
6769
}
6870
}
6971

source/module_io/write_dmr.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,21 @@ std::string dmr_gen_fname(const int out_type, const int ispin, const bool append
1616
{
1717
if (!append && istep >= 0)
1818
{
19-
fname = std::to_string(istep + 1) + "_data-DMR-sparse_SPIN" + std::to_string(ispin) + ".csr";
19+
// spa stands for sparse
20+
fname = "dmrs" + std::to_string(ispin+1) + "g" + std::to_string(istep + 1) + "_nao.csr";
2021
}
2122
else
2223
{
23-
fname = "data-DMR-sparse_SPIN" + std::to_string(ispin) + ".csr";
24+
fname = "dmrs" + std::to_string(ispin+1) + "_nao.csr";
2425
}
2526
}
2627
else if (out_type == 2)
2728
{
28-
fname = "output_DM" + std::to_string(ispin) + ".npz";
29+
fname = "dmrs" + std::to_string(ispin+1) + "_nao.npz";
2930
}
3031
else
3132
{
32-
ModuleBase::WARNING("write_dmr", "the output type of DMR should be npz or csr.");
33+
ModuleBase::WARNING("write_dmr", "the output type of density matrix DM(R) should be csr or npz.");
3334
}
3435
return fname;
3536
}
@@ -38,13 +39,13 @@ void write_dmr_csr(std::string& fname, hamilt::HContainer<double>* dm_serial, co
3839
{
3940
// write the head: ION step number, basis number and R loop number
4041
std::ofstream ofs(fname, std::ios::app);
41-
ofs << "STEP: " << istep << std::endl;
42+
ofs << "STEP: " << istep+1 << std::endl;
4243
ofs << "Matrix Dimension of DM(R): " << dm_serial->get_nbasis() << std::endl;
4344
ofs << "Matrix number of DM(R): " << dm_serial->size_R_loop() << std::endl;
4445

4546
// write HR_serial to ofs
46-
double sparse_threshold = 1e-10;
47-
int precision = 8;
47+
const double sparse_threshold = 1e-10;
48+
const int precision = 8;
4849
hamilt::Output_HContainer<double> out_dm(dm_serial, ofs, sparse_threshold, precision);
4950
out_dm.write();
5051
ofs.close();

tests/03_NAO_multik/04_NO_KP_GTH/INPUT

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
INPUT_PARAMETERS
2+
#Parameters (General)
3+
suffix autotest
4+
calculation scf
5+
nspin 2
6+
7+
#Parameters (Accuracy)
8+
ecutwfc 20
9+
scf_nmax 50
10+
scf_thr 1.0e-8
11+
12+
basis_type lcao
13+
14+
cal_stress 1
15+
cal_force 1
16+
17+
mixing_type broyden
18+
mixing_beta 0.7
19+
mixing_gg0 1.5
20+
pseudo_dir ../../PP_ORB
21+
orbital_dir ../../PP_ORB
22+
23+
out_dm1 1
24+
out_dm 1
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)