Skip to content

Commit ebc48d9

Browse files
committed
cannot run, but we have include ctrl_output_fp files
1 parent 9c7d553 commit ebc48d9

File tree

7 files changed

+184
-317
lines changed

7 files changed

+184
-317
lines changed

source/Makefile.Objects

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

source/source_esolver/esolver_fp.cpp

Lines changed: 3 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,9 @@
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,172 +157,9 @@ 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, istep);
165162

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

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

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_estate/elecstate.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ class ElecState
5151
{
5252
return;
5353
}
54-
// virtual void updateRhoK(const psi::Psi<std::complex<double>> &psi) = 0;
55-
// virtual void updateRhoK(const psi::Psi<double> &psi)=0
5654
virtual void cal_tau(const psi::Psi<std::complex<double>>& psi)
5755
{
5856
return;
@@ -77,12 +75,9 @@ class ElecState
7775
return;
7876
}
7977

80-
81-
8278
// use occupied weights from INPUT and skip calculate_weights
8379
// mohan updated on 2024-06-08
8480

85-
8681
// if nupdown is not 0(TWO_EFERMI case),
8782
// nelec_spin will be fixed and weights will be constrained
8883
void init_nelec_spin();

source/source_io/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ if(ENABLE_LCAO)
8282
cal_r_overlap_R.cpp
8383
output_mat_sparse.cpp
8484
ctrl_output_lcao.cpp
85+
ctrl_output_fp.cpp
8586
)
8687
endif()
8788

0 commit comments

Comments
 (0)