Psi4
solver.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2018 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This file is part of Psi4.
12  *
13  * Psi4 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation, version 3.
16  *
17  * Psi4 is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License along
23  * with Psi4; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * @END LICENSE
27  */
28 
29 #ifndef SOLVER_H
30 #define SOLVER_H
31 
32 #include <psi4/libmints/typedefs.h>
34 
35 #include <vector>
36 #include <string>
37 
38 namespace psi {
39 
40 class Vector;
41 class RHamiltonian;
42 class UHamiltonian;
43 
44 class Solver {
45  // => BASE CLASSES <= //
46 
47  protected:
49  int print_;
51  int debug_;
53  int bench_;
55  std::string name_;
57  size_t memory_;
58 
60  double criteria_;
62  int maxiter_;
64  bool converged_;
66  double convergence_;
70  std::string precondition_;
71 
73  void common_init();
74 
75  public:
76  // => Constructors < = //
77 
79  Solver();
81  virtual ~Solver();
82 
83  // => Knobs <= //
84 
86  void set_precondition(const std::string& precondition) { precondition_ = precondition; }
88  void set_memory(size_t memory) { memory_ = memory; }
90  void set_maxiter(int maxiter) { maxiter_ = maxiter; }
92  void set_convergence(double criteria) { criteria_ = criteria; }
94  void set_print(int print) { print_ = print; }
96  void set_debug(int debug) { debug_ = debug; }
98  void set_bench(int bench) { bench_ = bench; }
99 
100  // => Accessors <= //
101 
103  int iteration() const { return iteration_; }
105  bool converged() const { return converged_; }
110  virtual void print_header() const = 0;
112  virtual size_t memory_estimate() = 0;
113 
114  // => Computers <= //
115 
120  virtual void initialize() = 0;
125  virtual void solve() = 0;
130  virtual void finalize() = 0;
131 };
132 
133 class RSolver : public Solver {
134  protected:
136  std::shared_ptr<RHamiltonian> H_;
137 
138  public:
139  // => Constructors < = //
140 
141  RSolver(std::shared_ptr<RHamiltonian> H);
143  ~RSolver() override;
144 
145  // => Accessors <= //
146 
151  void set_Hamiltonian(std::shared_ptr<RHamiltonian> H) { H_ = H; }
152 
157  std::shared_ptr<RHamiltonian> H() const { return H_; }
158 };
159 
160 class USolver : public Solver {
161  protected:
163  std::shared_ptr<UHamiltonian> H_;
164 
165  public:
166  // => Constructors < = //
167 
169  USolver(std::shared_ptr<UHamiltonian> H);
171  ~USolver() override;
172 
173  // => Accessors <= //
174 
179  void set_Hamiltonian(std::shared_ptr<UHamiltonian> H) { H_ = H; }
180 
185  std::shared_ptr<UHamiltonian> H() const { return H_; }
186 };
187 
188 // => APPLIED CLASSES <= //
189 
190 class CGRSolver : public RSolver {
191  protected:
193  std::vector<std::shared_ptr<Vector> > b_;
195  std::vector<std::shared_ptr<Vector> > x_;
197  std::vector<std::shared_ptr<Vector> > Ap_;
199  std::vector<std::shared_ptr<Vector> > z_;
201  std::vector<std::shared_ptr<Vector> > r_;
203  std::vector<std::shared_ptr<Vector> > p_;
205  std::vector<double> alpha_;
207  std::vector<double> beta_;
209  std::vector<double> r_nrm2_;
211  std::vector<double> z_r_;
213  std::vector<bool> r_converged_;
216 
218  std::shared_ptr<Vector> diag_;
222  std::vector<std::vector<int> > A_inds_;
224  std::vector<std::vector<double> > shifts_;
226  int nguess_;
227 
228  void setup();
229  void guess();
230  void residual();
231  void products_x();
232  void products_p();
233  void alpha();
234  void update_x();
235  void update_r();
236  void check_convergence();
237  void update_z();
238  void beta();
239  void update_p();
240 
241  public:
242  CGRSolver(std::shared_ptr<RHamiltonian> H);
243  ~CGRSolver() override;
244 
246  static std::shared_ptr<CGRSolver> build_solver(Options& options, std::shared_ptr<RHamiltonian> H);
247 
248  std::vector<std::shared_ptr<Vector> >& x() { return x_; }
249  std::vector<std::shared_ptr<Vector> >& b() { return b_; }
250 
251  void print_header() const override;
252  size_t memory_estimate() override;
253  void initialize() override;
254  void solve() override;
255  void finalize() override;
256 
257  void set_shifts(const std::vector<std::vector<double> >& shifts) { shifts_ = shifts; }
258  void set_A(SharedMatrix A, const std::vector<std::vector<int> > inds) {
259  A_ = A;
260  A_inds_ = inds;
261  }
262  void set_nguess(int nguess) { nguess_ = nguess; }
263 };
264 
265 class DLRSolver : public RSolver {
266  protected:
267  // => Control parameters <= //
268 
270  int nroot_;
272  double norm_;
278  int nguess_;
279 
280  // => Iteration values <= //
281 
286 
287  // => State values <= //
288 
290  std::vector<std::shared_ptr<Vector> > c_;
292  std::vector<std::vector<double> > E_;
294  std::vector<std::shared_ptr<Vector> > b_;
296  std::vector<std::shared_ptr<Vector> > s_;
300  std::vector<std::vector<int> > A_inds_;
306  std::shared_ptr<Vector> l_;
308  std::vector<std::shared_ptr<Vector> > r_;
310  std::vector<double> n_;
312  std::vector<std::shared_ptr<Vector> > d_;
314  std::shared_ptr<Vector> diag_;
315 
316  // => Run routines <= //
317 
318  // Guess, based on diagonal
319  void guess();
320  // Compute sigma vectors for the given set of b
321  void sigma();
322  // Compute subspace Hamiltonian
323  void subspaceHamiltonian();
324  // Diagonalize subspace Hamiltonian
326  // Find eigenvectors
327  void eigenvecs();
328  // Find eigenvalues
329  void eigenvals();
330  // Find residuals, update convergence
331  void residuals();
332  // Find correctors
333  virtual void correctors();
334  // Orthogonalize/add significant correctors
335  void subspaceExpansion();
336  // Collapse subspace if needed
337  void subspaceCollapse();
338 
339  public:
340  // => Constructors <= //
341 
343  DLRSolver(std::shared_ptr<RHamiltonian> H);
345  ~DLRSolver() override;
346 
348  static std::shared_ptr<DLRSolver> build_solver(Options& options, std::shared_ptr<RHamiltonian> H);
349 
350  // => Required Methods <= //
351 
352  void print_header() const override;
353  size_t memory_estimate() override;
354  void initialize() override;
355  void solve() override;
356  void finalize() override;
357 
358  // => Accessors <= //
359 
361  const std::vector<std::shared_ptr<Vector> >& eigenvectors() const { return c_; }
363  const std::vector<std::vector<double> >& eigenvalues() const { return E_; }
364 
365  // => Knobs <= //
366 
368  void set_nroot(int nroot) { nroot_ = nroot; }
370  void set_max_subspace(double max_subspace) { max_subspace_ = max_subspace; }
372  void set_min_subspace(double min_subspace) { min_subspace_ = min_subspace; }
374  void set_nguess(int nguess) { nguess_ = nguess; }
376  void set_norm(double norm) { norm_ = norm; }
377 };
378 
379 class RayleighRSolver : public DLRSolver {
380  protected:
382  std::shared_ptr<CGRSolver> cg_;
383 
384  std::string precondition_steps_;
386  std::string quantity_;
387 
388  // Find correctors (Like, the most advanced correctors ever)
389  void correctors() override;
390 
391  public:
392  // => Constructors <= //
393 
395  RayleighRSolver(std::shared_ptr<RHamiltonian> H);
397  ~RayleighRSolver() override;
398 
400  static std::shared_ptr<RayleighRSolver> build_solver(Options& options, std::shared_ptr<RHamiltonian> H);
401 
402  // => Required Methods <= //
403 
404  void print_header() const override;
405  void initialize() override;
406  void finalize() override;
407 
408  void set_precondition_maxiter(int maxiter) { precondition_maxiter_ = maxiter; }
409  void set_precondition_steps(const std::string& steps) { precondition_steps_ = steps; }
410  void set_quantity(const std::string& quantity) { quantity_ = quantity; }
411 };
412 
413 class DLRXSolver : public RSolver {
414  protected:
415  // => Control parameters <= //
416 
418  int nroot_;
420  double norm_;
426  int nguess_;
427 
428  // => Iteration values <= //
429 
434 
435  // => State values <= //
436 
438  std::vector<std::shared_ptr<Vector> > c_;
440  std::vector<std::vector<double> > E_;
442  std::vector<std::shared_ptr<Vector> > b_;
444  std::vector<std::shared_ptr<Vector> > s_;
450  std::shared_ptr<Vector> l_;
452  std::vector<std::shared_ptr<Vector> > r_;
454  std::vector<double> n_;
456  std::vector<std::shared_ptr<Vector> > d_;
458  std::shared_ptr<Vector> diag_;
459 
460  // => Run routines <= //
461 
462  // Guess, based on diagonal
463  void guess();
464  // Compute sigma vectors
465  void sigma();
466  // Compute subspace Hamiltonian
467  void subspaceHamiltonian();
468  // Diagonalize subspace Hamiltonian
470  // Find eigenvectors
471  void eigenvecs();
472  // Find eigenvalues
473  void eigenvals();
474  // Find residuals, update convergence
475  void residuals();
476  // Find correctors
477  void correctors();
478  // Orthogonalize/add significant correctors
479  void subspaceExpansion();
480  // Collapse subspace if needed
481  void subspaceCollapse();
482 
483  public:
484  // => Constructors <= //
485 
487  DLRXSolver(std::shared_ptr<RHamiltonian> H);
489  ~DLRXSolver() override;
490 
492  static std::shared_ptr<DLRXSolver> build_solver(Options& options, std::shared_ptr<RHamiltonian> H);
493 
494  // => Required Methods <= //
495 
496  void print_header() const override;
497  size_t memory_estimate() override;
498  void initialize() override;
499  void solve() override;
500  void finalize() override;
501 
502  // => Accessors <= //
503 
505  const std::vector<std::shared_ptr<Vector> >& eigenvectors() const { return c_; }
507  const std::vector<std::vector<double> >& eigenvalues() const { return E_; }
508 
509  // => Knobs <= //
510 
512  void set_nroot(int nroot) { nroot_ = nroot; }
514  void set_max_subspace(double max_subspace) { max_subspace_ = max_subspace; }
516  void set_min_subspace(double min_subspace) { min_subspace_ = min_subspace; }
518  void set_nguess(int nguess) { nguess_ = nguess; }
520  void set_norm(double norm) { norm_ = norm; }
521 };
522 
523 // Class for solving UHF stability analysis.
524 class DLUSolver : public USolver {
525  protected:
526  // => Control parameters <= //
527 
529  int nroot_;
531  double norm_;
537  int nguess_;
538 
539  // => Iteration values <= //
540 
545 
546  // => State values <= //
547 
549  std::vector<std::shared_ptr<Vector> > c_;
551  std::vector<std::vector<double> > E_;
553  std::vector<std::shared_ptr<Vector> > b_;
555  std::vector<std::shared_ptr<Vector> > s_;
559  std::vector<std::vector<int> > A_inds_;
565  std::shared_ptr<Vector> l_;
567  std::vector<std::shared_ptr<Vector> > r_;
569  std::vector<double> n_;
571  std::vector<std::shared_ptr<Vector> > d_;
573  std::shared_ptr<Vector> diag_;
575  std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > diag_components;
576 
577  // => Run routines <= //
578 
579  // Guess, based on diagonal
580  void guess();
581  // Compute sigma vectors for the given set of b
582  void sigma();
583  // Compute subspace Hamiltonian
584  void subspaceHamiltonian();
585  // Diagonalize subspace Hamiltonian
587  // Find eigenvectors
588  void eigenvecs();
589  // Find eigenvalues
590  void eigenvals();
591  // Find residuals, update convergence
592  void residuals();
593  // Find correctors
594  virtual void correctors();
595  // Orthogonalize/add significant correctors
596  void subspaceExpansion();
597  // Collapse subspace if needed
598  void subspaceCollapse();
599 
600  public:
601  // => Constructors <= //
602 
604  DLUSolver(std::shared_ptr<UHamiltonian> H);
606  ~DLUSolver() override;
607 
609  static std::shared_ptr<DLUSolver> build_solver(Options& options, std::shared_ptr<UHamiltonian> H);
610 
611  // => Required Methods <= //
612 
613  void print_header() const override;
614  size_t memory_estimate() override { return 0; };
615  void initialize() override;
616  void solve() override;
617  void finalize() override;
618 
619  // => Accessors <= //
620 
622  const std::vector<std::shared_ptr<Vector> >& eigenvectors() const { return c_; }
624  const std::vector<std::vector<double> >& eigenvalues() const { return E_; }
626  std::shared_ptr<Vector> contract_pair(std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > components);
627  void contract_pair(std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > components,
628  std::shared_ptr<Vector> result);
630  std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > expand_pair(std::shared_ptr<Vector> vec);
631  void expand_pair(std::shared_ptr<Vector> vec, std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > result);
632 
633  // => Knobs <= //
634 
636  void set_nroot(int nroot) { nroot_ = nroot; }
638  void set_max_subspace(double max_subspace) { max_subspace_ = max_subspace; }
640  void set_min_subspace(double min_subspace) { min_subspace_ = min_subspace; }
642  void set_nguess(int nguess) { nguess_ = nguess; }
644  void set_norm(double norm) { norm_ = norm; }
645 };
646 }
647 #endif
std::vector< std::shared_ptr< Vector > > p_
Conjugate directions.
Definition: solver.h:203
virtual void correctors()
Definition: solver.cc:2721
const std::vector< std::shared_ptr< Vector > > & eigenvectors() const
Eigenvectors, by state.
Definition: solver.h:505
std::string quantity_
Definition: solver.h:386
void common_init()
Common initialization.
Definition: solver.cc:54
int bench_
Bench flag, defaults to 0.
Definition: solver.h:53
const std::vector< std::vector< double > > & eigenvalues() const
Eigenvalues, by state/irrep.
Definition: solver.h:363
int nsubspace_
The current subspace size.
Definition: solver.h:542
std::shared_ptr< Vector > l_
Subspace eigenvalues (nsubspace)
Definition: solver.h:306
int nguess_
Number of guess vectors to build.
Definition: solver.h:278
Definition: solver.h:524
std::shared_ptr< Vector > diag_
Diagonal of Hamiltonian.
Definition: solver.h:314
void subspaceDiagonalization()
Definition: solver.cc:1630
std::shared_ptr< Vector > contract_pair(std::pair< std::shared_ptr< Vector >, std::shared_ptr< Vector > > components)
Convert an alpha/beta pair into a single vector.
void finalize() override
Definition: solver.cc:1315
void correctors() override
Definition: solver.cc:1319
void eigenvecs()
Definition: solver.cc:917
virtual void finalize()=0
SharedMatrix A_
Delta Subspace Hamiltonian (preconditioner)
Definition: solver.h:298
void eigenvals()
Definition: solver.cc:1775
SharedMatrix A_
Delta Subspace Hamiltonian (preconditioner)
Definition: solver.h:557
std::vector< std::shared_ptr< Vector > > s_
Sigma vectors (nsubspace)
Definition: solver.h:555
void solve() override
Definition: solver.cc:2324
std::vector< std::vector< double > > shifts_
Shifts (to solve (A-mI)
Definition: solver.h:224
Definition: solver.h:133
void print_header() const override
Definition: solver.cc:1436
SharedMatrix G_
G_ij Subspace Hamiltonian (nsubspace x nsubspace)
Definition: solver.h:446
const std::vector< std::shared_ptr< Vector > > & eigenvectors() const
Eigenvectors, by state.
Definition: solver.h:622
void update_p()
Definition: solver.cc:570
size_t memory_estimate() override
Estimate of maximum memory usage (in doubles)
Definition: solver.cc:115
int min_subspace_
Minimum allowed subspace size (after collapse)
Definition: solver.h:276
void eigenvals()
Definition: solver.cc:2631
void initialize() override
Definition: solver.cc:2148
Definition: solver.h:379
void set_Hamiltonian(std::shared_ptr< UHamiltonian > H)
Definition: solver.h:179
void set_norm(double norm)
Set norm critera for adding vectors to subspace (defaults to 1.0E-6)
Definition: solver.h:520
size_t memory_estimate() override
Estimate of maximum memory usage (in doubles)
Definition: solver.cc:1448
~RayleighRSolver() override
Destructor.
Definition: solver.cc:1240
void set_debug(int debug)
Debug flag (defaults to 0)
Definition: solver.h:96
void eigenvals()
Definition: solver.cc:951
SharedMatrix a_
Subspace eigenvectors (nsubspace x nsubspace)
Definition: solver.h:448
std::vector< std::vector< double > > E_
Current eigenvalues (nroots)
Definition: solver.h:292
Definition: solver.h:413
std::vector< std::shared_ptr< Vector > > d_
Correction vectors (nroots)
Definition: solver.h:312
void beta()
Definition: solver.cc:549
double norm_
Required norm for subspace expansion.
Definition: solver.h:272
void finalize() override
Definition: solver.cc:1519
void update_x()
Definition: solver.cc:425
double convergence_
Convergence measure at this iteration.
Definition: solver.h:66
void set_shifts(const std::vector< std::vector< double > > &shifts)
Definition: solver.h:257
void solve() override
Definition: solver.cc:1464
void set_norm(double norm)
Set norm critera for adding vectors to subspace (defaults to 1.0E-6)
Definition: solver.h:644
void finalize() override
Definition: solver.cc:722
std::shared_ptr< UHamiltonian > H_
Reference to underlying UHamiltonian.
Definition: solver.h:163
void alpha()
Definition: solver.cc:400
void set_maxiter(int maxiter)
Set maximum number of iterations (defaults to 100)
Definition: solver.h:90
std::vector< std::vector< int > > A_inds_
A subspace indices.
Definition: solver.h:222
void finalize() override
Definition: solver.cc:2382
int min_subspace_
Minimum allowed subspace size (after collapse)
Definition: solver.h:535
std::vector< std::shared_ptr< Vector > > r_
Residual vectors (nroots)
Definition: solver.h:567
Definition: solver.h:44
void print_header() const override
Definition: solver.cc:1289
void set_nroot(int nroot)
Set number of roots (defaults to 1)
Definition: solver.h:368
std::vector< std::shared_ptr< Vector > > x_
Solution vectors.
Definition: solver.h:195
SharedMatrix G_
G_ij Subspace Hamiltonian (nsubspace x nsubspace)
Definition: solver.h:302
int print_
Print flag, defaults to 1.
Definition: solver.h:49
std::vector< std::shared_ptr< Vector > > b_
B vectors (nsubspace)
Definition: solver.h:553
Solver()
Default Constructor.
Definition: solver.cc:52
std::vector< std::shared_ptr< Vector > > d_
Correction vectors (nroots)
Definition: solver.h:456
const std::vector< std::vector< double > > & eigenvalues() const
Eigenvalues, by state/irrep.
Definition: solver.h:507
int nsubspace_
The current subspace size.
Definition: solver.h:431
void set_print(int print)
Print flag (defaults to 1)
Definition: solver.h:94
void set_A(SharedMatrix A, const std::vector< std::vector< int > > inds)
Definition: solver.h:258
void print_header() const override
Definition: solver.cc:106
int nconverged_
The number of converged roots.
Definition: solver.h:433
void print_header() const override
Definition: solver.cc:636
int max_subspace_
Maximum allowed subspace size.
Definition: solver.h:533
std::shared_ptr< Vector > diag_
Diagonal M, for guess and Jacobi preconditioning.
Definition: solver.h:218
int precondition_maxiter_
Definition: solver.h:385
const std::vector< std::shared_ptr< Vector > > & eigenvectors() const
Eigenvectors, by state.
Definition: solver.h:361
void subspaceHamiltonian()
Definition: solver.cc:846
SharedMatrix G_
G_ij Subspace Hamiltonian (nsubspace x nsubspace)
Definition: solver.h:561
std::vector< std::shared_ptr< Vector > > z_
M^-1 x.
Definition: solver.h:199
SharedMatrix A_
A subspace matrix, for preconditioning.
Definition: solver.h:220
double norm_
Required norm for subspace expansion.
Definition: solver.h:531
void sigma()
Definition: solver.cc:1562
std::vector< std::shared_ptr< Vector > > b_
B vectors (nsubspace)
Definition: solver.h:294
int max_subspace_
Maximum allowed subspace size.
Definition: solver.h:274
void subspaceCollapse()
Definition: solver.cc:1185
void subspaceExpansion()
Definition: solver.cc:1126
~RSolver() override
Destructor.
Definition: solver.cc:70
void sigma()
Definition: solver.cc:820
static std::shared_ptr< CGRSolver > build_solver(Options &options, std::shared_ptr< RHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:80
bool converged_
Converged or not?
Definition: solver.h:64
void print_header() const override
Definition: solver.cc:2120
void set_nguess(int nguess)
Set number of guesses (defaults to 1)
Definition: solver.h:642
void set_max_subspace(double max_subspace)
Set maximum subspace size (defaults to 6)
Definition: solver.h:514
void update_z()
Definition: solver.cc:490
std::shared_ptr< RHamiltonian > H_
Reference to underlying RHamiltonian.
Definition: solver.h:136
void correctors()
Definition: solver.cc:1864
virtual ~Solver()
Destructor.
Definition: solver.cc:53
int iteration_
Current iteration count.
Definition: solver.h:68
~DLUSolver() override
Destructor.
Definition: solver.cc:2074
void set_nroot(int nroot)
Set number of roots (defaults to 1)
Definition: solver.h:512
int nroot_
Number of desired roots.
Definition: solver.h:529
SharedMatrix a_
Subspace eigenvectors (nsubspace x nsubspace)
Definition: solver.h:304
Definition: solver.h:265
int nconverged_
The number of converged roots.
Definition: solver.h:544
void residuals()
Definition: solver.cc:971
void initialize() override
Definition: solver.cc:1456
std::vector< std::vector< double > > E_
Current eigenvalues (nroots)
Definition: solver.h:440
void set_max_subspace(double max_subspace)
Set maximum subspace size (defaults to 6)
Definition: solver.h:370
void set_precondition_maxiter(int maxiter)
Definition: solver.h:408
void set_min_subspace(double min_subspace)
Set minimum subspace size, for collapse (defaults to 2)
Definition: solver.h:516
int nguess_
Number of guess vectors to use for subspace preconditioner.
Definition: solver.h:226
std::vector< std::shared_ptr< Vector > > b_
B vectors (nsubspace)
Definition: solver.h:442
int max_subspace_
Maximum allowed subspace size.
Definition: solver.h:422
virtual void solve()=0
void set_min_subspace(double min_subspace)
Set minimum subspace size, for collapse (defaults to 2)
Definition: solver.h:372
static std::shared_ptr< DLRXSolver > build_solver(Options &options, std::shared_ptr< RHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:1403
virtual void initialize()=0
std::shared_ptr< Vector > diag_
Diagonal of Hamiltonian.
Definition: solver.h:573
~DLRSolver() override
Destructor.
Definition: solver.cc:596
void initialize() override
Definition: solver.cc:123
std::shared_ptr< UHamiltonian > H() const
Definition: solver.h:185
std::vector< std::shared_ptr< Vector > > d_
Correction vectors (nroots)
Definition: solver.h:571
SharedMatrix a_
Subspace eigenvectors (nsubspace x nsubspace)
Definition: solver.h:563
void finalize() override
Definition: solver.cc:197
~USolver() override
Destructor.
Definition: solver.cc:73
USolver(std::shared_ptr< UHamiltonian > H)
Reference to underlying RHamiltonian.
Definition: solver.cc:72
int debug_
Debug flag, defaults to 0.
Definition: solver.h:51
std::vector< bool > r_converged_
Which vectors are converged?
Definition: solver.h:213
CGRSolver(std::shared_ptr< RHamiltonian > H)
Definition: solver.cc:75
void subspaceDiagonalization()
Definition: solver.cc:875
DLUSolver(std::shared_ptr< UHamiltonian > H)
Constructor.
Definition: solver.cc:2062
RayleighRSolver(std::shared_ptr< RHamiltonian > H)
Constructor.
Definition: solver.cc:1234
void setup()
Definition: solver.cc:209
virtual size_t memory_estimate()=0
Estimate of maximum memory usage (in doubles)
double norm_
Required norm for subspace expansion.
Definition: solver.h:420
void set_nguess(int nguess)
Set number of guesses (defaults to 1)
Definition: solver.h:374
size_t memory_
Memory available, in doubles, defaults to 0 =&gt; Unlimited storage.
Definition: solver.h:57
virtual void correctors()
Definition: solver.cc:1039
int maxiter_
Maximum number of iterations, defaults to 100.
Definition: solver.h:62
const std::vector< std::vector< double > > & eigenvalues() const
Eigenvalues, by state/irrep.
Definition: solver.h:624
void set_quantity(const std::string &quantity)
Definition: solver.h:410
Definition: solver.h:190
std::vector< std::shared_ptr< Vector > > s_
Sigma vectors (nsubspace)
Definition: solver.h:296
void guess()
Definition: solver.cc:1530
void subspaceCollapse()
Definition: solver.cc:2004
static std::shared_ptr< RayleighRSolver > build_solver(Options &options, std::shared_ptr< RHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:1241
~CGRSolver() override
Definition: solver.cc:79
int nguess_
Number of guess vectors to build.
Definition: solver.h:537
std::vector< double > r_nrm2_
Residual norm.
Definition: solver.h:209
void eigenvecs()
Definition: solver.cc:1737
std::vector< double > n_
Residual vector 2-norms (nroots)
Definition: solver.h:454
std::vector< std::vector< int > > A_inds_
Delta Subspace indices.
Definition: solver.h:300
void set_precondition(const std::string &precondition)
Set precondition type (specific to solver type)
Definition: solver.h:86
void residual()
Definition: solver.cc:338
void subspaceDiagonalization()
Definition: solver.cc:2553
void products_x()
Definition: solver.cc:352
void sigma()
Definition: solver.cc:2481
int iteration() const
What iteration is it?
Definition: solver.h:103
int nconverged_
The number of converged roots.
Definition: solver.h:285
void set_nguess(int nguess)
Definition: solver.h:262
std::vector< std::shared_ptr< Vector > > b_
Force vectors.
Definition: solver.h:193
void set_precondition_steps(const std::string &steps)
Definition: solver.h:409
RSolver(std::shared_ptr< RHamiltonian > H)
Definition: solver.cc:69
void set_bench(int bench)
Bench flag (defaults to 0)
Definition: solver.h:98
void initialize() override
Definition: solver.cc:657
std::pair< std::shared_ptr< Vector >, std::shared_ptr< Vector > > diag_components
Diagonal components of UHamiltonian.
Definition: solver.h:575
Definition: liboptions.h:352
void guess()
Definition: solver.cc:279
std::vector< std::shared_ptr< Vector > > r_
Residual vectors.
Definition: solver.h:201
int nroot_
Number of desired roots.
Definition: solver.h:418
std::pair< std::shared_ptr< Vector >, std::shared_ptr< Vector > > expand_pair(std::shared_ptr< Vector > vec)
Convert a single vector into an alpha/beta pair.
Definition: solver.cc:2252
void set_min_subspace(double min_subspace)
Set minimum subspace size, for collapse (defaults to 2)
Definition: solver.h:640
void subspaceExpansion()
Definition: solver.cc:2809
DLRSolver(std::shared_ptr< RHamiltonian > H)
Constructor.
Definition: solver.cc:585
std::vector< std::shared_ptr< Vector > > r_
Residual vectors (nroots)
Definition: solver.h:452
std::string name_
Name of solver (set by subclasses)
Definition: solver.h:55
std::string precondition_
Preconditioner type.
Definition: solver.h:70
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
std::vector< std::shared_ptr< Vector > > c_
Current eigenvectors (nroots)
Definition: solver.h:438
int nguess_
Number of guess vectors to build.
Definition: solver.h:426
Definition: solver.h:160
void residuals()
Definition: solver.cc:1795
std::vector< std::shared_ptr< Vector > > c_
Current eigenvectors (nroots)
Definition: solver.h:290
int nconverged_
Number of converged vectors.
Definition: solver.h:215
std::shared_ptr< RHamiltonian > H() const
Definition: solver.h:157
void set_convergence(double criteria)
Set convergence criteria (defaults to 1.0E-6)
Definition: solver.h:92
size_t memory_estimate() override
Estimate of maximum memory usage (in doubles)
Definition: solver.cc:649
std::vector< std::vector< int > > A_inds_
Delta Subspace indices.
Definition: solver.h:559
std::shared_ptr< Vector > l_
Subspace eigenvalues (nsubspace)
Definition: solver.h:450
void set_memory(size_t memory)
Set maximum vector storage space (defaults to 0 MB =&gt; Unlimited storage)
Definition: solver.h:88
std::vector< std::shared_ptr< Vector > > c_
Current eigenvectors (nroots)
Definition: solver.h:549
int nsubspace_
The current subspace size.
Definition: solver.h:283
void set_max_subspace(double max_subspace)
Set maximum subspace size (defaults to 6)
Definition: solver.h:638
size_t memory_estimate() override
Estimate of maximum memory usage (in doubles)
Definition: solver.h:614
std::vector< std::shared_ptr< Vector > > & b()
Definition: solver.h:249
void guess()
Definition: solver.cc:733
void subspaceExpansion()
Definition: solver.cc:1917
std::string precondition_steps_
Definition: solver.h:384
std::vector< double > alpha_
Alpha values.
Definition: solver.h:205
virtual void print_header() const =0
static std::shared_ptr< DLUSolver > build_solver(Options &options, std::shared_ptr< UHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:2076
bool converged() const
Did the solver converge?
Definition: solver.h:105
void check_convergence()
Definition: solver.cc:463
std::shared_ptr< Vector > diag_
Diagonal of Hamiltonian.
Definition: solver.h:458
int min_subspace_
Minimum allowed subspace size (after collapse)
Definition: solver.h:424
void set_nguess(int nguess)
Set number of guesses (defaults to 1)
Definition: solver.h:518
~DLRXSolver() override
Destructor.
Definition: solver.cc:1402
std::shared_ptr< Vector > l_
Subspace eigenvalues (nsubspace)
Definition: solver.h:565
void precondition(dpdfile2 *RIA, dpdfile2 *Ria, dpdbuf4 *RIJAB, dpdbuf4 *Rijab, dpdbuf4 *RIjAb, double eval)
Definition: precondition.cc:50
void residuals()
Definition: solver.cc:2652
static std::shared_ptr< DLRSolver > build_solver(Options &options, std::shared_ptr< RHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:597
std::vector< double > z_r_
z&#39;r
Definition: solver.h:211
void guess()
Definition: solver.cc:2394
void initialize() override
Definition: solver.cc:1310
void products_p()
Definition: solver.cc:371
void set_norm(double norm)
Set norm critera for adding vectors to subspace (defaults to 1.0E-6)
Definition: solver.h:376
std::vector< std::vector< double > > E_
Current eigenvalues (nroots)
Definition: solver.h:551
void eigenvecs()
Definition: solver.cc:2596
void solve() override
Definition: solver.cc:152
DLRXSolver(std::shared_ptr< RHamiltonian > H)
Constructor.
Definition: solver.cc:1393
void subspaceCollapse()
Definition: solver.cc:2869
std::vector< double > n_
Residual vector 2-norms (nroots)
Definition: solver.h:310
std::shared_ptr< CGRSolver > cg_
Turn an eigenproblem into a linear equations problem.
Definition: solver.h:382
void set_nroot(int nroot)
Set number of roots (defaults to 1)
Definition: solver.h:636
int nroot_
Number of desired roots.
Definition: solver.h:270
void update_r()
Definition: solver.cc:444
std::vector< std::shared_ptr< Vector > > Ap_
Product vectors.
Definition: solver.h:197
std::vector< std::shared_ptr< Vector > > & x()
Definition: solver.h:248
std::vector< double > beta_
Beta values.
Definition: solver.h:207
std::vector< std::shared_ptr< Vector > > s_
Sigma vectors (nsubspace)
Definition: solver.h:444
double criteria_
Convergence criteria, defaults to 1.0E-6.
Definition: solver.h:60
std::vector< std::shared_ptr< Vector > > r_
Residual vectors (nroots)
Definition: solver.h:308
std::vector< double > n_
Residual vector 2-norms (nroots)
Definition: solver.h:569
void subspaceHamiltonian()
Definition: solver.cc:1588
void set_Hamiltonian(std::shared_ptr< RHamiltonian > H)
Definition: solver.h:151
void subspaceHamiltonian()
Definition: solver.cc:2524
void solve() override
Definition: solver.cc:665