Skip to content

Commit b0a4fd8

Browse files
committed
fix bugs, default value of out_freq_ion is 0, if one needs out_freq_elec, he/she should first turn on out_freq_ion
1 parent ff12693 commit b0a4fd8

File tree

8 files changed

+213
-191
lines changed

8 files changed

+213
-191
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@
132132
- [fixed\_atoms](#fixed_atoms)
133133
- [cell\_factor](#cell_factor)
134134
- [Output Variables](#variables-related-to-output-information)
135+
- [out\_freq\_ion](#out_freq_ion)
135136
- [out\_freq\_elec](#out_freq_elec)
136137
- [out\_chg](#out_chg)
137-
- [out\_xc\_r](#out_xc_r)
138138
- [out\_pot](#out_pot)
139139
- [out\_dm](#out_dmk)
140140
- [out\_dm1](#out_dmr)
@@ -158,12 +158,12 @@
158158
- [out\_mat\_xc](#out_mat_xc)
159159
- [out\_mat\_xc2](#out_mat_xc2)
160160
- [out\_mat\_l](#out_mat_l)
161+
- [out\_xc\_r](#out_xc_r)
161162
- [out\_eband\_terms](#out_eband_terms)
162163
- [dm\_to\_rho](#dm_to_rho)
163164
- [out\_mul](#out_mul)
164165
- [out\_app\_flag](#out_app_flag)
165166
- [out\_ndigits](#out_ndigits)
166-
- [out\_freq\_ion](#out_freq_ion)
167167
- [out\_element\_info](#out_element_info)
168168
- [restart\_save](#restart_save)
169169
- [rpa](#rpa)
@@ -1626,6 +1626,12 @@ These variables are used to control the geometry relaxation.
16261626

16271627
These variables are used to control the output of properties.
16281628

1629+
### out_freq_ion
1630+
1631+
- **Type**: Integer
1632+
- **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.
1633+
- **Default**: 1
1634+
16291635
### out_freq_elec
16301636

16311637
- **Type**: Integer
@@ -1659,25 +1665,6 @@ These variables are used to control the output of properties.
16591665
- **Default**: 0 3
16601666
- **Note**: In the 3.10-LTS version, the file names are SPIN1_CHG.cube and SPIN1_CHG_INI.cube, etc.
16611667

1662-
### out_xc_r
1663-
1664-
- **Type**: Integer \[Integer\](optional)
1665-
- **Description**:
1666-
The first integer controls whether to output the exchange-correlation (in Bohr^-3) on real space grids using Libxc to folder `OUT.${suffix}`:
1667-
- 0: rho, amag, sigma, exc
1668-
- 1: vrho, vsigma
1669-
- 2: v2rho2, v2rhosigma, v2sigma2
1670-
- 3: v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3
1671-
- 4: v4rho4, v4rho3sigma, v4rho2sigma2, v4rhosigma3, v4sigma4
1672-
The meaning of the files is presented in [Libxc](https://libxc.gitlab.io/manual/libxc-5.1.x/)
1673-
1674-
The second integer controls the precision of the charge density output, if not given, will use `3` as default.
1675-
1676-
---
1677-
The circle order of the charge density on real space grids is: x is the outer loop, then y and finally z (z is moving fastest).
1678-
1679-
- **Default**: -1 3
1680-
16811668
### out_pot
16821669

16831670
- **Type**: Integer
@@ -1918,6 +1905,25 @@ These variables are used to control the output of properties.
19181905
- **Description**: Whether to print the expectation value of the angular momentum operator $\hat{L}_x$, $\hat{L}_y$, and $\hat{L}_z$ in the basis of the localized atomic orbitals. The files are named `OUT.${suffix}/${suffix}_Lx.dat`, `OUT.${suffix}/${suffix}_Ly.dat`, and `OUT.${suffix}/${suffix}_Lz.dat`. The second integer controls the precision of the output.
19191906
- **Default**: False 8
19201907

1908+
### out_xc_r
1909+
1910+
- **Type**: Integer \[Integer\](optional)
1911+
- **Description**:
1912+
The first integer controls whether to output the exchange-correlation (in Bohr^-3) on real space grids using Libxc to folder `OUT.${suffix}`:
1913+
- 0: rho, amag, sigma, exc
1914+
- 1: vrho, vsigma
1915+
- 2: v2rho2, v2rhosigma, v2sigma2
1916+
- 3: v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3
1917+
- 4: v4rho4, v4rho3sigma, v4rho2sigma2, v4rhosigma3, v4sigma4
1918+
The meaning of the files is presented in [Libxc](https://libxc.gitlab.io/manual/libxc-5.1.x/)
1919+
1920+
The second integer controls the precision of the charge density output, if not given, will use `3` as default.
1921+
1922+
---
1923+
The circle order of the charge density on real space grids is: x is the outer loop, then y and finally z (z is moving fastest).
1924+
1925+
- **Default**: -1 3
1926+
19211927
### out_eband_terms
19221928

19231929
- **Type**: Boolean
@@ -1953,12 +1959,6 @@ These variables are used to control the output of properties.
19531959
- **Description**: Controls the length of decimal part of output data, such as charge density, Hamiltonian matrix, Overlap matrix and so on.
19541960
- **Default**: 8
19551961

1956-
### out_freq_ion
1957-
1958-
- **Type**: Integer
1959-
- **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.
1960-
- **Default**: 1
1961-
19621962
### out_element_info
19631963

19641964
- **Type**: Boolean

source/source_esolver/esolver_fp.cpp

Lines changed: 110 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -162,120 +162,123 @@ 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_freq_ion == 0)
166-
{
167-
// 4) write charge density
168-
if (PARAM.inp.out_chg[0] > 0)
169-
{
170-
for (int is = 0; is < PARAM.inp.nspin; is++)
171-
{
172-
this->pw_rhod->real2recip(this->chr.rho_save[is], this->chr.rhog_save[is]);
173-
std::string fn =PARAM.globalv.global_out_dir + "/chgs" + std::to_string(is + 1) + ".cube";
174-
ModuleIO::write_vdata_palgrid(Pgrid,
175-
this->chr.rho_save[is],
176-
is,
177-
PARAM.inp.nspin,
178-
istep,
179-
fn,
180-
this->pelec->eferm.get_efval(is),
181-
&(ucell),
182-
PARAM.inp.out_chg[1],
183-
1);
184-
185-
if (XC_Functional::get_ked_flag())
186-
{
187-
fn =PARAM.globalv.global_out_dir + "/taus" + std::to_string(is + 1) + ".cube";
188-
ModuleIO::write_vdata_palgrid(Pgrid,
189-
this->chr.kin_r_save[is],
190-
is,
191-
PARAM.inp.nspin,
192-
istep,
193-
fn,
194-
this->pelec->eferm.get_efval(is),
195-
&(ucell));
196-
}
197-
}
198-
}
199-
200-
// 5) write potential
201-
if (PARAM.inp.out_pot == 1 || PARAM.inp.out_pot == 3)
202-
{
203-
for (int is = 0; is < PARAM.inp.nspin; is++)
204-
{
205-
std::string fn =PARAM.globalv.global_out_dir + "/pots" + std::to_string(is + 1) + ".cube";
206-
207-
ModuleIO::write_vdata_palgrid(Pgrid,
208-
this->pelec->pot->get_effective_v(is),
209-
is,
210-
PARAM.inp.nspin,
211-
istep,
212-
fn,
213-
0.0, // efermi
214-
&(ucell),
215-
3, // precision
216-
0); // out_fermi
217-
}
218-
}
219-
else if (PARAM.inp.out_pot == 2)
220-
{
221-
std::string fn =PARAM.globalv.global_out_dir + "/pot_es.cube";
222-
ModuleIO::write_elecstat_pot(
165+
if (PARAM.inp.out_freq_ion>0) // default value of out_freq_ion is 0
166+
{
167+
if (istep % PARAM.inp.out_freq_ion == 0)
168+
{
169+
// 4) write charge density
170+
if (PARAM.inp.out_chg[0] > 0)
171+
{
172+
for (int is = 0; is < PARAM.inp.nspin; is++)
173+
{
174+
this->pw_rhod->real2recip(this->chr.rho_save[is], this->chr.rhog_save[is]);
175+
std::string fn =PARAM.globalv.global_out_dir + "/chgs" + std::to_string(is + 1) + ".cube";
176+
ModuleIO::write_vdata_palgrid(Pgrid,
177+
this->chr.rho_save[is],
178+
is,
179+
PARAM.inp.nspin,
180+
istep,
181+
fn,
182+
this->pelec->eferm.get_efval(is),
183+
&(ucell),
184+
PARAM.inp.out_chg[1],
185+
1);
186+
187+
if (XC_Functional::get_ked_flag())
188+
{
189+
fn =PARAM.globalv.global_out_dir + "/taus" + std::to_string(is + 1) + ".cube";
190+
ModuleIO::write_vdata_palgrid(Pgrid,
191+
this->chr.kin_r_save[is],
192+
is,
193+
PARAM.inp.nspin,
194+
istep,
195+
fn,
196+
this->pelec->eferm.get_efval(is),
197+
&(ucell));
198+
}
199+
}
200+
}
201+
202+
// 5) write potential
203+
if (PARAM.inp.out_pot == 1 || PARAM.inp.out_pot == 3)
204+
{
205+
for (int is = 0; is < PARAM.inp.nspin; is++)
206+
{
207+
std::string fn =PARAM.globalv.global_out_dir + "/pots" + std::to_string(is + 1) + ".cube";
208+
209+
ModuleIO::write_vdata_palgrid(Pgrid,
210+
this->pelec->pot->get_effective_v(is),
211+
is,
212+
PARAM.inp.nspin,
213+
istep,
214+
fn,
215+
0.0, // efermi
216+
&(ucell),
217+
3, // precision
218+
0); // out_fermi
219+
}
220+
}
221+
else if (PARAM.inp.out_pot == 2)
222+
{
223+
std::string fn =PARAM.globalv.global_out_dir + "/pot_es.cube";
224+
ModuleIO::write_elecstat_pot(
223225
#ifdef __MPI
224-
this->pw_big->bz,
225-
this->pw_big->nbz,
226+
this->pw_big->bz,
227+
this->pw_big->nbz,
226228
#endif
227-
fn,
228-
istep,
229-
this->pw_rhod,
230-
&this->chr,
231-
&(ucell),
232-
this->pelec->pot->get_fixed_v(),
233-
this->solvent);
234-
}
235-
236-
// 6) write ELF
237-
if (PARAM.inp.out_elf[0] > 0)
238-
{
239-
this->chr.cal_elf = true;
240-
Symmetry_rho srho;
241-
for (int is = 0; is < PARAM.inp.nspin; is++)
242-
{
243-
srho.begin(is, this->chr, this->pw_rhod, ucell.symm);
244-
}
245-
246-
std::string out_dir =PARAM.globalv.global_out_dir;
247-
ModuleIO::write_elf(
229+
fn,
230+
istep,
231+
this->pw_rhod,
232+
&this->chr,
233+
&(ucell),
234+
this->pelec->pot->get_fixed_v(),
235+
this->solvent);
236+
}
237+
238+
// 6) write ELF
239+
if (PARAM.inp.out_elf[0] > 0)
240+
{
241+
this->chr.cal_elf = true;
242+
Symmetry_rho srho;
243+
for (int is = 0; is < PARAM.inp.nspin; is++)
244+
{
245+
srho.begin(is, this->chr, this->pw_rhod, ucell.symm);
246+
}
247+
248+
std::string out_dir =PARAM.globalv.global_out_dir;
249+
ModuleIO::write_elf(
248250
#ifdef __MPI
249-
this->pw_big->bz,
250-
this->pw_big->nbz,
251+
this->pw_big->bz,
252+
this->pw_big->nbz,
251253
#endif
252-
out_dir,
253-
istep,
254-
PARAM.inp.nspin,
255-
this->chr.rho,
256-
this->chr.kin_r,
257-
this->pw_rhod,
258-
this->Pgrid,
259-
&(ucell),
260-
PARAM.inp.out_elf[1]);
261-
}
254+
out_dir,
255+
istep,
256+
PARAM.inp.nspin,
257+
this->chr.rho,
258+
this->chr.kin_r,
259+
this->pw_rhod,
260+
this->Pgrid,
261+
&(ucell),
262+
PARAM.inp.out_elf[1]);
263+
}
262264

263265
#ifdef USE_LIBXC
264-
// 7) write xc(r)
265-
if(PARAM.inp.out_xc_r[0]>=0)
266-
{
267-
ModuleIO::write_libxc_r(
268-
PARAM.inp.out_xc_r[0],
269-
XC_Functional::get_func_id(),
270-
this->pw_rhod->nrxx, // number of real-space grid
271-
ucell.omega, // volume of cell
272-
ucell.tpiba,
273-
this->chr,
274-
*this->pw_big,
275-
*this->pw_rhod);
276-
}
266+
// 7) write xc(r)
267+
if(PARAM.inp.out_xc_r[0]>=0)
268+
{
269+
ModuleIO::write_libxc_r(
270+
PARAM.inp.out_xc_r[0],
271+
XC_Functional::get_func_id(),
272+
this->pw_rhod->nrxx, // number of real-space grid
273+
ucell.omega, // volume of cell
274+
ucell.tpiba,
275+
this->chr,
276+
*this->pw_big,
277+
*this->pw_rhod);
278+
}
277279
#endif
278-
}
280+
}
281+
} // end if PARAM.inp.out_freq_ion > 0
279282
}
280283

281284
void ESolver_FP::before_scf(UnitCell& ucell, const int istep)

source/source_esolver/esolver_ks.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,10 +557,13 @@ 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_freq_ion == 0)
561-
{
562-
// elecstate::print_eigenvalue(this->pelec->ekb,this->pelec->wg,this->pelec->klist,GlobalV::ofs_running);
563-
}
560+
if (PARAM.inp.out_freq_ion>0) // default value of out_freq_ion is 0
561+
{
562+
if (istep % PARAM.inp.out_freq_ion == 0)
563+
{
564+
// elecstate::print_eigenvalue(this->pelec->ekb,this->pelec->wg,this->pelec->klist,GlobalV::ofs_running);
565+
}
566+
}
564567
}
565568

566569
template <typename T, typename Device>

source/source_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,13 @@ 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_freq_ion == 0)
528-
{
529-
td_p->out_restart_info(istep, elecstate::H_TDDFT_pw::At, elecstate::H_TDDFT_pw::At_laststep);
530-
}
527+
if (PARAM.inp.out_freq_ion>0) // default value of out_freq_ion is 0
528+
{
529+
if(istep % PARAM.inp.out_freq_ion == 0)
530+
{
531+
td_p->out_restart_info(istep, elecstate::H_TDDFT_pw::At, elecstate::H_TDDFT_pw::At_laststep);
532+
}
533+
}
531534

532535
ModuleBase::timer::tick("ESolver_LCAO_TDDFT", "after_scf");
533536
}

0 commit comments

Comments
 (0)