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-2017 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * @END LICENSE
26  */
27 
28 #ifndef SOLVER_H
29 #define SOLVER_H
30 
31 namespace psi {
32 
33 class Matrix;
34 class Vector;
35 class Hamiltonian;
36 class RHamiltonian;
37 class UHamiltonian;
38 
39 class Solver {
40 
41 // => BASE CLASSES <= //
42 
43 protected:
44 
46  int print_;
48  int debug_;
50  int bench_;
52  std::string name_;
54  unsigned long int memory_;
55 
57  double criteria_;
59  int maxiter_;
61  bool converged_;
63  double convergence_;
67  std::string precondition_;
68 
70  void common_init();
71 
72 public:
73  // => Constructors < = //
74 
76  Solver();
78  virtual ~Solver();
79 
80  // => Knobs <= //
81 
83  void set_precondition(const std::string& precondition) { precondition_ = precondition; }
85  void set_memory(unsigned long int memory) { memory_ = memory; }
87  void set_maxiter(int maxiter) { maxiter_ = maxiter; }
89  void set_convergence(double criteria) { criteria_ = criteria; }
91  void set_print(int print) { print_ = print; }
93  void set_debug(int debug) { debug_ = debug; }
95  void set_bench(int bench) { bench_ = bench; }
96 
97  // => Accessors <= //
98 
100  int iteration() const { return iteration_; }
102  bool converged() const { return converged_; }
107  virtual void print_header() const = 0;
109  virtual unsigned long int memory_estimate() = 0;
110 
111  // => Computers <= //
112 
117  virtual void initialize() = 0;
122  virtual void solve() = 0;
127  virtual void finalize() = 0;
128 
129 
130 };
131 
132 class RSolver : public Solver {
133 
134 protected:
136  std::shared_ptr<RHamiltonian> H_;
137 
138 public:
139  // => Constructors < = //
140 
141  RSolver(std::shared_ptr<RHamiltonian> H);
143  virtual ~RSolver();
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 
162 protected:
164  std::shared_ptr<UHamiltonian> H_;
165 
166 public:
167  // => Constructors < = //
168 
170  USolver(std::shared_ptr<UHamiltonian> H);
172  virtual ~USolver();
173 
174  // => Accessors <= //
175 
180  void set_Hamiltonian(std::shared_ptr<UHamiltonian> H) { H_ = H; }
181 
186  std::shared_ptr<UHamiltonian> H() const { return H_; }
187 };
188 
189 // => APPLIED CLASSES <= //
190 
191 class CGRSolver : public RSolver {
192 
193 protected:
194 
196  std::vector<std::shared_ptr<Vector> > b_;
198  std::vector<std::shared_ptr<Vector> > x_;
200  std::vector<std::shared_ptr<Vector> > Ap_;
202  std::vector<std::shared_ptr<Vector> > z_;
204  std::vector<std::shared_ptr<Vector> > r_;
206  std::vector<std::shared_ptr<Vector> > p_;
208  std::vector<double> alpha_;
210  std::vector<double> beta_;
212  std::vector<double> r_nrm2_;
214  std::vector<double> z_r_;
216  std::vector<bool> r_converged_;
219 
221  std::shared_ptr<Vector> diag_;
225  std::vector<std::vector<int> > A_inds_;
227  std::vector<std::vector<double> > shifts_;
229  int nguess_;
230 
231  void setup();
232  void guess();
233  void residual();
234  void products_x();
235  void products_p();
236  void alpha();
237  void update_x();
238  void update_r();
239  void check_convergence();
240  void update_z();
241  void beta();
242  void update_p();
243 
244 public:
245 
246  CGRSolver(std::shared_ptr<RHamiltonian> H);
247  virtual ~CGRSolver();
248 
250  static std::shared_ptr<CGRSolver> build_solver(Options& options,
251  std::shared_ptr<RHamiltonian> H);
252 
253  std::vector<std::shared_ptr<Vector> >& x() { return x_; }
254  std::vector<std::shared_ptr<Vector> >& b() { return b_; }
255 
256  void print_header() const;
257  unsigned long int memory_estimate();
258  void initialize();
259  void solve();
260  void finalize();
261 
262  void set_shifts(const std::vector<std::vector<double> >& shifts) { shifts_ = shifts; }
263  void set_A(SharedMatrix A, const std::vector<std::vector<int> > inds) { A_ = A; A_inds_ = inds; }
264  void set_nguess(int nguess) { nguess_ = nguess; }
265 };
266 
267 class DLRSolver : public RSolver {
268 
269 protected:
270 
271  // => Control parameters <= //
272 
274  int nroot_;
276  double norm_;
282  int nguess_;
283 
284  // => Iteration values <= //
285 
290 
291  // => State values <= //
292 
294  std::vector<std::shared_ptr<Vector> > c_;
296  std::vector<std::vector<double> > E_;
298  std::vector<std::shared_ptr<Vector> > b_;
300  std::vector<std::shared_ptr<Vector> > s_;
304  std::vector<std::vector<int> > A_inds_;
310  std::shared_ptr<Vector> l_;
312  std::vector<std::shared_ptr<Vector> > r_;
314  std::vector<double> n_;
316  std::vector<std::shared_ptr<Vector> > d_;
318  std::shared_ptr<Vector> diag_;
319 
320  // => Run routines <= //
321 
322  // Guess, based on diagonal
323  void guess();
324  // Compute sigma vectors for the given set of b
325  void sigma();
326  // Compute subspace Hamiltonian
327  void subspaceHamiltonian();
328  // Diagonalize subspace Hamiltonian
330  // Find eigenvectors
331  void eigenvecs();
332  // Find eigenvalues
333  void eigenvals();
334  // Find residuals, update convergence
335  void residuals();
336  // Find correctors
337  virtual void correctors();
338  // Orthogonalize/add significant correctors
339  void subspaceExpansion();
340  // Collapse subspace if needed
341  void subspaceCollapse();
342 
343 public:
344 
345  // => Constructors <= //
346 
348  DLRSolver(std::shared_ptr<RHamiltonian> H);
350  virtual ~DLRSolver();
351 
353  static std::shared_ptr<DLRSolver> build_solver(Options& options,
354  std::shared_ptr<RHamiltonian> H);
355 
356  // => Required Methods <= //
357 
358  virtual void print_header() const;
359  virtual unsigned long int memory_estimate();
360  virtual void initialize();
361  void solve();
362  void finalize();
363 
364  // => Accessors <= //
365 
367  const std::vector<std::shared_ptr<Vector> >& eigenvectors() const { return c_; }
369  const std::vector<std::vector<double> >& eigenvalues() const { return E_; }
370 
371  // => Knobs <= //
372 
374  void set_nroot(int nroot) { nroot_ = nroot; }
376  void set_max_subspace(double max_subspace) { max_subspace_ = max_subspace; }
378  void set_min_subspace(double min_subspace) { min_subspace_ = min_subspace; }
380  void set_nguess(int nguess) { nguess_ = nguess; }
382  void set_norm(double norm) { norm_ = norm; }
383 };
384 
385 class RayleighRSolver : public DLRSolver {
386 
387 protected:
388 
390  std::shared_ptr<CGRSolver> cg_;
391 
392  std::string precondition_steps_;
394  std::string quantity_;
395 
396  // Find correctors (Like, the most advanced correctors ever)
397  void correctors();
398 
399 public:
400 
401  // => Constructors <= //
402 
404  RayleighRSolver(std::shared_ptr<RHamiltonian> H);
406  virtual ~RayleighRSolver();
407 
409  static std::shared_ptr<RayleighRSolver> build_solver(Options& options,
410  std::shared_ptr<RHamiltonian> H);
411 
412  // => Required Methods <= //
413 
414  void print_header() const;
415  void initialize();
416  void finalize();
417 
418  void set_precondition_maxiter(int maxiter) { precondition_maxiter_ = maxiter; }
419  void set_precondition_steps(const std::string& steps) { precondition_steps_ = steps; }
420  void set_quantity(const std::string& quantity) { quantity_ = quantity; }
421 };
422 
423 class DLRXSolver : public RSolver {
424 
425 protected:
426 
427  // => Control parameters <= //
428 
430  int nroot_;
432  double norm_;
438  int nguess_;
439 
440  // => Iteration values <= //
441 
446 
447  // => State values <= //
448 
450  std::vector<std::shared_ptr<Vector> > c_;
452  std::vector<std::vector<double> > E_;
454  std::vector<std::shared_ptr<Vector> > b_;
456  std::vector<std::shared_ptr<Vector> > s_;
462  std::shared_ptr<Vector> l_;
464  std::vector<std::shared_ptr<Vector> > r_;
466  std::vector<double> n_;
468  std::vector<std::shared_ptr<Vector> > d_;
470  std::shared_ptr<Vector> diag_;
471 
472  // => Run routines <= //
473 
474  // Guess, based on diagonal
475  void guess();
476  // Compute sigma vectors
477  void sigma();
478  // Compute subspace Hamiltonian
479  void subspaceHamiltonian();
480  // Diagonalize subspace Hamiltonian
482  // Find eigenvectors
483  void eigenvecs();
484  // Find eigenvalues
485  void eigenvals();
486  // Find residuals, update convergence
487  void residuals();
488  // Find correctors
489  void correctors();
490  // Orthogonalize/add significant correctors
491  void subspaceExpansion();
492  // Collapse subspace if needed
493  void subspaceCollapse();
494 
495 public:
496 
497  // => Constructors <= //
498 
500  DLRXSolver(std::shared_ptr<RHamiltonian> H);
502  virtual ~DLRXSolver();
503 
505  static std::shared_ptr<DLRXSolver> build_solver(Options& options,
506  std::shared_ptr<RHamiltonian> H);
507 
508  // => Required Methods <= //
509 
510  void print_header() const;
511  unsigned long int memory_estimate();
512  void initialize();
513  void solve();
514  void finalize();
515 
516  // => Accessors <= //
517 
519  const std::vector<std::shared_ptr<Vector> >& eigenvectors() const { return c_; }
521  const std::vector<std::vector<double> >& eigenvalues() const { return E_; }
522 
523  // => Knobs <= //
524 
526  void set_nroot(int nroot) { nroot_ = nroot; }
528  void set_max_subspace(double max_subspace) { max_subspace_ = max_subspace; }
530  void set_min_subspace(double min_subspace) { min_subspace_ = min_subspace; }
532  void set_nguess(int nguess) { nguess_ = nguess; }
534  void set_norm(double norm) { norm_ = norm; }
535 };
536 
537 // Class for solving UHF stability analysis.
538 class DLUSolver : public USolver {
539 
540 protected:
541 
542  // => Control parameters <= //
543 
545  int nroot_;
547  double norm_;
553  int nguess_;
554 
555  // => Iteration values <= //
556 
561 
562  // => State values <= //
563 
565  std::vector<std::shared_ptr<Vector> > c_;
567  std::vector<std::vector<double> > E_;
569  std::vector<std::shared_ptr<Vector> > b_;
571  std::vector<std::shared_ptr<Vector> > s_;
575  std::vector<std::vector<int> > A_inds_;
581  std::shared_ptr<Vector> l_;
583  std::vector<std::shared_ptr<Vector> > r_;
585  std::vector<double> n_;
587  std::vector<std::shared_ptr<Vector> > d_;
589  std::shared_ptr<Vector> diag_;
591  std::pair< std::shared_ptr<Vector>, std::shared_ptr<Vector> > diag_components;
592 
593  // => Run routines <= //
594 
595  // Guess, based on diagonal
596  void guess();
597  // Compute sigma vectors for the given set of b
598  void sigma();
599  // Compute subspace Hamiltonian
600  void subspaceHamiltonian();
601  // Diagonalize subspace Hamiltonian
603  // Find eigenvectors
604  void eigenvecs();
605  // Find eigenvalues
606  void eigenvals();
607  // Find residuals, update convergence
608  void residuals();
609  // Find correctors
610  virtual void correctors();
611  // Orthogonalize/add significant correctors
612  void subspaceExpansion();
613  // Collapse subspace if needed
614  void subspaceCollapse();
615 
616 public:
617 
618  // => Constructors <= //
619 
621  DLUSolver(std::shared_ptr<UHamiltonian> H);
623  virtual ~DLUSolver();
624 
626  static std::shared_ptr<DLUSolver> build_solver(Options& options,
627  std::shared_ptr<UHamiltonian> H);
628 
629  // => Required Methods <= //
630 
631  virtual void print_header() const;
632  virtual unsigned long int memory_estimate(){ return 0;};
633  virtual void initialize();
634  void solve();
635  void finalize();
636 
637  // => Accessors <= //
638 
640  const std::vector<std::shared_ptr<Vector> >& eigenvectors() const { return c_; }
642  const std::vector<std::vector<double> >& eigenvalues() const { return E_; }
644  std::shared_ptr<Vector> contract_pair(
645  std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > components );
646  void contract_pair(
647  std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > components,
648  std::shared_ptr<Vector> result);
650  std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > expand_pair(
651  std::shared_ptr<Vector> vec);
652  void expand_pair(std::shared_ptr<Vector> vec,
653  std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > result);
654 
655  // => Knobs <= //
656 
658  void set_nroot(int nroot) { nroot_ = nroot; }
660  void set_max_subspace(double max_subspace) { max_subspace_ = max_subspace; }
662  void set_min_subspace(double min_subspace) { min_subspace_ = min_subspace; }
664  void set_nguess(int nguess) { nguess_ = nguess; }
666  void set_norm(double norm) { norm_ = norm; }
667 
668 };
669 
670 
671 }
672 #endif
std::vector< std::shared_ptr< Vector > > p_
Conjugate directions.
Definition: solver.h:206
virtual void correctors()
Definition: solver.cc:2914
virtual unsigned long int memory_estimate()
Estimate of maximum memory usage (in doubles)
Definition: solver.cc:698
const std::vector< std::shared_ptr< Vector > > & eigenvectors() const
Eigenvectors, by state.
Definition: solver.h:519
std::string quantity_
Definition: solver.h:394
void solve()
Definition: solver.cc:176
void common_init()
Common initialization.
Definition: solver.cc:56
int bench_
Bench flag, defaults to 0.
Definition: solver.h:50
const std::vector< std::vector< double > > & eigenvalues() const
Eigenvalues, by state/irrep.
Definition: solver.h:369
int nsubspace_
The current subspace size.
Definition: solver.h:558
std::shared_ptr< Vector > l_
Subspace eigenvalues (nsubspace)
Definition: solver.h:310
int nguess_
Number of guess vectors to build.
Definition: solver.h:282
Definition: solver.h:538
virtual unsigned long int memory_estimate()=0
Estimate of maximum memory usage (in doubles)
std::shared_ptr< Vector > diag_
Diagonal of Hamiltonian.
Definition: solver.h:318
void subspaceDiagonalization()
Definition: solver.cc:1750
virtual ~RayleighRSolver()
Destructor.
Definition: solver.cc:1328
void finalize()
Definition: solver.cc:2551
void eigenvecs()
Definition: solver.cc:984
virtual void finalize()=0
SharedMatrix A_
Delta Subspace Hamiltonian (preconditioner)
Definition: solver.h:302
void eigenvals()
Definition: solver.cc:1903
SharedMatrix A_
Delta Subspace Hamiltonian (preconditioner)
Definition: solver.h:573
std::vector< std::shared_ptr< Vector > > s_
Sigma vectors (nsubspace)
Definition: solver.h:571
std::vector< std::vector< double > > shifts_
Shifts (to solve (A-mI)
Definition: solver.h:227
Definition: solver.h:132
unsigned long int memory_estimate()
Estimate of maximum memory usage (in doubles)
Definition: solver.cc:137
SharedMatrix G_
G_ij Subspace Hamiltonian (nsubspace x nsubspace)
Definition: solver.h:458
const std::vector< std::shared_ptr< Vector > > & eigenvectors() const
Eigenvectors, by state.
Definition: solver.h:640
void update_p()
Definition: solver.cc:612
int min_subspace_
Minimum allowed subspace size (after collapse)
Definition: solver.h:280
void eigenvals()
Definition: solver.cc:2816
Definition: solver.h:385
void set_Hamiltonian(std::shared_ptr< UHamiltonian > H)
Definition: solver.h:180
void set_norm(double norm)
Set norm critera for adding vectors to subspace (defaults to 1.0E-6)
Definition: solver.h:534
virtual void initialize()
Definition: solver.cc:707
void set_debug(int debug)
Debug flag (defaults to 0)
Definition: solver.h:93
void eigenvals()
Definition: solver.cc:1021
virtual void initialize()
Definition: solver.cc:2300
SharedMatrix a_
Subspace eigenvectors (nsubspace x nsubspace)
Definition: solver.h:460
std::vector< std::vector< double > > E_
Current eigenvalues (nroots)
Definition: solver.h:296
Definition: solver.h:423
std::vector< std::shared_ptr< Vector > > d_
Correction vectors (nroots)
Definition: solver.h:316
void beta()
Definition: solver.cc:590
void correctors()
Definition: solver.cc:1414
double norm_
Required norm for subspace expansion.
Definition: solver.h:276
void update_x()
Definition: solver.cc:462
double convergence_
Convergence measure at this iteration.
Definition: solver.h:63
void set_shifts(const std::vector< std::vector< double > > &shifts)
Definition: solver.h:262
void solve()
Definition: solver.cc:1570
void set_norm(double norm)
Set norm critera for adding vectors to subspace (defaults to 1.0E-6)
Definition: solver.h:666
std::shared_ptr< UHamiltonian > H_
Reference to underlying UHamiltonian.
Definition: solver.h:164
void alpha()
Definition: solver.cc:436
void set_maxiter(int maxiter)
Set maximum number of iterations (defaults to 100)
Definition: solver.h:87
std::vector< std::vector< int > > A_inds_
A subspace indices.
Definition: solver.h:225
virtual void print_header() const
Definition: solver.cc:2271
int min_subspace_
Minimum allowed subspace size (after collapse)
Definition: solver.h:551
std::vector< std::shared_ptr< Vector > > r_
Residual vectors (nroots)
Definition: solver.h:583
void finalize()
Definition: solver.cc:1409
void initialize()
Definition: solver.cc:1403
Definition: solver.h:39
void set_nroot(int nroot)
Set number of roots (defaults to 1)
Definition: solver.h:374
void finalize()
Definition: solver.cc:1631
std::vector< std::shared_ptr< Vector > > x_
Solution vectors.
Definition: solver.h:198
SharedMatrix G_
G_ij Subspace Hamiltonian (nsubspace x nsubspace)
Definition: solver.h:306
int print_
Print flag, defaults to 1.
Definition: solver.h:46
void print_header() const
Definition: solver.cc:1381
void finalize()
Definition: solver.cc:225
std::vector< std::shared_ptr< Vector > > b_
B vectors (nsubspace)
Definition: solver.h:569
Solver()
Default Constructor.
Definition: solver.cc:49
std::vector< std::shared_ptr< Vector > > d_
Correction vectors (nroots)
Definition: solver.h:468
const std::vector< std::vector< double > > & eigenvalues() const
Eigenvalues, by state/irrep.
Definition: solver.h:521
virtual ~RSolver()
Destructor.
Definition: solver.cc:77
int nsubspace_
The current subspace size.
Definition: solver.h:443
void set_print(int print)
Print flag (defaults to 1)
Definition: solver.h:91
void set_A(SharedMatrix A, const std::vector< std::vector< int > > inds)
Definition: solver.h:263
int nconverged_
The number of converged roots.
Definition: solver.h:445
int max_subspace_
Maximum allowed subspace size.
Definition: solver.h:549
std::shared_ptr< Vector > diag_
Diagonal M, for guess and Jacobi preconditioning.
Definition: solver.h:221
int precondition_maxiter_
Definition: solver.h:393
const std::vector< std::shared_ptr< Vector > > & eigenvectors() const
Eigenvectors, by state.
Definition: solver.h:367
void subspaceHamiltonian()
Definition: solver.cc:906
SharedMatrix G_
G_ij Subspace Hamiltonian (nsubspace x nsubspace)
Definition: solver.h:577
std::vector< std::shared_ptr< Vector > > z_
M^-1 x.
Definition: solver.h:202
unsigned long int memory_
Memory available, in doubles, defaults to 0 =&gt; Unlimited storage.
Definition: solver.h:54
SharedMatrix A_
A subspace matrix, for preconditioning.
Definition: solver.h:223
virtual ~CGRSolver()
Definition: solver.cc:96
double norm_
Required norm for subspace expansion.
Definition: solver.h:547
void sigma()
Definition: solver.cc:1677
std::vector< std::shared_ptr< Vector > > b_
B vectors (nsubspace)
Definition: solver.h:298
int max_subspace_
Maximum allowed subspace size.
Definition: solver.h:278
void subspaceCollapse()
Definition: solver.cc:1270
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.
Definition: solver.cc:2339
void subspaceExpansion()
Definition: solver.cc:1208
void sigma()
Definition: solver.cc:878
static std::shared_ptr< CGRSolver > build_solver(Options &options, std::shared_ptr< RHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:99
bool converged_
Converged or not?
Definition: solver.h:61
void set_nguess(int nguess)
Set number of guesses (defaults to 1)
Definition: solver.h:664
void set_max_subspace(double max_subspace)
Set maximum subspace size (defaults to 6)
Definition: solver.h:528
void update_z()
Definition: solver.cc:530
std::pair< std::shared_ptr< Vector >, std::shared_ptr< Vector > > diag_components
Diagonal components of UHamiltonian.
Definition: solver.h:591
std::shared_ptr< RHamiltonian > H_
Reference to underlying RHamiltonian.
Definition: solver.h:136
void correctors()
Definition: solver.cc:2000
virtual ~Solver()
Destructor.
Definition: solver.cc:53
void print_header() const
Definition: solver.cc:127
int iteration_
Current iteration count.
Definition: solver.h:65
void set_nroot(int nroot)
Set number of roots (defaults to 1)
Definition: solver.h:526
int nroot_
Number of desired roots.
Definition: solver.h:545
SharedMatrix a_
Subspace eigenvectors (nsubspace x nsubspace)
Definition: solver.h:308
Definition: solver.h:267
void initialize()
Definition: solver.cc:146
int nconverged_
The number of converged roots.
Definition: solver.h:560
void residuals()
Definition: solver.cc:1043
std::vector< std::vector< double > > E_
Current eigenvalues (nroots)
Definition: solver.h:452
void set_max_subspace(double max_subspace)
Set maximum subspace size (defaults to 6)
Definition: solver.h:376
void set_precondition_maxiter(int maxiter)
Definition: solver.h:418
void set_min_subspace(double min_subspace)
Set minimum subspace size, for collapse (defaults to 2)
Definition: solver.h:530
int nguess_
Number of guess vectors to use for subspace preconditioner.
Definition: solver.h:229
std::vector< std::shared_ptr< Vector > > b_
B vectors (nsubspace)
Definition: solver.h:454
int max_subspace_
Maximum allowed subspace size.
Definition: solver.h:434
virtual void solve()=0
void set_min_subspace(double min_subspace)
Set minimum subspace size, for collapse (defaults to 2)
Definition: solver.h:378
static std::shared_ptr< DLRXSolver > build_solver(Options &options, std::shared_ptr< RHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:1504
virtual void initialize()=0
std::shared_ptr< Vector > diag_
Diagonal of Hamiltonian.
Definition: solver.h:589
std::shared_ptr< UHamiltonian > H() const
Definition: solver.h:186
std::vector< std::shared_ptr< Vector > > d_
Correction vectors (nroots)
Definition: solver.h:587
SharedMatrix a_
Subspace eigenvectors (nsubspace x nsubspace)
Definition: solver.h:579
USolver(std::shared_ptr< UHamiltonian > H)
Reference to underlying RHamiltonian.
Definition: solver.cc:81
int debug_
Debug flag, defaults to 0.
Definition: solver.h:48
std::vector< bool > r_converged_
Which vectors are converged?
Definition: solver.h:216
CGRSolver(std::shared_ptr< RHamiltonian > H)
Definition: solver.cc:90
void subspaceDiagonalization()
Definition: solver.cc:938
DLUSolver(std::shared_ptr< UHamiltonian > H)
Constructor.
Definition: solver.cc:2208
virtual ~USolver()
Destructor.
Definition: solver.cc:86
RayleighRSolver(std::shared_ptr< RHamiltonian > H)
Constructor.
Definition: solver.cc:1320
void setup()
Definition: solver.cc:238
double norm_
Required norm for subspace expansion.
Definition: solver.h:432
void initialize()
Definition: solver.cc:1561
void set_nguess(int nguess)
Set number of guesses (defaults to 1)
Definition: solver.h:380
virtual void correctors()
Definition: solver.cc:1117
int maxiter_
Maximum number of iterations, defaults to 100.
Definition: solver.h:59
virtual ~DLRXSolver()
Destructor.
Definition: solver.cc:1501
const std::vector< std::vector< double > > & eigenvalues() const
Eigenvalues, by state/irrep.
Definition: solver.h:642
void set_quantity(const std::string &quantity)
Definition: solver.h:420
Definition: solver.h:191
void solve()
Definition: solver.cc:716
std::vector< std::shared_ptr< Vector > > s_
Sigma vectors (nsubspace)
Definition: solver.h:300
void guess()
Definition: solver.cc:1643
void subspaceCollapse()
Definition: solver.cc:2149
static std::shared_ptr< RayleighRSolver > build_solver(Options &options, std::shared_ptr< RHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:1331
virtual void print_header() const
Definition: solver.cc:684
int nguess_
Number of guess vectors to build.
Definition: solver.h:553
std::vector< double > r_nrm2_
Residual norm.
Definition: solver.h:212
void eigenvecs()
Definition: solver.cc:1861
std::vector< double > n_
Residual vector 2-norms (nroots)
Definition: solver.h:466
std::vector< std::vector< int > > A_inds_
Delta Subspace indices.
Definition: solver.h:304
void set_precondition(const std::string &precondition)
Set precondition type (specific to solver type)
Definition: solver.h:83
void residual()
Definition: solver.cc:371
void subspaceDiagonalization()
Definition: solver.cc:2731
void products_x()
Definition: solver.cc:386
void sigma()
Definition: solver.cc:2653
int iteration() const
What iteration is it?
Definition: solver.h:100
int nconverged_
The number of converged roots.
Definition: solver.h:289
void set_nguess(int nguess)
Definition: solver.h:264
void set_memory(unsigned long int memory)
Set maximum vector storage space (defaults to 0 MB =&gt; Unlimited storage)
Definition: solver.h:85
std::vector< std::shared_ptr< Vector > > b_
Force vectors.
Definition: solver.h:196
void set_precondition_steps(const std::string &steps)
Definition: solver.h:419
RSolver(std::shared_ptr< RHamiltonian > H)
Definition: solver.cc:72
virtual ~DLUSolver()
Destructor.
Definition: solver.cc:2221
void set_bench(int bench)
Bench flag (defaults to 0)
Definition: solver.h:95
Definition: liboptions.h:359
void guess()
Definition: solver.cc:311
std::vector< std::shared_ptr< Vector > > r_
Residual vectors.
Definition: solver.h:204
int nroot_
Number of desired roots.
Definition: solver.h:430
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:2409
void set_min_subspace(double min_subspace)
Set minimum subspace size, for collapse (defaults to 2)
Definition: solver.h:662
void subspaceExpansion()
Definition: solver.cc:3006
DLRSolver(std::shared_ptr< RHamiltonian > H)
Constructor.
Definition: solver.cc:628
std::vector< std::shared_ptr< Vector > > r_
Residual vectors (nroots)
Definition: solver.h:464
void print_header() const
Definition: solver.cc:1539
virtual unsigned long int memory_estimate()
Estimate of maximum memory usage (in doubles)
Definition: solver.h:632
std::string name_
Name of solver (set by subclasses)
Definition: solver.h:52
std::string precondition_
Preconditioner type.
Definition: solver.h:67
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:50
std::vector< std::shared_ptr< Vector > > c_
Current eigenvectors (nroots)
Definition: solver.h:450
int nguess_
Number of guess vectors to build.
Definition: solver.h:438
Definition: solver.h:160
void residuals()
Definition: solver.cc:1925
std::vector< std::shared_ptr< Vector > > c_
Current eigenvectors (nroots)
Definition: solver.h:294
int nconverged_
Number of converged vectors.
Definition: solver.h:218
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:89
std::vector< std::vector< int > > A_inds_
Delta Subspace indices.
Definition: solver.h:575
std::shared_ptr< Vector > l_
Subspace eigenvalues (nsubspace)
Definition: solver.h:462
std::vector< std::shared_ptr< Vector > > c_
Current eigenvectors (nroots)
Definition: solver.h:565
virtual ~DLRSolver()
Destructor.
Definition: solver.cc:640
int nsubspace_
The current subspace size.
Definition: solver.h:287
void set_max_subspace(double max_subspace)
Set maximum subspace size (defaults to 6)
Definition: solver.h:660
std::vector< std::shared_ptr< Vector > > & b()
Definition: solver.h:254
void guess()
Definition: solver.cc:789
void subspaceExpansion()
Definition: solver.cc:2057
std::string precondition_steps_
Definition: solver.h:392
std::vector< double > alpha_
Alpha values.
Definition: solver.h:208
virtual void print_header() const =0
void solve()
Definition: solver.cc:2489
static std::shared_ptr< DLUSolver > build_solver(Options &options, std::shared_ptr< UHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:2225
bool converged() const
Did the solver converge?
Definition: solver.h:102
void check_convergence()
Definition: solver.cc:502
std::shared_ptr< Vector > diag_
Diagonal of Hamiltonian.
Definition: solver.h:470
int min_subspace_
Minimum allowed subspace size (after collapse)
Definition: solver.h:436
void set_nguess(int nguess)
Set number of guesses (defaults to 1)
Definition: solver.h:532
std::shared_ptr< Vector > l_
Subspace eigenvalues (nsubspace)
Definition: solver.h:581
void precondition(dpdfile2 *RIA, dpdfile2 *Ria, dpdbuf4 *RIJAB, dpdbuf4 *Rijab, dpdbuf4 *RIjAb, double eval)
Definition: precondition.cc:48
void residuals()
Definition: solver.cc:2839
static std::shared_ptr< DLRSolver > build_solver(Options &options, std::shared_ptr< RHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:643
std::vector< double > z_r_
z&#39;r
Definition: solver.h:214
void guess()
Definition: solver.cc:2564
void products_p()
Definition: solver.cc:406
Definition: PsiFileImpl.h:38
void set_norm(double norm)
Set norm critera for adding vectors to subspace (defaults to 1.0E-6)
Definition: solver.h:382
std::vector< std::vector< double > > E_
Current eigenvalues (nroots)
Definition: solver.h:567
void eigenvecs()
Definition: solver.cc:2778
DLRXSolver(std::shared_ptr< RHamiltonian > H)
Constructor.
Definition: solver.cc:1490
unsigned long int memory_estimate()
Estimate of maximum memory usage (in doubles)
Definition: solver.cc:1552
void subspaceCollapse()
Definition: solver.cc:3069
std::vector< double > n_
Residual vector 2-norms (nroots)
Definition: solver.h:314
void finalize()
Definition: solver.cc:777
std::shared_ptr< CGRSolver > cg_
Turn an eigenproblem into a linear equations problem.
Definition: solver.h:390
void set_nroot(int nroot)
Set number of roots (defaults to 1)
Definition: solver.h:658
int nroot_
Number of desired roots.
Definition: solver.h:274
void update_r()
Definition: solver.cc:482
std::vector< std::shared_ptr< Vector > > Ap_
Product vectors.
Definition: solver.h:200
std::vector< std::shared_ptr< Vector > > & x()
Definition: solver.h:253
std::vector< double > beta_
Beta values.
Definition: solver.h:210
std::vector< std::shared_ptr< Vector > > s_
Sigma vectors (nsubspace)
Definition: solver.h:456
double criteria_
Convergence criteria, defaults to 1.0E-6.
Definition: solver.h:57
std::vector< std::shared_ptr< Vector > > r_
Residual vectors (nroots)
Definition: solver.h:312
std::vector< double > n_
Residual vector 2-norms (nroots)
Definition: solver.h:585
void subspaceHamiltonian()
Definition: solver.cc:1705
void set_Hamiltonian(std::shared_ptr< RHamiltonian > H)
Definition: solver.h:151
void subspaceHamiltonian()
Definition: solver.cc:2699