ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
pot_sccs.h
Go to the documentation of this file.
1#ifndef POT_SCCS_H
2#define POT_SCCS_H
3
4#include "pot_base.h"
5#include "sccs_output.h"
6#include "sccs_fixed_src.h"
8
9#include <iosfwd>
10#include <string>
11
12struct Input_para;
13namespace elecstate
14{
15// Map INPUT values, already validated by the INPUT reader, onto the solver.
16void sccs_cfg_input(const Input_para& input,
17 ModuleSccs::SccsConfig& config,
18 ModuleSccs::PolarizationSolverParameters& solver);
19
20// Structure-dependent checks that the INPUT reader cannot make: a
21// sccs_corespread count other than one or nat stops the run. Returns a warning
22// (empty if none) when a single width meets an unknown pseudopotential
23// element, whose automatic core exclusion is then not possible.
24std::string check_sccs_cell(const ModuleSccs::SccsConfig& config, const UnitCell& cell);
25
26// Returns a warning (empty if none) for a charged cell in a dielectric: the
27// periodic Poisson solver drops the G = 0 component of the net charge, so the
28// energy depends on the cell size. electron_count is the resolved nelec (the
29// INPUT value, or the valence count when it is not set).
30std::string check_charge(const ModuleSccs::SccsConfig& config, const UnitCell& cell, double electron_count);
31
32// State carried from the component of the previous ionic step, which is
33// rebuilt every ionic step: an activation already reached, the last
34// unshifted sqrt-CG solution as a warm start, and the solvent-aware probe
35// kernel of the fixed cell and grid. The solver keeps the warm start only when
36// it lowers the initial charge residual, so moved atoms are safe.
38{
39 bool active = false;
40 std::vector<double> restart_potential;
41 bool probe_ready = false; // same on every pool rank
42 std::vector<double> probe_kernel; // local G vectors
43};
44
45class PotSccs : public PotBase
46{
47public:
48 // electron_count is the expected number of electrons (resolved nelec); a grid
49 // density that differs from it by more than 1e-6 e is reported in the
50 // warning log, and the solute charge uses the grid density.
51 // resume carries the activation and warm start of the previous ionic step.
52 PotSccs(const ModulePW::PW_Basis* basis,
53 const ModuleSccs::SccsConfig& config,
55 double electron_count,
56 const SccsResume& resume);
57 void cal_v_eff(const Charge* charge, const UnitCell* cell, ModuleBase::matrix& potential) override;
58 double get_energy() const override;
59 void add_sol_force(const UnitCell& cell, ModuleBase::matrix& force) const override;
60 void sol_energy(double& electrostatic, double& non_electrostatic) const override;
61 const std::vector<double>* sol_elec_pot() const override;
62 // eps and the cavity s of the last active evaluation, plus the local s
63 // (cavity_local) and the probe solute fraction c (filled_fraction) of a
64 // solvent-aware cavity; none before the start.
65 void add_sol_fields(std::vector<SolventGridField>& fields) const override;
66
67 // Delayed start: called once per electronic iteration while SCCS waits,
68 // with the density residual broadcast to every rank. Returns true only in
69 // the iteration that activates SCCS; activation is irreversible.
70 bool try_activate(int electronic_iteration, double density_residual);
71 bool is_active() const { return sccs_active_; }
73 bool has_output() const { return output_.valid; }
74 void write_iter(std::ostream& output, int level, double residual, double pcc_energy) const;
75
76private:
77 bool sccs_active_ = false;
80 const double electron_count_;
85 std::vector<double> electrostatic_potential_;
86 std::vector<double> restart_potential_;
87 std::vector<double> cavity_potential_;
88 std::vector<double> epsilon_;
89 std::vector<double> solute_;
90 std::vector<double> local_solute_;
91 std::vector<double> filled_fraction_;
92};
93} // namespace elecstate
94#endif
Definition charge.h:24
Definition matrix.h:15
A class which can convert a function of "r" to the corresponding linear superposition of plane waves ...
Definition pw_basis.h:60
Provide the basic information about unitcell.
Definition unitcell.h:16
PotBase()
Definition pot_base.h:26
std::vector< double > solute_
Definition pot_sccs.h:89
double non_electrostatic_rydberg_
Definition pot_sccs.h:84
std::vector< double > electrostatic_potential_
Definition pot_sccs.h:85
double electrostatic_rydberg_
Definition pot_sccs.h:83
bool is_active() const
Definition pot_sccs.h:71
std::vector< double > local_solute_
Definition pot_sccs.h:90
std::vector< double > restart_potential_
Definition pot_sccs.h:86
std::vector< double > cavity_potential_
Definition pot_sccs.h:87
bool sccs_active_
Definition pot_sccs.h:77
SccsOutput output_
Definition pot_sccs.h:81
void add_sol_fields(std::vector< SolventGridField > &fields) const override
Definition pot_sccs.cpp:363
void sol_energy(double &electrostatic, double &non_electrostatic) const override
Definition pot_sccs.cpp:352
bool has_output() const
Definition pot_sccs.h:73
void cal_v_eff(const Charge *charge, const UnitCell *cell, ModuleBase::matrix &potential) override
Definition pot_sccs.cpp:172
double get_energy() const override
Definition pot_sccs.cpp:347
const std::vector< double > * sol_elec_pot() const override
Definition pot_sccs.cpp:358
std::vector< double > filled_fraction_
Definition pot_sccs.h:91
std::vector< double > epsilon_
Definition pot_sccs.h:88
void add_sol_force(const UnitCell &cell, ModuleBase::matrix &force) const override
Definition pot_sccs.cpp:290
void write_iter(std::ostream &output, int level, double residual, double pcc_energy) const
Definition pot_sccs.cpp:331
const ModuleSccs::SccsConfig config_
Definition pot_sccs.h:78
const double electron_count_
Definition pot_sccs.h:80
PotSccs(const ModulePW::PW_Basis *basis, const ModuleSccs::SccsConfig &config, const ModuleSccs::PolarizationSolverParameters &solver, double electron_count, const SccsResume &resume)
Definition pot_sccs.cpp:130
bool try_activate(int electronic_iteration, double density_residual)
Definition pot_sccs.cpp:157
const ModuleSccs::PolarizationSolverParameters solver_
Definition pot_sccs.h:79
SccsFixedSources fixed_sources_
Definition pot_sccs.h:82
SccsResume resume_state() const
Definition pot_sccs.cpp:147
Definition sccs_fixed_src.h:21
Definition output.h:13
Definition read_atoms_hlp_test.cpp:13
std::string check_sccs_cell(const ModuleSccs::SccsConfig &config, const UnitCell &cell)
Definition pot_sccs.cpp:80
void sccs_cfg_input(const Input_para &input, ModuleSccs::SccsConfig &config, ModuleSccs::PolarizationSolverParameters &solver)
Definition pot_sccs.cpp:31
std::string check_charge(const ModuleSccs::SccsConfig &config, const UnitCell &cell, double electron_count)
Definition pot_sccs.cpp:112
Definition input_parameter.h:13
Definition sccs_parameters.h:43
Definition sccs_parameters.h:28
Definition sccs_output.h:32
Definition pot_sccs.h:38
std::vector< double > restart_potential
Definition pot_sccs.h:40
std::vector< double > probe_kernel
Definition pot_sccs.h:42
bool probe_ready
Definition pot_sccs.h:41
bool active
Definition pot_sccs.h:39
Input_para input
Definition test_io_sys_var.cpp:58