Skip to content

Commit d8c10d8

Browse files
committed
Refactor in a more elegant way
1 parent 9ae2066 commit d8c10d8

5 files changed

Lines changed: 37 additions & 13 deletions

File tree

docs/advanced/input_files/input-main.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
- [cell\_factor](#cell_factor)
136136
- [Output Variables](#variables-related-to-output-information)
137137
- [out\_freq\_ion](#out_freq_ion)
138+
- [out\_freq\_td](#out_freq_td)
138139
- [out\_freq\_elec](#out_freq_elec)
139140
- [out\_chg](#out_chg)
140141
- [out\_pot](#out_pot)
@@ -535,7 +536,7 @@ These variables are used to control general system parameters.
535536
- ofdft: orbital-free density functional theory
536537
- tdofdft: time-dependent orbital-free density functional theory
537538
- sdft: [stochastic density functional theory](#electronic-structure-sdft)
538-
- tddft: real-time time-dependent density functional theory (TDDFT)
539+
- tddft: real-time time-dependent density functional theory (RT-TDDFT)
539540
- lj: Leonard Jones potential
540541
- dp: DeeP potential, see details in [md.md](../md.md#dpmd)
541542
- nep: Neuroevolution Potential, see details in [md.md](../md.md#nep)
@@ -1688,15 +1689,22 @@ These variables are used to control the output of properties.
16881689
### out_freq_ion
16891690

16901691
- **Type**: Integer
1691-
- **Description**: Control the interval to print information every few ion steps. These properties cover charge density, local potential, electrostatic potential, Hamiltonian matrix, overlap matrix, density matrix, Mulliken population analysis and so on.
1692+
- **Description**: Controls the output interval in **ionic steps**. When set to a positive integer $N$, information such as charge density, local potential, electrostatic potential, Hamiltonian matrix, overlap matrix, density matrix, and Mulliken population analysis is printed every $N$ ionic steps.
16921693
- **Default**: 0
1693-
- **Note**: The integer indicates to print information every 'out_freq_ion' ion steps.
1694+
- **Note**: In RT-TDDFT calculations, this parameter is inactive; output frequency is instead controlled by [`out_freq_td`](#out_freq_td)—see its description for details.
1695+
1696+
### out_freq_td
1697+
1698+
- **Type**: Integer
1699+
- **Description**: Controls the output interval in **completed electronic evolution steps** during RT-TDDFT calculations. When set to a positive integer $N$, detailed information (see [`out_freq_ion`](#out_freq_ion)) is printed every $N$ electron time-evolution steps (i.e., every $N$ `STEP OF ELECTRON EVOLVE`). For example, if you wish to output information once per ionic step, you should set `out_freq_td` equal to [`estep_per_md`](#estep_per_md), since one ionic step corresponds to [`estep_per_md`](#estep_per_md) electronic evolution steps.
1700+
- **Default**: 0
1701+
- **Note**: This parameter is **only active in RT-TDDFT mode** (`esolver_type = tddft`). It has no effect in ground-state calculations.
16941702

16951703
### out_freq_elec
16961704

16971705
- **Type**: Integer
1698-
- **Description**: Output the charge density (only binary format, controlled by [out_chg](#out_chg)), wavefunction (controlled by [out_wfc_pw](#out_wfc_pw)) per `out_freq_elec` electronic iterations. Note that they are always output when converged or reach the maximum iterations [scf_nmax](#scf_nmax).
1699-
- **Default**: [scf_nmax](#scf_nmax)
1706+
- **Description**: Output the charge density (only binary format, controlled by [`out_chg`](#out_chg)), wavefunction (controlled by [`out_wfc_pw`](#out_wfc_pw)) per `out_freq_elec` electronic iterations. Note that they are always output when converged or reach the maximum iterations [`scf_nmax`](#scf_nmax).
1707+
- **Default**: [`scf_nmax`](#scf_nmax)
17001708

17011709
### out_chg
17021710

source/source_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::runner(UnitCell& ucell, const int istep)
107107
{
108108
estep_max = PARAM.inp.estep_per_md + 1;
109109
}
110-
// reset laststep matrix and wfc, if any atom cross the boundary
110+
111+
// Reset laststep matrix and wfc, if any atom cross the boundary
112+
// Apply a phase correction to H, S, and psi to keep consistency when atoms cross periodic boundaries
111113
const size_t len_hs_ik = use_tensor && use_lapack ? PARAM.globalv.nlocal * PARAM.globalv.nlocal : this->pv.nloc;
112114
module_rt::reset_matrix_boundary(ucell,
113115
this->kv,
@@ -116,6 +118,7 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::runner(UnitCell& ucell, const int istep)
116118
this->Sk_laststep,
117119
this->psi_laststep,
118120
len_hs_ik);
121+
119122
for (int estep = 0; estep < estep_max; estep++)
120123
{
121124
// calculate total time step

source/source_io/module_parameter/input_parameter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ struct Input_para
367367
bool out_stru = false; ///< outut stru file each ion step
368368
int out_freq_elec = 0; ///< print information every few electronic steps
369369
int out_freq_ion = 0; ///< print information every few ionic steps
370+
int out_freq_td = 0; ///< print information every few completed electronic iterations in RT-TDDFT
370371
std::vector<int> out_chg = {0, 3}; ///< output charge density. 0: no; 1: yes
371372
std::vector<int> out_xc_r = {-1, 3}; ///< output xc(r). -1: no; >=0: output the order of xc(r)
372373
int out_pot = 0; ///< yes or no

source/source_io/read_input_item_output.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,24 @@ void ReadInput::item_output()
345345
Input_Item item("out_freq_ion");
346346
item.annotation = "print information every few ionic steps";
347347
item.reset_value = [](const Input_Item& item, Parameter& para) {
348-
if (para.input.out_freq_ion <= 0)
349-
{
350-
para.input.out_freq_ion = 0; // 0 means no output of info
351-
}
352-
};
353-
read_sync_int(input.out_freq_ion);
348+
if (para.input.out_freq_ion <= 0)
349+
{
350+
para.input.out_freq_ion = 0; // 0 means no output of info
351+
}
352+
};
353+
read_sync_int(input.out_freq_ion);
354+
this->add_item(item);
355+
}
356+
{
357+
Input_Item item("out_freq_td");
358+
item.annotation = "print information every few completed electronic iterations in RT-TDDFT";
359+
item.reset_value = [](const Input_Item& item, Parameter& para) {
360+
if (para.input.out_freq_td <= 0)
361+
{
362+
para.input.out_freq_td = 0; // 0 means no output of info
363+
}
364+
};
365+
read_sync_int(input.out_freq_td);
354366
this->add_item(item);
355367
}
356368
{

source/source_io/test/read_input_ptest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ TEST_F(InputParaTest, ParaRead)
182182
EXPECT_EQ(param.inp.chg_extrap, "atomic");
183183
EXPECT_EQ(param.inp.out_freq_elec, 50);
184184
EXPECT_EQ(param.inp.out_freq_ion, 0);
185+
EXPECT_EQ(param.inp.out_freq_td, 0);
185186
EXPECT_EQ(param.inp.out_chg[0], 0);
186187
EXPECT_EQ(param.inp.out_chg[1], 3);
187188
EXPECT_EQ(param.inp.out_elf[0], 0);
@@ -207,7 +208,6 @@ TEST_F(InputParaTest, ParaRead)
207208
EXPECT_FALSE(param.inp.out_mat_xc);
208209
EXPECT_FALSE(param.inp.out_mat_xc2);
209210
EXPECT_FALSE(param.inp.out_eband_terms);
210-
EXPECT_EQ(param.inp.out_freq_ion, 0);
211211
EXPECT_EQ(param.inp.out_app_flag, 0);
212212
EXPECT_EQ(param.inp.out_mat_r, 0);
213213
EXPECT_FALSE(param.inp.out_wfc_lcao);

0 commit comments

Comments
 (0)