Skip to content

Commit ff12693

Browse files
committed
add iter and itep into the output wave function file name in pw basis, change out_interval to out_freq_ion
1 parent 9e6bb70 commit ff12693

File tree

13 files changed

+81
-87
lines changed

13 files changed

+81
-87
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
- [out\_mul](#out_mul)
164164
- [out\_app\_flag](#out_app_flag)
165165
- [out\_ndigits](#out_ndigits)
166-
- [out\_interval](#out_interval)
166+
- [out\_freq\_ion](#out_freq_ion)
167167
- [out\_element\_info](#out_element_info)
168168
- [restart\_save](#restart_save)
169169
- [rpa](#rpa)
@@ -1655,7 +1655,7 @@ These variables are used to control the output of properties.
16551655

16561656
In EXX(exact exchange) calculations, (i.e. *[dft_fuctional](#dft_functional)==hse/hf/pbe0/scan0* or *[rpa](#rpa)==True*), the Hexx(R) files will be output in the folder `OUT.${suffix}` too, which can be read in NSCF calculation.
16571657

1658-
In molecular dynamics simulations, the output frequency is controlled by [out_interval](#out_interval).
1658+
In molecular dynamics simulations, the output frequency is controlled by [out_freq_ion](#out_freq_ion).
16591659
- **Default**: 0 3
16601660
- **Note**: In the 3.10-LTS version, the file names are SPIN1_CHG.cube and SPIN1_CHG_INI.cube, etc.
16611661

@@ -1693,7 +1693,7 @@ These variables are used to control the output of properties.
16931693
- nspin = 2: `pots1_ini.cube` and `pots2_ini.cube`;
16941694
- nspin = 4: `pots1_ini.cube`, `pots2_ini.cube`, `pots3_ini.cube`, and `pots4_ini.cube`
16951695

1696-
In molecular dynamics calculations, the output frequency is controlled by [out_interval](#out_interval).
1696+
In molecular dynamics calculations, the output frequency is controlled by [out_freq_ion](#out_freq_ion).
16971697
- **Default**: 0
16981698
- **Note**: In the 3.10-LTS version, the file names are SPIN1_POT.cube and SPIN1_POT_INI.cube, etc.
16991699

@@ -1749,7 +1749,7 @@ These variables are used to control the output of properties.
17491749

17501750
The corresponding sequence of the orbitals can be seen in [Basis Set](../pp_orb.md#basis-set).
17511751

1752-
Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag).
1752+
Also controled by [out_freq_ion](#out_freq_ion) and [out_app_flag](#out_app_flag).
17531753
- **Default**: False
17541754
- **Note**: In the 3.10-LTS version, the file names are WFC_NAO_GAMMA1_ION1.txt and WFC_NAO_K1_ION1.txt, etc.
17551755

@@ -1826,7 +1826,7 @@ These variables are used to control the output of properties.
18261826

18271827
- **Type**: Boolean \[Integer\](optional)
18281828
- **Availability**: Numerical atomic orbital basis
1829-
- **Description**: Whether to print the upper triangular part of the Hamiltonian matrices and overlap matrices for each k-point into files in the directory `OUT.${suffix}`. The second number controls precision. For more information, please refer to [hs_matrix.md](../elec_properties/hs_matrix.md#out_mat_hs). Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag).
1829+
- **Description**: Whether to print the upper triangular part of the Hamiltonian matrices and overlap matrices for each k-point into files in the directory `OUT.${suffix}`. The second number controls precision. For more information, please refer to [hs_matrix.md](../elec_properties/hs_matrix.md#out_mat_hs). Also controled by [out_freq_ion](#out_freq_ion) and [out_app_flag](#out_app_flag).
18301830
- For gamma only case:
18311831
- nspin = 1: `hks1_nao.txt` for the Hamiltonian matrix and `sks1_nao.txt` for the overlap matrix;
18321832
- nspin = 2: `hks1_nao.txt` and `hks2_nao.txt` for the Hamiltonian matrix and `sks1_nao.txt` for the overlap matrix. Note that the code will not output `sks2_nao.txt` because it is the same as `sks1_nao.txt`;
@@ -1870,7 +1870,7 @@ These variables are used to control the output of properties.
18701870

18711871
- **Type**: Boolean
18721872
- **Availability**: Numerical atomic orbital basis (not gamma-only algorithm)
1873-
- **Description**: Generate files containing the kinetic energy matrix $T(R)$. The format will be the same as the Hamiltonian matrix $H(R)$ and overlap matrix $S(R)$ as mentioned in [out_mat_hs2](#out_mat_hs2). The name of the files will be `trs1_nao.csr` and so on. Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag).
1873+
- **Description**: Generate files containing the kinetic energy matrix $T(R)$. The format will be the same as the Hamiltonian matrix $H(R)$ and overlap matrix $S(R)$ as mentioned in [out_mat_hs2](#out_mat_hs2). The name of the files will be `trs1_nao.csr` and so on. Also controled by [out_freq_ion](#out_freq_ion) and [out_app_flag](#out_app_flag).
18741874
- **Default**: False
18751875
- **Unit**: Ry
18761876
- **Note**: In the 3.10-LTS version, the file name is data-TR-sparse_SPIN0.csr.
@@ -1879,7 +1879,7 @@ These variables are used to control the output of properties.
18791879

18801880
- **Type**: Boolean
18811881
- **Availability**: Numerical atomic orbital basis (not gamma-only algorithm)
1882-
- **Description**: Whether to print files containing the derivatives of the Hamiltonian matrix. The format will be the same as the Hamiltonian matrix $H(R)$ and overlap matrix $S(R)$ as mentioned in [out_mat_hs2](#out_mat_hs2). The name of the files will be `dhrxs1_nao.csr`, `dhrys1_nao.csr`, `dhrzs1_nao.csr` and so on. Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag).
1882+
- **Description**: Whether to print files containing the derivatives of the Hamiltonian matrix. The format will be the same as the Hamiltonian matrix $H(R)$ and overlap matrix $S(R)$ as mentioned in [out_mat_hs2](#out_mat_hs2). The name of the files will be `dhrxs1_nao.csr`, `dhrys1_nao.csr`, `dhrzs1_nao.csr` and so on. Also controled by [out_freq_ion](#out_freq_ion) and [out_app_flag](#out_app_flag).
18831883
- **Default**: False
18841884
- **Unit**: Ry/Bohr
18851885
- **Note**: In the 3.10-LTS version, the file name is data-dHRx-sparse_SPIN0.csr and so on.
@@ -1888,7 +1888,7 @@ These variables are used to control the output of properties.
18881888

18891889
- **Type**: Boolean
18901890
- **Availability**: Numerical atomic orbital basis (not gamma-only algorithm)
1891-
- **Description**: Whether to print files containing the derivatives of the overlap matrix. The format will be the same as the overlap matrix $dH(R)$ as mentioned in [out_mat_dh](#out_mat_dh). The name of the files will be `dsrxs1.csr` and so on. Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag). This feature can be used with `calculation get_s`.
1891+
- **Description**: Whether to print files containing the derivatives of the overlap matrix. The format will be the same as the overlap matrix $dH(R)$ as mentioned in [out_mat_dh](#out_mat_dh). The name of the files will be `dsrxs1.csr` and so on. Also controled by [out_freq_ion](#out_freq_ion) and [out_app_flag](#out_app_flag). This feature can be used with `calculation get_s`.
18921892
- **Default**: False
18931893
- **Unit**: Ry/Bohr
18941894
- **Note**: In the 3.10-LTS version, the file name is data-dSRx-sparse_SPIN0.csr and so on.
@@ -1936,7 +1936,7 @@ These variables are used to control the output of properties.
19361936

19371937
- **Type**: Boolean
19381938
- **Availability**: Numerical atomic orbital basis
1939-
- **Description**: Whether to print the Mulliken population analysis result into `OUT.${suffix}/mulliken.txt`. In molecular dynamics calculations, the output frequency is controlled by [out_interval](#out_interval).
1939+
- **Description**: Whether to print the Mulliken population analysis result into `OUT.${suffix}/mulliken.txt`. In molecular dynamics calculations, the output frequency is controlled by [out_freq_ion](#out_freq_ion).
19401940
- **Default**: False
19411941

19421942
### out_app_flag
@@ -1953,7 +1953,7 @@ These variables are used to control the output of properties.
19531953
- **Description**: Controls the length of decimal part of output data, such as charge density, Hamiltonian matrix, Overlap matrix and so on.
19541954
- **Default**: 8
19551955

1956-
### out_interval
1956+
### out_freq_ion
19571957

19581958
- **Type**: Integer
19591959
- **Description**: After self-consistent-field calculations, control the interval of ionic movements for printing properties. These properties cover charge density, local potential, electrostatic potential, Hamiltonian matrix, overlap matrix, density matrix, Mulliken population analysis and so on.
@@ -2025,7 +2025,7 @@ These variables are used to control the output of properties.
20252025
The second integer controls the precision of the kinetic energy density output, if not given, will use `3` as default. For purpose restarting from this file and other high-precision involved calculation, recommend to use `10`.
20262026

20272027
---
2028-
In molecular dynamics calculations, the output frequency is controlled by [out_interval](#out_interval).
2028+
In molecular dynamics calculations, the output frequency is controlled by [out_freq_ion](#out_freq_ion).
20292029
- **Default**: 0 3
20302030

20312031
### out_spillage

source/source_esolver/esolver_fp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void ESolver_FP::after_scf(UnitCell& ucell, const int istep, const bool conv_eso
162162
// 3) update delta_rho for charge extrapolation
163163
CE.update_delta_rho(ucell, &(this->chr), &(this->sf));
164164

165-
if (istep % PARAM.inp.out_interval == 0)
165+
if (istep % PARAM.inp.out_freq_ion == 0)
166166
{
167167
// 4) write charge density
168168
if (PARAM.inp.out_chg[0] > 0)

source/source_esolver/esolver_ks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ void ESolver_KS<T, Device>::after_scf(UnitCell& ucell, const int istep, const bo
557557
ESolver_FP::after_scf(ucell, istep, conv_esolver);
558558

559559
// 3) write eigenvalues
560-
if (istep % PARAM.inp.out_interval == 0)
560+
if (istep % PARAM.inp.out_freq_ion == 0)
561561
{
562562
// elecstate::print_eigenvalue(this->pelec->ekb,this->pelec->wg,this->pelec->klist,GlobalV::ofs_running);
563563
}

source/source_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::after_scf(UnitCell& ucell, const int ist
524524
std::cout << " Potential (Ry): " << std::setprecision(15) << this->pelec->f_en.etot <<std::endl;
525525

526526
// (4) output file for restart
527-
if(istep % PARAM.inp.out_interval == 0)
527+
if(istep % PARAM.inp.out_freq_ion == 0)
528528
{
529529
td_p->out_restart_info(istep, elecstate::H_TDDFT_pw::At, elecstate::H_TDDFT_pw::At_laststep);
530530
}

source/source_esolver/esolver_ks_pw.cpp

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -643,25 +643,37 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
643643

644644
//----------------------------------------------------------
645645
// 3) Print out electronic wavefunctions in pw basis
646+
// we only print information every few ionic steps
646647
//----------------------------------------------------------
647-
if (iter % PARAM.inp.out_freq_elec == 0 || iter == PARAM.inp.scf_nmax || conv_esolver)
648-
{
649-
ModuleIO::write_wfc_pw(GlobalV::KPAR,
650-
GlobalV::MY_POOL,
651-
GlobalV::MY_RANK,
652-
PARAM.inp.nbands,
653-
PARAM.inp.nspin,
654-
PARAM.globalv.npol,
655-
GlobalV::RANK_IN_POOL,
656-
GlobalV::NPROC_IN_POOL,
657-
PARAM.inp.out_wfc_pw,
658-
PARAM.inp.ecutwfc,
659-
PARAM.globalv.global_out_dir,
660-
this->psi[0],
661-
this->kv,
662-
this->pw_wfc,
663-
GlobalV::ofs_running);
664-
}
648+
if (istep % PARAM.inp.out_freq_ion == 0)
649+
{
650+
if (iter % PARAM.inp.out_freq_elec == 0 || iter == PARAM.inp.scf_nmax || conv_esolver)
651+
{
652+
// if iter_in = -1, iter will not appera in file name
653+
int iter_in = -1;
654+
if(iter % PARAM.inp.out_freq_elec == 0)
655+
{
656+
iter_in = iter;
657+
}
658+
659+
ModuleIO::write_wfc_pw(istep, iter_in,
660+
GlobalV::KPAR,
661+
GlobalV::MY_POOL,
662+
GlobalV::MY_RANK,
663+
PARAM.inp.nbands,
664+
PARAM.inp.nspin,
665+
PARAM.globalv.npol,
666+
GlobalV::RANK_IN_POOL,
667+
GlobalV::NPROC_IN_POOL,
668+
PARAM.inp.out_wfc_pw,
669+
PARAM.inp.ecutwfc,
670+
PARAM.globalv.global_out_dir,
671+
this->psi[0],
672+
this->kv,
673+
this->pw_wfc,
674+
GlobalV::ofs_running);
675+
}
676+
}
665677

666678
//----------------------------------------------------------
667679
// 4) check if oscillate for delta_spin method
@@ -748,23 +760,6 @@ void ESolver_KS_PW<T, Device>::after_scf(UnitCell& ucell, const int istep, const
748760
&this->chr);
749761
}
750762

751-
// tmp 2025-05-17, mohan note
752-
ModuleIO::write_wfc_pw(GlobalV::KPAR,
753-
GlobalV::MY_POOL,
754-
GlobalV::MY_RANK,
755-
PARAM.inp.nbands,
756-
PARAM.inp.nspin,
757-
PARAM.globalv.npol,
758-
GlobalV::RANK_IN_POOL,
759-
GlobalV::NPROC_IN_POOL,
760-
PARAM.inp.out_wfc_pw,
761-
PARAM.inp.ecutwfc,
762-
PARAM.globalv.global_out_dir,
763-
this->psi[0],
764-
this->kv,
765-
this->pw_wfc,
766-
GlobalV::ofs_running);
767-
768763
//------------------------------------------------------------------
769764
//! 5) calculate Wannier functions in pw basis
770765
//------------------------------------------------------------------

source/source_esolver/lcao_after_scf.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep, const
2626
ModuleBase::WARNING_QUIT("ModuleIO::ctrl_output_lcao","pelec does not exist");
2727
}
2828

29-
if(istep % PARAM.inp.out_interval == 0)
29+
if(istep % PARAM.inp.out_freq_ion == 0)
3030
{
31-
3231
ModuleIO::ctrl_output_lcao<TK, TR>(ucell,
3332
this->kv,
3433
estate,

source/source_io/filename.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ std::string filename_output(
1616
const int out_type,
1717
const bool out_app_flag,
1818
const bool gamma_only,
19-
const int istep)
19+
const int istep,
20+
const int iter)
2021
{
2122
// output filename = "{PARAM.globalv.global_out_dir}/property{s}{spin index}
2223
// {k(optional)}{k-point index}{g(optional)}{geometry index1}{_basis(nao|pw)}
@@ -44,9 +45,10 @@ std::string filename_output(
4445
// ik0 is the k-point index, starting from 0
4546
int ik0 = ik2iktot[ik_local];
4647

48+
// spin part
49+
std::string spin_block;
4750
if(nspin == 1)
4851
{
49-
is0 = 1;
5052
}
5153
else if(nspin == 2)
5254
{
@@ -60,15 +62,14 @@ std::string filename_output(
6062
{
6163
is0 = 1;
6264
}
65+
spin_block = "s" + std::to_string(is0);
6366
}
6467
else if(nspin==4)
6568
{
66-
is0 = 12;
69+
is0 = 4;
70+
spin_block = "s" + std::to_string(is0);
6771
}
6872

69-
// spin part
70-
std::string spin_block;
71-
spin_block = "s" + std::to_string(is0);
7273

7374
// k-point part
7475
std::string kpoint_block;
@@ -83,7 +84,12 @@ std::string filename_output(
8384

8485
std::string istep_block
8586
= (istep >= 0 && (!out_app_flag))
86-
? "g" + std::to_string(istep + 1)
87+
? "g" + std::to_string(istep + 1) // istep starts from 0
88+
: ""; // only when istep >= 0 and out_app_flag is false will write each wfc to a separate file
89+
90+
std::string iter_block
91+
= (iter >= 0 && (!out_app_flag))
92+
? "e" + std::to_string(iter) // iter starts from 1
8793
: ""; // only when istep >= 0 and out_app_flag is false will write each wfc to a separate file
8894

8995
std::string suffix_block;
@@ -102,8 +108,8 @@ std::string filename_output(
102108
}
103109

104110
std::string fn_out
105-
= directory + property + spin_block + kpoint_block
106-
+ istep_block + "_" + basis + suffix_block;
111+
= directory + property + kpoint_block + spin_block
112+
+ istep_block + iter_block + "_" + basis + suffix_block;
107113

108114
return fn_out;
109115
}

source/source_io/filename.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace ModuleIO
1919
* @param out_app_flag: whether to append to existing file.
2020
* @param gamma_only: gamma_only algorithm or not.
2121
* @param istep: index of the ion step starting from 0. If < 0, the step number is not included in the file name.
22+
* @param iter: index of the electronic step starting from 0. If < 0, the step number is not included in the file name.
2223
* @return The generated filename.
2324
*/
2425
std::string filename_output(
@@ -32,7 +33,8 @@ std::string filename_output(
3233
const int out_type,
3334
const bool out_app_flag,
3435
const bool gamma_only,
35-
const int istep=-1);
36+
const int istep=-1,
37+
const int iter=-1);
3638

3739
}
3840
#endif

source/source_io/get_wf_lcao.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,10 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
203203
}
204204
}
205205

206-
ModuleIO::write_wfc_pw(GlobalV::KPAR,
206+
207+
const int iter = -1; // -1 means electronic iteration number will not appear in file name
208+
const int istep = -1; // -1 means ionic iteration number will not appear in file name
209+
ModuleIO::write_wfc_pw(istep, iter, GlobalV::KPAR,
207210
GlobalV::MY_POOL,
208211
GlobalV::MY_RANK,
209212
nbands,
@@ -366,7 +369,9 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
366369
}
367370
}
368371

369-
ModuleIO::write_wfc_pw(GlobalV::KPAR,
372+
const int iter = -1; // -1 means electronic iteration number will not appear in file name
373+
const int istep = -1; // -1 means ionic iteration number will not appear in file name
374+
ModuleIO::write_wfc_pw(istep, iter, GlobalV::KPAR,
370375
GlobalV::MY_POOL,
371376
GlobalV::MY_RANK,
372377
nbands,

source/source_io/module_parameter/input_parameter.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,8 @@ struct Input_para
361361
= {}; ///< the number of basis functions for each atom type used in FHI-aims (for benchmark)
362362
// ============== #Parameters (11.Output) ===========================
363363
bool out_stru = false; ///< outut stru file each ion step
364-
int out_freq_elec = 0; ///< the frequency of electronic iter to output charge and wavefunction
365-
int out_freq_ion = 0; ///< the frequency ( >= 0 ) of ionic step to output charge density;
366-
///< 0: output only when ion steps are finished
364+
int out_freq_elec = -1; ///< print information every few electronic steps
365+
int out_freq_ion = -1; ///< print information every few ionic steps
367366
std::vector<int> out_chg = {0, 3}; ///< output charge density. 0: no; 1: yes
368367
std::vector<int> out_xc_r = {-1, 3}; ///< output xc(r). -1: no; >=0: output the order of xc(r)
369368
int out_pot = 0; ///< yes or no
@@ -388,7 +387,6 @@ struct Input_para
388387
///< KS-orbital representation.
389388
bool out_mat_xc2 = false; ///< output exchange-correlation matrix Vxc(R) in NAO representation.
390389
bool out_eband_terms = false; ///< output the band energy terms separately
391-
int out_interval = 1;
392390
bool out_app_flag = true; ///< whether output r(R), H(R), S(R), T(R), and dH(R) matrices
393391
///< in an append manner during MD liuyu 2023-03-20
394392
int out_ndigits = 8; ///< Assuming 8 digits precision is needed for matrices output

0 commit comments

Comments
 (0)