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 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 
46 // => BASE CLASSES <= //
47 
48 protected:
49 
51  int print_;
53  int debug_;
55  int bench_;
57  std::string name_;
59  size_t memory_;
60 
62  double criteria_;
64  int maxiter_;
66  bool converged_;
68  double convergence_;
72  std::string precondition_;
73 
75  void common_init();
76 
77 public:
78  // => Constructors < = //
79 
81  Solver();
83  virtual ~Solver();
84 
85  // => Knobs <= //
86 
88  void set_precondition(const std::string& precondition) { precondition_ = precondition; }
90  void set_memory(size_t memory) { memory_ = memory; }
92  void set_maxiter(int maxiter) { maxiter_ = maxiter; }
94  void set_convergence(double criteria) { criteria_ = criteria; }
96  void set_print(int print) { print_ = print; }
98  void set_debug(int debug) { debug_ = debug; }
100  void set_bench(int bench) { bench_ = bench; }
101 
102  // => Accessors <= //
103 
105  int iteration() const { return iteration_; }
107  bool converged() const { return converged_; }
112  virtual void print_header() const = 0;
114  virtual size_t memory_estimate() = 0;
115 
116  // => Computers <= //
117 
122  virtual void initialize() = 0;
127  virtual void solve() = 0;
132  virtual void finalize() = 0;
133 
134 
135 };
136 
137 class RSolver : public Solver {
138 
139 protected:
141  std::shared_ptr<RHamiltonian> H_;
142 
143 public:
144  // => Constructors < = //
145 
146  RSolver(std::shared_ptr<RHamiltonian> H);
148  virtual ~RSolver();
149 
150  // => Accessors <= //
151 
156  void set_Hamiltonian(std::shared_ptr<RHamiltonian> H) { H_ = H; }
157 
162  std::shared_ptr<RHamiltonian> H() const { return H_; }
163 };
164 
165 class USolver : public Solver {
166 
167 protected:
169  std::shared_ptr<UHamiltonian> H_;
170 
171 public:
172  // => Constructors < = //
173 
175  USolver(std::shared_ptr<UHamiltonian> H);
177  virtual ~USolver();
178 
179  // => Accessors <= //
180 
185  void set_Hamiltonian(std::shared_ptr<UHamiltonian> H) { H_ = H; }
186 
191  std::shared_ptr<UHamiltonian> H() const { return H_; }
192 };
193 
194 // => APPLIED CLASSES <= //
195 
196 class CGRSolver : public RSolver {
197 
198 protected:
199 
201  std::vector<std::shared_ptr<Vector> > b_;
203  std::vector<std::shared_ptr<Vector> > x_;
205  std::vector<std::shared_ptr<Vector> > Ap_;
207  std::vector<std::shared_ptr<Vector> > z_;
209  std::vector<std::shared_ptr<Vector> > r_;
211  std::vector<std::shared_ptr<Vector> > p_;
213  std::vector<double> alpha_;
215  std::vector<double> beta_;
217  std::vector<double> r_nrm2_;
219  std::vector<double> z_r_;
221  std::vector<bool> r_converged_;
224 
226  std::shared_ptr<Vector> diag_;
230  std::vector<std::vector<int> > A_inds_;
232  std::vector<std::vector<double> > shifts_;
234  int nguess_;
235 
236  void setup();
237  void guess();
238  void residual();
239  void products_x();
240  void products_p();
241  void alpha();
242  void update_x();
243  void update_r();
244  void check_convergence();
245  void update_z();
246  void beta();
247  void update_p();
248 
249 public:
250 
251  CGRSolver(std::shared_ptr<RHamiltonian> H);
252  virtual ~CGRSolver();
253 
255  static std::shared_ptr<CGRSolver> build_solver(Options& options,
256  std::shared_ptr<RHamiltonian> H);
257 
258  std::vector<std::shared_ptr<Vector> >& x() { return x_; }
259  std::vector<std::shared_ptr<Vector> >& b() { return b_; }
260 
261  void print_header() const;
262  size_t memory_estimate();
263  void initialize();
264  void solve();
265  void finalize();
266 
267  void set_shifts(const std::vector<std::vector<double> >& shifts) { shifts_ = shifts; }
268  void set_A(SharedMatrix A, const std::vector<std::vector<int> > inds) { A_ = A; A_inds_ = inds; }
269  void set_nguess(int nguess) { nguess_ = nguess; }
270 };
271 
272 class DLRSolver : public RSolver {
273 
274 protected:
275 
276  // => Control parameters <= //
277 
279  int nroot_;
281  double norm_;
287  int nguess_;
288 
289  // => Iteration values <= //
290 
295 
296  // => State values <= //
297 
299  std::vector<std::shared_ptr<Vector> > c_;
301  std::vector<std::vector<double> > E_;
303  std::vector<std::shared_ptr<Vector> > b_;
305  std::vector<std::shared_ptr<Vector> > s_;
309  std::vector<std::vector<int> > A_inds_;
315  std::shared_ptr<Vector> l_;
317  std::vector<std::shared_ptr<Vector> > r_;
319  std::vector<double> n_;
321  std::vector<std::shared_ptr<Vector> > d_;
323  std::shared_ptr<Vector> diag_;
324 
325  // => Run routines <= //
326 
327  // Guess, based on diagonal
328  void guess();
329  // Compute sigma vectors for the given set of b
330  void sigma();
331  // Compute subspace Hamiltonian
332  void subspaceHamiltonian();
333  // Diagonalize subspace Hamiltonian
335  // Find eigenvectors
336  void eigenvecs();
337  // Find eigenvalues
338  void eigenvals();
339  // Find residuals, update convergence
340  void residuals();
341  // Find correctors
342  virtual void correctors();
343  // Orthogonalize/add significant correctors
344  void subspaceExpansion();
345  // Collapse subspace if needed
346  void subspaceCollapse();
347 
348 public:
349 
350  // => Constructors <= //
351 
353  DLRSolver(std::shared_ptr<RHamiltonian> H);
355  virtual ~DLRSolver();
356 
358  static std::shared_ptr<DLRSolver> build_solver(Options& options,
359  std::shared_ptr<RHamiltonian> H);
360 
361  // => Required Methods <= //
362 
363  virtual void print_header() const;
364  virtual size_t memory_estimate();
365  virtual void initialize();
366  void solve();
367  void finalize();
368 
369  // => Accessors <= //
370 
372  const std::vector<std::shared_ptr<Vector> >& eigenvectors() const { return c_; }
374  const std::vector<std::vector<double> >& eigenvalues() const { return E_; }
375 
376  // => Knobs <= //
377 
379  void set_nroot(int nroot) { nroot_ = nroot; }
381  void set_max_subspace(double max_subspace) { max_subspace_ = max_subspace; }
383  void set_min_subspace(double min_subspace) { min_subspace_ = min_subspace; }
385  void set_nguess(int nguess) { nguess_ = nguess; }
387  void set_norm(double norm) { norm_ = norm; }
388 };
389 
390 class RayleighRSolver : public DLRSolver {
391 
392 protected:
393 
395  std::shared_ptr<CGRSolver> cg_;
396 
397  std::string precondition_steps_;
399  std::string quantity_;
400 
401  // Find correctors (Like, the most advanced correctors ever)
402  void correctors();
403 
404 public:
405 
406  // => Constructors <= //
407 
409  RayleighRSolver(std::shared_ptr<RHamiltonian> H);
411  virtual ~RayleighRSolver();
412 
414  static std::shared_ptr<RayleighRSolver> build_solver(Options& options,
415  std::shared_ptr<RHamiltonian> H);
416 
417  // => Required Methods <= //
418 
419  void print_header() const;
420  void initialize();
421  void finalize();
422 
423  void set_precondition_maxiter(int maxiter) { precondition_maxiter_ = maxiter; }
424  void set_precondition_steps(const std::string& steps) { precondition_steps_ = steps; }
425  void set_quantity(const std::string& quantity) { quantity_ = quantity; }
426 };
427 
428 class DLRXSolver : public RSolver {
429 
430 protected:
431 
432  // => Control parameters <= //
433 
435  int nroot_;
437  double norm_;
443  int nguess_;
444 
445  // => Iteration values <= //
446 
451 
452  // => State values <= //
453 
455  std::vector<std::shared_ptr<Vector> > c_;
457  std::vector<std::vector<double> > E_;
459  std::vector<std::shared_ptr<Vector> > b_;
461  std::vector<std::shared_ptr<Vector> > s_;
467  std::shared_ptr<Vector> l_;
469  std::vector<std::shared_ptr<Vector> > r_;
471  std::vector<double> n_;
473  std::vector<std::shared_ptr<Vector> > d_;
475  std::shared_ptr<Vector> diag_;
476 
477  // => Run routines <= //
478 
479  // Guess, based on diagonal
480  void guess();
481  // Compute sigma vectors
482  void sigma();
483  // Compute subspace Hamiltonian
484  void subspaceHamiltonian();
485  // Diagonalize subspace Hamiltonian
487  // Find eigenvectors
488  void eigenvecs();
489  // Find eigenvalues
490  void eigenvals();
491  // Find residuals, update convergence
492  void residuals();
493  // Find correctors
494  void correctors();
495  // Orthogonalize/add significant correctors
496  void subspaceExpansion();
497  // Collapse subspace if needed
498  void subspaceCollapse();
499 
500 public:
501 
502  // => Constructors <= //
503 
505  DLRXSolver(std::shared_ptr<RHamiltonian> H);
507  virtual ~DLRXSolver();
508 
510  static std::shared_ptr<DLRXSolver> build_solver(Options& options,
511  std::shared_ptr<RHamiltonian> H);
512 
513  // => Required Methods <= //
514 
515  void print_header() const;
516  size_t memory_estimate();
517  void initialize();
518  void solve();
519  void finalize();
520 
521  // => Accessors <= //
522 
524  const std::vector<std::shared_ptr<Vector> >& eigenvectors() const { return c_; }
526  const std::vector<std::vector<double> >& eigenvalues() const { return E_; }
527 
528  // => Knobs <= //
529 
531  void set_nroot(int nroot) { nroot_ = nroot; }
533  void set_max_subspace(double max_subspace) { max_subspace_ = max_subspace; }
535  void set_min_subspace(double min_subspace) { min_subspace_ = min_subspace; }
537  void set_nguess(int nguess) { nguess_ = nguess; }
539  void set_norm(double norm) { norm_ = norm; }
540 };
541 
542 // Class for solving UHF stability analysis.
543 class DLUSolver : public USolver {
544 
545 protected:
546 
547  // => Control parameters <= //
548 
550  int nroot_;
552  double norm_;
558  int nguess_;
559 
560  // => Iteration values <= //
561 
566 
567  // => State values <= //
568 
570  std::vector<std::shared_ptr<Vector> > c_;
572  std::vector<std::vector<double> > E_;
574  std::vector<std::shared_ptr<Vector> > b_;
576  std::vector<std::shared_ptr<Vector> > s_;
580  std::vector<std::vector<int> > A_inds_;
586  std::shared_ptr<Vector> l_;
588  std::vector<std::shared_ptr<Vector> > r_;
590  std::vector<double> n_;
592  std::vector<std::shared_ptr<Vector> > d_;
594  std::shared_ptr<Vector> diag_;
596  std::pair< std::shared_ptr<Vector>, std::shared_ptr<Vector> > diag_components;
597 
598  // => Run routines <= //
599 
600  // Guess, based on diagonal
601  void guess();
602  // Compute sigma vectors for the given set of b
603  void sigma();
604  // Compute subspace Hamiltonian
605  void subspaceHamiltonian();
606  // Diagonalize subspace Hamiltonian
608  // Find eigenvectors
609  void eigenvecs();
610  // Find eigenvalues
611  void eigenvals();
612  // Find residuals, update convergence
613  void residuals();
614  // Find correctors
615  virtual void correctors();
616  // Orthogonalize/add significant correctors
617  void subspaceExpansion();
618  // Collapse subspace if needed
619  void subspaceCollapse();
620 
621 public:
622 
623  // => Constructors <= //
624 
626  DLUSolver(std::shared_ptr<UHamiltonian> H);
628  virtual ~DLUSolver();
629 
631  static std::shared_ptr<DLUSolver> build_solver(Options& options,
632  std::shared_ptr<UHamiltonian> H);
633 
634  // => Required Methods <= //
635 
636  virtual void print_header() const;
637  virtual size_t memory_estimate(){ return 0;};
638  virtual void initialize();
639  void solve();
640  void finalize();
641 
642  // => Accessors <= //
643 
645  const std::vector<std::shared_ptr<Vector> >& eigenvectors() const { return c_; }
647  const std::vector<std::vector<double> >& eigenvalues() const { return E_; }
649  std::shared_ptr<Vector> contract_pair(
650  std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > components );
651  void contract_pair(
652  std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > components,
653  std::shared_ptr<Vector> result);
655  std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > expand_pair(
656  std::shared_ptr<Vector> vec);
657  void expand_pair(std::shared_ptr<Vector> vec,
658  std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > result);
659 
660  // => Knobs <= //
661 
663  void set_nroot(int nroot) { nroot_ = nroot; }
665  void set_max_subspace(double max_subspace) { max_subspace_ = max_subspace; }
667  void set_min_subspace(double min_subspace) { min_subspace_ = min_subspace; }
669  void set_nguess(int nguess) { nguess_ = nguess; }
671  void set_norm(double norm) { norm_ = norm; }
672 
673 };
674 
675 
676 }
677 #endif
std::vector< std::shared_ptr< Vector > > p_
Conjugate directions.
Definition: solver.h:211
virtual void correctors()
Definition: solver.cc:2915
const std::vector< std::shared_ptr< Vector > > & eigenvectors() const
Eigenvectors, by state.
Definition: solver.h:524
std::string quantity_
Definition: solver.h:399
void solve()
Definition: solver.cc:177
void common_init()
Common initialization.
Definition: solver.cc:57
int bench_
Bench flag, defaults to 0.
Definition: solver.h:55
const std::vector< std::vector< double > > & eigenvalues() const
Eigenvalues, by state/irrep.
Definition: solver.h:374
int nsubspace_
The current subspace size.
Definition: solver.h:563
std::shared_ptr< Vector > l_
Subspace eigenvalues (nsubspace)
Definition: solver.h:315
int nguess_
Number of guess vectors to build.
Definition: solver.h:287
Definition: solver.h:543
std::shared_ptr< Vector > diag_
Diagonal of Hamiltonian.
Definition: solver.h:323
void subspaceDiagonalization()
Definition: solver.cc:1751
virtual ~RayleighRSolver()
Destructor.
Definition: solver.cc:1329
void finalize()
Definition: solver.cc:2552
void eigenvecs()
Definition: solver.cc:985
virtual void finalize()=0
SharedMatrix A_
Delta Subspace Hamiltonian (preconditioner)
Definition: solver.h:307
void eigenvals()
Definition: solver.cc:1904
SharedMatrix A_
Delta Subspace Hamiltonian (preconditioner)
Definition: solver.h:578
std::vector< std::shared_ptr< Vector > > s_
Sigma vectors (nsubspace)
Definition: solver.h:576
std::vector< std::vector< double > > shifts_
Shifts (to solve (A-mI)
Definition: solver.h:232
Definition: solver.h:137
virtual size_t memory_estimate()
Estimate of maximum memory usage (in doubles)
Definition: solver.cc:699
SharedMatrix G_
G_ij Subspace Hamiltonian (nsubspace x nsubspace)
Definition: solver.h:463
const std::vector< std::shared_ptr< Vector > > & eigenvectors() const
Eigenvectors, by state.
Definition: solver.h:645
void update_p()
Definition: solver.cc:613
int min_subspace_
Minimum allowed subspace size (after collapse)
Definition: solver.h:285
void eigenvals()
Definition: solver.cc:2817
Definition: solver.h:390
void set_Hamiltonian(std::shared_ptr< UHamiltonian > H)
Definition: solver.h:185
void set_norm(double norm)
Set norm critera for adding vectors to subspace (defaults to 1.0E-6)
Definition: solver.h:539
virtual void initialize()
Definition: solver.cc:708
void set_debug(int debug)
Debug flag (defaults to 0)
Definition: solver.h:98
void eigenvals()
Definition: solver.cc:1022
virtual void initialize()
Definition: solver.cc:2301
SharedMatrix a_
Subspace eigenvectors (nsubspace x nsubspace)
Definition: solver.h:465
std::vector< std::vector< double > > E_
Current eigenvalues (nroots)
Definition: solver.h:301
Definition: solver.h:428
std::vector< std::shared_ptr< Vector > > d_
Correction vectors (nroots)
Definition: solver.h:321
void beta()
Definition: solver.cc:591
void correctors()
Definition: solver.cc:1415
double norm_
Required norm for subspace expansion.
Definition: solver.h:281
void update_x()
Definition: solver.cc:463
double convergence_
Convergence measure at this iteration.
Definition: solver.h:68
void set_shifts(const std::vector< std::vector< double > > &shifts)
Definition: solver.h:267
void solve()
Definition: solver.cc:1571
void set_norm(double norm)
Set norm critera for adding vectors to subspace (defaults to 1.0E-6)
Definition: solver.h:671
std::shared_ptr< UHamiltonian > H_
Reference to underlying UHamiltonian.
Definition: solver.h:169
void alpha()
Definition: solver.cc:437
void set_maxiter(int maxiter)
Set maximum number of iterations (defaults to 100)
Definition: solver.h:92
std::vector< std::vector< int > > A_inds_
A subspace indices.
Definition: solver.h:230
virtual void print_header() const
Definition: solver.cc:2272
int min_subspace_
Minimum allowed subspace size (after collapse)
Definition: solver.h:556
std::vector< std::shared_ptr< Vector > > r_
Residual vectors (nroots)
Definition: solver.h:588
void finalize()
Definition: solver.cc:1410
void initialize()
Definition: solver.cc:1404
Definition: solver.h:44
void set_nroot(int nroot)
Set number of roots (defaults to 1)
Definition: solver.h:379
void finalize()
Definition: solver.cc:1632
virtual size_t memory_estimate()
Estimate of maximum memory usage (in doubles)
Definition: solver.h:637
std::vector< std::shared_ptr< Vector > > x_
Solution vectors.
Definition: solver.h:203
SharedMatrix G_
G_ij Subspace Hamiltonian (nsubspace x nsubspace)
Definition: solver.h:311
int print_
Print flag, defaults to 1.
Definition: solver.h:51
void print_header() const
Definition: solver.cc:1382
void finalize()
Definition: solver.cc:226
std::vector< std::shared_ptr< Vector > > b_
B vectors (nsubspace)
Definition: solver.h:574
Solver()
Default Constructor.
Definition: solver.cc:50
std::vector< std::shared_ptr< Vector > > d_
Correction vectors (nroots)
Definition: solver.h:473
const std::vector< std::vector< double > > & eigenvalues() const
Eigenvalues, by state/irrep.
Definition: solver.h:526
virtual ~RSolver()
Destructor.
Definition: solver.cc:78
int nsubspace_
The current subspace size.
Definition: solver.h:448
void set_print(int print)
Print flag (defaults to 1)
Definition: solver.h:96
void set_A(SharedMatrix A, const std::vector< std::vector< int > > inds)
Definition: solver.h:268
int nconverged_
The number of converged roots.
Definition: solver.h:450
int max_subspace_
Maximum allowed subspace size.
Definition: solver.h:554
std::shared_ptr< Vector > diag_
Diagonal M, for guess and Jacobi preconditioning.
Definition: solver.h:226
int precondition_maxiter_
Definition: solver.h:398
const std::vector< std::shared_ptr< Vector > > & eigenvectors() const
Eigenvectors, by state.
Definition: solver.h:372
void subspaceHamiltonian()
Definition: solver.cc:907
SharedMatrix G_
G_ij Subspace Hamiltonian (nsubspace x nsubspace)
Definition: solver.h:582
std::vector< std::shared_ptr< Vector > > z_
M^-1 x.
Definition: solver.h:207
SharedMatrix A_
A subspace matrix, for preconditioning.
Definition: solver.h:228
virtual ~CGRSolver()
Definition: solver.cc:97
double norm_
Required norm for subspace expansion.
Definition: solver.h:552
void sigma()
Definition: solver.cc:1678
std::vector< std::shared_ptr< Vector > > b_
B vectors (nsubspace)
Definition: solver.h:303
int max_subspace_
Maximum allowed subspace size.
Definition: solver.h:283
void subspaceCollapse()
Definition: solver.cc:1271
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:2340
void subspaceExpansion()
Definition: solver.cc:1209
void sigma()
Definition: solver.cc:879
static std::shared_ptr< CGRSolver > build_solver(Options &options, std::shared_ptr< RHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:100
bool converged_
Converged or not?
Definition: solver.h:66
void set_nguess(int nguess)
Set number of guesses (defaults to 1)
Definition: solver.h:669
void set_max_subspace(double max_subspace)
Set maximum subspace size (defaults to 6)
Definition: solver.h:533
void update_z()
Definition: solver.cc:531
std::pair< std::shared_ptr< Vector >, std::shared_ptr< Vector > > diag_components
Diagonal components of UHamiltonian.
Definition: solver.h:596
std::shared_ptr< RHamiltonian > H_
Reference to underlying RHamiltonian.
Definition: solver.h:141
void correctors()
Definition: solver.cc:2001
virtual ~Solver()
Destructor.
Definition: solver.cc:54
void print_header() const
Definition: solver.cc:128
int iteration_
Current iteration count.
Definition: solver.h:70
void set_nroot(int nroot)
Set number of roots (defaults to 1)
Definition: solver.h:531
int nroot_
Number of desired roots.
Definition: solver.h:550
SharedMatrix a_
Subspace eigenvectors (nsubspace x nsubspace)
Definition: solver.h:313
Definition: solver.h:272
void initialize()
Definition: solver.cc:147
int nconverged_
The number of converged roots.
Definition: solver.h:565
void residuals()
Definition: solver.cc:1044
std::vector< std::vector< double > > E_
Current eigenvalues (nroots)
Definition: solver.h:457
void set_max_subspace(double max_subspace)
Set maximum subspace size (defaults to 6)
Definition: solver.h:381
void set_precondition_maxiter(int maxiter)
Definition: solver.h:423
void set_min_subspace(double min_subspace)
Set minimum subspace size, for collapse (defaults to 2)
Definition: solver.h:535
int nguess_
Number of guess vectors to use for subspace preconditioner.
Definition: solver.h:234
std::vector< std::shared_ptr< Vector > > b_
B vectors (nsubspace)
Definition: solver.h:459
int max_subspace_
Maximum allowed subspace size.
Definition: solver.h:439
virtual void solve()=0
void set_min_subspace(double min_subspace)
Set minimum subspace size, for collapse (defaults to 2)
Definition: solver.h:383
static std::shared_ptr< DLRXSolver > build_solver(Options &options, std::shared_ptr< RHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:1505
virtual void initialize()=0
std::shared_ptr< Vector > diag_
Diagonal of Hamiltonian.
Definition: solver.h:594
std::shared_ptr< UHamiltonian > H() const
Definition: solver.h:191
std::vector< std::shared_ptr< Vector > > d_
Correction vectors (nroots)
Definition: solver.h:592
SharedMatrix a_
Subspace eigenvectors (nsubspace x nsubspace)
Definition: solver.h:584
USolver(std::shared_ptr< UHamiltonian > H)
Reference to underlying RHamiltonian.
Definition: solver.cc:82
int debug_
Debug flag, defaults to 0.
Definition: solver.h:53
std::vector< bool > r_converged_
Which vectors are converged?
Definition: solver.h:221
CGRSolver(std::shared_ptr< RHamiltonian > H)
Definition: solver.cc:91
void subspaceDiagonalization()
Definition: solver.cc:939
DLUSolver(std::shared_ptr< UHamiltonian > H)
Constructor.
Definition: solver.cc:2209
virtual ~USolver()
Destructor.
Definition: solver.cc:87
RayleighRSolver(std::shared_ptr< RHamiltonian > H)
Constructor.
Definition: solver.cc:1321
void setup()
Definition: solver.cc:239
virtual size_t memory_estimate()=0
Estimate of maximum memory usage (in doubles)
double norm_
Required norm for subspace expansion.
Definition: solver.h:437
void initialize()
Definition: solver.cc:1562
void set_nguess(int nguess)
Set number of guesses (defaults to 1)
Definition: solver.h:385
size_t memory_
Memory available, in doubles, defaults to 0 =&gt; Unlimited storage.
Definition: solver.h:59
virtual void correctors()
Definition: solver.cc:1118
size_t memory_estimate()
Estimate of maximum memory usage (in doubles)
Definition: solver.cc:1553
int maxiter_
Maximum number of iterations, defaults to 100.
Definition: solver.h:64
virtual ~DLRXSolver()
Destructor.
Definition: solver.cc:1502
const std::vector< std::vector< double > > & eigenvalues() const
Eigenvalues, by state/irrep.
Definition: solver.h:647
void set_quantity(const std::string &quantity)
Definition: solver.h:425
Definition: solver.h:196
void solve()
Definition: solver.cc:717
std::vector< std::shared_ptr< Vector > > s_
Sigma vectors (nsubspace)
Definition: solver.h:305
void guess()
Definition: solver.cc:1644
void subspaceCollapse()
Definition: solver.cc:2150
static std::shared_ptr< RayleighRSolver > build_solver(Options &options, std::shared_ptr< RHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:1332
virtual void print_header() const
Definition: solver.cc:685
int nguess_
Number of guess vectors to build.
Definition: solver.h:558
std::vector< double > r_nrm2_
Residual norm.
Definition: solver.h:217
void eigenvecs()
Definition: solver.cc:1862
std::vector< double > n_
Residual vector 2-norms (nroots)
Definition: solver.h:471
std::vector< std::vector< int > > A_inds_
Delta Subspace indices.
Definition: solver.h:309
void set_precondition(const std::string &precondition)
Set precondition type (specific to solver type)
Definition: solver.h:88
void residual()
Definition: solver.cc:372
void subspaceDiagonalization()
Definition: solver.cc:2732
void products_x()
Definition: solver.cc:387
void sigma()
Definition: solver.cc:2654
int iteration() const
What iteration is it?
Definition: solver.h:105
int nconverged_
The number of converged roots.
Definition: solver.h:294
void set_nguess(int nguess)
Definition: solver.h:269
std::vector< std::shared_ptr< Vector > > b_
Force vectors.
Definition: solver.h:201
void set_precondition_steps(const std::string &steps)
Definition: solver.h:424
RSolver(std::shared_ptr< RHamiltonian > H)
Definition: solver.cc:73
virtual ~DLUSolver()
Destructor.
Definition: solver.cc:2222
void set_bench(int bench)
Bench flag (defaults to 0)
Definition: solver.h:100
Definition: liboptions.h:355
void guess()
Definition: solver.cc:312
std::vector< std::shared_ptr< Vector > > r_
Residual vectors.
Definition: solver.h:209
int nroot_
Number of desired roots.
Definition: solver.h:435
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:2410
void set_min_subspace(double min_subspace)
Set minimum subspace size, for collapse (defaults to 2)
Definition: solver.h:667
void subspaceExpansion()
Definition: solver.cc:3007
DLRSolver(std::shared_ptr< RHamiltonian > H)
Constructor.
Definition: solver.cc:629
std::vector< std::shared_ptr< Vector > > r_
Residual vectors (nroots)
Definition: solver.h:469
void print_header() const
Definition: solver.cc:1540
std::string name_
Name of solver (set by subclasses)
Definition: solver.h:57
std::string precondition_
Preconditioner type.
Definition: solver.h:72
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
std::vector< std::shared_ptr< Vector > > c_
Current eigenvectors (nroots)
Definition: solver.h:455
int nguess_
Number of guess vectors to build.
Definition: solver.h:443
Definition: solver.h:165
void residuals()
Definition: solver.cc:1926
std::vector< std::shared_ptr< Vector > > c_
Current eigenvectors (nroots)
Definition: solver.h:299
int nconverged_
Number of converged vectors.
Definition: solver.h:223
std::shared_ptr< RHamiltonian > H() const
Definition: solver.h:162
void set_convergence(double criteria)
Set convergence criteria (defaults to 1.0E-6)
Definition: solver.h:94
std::vector< std::vector< int > > A_inds_
Delta Subspace indices.
Definition: solver.h:580
std::shared_ptr< Vector > l_
Subspace eigenvalues (nsubspace)
Definition: solver.h:467
void set_memory(size_t memory)
Set maximum vector storage space (defaults to 0 MB =&gt; Unlimited storage)
Definition: solver.h:90
std::vector< std::shared_ptr< Vector > > c_
Current eigenvectors (nroots)
Definition: solver.h:570
virtual ~DLRSolver()
Destructor.
Definition: solver.cc:641
int nsubspace_
The current subspace size.
Definition: solver.h:292
void set_max_subspace(double max_subspace)
Set maximum subspace size (defaults to 6)
Definition: solver.h:665
std::vector< std::shared_ptr< Vector > > & b()
Definition: solver.h:259
void guess()
Definition: solver.cc:790
void subspaceExpansion()
Definition: solver.cc:2058
std::string precondition_steps_
Definition: solver.h:397
std::vector< double > alpha_
Alpha values.
Definition: solver.h:213
virtual void print_header() const =0
void solve()
Definition: solver.cc:2490
static std::shared_ptr< DLUSolver > build_solver(Options &options, std::shared_ptr< UHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:2226
bool converged() const
Did the solver converge?
Definition: solver.h:107
void check_convergence()
Definition: solver.cc:503
std::shared_ptr< Vector > diag_
Diagonal of Hamiltonian.
Definition: solver.h:475
int min_subspace_
Minimum allowed subspace size (after collapse)
Definition: solver.h:441
void set_nguess(int nguess)
Set number of guesses (defaults to 1)
Definition: solver.h:537
std::shared_ptr< Vector > l_
Subspace eigenvalues (nsubspace)
Definition: solver.h:586
void precondition(dpdfile2 *RIA, dpdfile2 *Ria, dpdbuf4 *RIJAB, dpdbuf4 *Rijab, dpdbuf4 *RIjAb, double eval)
Definition: precondition.cc:49
void residuals()
Definition: solver.cc:2840
static std::shared_ptr< DLRSolver > build_solver(Options &options, std::shared_ptr< RHamiltonian > H)
Static constructor, uses Options object.
Definition: solver.cc:644
std::vector< double > z_r_
z&#39;r
Definition: solver.h:219
void guess()
Definition: solver.cc:2565
void products_p()
Definition: solver.cc:407
void set_norm(double norm)
Set norm critera for adding vectors to subspace (defaults to 1.0E-6)
Definition: solver.h:387
std::vector< std::vector< double > > E_
Current eigenvalues (nroots)
Definition: solver.h:572
void eigenvecs()
Definition: solver.cc:2779
DLRXSolver(std::shared_ptr< RHamiltonian > H)
Constructor.
Definition: solver.cc:1491
void subspaceCollapse()
Definition: solver.cc:3070
size_t memory_estimate()
Estimate of maximum memory usage (in doubles)
Definition: solver.cc:138
std::vector< double > n_
Residual vector 2-norms (nroots)
Definition: solver.h:319
void finalize()
Definition: solver.cc:778
std::shared_ptr< CGRSolver > cg_
Turn an eigenproblem into a linear equations problem.
Definition: solver.h:395
void set_nroot(int nroot)
Set number of roots (defaults to 1)
Definition: solver.h:663
int nroot_
Number of desired roots.
Definition: solver.h:279
void update_r()
Definition: solver.cc:483
std::vector< std::shared_ptr< Vector > > Ap_
Product vectors.
Definition: solver.h:205
std::vector< std::shared_ptr< Vector > > & x()
Definition: solver.h:258
std::vector< double > beta_
Beta values.
Definition: solver.h:215
std::vector< std::shared_ptr< Vector > > s_
Sigma vectors (nsubspace)
Definition: solver.h:461
double criteria_
Convergence criteria, defaults to 1.0E-6.
Definition: solver.h:62
std::vector< std::shared_ptr< Vector > > r_
Residual vectors (nroots)
Definition: solver.h:317
std::vector< double > n_
Residual vector 2-norms (nroots)
Definition: solver.h:590
void subspaceHamiltonian()
Definition: solver.cc:1706
void set_Hamiltonian(std::shared_ptr< RHamiltonian > H)
Definition: solver.h:156
void subspaceHamiltonian()
Definition: solver.cc:2700