Skip to content

Commit e944a7d

Browse files
committed
Refactor output of td_print_eij
1 parent 79ef3ca commit e944a7d

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3720,10 +3720,11 @@ These variables are used to control berry phase and wannier90 interface paramete
37203720
### td_print_eij
37213721

37223722
- **Type**: Real
3723-
- **Description**:
3724-
- $<0$: Do not print $E_{ij}$.
3725-
- $\geqslant 0$: Print the $E_{ij}=\Braket{\psi_i|\hat{H}|\psi_j}$ elements which are larger than `td_print_eij`.
3723+
- **Description**: Controls the printing of Hamiltonian matrix elements $E_{ij}=\Braket{\psi_i|\hat{H}|\psi_j}$.
3724+
- $<0$: Suppress all $E_{ij}$ output.
3725+
- $\geqslant 0$: Print only elements with ​​either $|\text{Re}(E_{ij})|$ or $|\text{Im}(E_{ij})|$​​ exceeding `td_print_eij`.
37263726
- **Default**: -1
3727+
- **Unit**: Ry
37273728

37283729
### td_propagator
37293730

source/source_lcao/module_rt/band_energy.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,15 @@ void compute_ekb(const Parallel_Orbitals* pv,
9696
{
9797
bb = 0.0;
9898
}
99-
if (aa > 0.0 || bb > 0.0)
99+
if (std::abs(aa) > 0.0 || std::abs(bb) > 0.0)
100100
{
101-
ofs_running << i << " " << j << " " << aa << "+" << bb << "i " << std::endl;
101+
std::streamsize original_precision = ofs_running.precision();
102+
ofs_running << std::fixed << std::setprecision(8);
103+
ofs_running << "i = " << std::setw(2) << i << ", j = " << std::setw(2) << j
104+
<< ", Eij = " << std::setw(12) << aa << " + " << std::setw(12) << bb << " i"
105+
<< std::endl;
106+
ofs_running.unsetf(std::ios_base::fixed);
107+
ofs_running.precision(original_precision);
102108
}
103109
}
104110
}
@@ -233,9 +239,15 @@ void compute_ekb_tensor(const Parallel_Orbitals* pv,
233239
{
234240
bb = 0.0;
235241
}
236-
if (aa > 0.0 || bb > 0.0)
242+
if (std::abs(aa) > 0.0 || std::abs(bb) > 0.0)
237243
{
238-
ofs_running << i << " " << j << " " << aa << "+" << bb << "i " << std::endl;
244+
std::streamsize original_precision = ofs_running.precision();
245+
ofs_running << std::fixed << std::setprecision(8);
246+
ofs_running << "i = " << std::setw(2) << i << ", j = " << std::setw(2) << j
247+
<< ", Eij = " << std::setw(12) << aa << " + " << std::setw(12) << bb << " i"
248+
<< std::endl;
249+
ofs_running.unsetf(std::ios_base::fixed);
250+
ofs_running.precision(original_precision);
239251
}
240252
}
241253
}
@@ -371,9 +383,15 @@ void compute_ekb_tensor_lapack(const Parallel_Orbitals* pv,
371383
{
372384
bb = 0.0;
373385
}
374-
if (aa > 0.0 || bb > 0.0)
386+
if (std::abs(aa) > 0.0 || std::abs(bb) > 0.0)
375387
{
376-
ofs_running << i << " " << j << " " << aa << "+" << bb << "i " << std::endl;
388+
std::streamsize original_precision = ofs_running.precision();
389+
ofs_running << std::fixed << std::setprecision(8);
390+
ofs_running << "i = " << std::setw(2) << i << ", j = " << std::setw(2) << j
391+
<< ", Eij = " << std::setw(12) << aa << " + " << std::setw(12) << bb << " i"
392+
<< std::endl;
393+
ofs_running.unsetf(std::ios_base::fixed);
394+
ofs_running.precision(original_precision);
377395
}
378396
}
379397
}

0 commit comments

Comments
 (0)