ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
cn_solver_pw.h
Go to the documentation of this file.
1#ifndef HSOLVER_CN_SOLVER_PW_H
2#define HSOLVER_CN_SOLVER_PW_H
3
10#include "source_psi/psi.h"
11
12#include <iosfwd>
13#include <memory>
14#include <string>
15
16namespace hsolver
17{
18
26
35
36LinearMethod parse_linear_method(const std::string& name);
37PWPreconditioner parse_pw_precond(const std::string& name);
38
40template <typename T, typename Device>
42{
43 public:
46 const CNControls& cn_ctrl,
47 int npol,
48 const std::vector<int>& global_k,
49 const diag_comm_info& comm,
50 std::ostream& log);
51
57 void invalidate_basis();
65 const psi::Psi<T, Device>& previous,
66 psi::Psi<T, Device>* current,
67 const double dt,
68 const ModuleBase::Vector3<double>& momentum_shift,
69 const int istep,
70 const int iter,
71 const bool detailed_output);
72
73 private:
74 using Real = typename GetTypeReal<T>::type;
82 {
83 double dt = -1.0;
84 int step = -1;
85 int iteration = -1;
86 int ld = -1;
87 int bands = -1;
88 };
90 {
91 int ld;
92 int dim;
93 int bands;
94 };
96 {
98 int coarse_rank = 0;
99 bool projected = false;
100 bool cn_initial = false;
101 bool retried = false;
102 };
106 const int npol_;
107 const std::vector<int> global_k_;
110 std::ostream& log_;
112 std::vector<KPointState> states_;
114 std::unique_ptr<HSolverLinear<T, Device>> linear_solver_;
119
120 void initialize();
121 bool tracks_state() const;
122 void prepare_sequence(int nk, int ld, int bands, double dt, int step, int iteration);
123 bool require_audit(int step, KPointState* state) const;
125 const T* previous,
126 T* current,
127 const BatchLayout& batch,
128 int step,
129 int iteration,
130 KPointState* state);
131 void retry_kinetic(const LinearOperator<T, Device>& op, T* current, const BatchLayout& batch, LinearSolveResult* result);
132 void update_state(KPointState* state, const SolveDetails& details, int step, const BatchLayout& batch, const T* current);
133 void report_solve(const SolveDetails& details, int ik, int step, int iteration) const;
134 void prepare_buffers(const int nbands, const int nbasis);
135 void update_precond(const int ik, const int dim, const T coefficient, const ModuleBase::Vector3<double>& momentum_shift);
136};
137
138} // namespace hsolver
139#endif
3 elements vector
Definition vector3.h:21
Special pw_basis class. It includes different k-points.
Definition pw_basis_k.h:56
A multi-dimensional array of elements of a single data type.
Definition tensor.h:32
void update_state(KPointState *state, const SolveDetails &details, int step, const BatchLayout &batch, const T *current)
Definition cn_solver_pw.cpp:281
const std::vector< int > global_k_
Definition cn_solver_pw.h:107
void prepare_buffers(const int nbands, const int nbasis)
Definition cn_solver_pw.cpp:157
bool tracks_state() const
Definition cn_solver_pw.cpp:209
ct::Tensor rhs_
Definition cn_solver_pw.h:115
void invalidate_basis()
Invalidate basis-dependent history and restart independent residual checks without releasing buffers....
Definition cn_solver_pw.cpp:236
std::unique_ptr< HSolverLinear< T, Device > > linear_solver_
Definition cn_solver_pw.h:114
ct::Tensor response_workspace_
Definition cn_solver_pw.h:117
void update_precond(const int ik, const int dim, const T coefficient, const ModuleBase::Vector3< double > &momentum_shift)
Definition cn_solver_pw.cpp:173
std::ostream & log_
Definition cn_solver_pw.h:110
ct::Tensor inverse_kinetic_
Definition cn_solver_pw.h:116
ct::Tensor correction_workspace_
Definition cn_solver_pw.h:118
void solve(HSOperator< T, Device > &op, const psi::Psi< T, Device > &previous, psi::Psi< T, Device > *current, const double dt, const ModuleBase::Vector3< double > &momentum_shift, const int istep, const int iter, const bool detailed_output)
Propagate from the fixed previous step, retaining the current iterate as the initial guess.
Definition cn_solver_pw.cpp:380
const ModulePW::PW_Basis_K & basis_
Definition cn_solver_pw.h:103
CNControls cn_ctrl_
Definition cn_solver_pw.h:105
const diag_comm_info comm_
Definition cn_solver_pw.h:104
void prepare_sequence(int nk, int ld, int bands, double dt, int step, int iteration)
Definition cn_solver_pw.cpp:215
LinearAlgebra< T, Device > algebra_
Definition cn_solver_pw.h:109
std::vector< KPointState > states_
Definition cn_solver_pw.h:112
ct::Tensor clean_
Definition cn_solver_pw.h:108
void report_solve(const SolveDetails &details, int ik, int step, int iteration) const
Definition cn_solver_pw.cpp:364
void initialize()
Definition cn_solver_pw.cpp:111
bool require_audit(int step, KPointState *state) const
Definition cn_solver_pw.cpp:247
SequenceState sequence_
Definition cn_solver_pw.h:113
typename GetTypeReal< T >::type Real
Definition cn_solver_pw.h:74
void retry_kinetic(const LinearOperator< T, Device > &op, T *current, const BatchLayout &batch, LinearSolveResult *result)
Definition cn_solver_pw.cpp:260
SolveDetails solve_kpoint(const LinearOperator< T, Device > &op, const T *previous, T *current, const BatchLayout &batch, int step, int iteration, KPointState *state)
Definition cn_solver_pw.cpp:310
CNSubspace< T, Device > projection_
Definition cn_solver_pw.h:111
const int npol_
Definition cn_solver_pw.h:106
CNSolverPW(const ModulePW::PW_Basis_K &basis, const CNControls &cn_ctrl, int npol, const std::vector< int > &global_k, const diag_comm_info &comm, std::ostream &log)
Configure propagation with explicit numerical controls and orbital layout.
Definition cn_solver_pw.cpp:99
CN projection derived from A*U = 2*U - B without another Hamiltonian application.
Definition cn_subspace.h:10
What an iterative eigensolver needs from the generalized eigenproblem H x = e S x: the ability to app...
Definition hs_operator.h:24
Collective block algebra; only small coefficients cross the device boundary.
Definition linear_algebra.h:53
Device-resident block operator for independent right-hand sides.
Definition linear_operator.h:31
A bounded, paired-orthogonalized response history for one k point.
Definition linear_low_rank.h:11
Definition psi.h:37
#define T
Definition exp.cpp:237
Definition dense_eigensolver.cpp:23
PWPreconditioner
Definition cn_solver_pw.h:20
@ kinetic
Definition cn_solver_pw.h:22
@ kinetic_recycle
Definition cn_solver_pw.h:23
@ kinetic_subspace
Definition cn_solver_pw.h:24
LinearMethod
Definition linear_solver_types.h:34
PWPreconditioner parse_pw_precond(const std::string &name)
Definition cn_solver_pw.cpp:84
@ none
Definition orthonormal.h:14
LinearMethod parse_linear_method(const std::string &name)
Definition cn_solver_pw.cpp:70
T type
Definition macros.h:8
Crank-Nicolson linear solve and preconditioner controls.
Definition cn_solver_pw.h:29
bool kinetic_enabled
Definition cn_solver_pw.h:33
PWPreconditioner preconditioner
Definition cn_solver_pw.h:31
LinearControls linear
Definition cn_solver_pw.h:30
bool cn_init
Definition cn_solver_pw.h:32
Definition cn_solver_pw.h:90
int ld
Definition cn_solver_pw.h:91
int dim
Definition cn_solver_pw.h:92
int bands
Definition cn_solver_pw.h:93
Definition cn_solver_pw.h:76
LinearResponse< T, Device > response
Definition cn_solver_pw.h:77
unsigned int solve_count
Definition cn_solver_pw.h:78
int independent_step
Definition cn_solver_pw.h:79
Definition cn_solver_pw.h:82
int iteration
Definition cn_solver_pw.h:85
int step
Definition cn_solver_pw.h:84
double dt
Definition cn_solver_pw.h:83
int ld
Definition cn_solver_pw.h:86
int bands
Definition cn_solver_pw.h:87
Definition cn_solver_pw.h:96
int coarse_rank
Definition cn_solver_pw.h:98
bool retried
Definition cn_solver_pw.h:101
bool projected
Definition cn_solver_pw.h:99
LinearSolveResult linear
Definition cn_solver_pw.h:97
bool cn_initial
Definition cn_solver_pw.h:100
Numerical policy; tolerance zero selects the precision-aware default.
Definition linear_solver_types.h:42
Convergence result, operator work, and independent or reconstructed residual provenance.
Definition linear_solver_types.h:20
Definition diag_comm_info.h:12