Skip to content

Commit 77a064a

Browse files
authored
Merge branch 'develop' into develop
2 parents 325fddc + 860ce0f commit 77a064a

File tree

9 files changed

+236
-329
lines changed

9 files changed

+236
-329
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ If only one value is set (such as `kspacing 0.5`), then kspacing values of a/b/c
732732

733733
[back to top](#full-list-of-input-keywords)
734734

735-
## Variables related to input files
735+
## Input files
736736

737737
These variables are used to control parameters related to input files.
738738

@@ -1656,16 +1656,16 @@ These variables are used to control the geometry relaxation.
16561656

16571657
[back to top](#full-list-of-input-keywords)
16581658

1659-
## Variables related to output information
1659+
## Output information
16601660

16611661
These variables are used to control the output of properties.
16621662

16631663
### out_freq_ion
16641664

16651665
- **Type**: Integer
1666-
- **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.
1666+
- **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.
16671667
- **Default**: 0
1668-
- **Note**: If you want to use out_freq_elec, please set out_freq_ion to 1, otherwise out_freq_elec is useless
1668+
- **Note**: The integer indicates to print information every 'out_freq_ion' ion steps.
16691669

16701670
### out_freq_elec
16711671

@@ -1679,11 +1679,11 @@ These variables are used to control the output of properties.
16791679
- **Description**:
16801680
The first integer controls whether to output the charge density on real space grids:
16811681
- 1: Output the charge density (in Bohr^-3) on real space grids into the density files in the folder `OUT.${suffix}`. The files are named as:
1682-
- nspin = 1: `chgs1.cube`;
1682+
- nspin = 1: `chg.cube`;
16831683
- nspin = 2: `chgs1.cube`, and `chgs2.cube`;
16841684
- nspin = 4: `chgs1.cube`, `chgs2.cube`, `chgs3.cube`, and `chgs4.cube`;
16851685
Note that by using the Meta-GGA functional, additional files containing the kinetic energy density will be output with the following names:
1686-
- nspin = 1: `taus1.cube`;
1686+
- nspin = 1: `tau.cube`;
16871687
- nspin = 2: `taus1.cube`, and `taus2.cube`;
16881688
- nspin = 4: `taus1.cube`, `taus2.cube`, `taus3.cube`, and `taus4.cube`;
16891689
- 2: On top of 1, also output the initial charge density files with a suffix name as '_ini', such as `taus1_ini.cube`, etc.

source/Makefile.Objects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ OBJS_IO=input_conv.o\
580580
output_log.o\
581581
output_mat_sparse.o\
582582
ctrl_output_lcao.o\
583+
ctrl_output_fp.o\
583584
para_json.o\
584585
abacusjson.o\
585586
general_info.o\

source/source_esolver/esolver_fp.cpp

Lines changed: 34 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,15 @@
88
#include "source_hamilt/module_vdw/vdw.h"
99
#include "source_pw/module_pwdft/global.h"
1010
#include "source_io/cif_io.h"
11-
#include "source_io/cube_io.h"
11+
#include "source_io/cube_io.h" // use write_vdata_palgrid
1212
#include "source_io/json_output/init_info.h"
1313
#include "source_io/json_output/output_info.h"
1414
#include "source_io/output_log.h"
1515
#include "source_io/print_info.h"
1616
#include "source_io/rhog_io.h"
17-
#include "source_io/write_elecstat_pot.h"
18-
#include "source_io/write_elf.h"
1917
#include "source_io/module_parameter/parameter.h"
2018
#include "source_cell/k_vector_utils.h"
21-
22-
#ifdef USE_LIBXC
23-
#include "source_io/write_libxc_r.h"
24-
#endif
19+
#include "source_io/ctrl_output_fp.h"
2520

2621
namespace ModuleESolver
2722
{
@@ -162,169 +157,10 @@ void ESolver_FP::after_scf(UnitCell& ucell, const int istep, const bool conv_eso
162157
// 3) update delta_rho for charge extrapolation
163158
CE.update_delta_rho(ucell, &(this->chr), &(this->sf));
164159

160+
// 4) print out charge density, potential, elf, etc.
161+
ModuleIO::ctrl_output_fp(ucell, this->pelec, this->pw_big, this->pw_rhod,
162+
this->chr, this->solvent, this->Pgrid, istep);
165163

166-
// print out the 'g' index when istep_in!=-1
167-
int istep_in = -1;
168-
if (PARAM.inp.out_freq_ion>0) // default value of out_freq_ion is 0
169-
{
170-
if (istep % PARAM.inp.out_freq_ion == 0)
171-
{
172-
istep_in = istep;
173-
}
174-
}
175-
176-
std::string geom_block;
177-
if(istep_in==-1)
178-
{
179-
// do nothing
180-
}
181-
else if(istep_in>=0)
182-
{
183-
geom_block = "g" + std::to_string(istep + 1);
184-
}
185-
186-
// 4) write charge density
187-
if (PARAM.inp.out_chg[0] > 0)
188-
{
189-
for (int is = 0; is < PARAM.inp.nspin; ++is)
190-
{
191-
this->pw_rhod->real2recip(this->chr.rho_save[is], this->chr.rhog_save[is]);
192-
193-
std::string fn =PARAM.globalv.global_out_dir + "chg";
194-
195-
std::string spin_block;
196-
if(PARAM.inp.nspin == 2 || PARAM.inp.nspin == 4)
197-
{
198-
spin_block= "s" + std::to_string(is + 1);
199-
}
200-
else if(PARAM.inp.nspin == 1)
201-
{
202-
// do nothing
203-
}
204-
205-
fn += spin_block + geom_block + ".cube";
206-
207-
ModuleIO::write_vdata_palgrid(Pgrid,
208-
this->chr.rho_save[is],
209-
is,
210-
PARAM.inp.nspin,
211-
istep_in,
212-
fn,
213-
this->pelec->eferm.get_efval(is),
214-
&(ucell),
215-
PARAM.inp.out_chg[1],
216-
1);
217-
218-
if (XC_Functional::get_ked_flag())
219-
{
220-
fn = PARAM.globalv.global_out_dir + "tau";
221-
222-
fn += spin_block + geom_block + ".cube";
223-
224-
ModuleIO::write_vdata_palgrid(Pgrid,
225-
this->chr.kin_r_save[is],
226-
is,
227-
PARAM.inp.nspin,
228-
istep,
229-
fn,
230-
this->pelec->eferm.get_efval(is),
231-
&(ucell));
232-
}
233-
}
234-
}
235-
236-
// 5) write potential
237-
if (PARAM.inp.out_pot == 1 || PARAM.inp.out_pot == 3)
238-
{
239-
for (int is = 0; is < PARAM.inp.nspin; is++)
240-
{
241-
std::string fn =PARAM.globalv.global_out_dir + "pot";
242-
243-
std::string spin_block;
244-
if(PARAM.inp.nspin == 2 || PARAM.inp.nspin == 4)
245-
{
246-
spin_block= "s" + std::to_string(is + 1);
247-
}
248-
else if(PARAM.inp.nspin == 1)
249-
{
250-
// do nothing
251-
}
252-
253-
fn += spin_block + geom_block + ".cube";
254-
255-
ModuleIO::write_vdata_palgrid(Pgrid,
256-
this->pelec->pot->get_effective_v(is),
257-
is,
258-
PARAM.inp.nspin,
259-
istep_in,
260-
fn,
261-
0.0, // efermi
262-
&(ucell),
263-
3, // precision
264-
0); // out_fermi
265-
}
266-
}
267-
else if (PARAM.inp.out_pot == 2)
268-
{
269-
std::string fn =PARAM.globalv.global_out_dir + "potes";
270-
fn += geom_block + ".cube";
271-
272-
ModuleIO::write_elecstat_pot(
273-
#ifdef __MPI
274-
this->pw_big->bz,
275-
this->pw_big->nbz,
276-
#endif
277-
fn,
278-
istep,
279-
this->pw_rhod,
280-
&this->chr,
281-
&(ucell),
282-
this->pelec->pot->get_fixed_v(),
283-
this->solvent);
284-
}
285-
286-
// 6) write ELF
287-
if (PARAM.inp.out_elf[0] > 0)
288-
{
289-
this->chr.cal_elf = true;
290-
Symmetry_rho srho;
291-
for (int is = 0; is < PARAM.inp.nspin; is++)
292-
{
293-
srho.begin(is, this->chr, this->pw_rhod, ucell.symm);
294-
}
295-
296-
std::string out_dir =PARAM.globalv.global_out_dir;
297-
ModuleIO::write_elf(
298-
#ifdef __MPI
299-
this->pw_big->bz,
300-
this->pw_big->nbz,
301-
#endif
302-
out_dir,
303-
istep,
304-
PARAM.inp.nspin,
305-
this->chr.rho,
306-
this->chr.kin_r,
307-
this->pw_rhod,
308-
this->Pgrid,
309-
&(ucell),
310-
PARAM.inp.out_elf[1]);
311-
}
312-
313-
#ifdef USE_LIBXC
314-
// 7) write xc(r)
315-
if(PARAM.inp.out_xc_r[0]>=0)
316-
{
317-
ModuleIO::write_libxc_r(
318-
PARAM.inp.out_xc_r[0],
319-
XC_Functional::get_func_id(),
320-
this->pw_rhod->nrxx, // number of real-space grid
321-
ucell.omega, // volume of cell
322-
ucell.tpiba,
323-
this->chr,
324-
*this->pw_big,
325-
*this->pw_rhod);
326-
}
327-
#endif
328164
}
329165

330166
void ESolver_FP::before_scf(UnitCell& ucell, const int istep)
@@ -402,19 +238,32 @@ void ESolver_FP::before_scf(UnitCell& ucell, const int istep)
402238
//----------------------------------------------------------
403239
elecstate::cal_ux(ucell);
404240

241+
242+
405243
//----------------------------------------------------------
406244
//! output the initial charge density
407245
//----------------------------------------------------------
246+
const int nspin = PARAM.inp.nspin;
408247
if (PARAM.inp.out_chg[0] == 2)
409248
{
410-
for (int is = 0; is < PARAM.inp.nspin; is++)
249+
for (int is = 0; is < nspin; is++)
411250
{
412251
std::stringstream ss;
413-
ss << PARAM.globalv.global_out_dir << "chgs" << is + 1 << "_ini.cube";
252+
ss << PARAM.globalv.global_out_dir << "chg";
253+
254+
if(nspin==1)
255+
{
256+
ss << "ini.cube";
257+
}
258+
else if(nspin==2 || nspin==4)
259+
{
260+
ss << "s" << is + 1 << "ini.cube";
261+
}
262+
414263
ModuleIO::write_vdata_palgrid(this->Pgrid,
415264
this->chr.rho[is],
416265
is,
417-
PARAM.inp.nspin,
266+
nspin,
418267
istep,
419268
ss.str(),
420269
this->pelec->eferm.ef,
@@ -427,14 +276,24 @@ void ESolver_FP::before_scf(UnitCell& ucell, const int istep)
427276
//----------------------------------------------------------
428277
if (PARAM.inp.out_pot == 3)
429278
{
430-
for (int is = 0; is < PARAM.inp.nspin; is++)
279+
for (int is = 0; is < nspin; is++)
431280
{
432281
std::stringstream ss;
433-
ss << PARAM.globalv.global_out_dir << "pots" << is + 1 << "_ini.cube";
282+
ss << PARAM.globalv.global_out_dir << "pot";
283+
284+
if(nspin==1)
285+
{
286+
ss << "ini.cube";
287+
}
288+
else if(nspin==2 || nspin==4)
289+
{
290+
ss << "s" << is + 1 << "ini.cube";
291+
}
292+
434293
ModuleIO::write_vdata_palgrid(this->Pgrid,
435294
this->pelec->pot->get_effective_v(is),
436295
is,
437-
PARAM.inp.nspin,
296+
nspin,
438297
istep,
439298
ss.str(),
440299
0.0, // efermi

source/source_esolver/esolver_fp.h

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,13 @@
77
#include <chrono>
88
#endif
99

10-
//! plane wave basis
11-
#include "source_basis/module_pw/pw_basis.h"
12-
13-
//! symmetry analysis
14-
#include "source_cell/module_symmetry/symmetry.h"
15-
16-
//! electronic states
17-
#include "source_estate/elecstate.h"
18-
19-
//! charge extrapolation
20-
#include "source_estate/module_charge/charge_extra.h"
21-
22-
//! solvation model
23-
#include "source_hamilt/module_surchem/surchem.h"
24-
25-
//! local pseudopotential
26-
#include "source_pw/module_pwdft/VL_in_pw.h"
27-
28-
//! structure factor related to plane wave basis
29-
#include "source_pw/module_pwdft/structure_factor.h"
10+
#include "source_basis/module_pw/pw_basis.h" // plane wave basis
11+
#include "source_cell/module_symmetry/symmetry.h" // symmetry analysis
12+
#include "source_estate/elecstate.h" // electronic states
13+
#include "source_estate/module_charge/charge_extra.h" // charge extrapolation
14+
#include "source_hamilt/module_surchem/surchem.h" // solvation model
15+
#include "source_pw/module_pwdft/VL_in_pw.h" // local pseudopotential
16+
#include "source_pw/module_pwdft/structure_factor.h" // structure factor
3017

3118
#include <fstream>
3219

@@ -44,10 +31,8 @@ namespace ModuleESolver
4431
class ESolver_FP: public ESolver
4532
{
4633
public:
47-
//! Constructor
4834
ESolver_FP();
4935

50-
//! Deconstructor
5136
virtual ~ESolver_FP();
5237

5338
//! Initialize of the first-principels energy solver
@@ -56,13 +41,10 @@ class ESolver_FP: public ESolver
5641
virtual void after_all_runners(UnitCell& ucell) override;
5742

5843
protected:
59-
//! Something to do before SCF iterations.
6044
virtual void before_scf(UnitCell& ucell, const int istep);
6145

62-
//! Something to do after SCF iterations when SCF is converged or comes to the max iter step.
6346
virtual void after_scf(UnitCell& ucell, const int istep, const bool conv_esolver);
6447

65-
//! Something to do after hamilt2rho function in each iter loop.
6648
virtual void iter_finish(UnitCell& ucell, const int istep, int& iter, bool &conv_esolver);
6749

6850
//! ------------------------------------------------------------------------------

source/source_esolver/esolver_of.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
#include "source_pw/module_pwdft/global.h"
1212
#include "source_io/print_info.h"
1313
#include "source_estate/cal_ux.h"
14-
//-----force-------------------
1514
#include "source_pw/module_pwdft/forces.h"
16-
//-----stress------------------
1715
#include "source_pw/module_ofdft/of_stress_pw.h"
1816

1917
namespace ModuleESolver

0 commit comments

Comments
 (0)