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 namespace psi {
33 
34 class Vector;
35 class RHamiltonian;
36 class UHamiltonian;
37 
38 class Solver {
39 
40 // => BASE CLASSES <= //
41 
42 protected:
43 
45  int print_;
47  int debug_;
49  int bench_;
51  std::string name_;
53  unsigned long int memory_;
54 
56  double criteria_;
58  int maxiter_;
60  bool converged_;
62  double convergence_;
66  std::string precondition_;
67 
69  void common_init();
70 
71 public:
72  // => Constructors < = //
73 
75  Solver();
77  virtual ~Solver();
78 
79  // => Knobs <= //
80 
82  void set_precondition(const std::string& precondition) { precondition_ = precondition; }
84  void set_memory(unsigned long int memory) { memory_ = memory; }
86  void set_maxiter(int maxiter) { maxiter_ = maxiter; }
88  void set_convergence(double criteria) { criteria_ = criteria; }
90  void set_print(int print) { print_ = print; }
92  void set_debug(int debug) { debug_ = debug; }
94  void set_bench(int bench) { bench_ = bench; }
95 
96  // => Accessors <= //
97 
99  int iteration() const { return iteration_; }
101  bool converged() const { return converged_; }
106  virtual void print_header() const = 0;
108  virtual unsigned long int memory_estimate() = 0;
109 
110  // => Computers <= //
111 
116  virtual void initialize() = 0;
121  virtual void solve() = 0;
126  virtual void finalize() = 0;
127 
128 
129 };
130 
131 class RSolver : public Solver {
132 
133 protected:
135  std::shared_ptr<RHamiltonian> H_;
136 
137 public:
138  // => Constructors < = //
139 
140  RSolver(std::shared_ptr<RHamiltonian> H);
142  virtual ~RSolver();
143 
144  // => Accessors <= //
145 
150  void set_Hamiltonian(std::shared_ptr<RHamiltonian> H) { H_ = H; }
151 
156  std::shared_ptr<RHamiltonian> H() const { return H_; }
157 };
158 
159 class USolver : public Solver {
160 
161 protected:
163  std::shared_ptr<UHamiltonian> H_;
164 
165 public:
166  // => Constructors < = //
167 
169  USolver(std::shared_ptr<UHamiltonian> H);
171  virtual ~USolver();
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 
192 protected:
193 
195  std::vector<std::shared_ptr<Vector> > b_;
197  std::vector<std::shared_ptr<Vector> > x_;
199  std::vector<std::shared_ptr<Vector> > Ap_;
201  std::vector<std::shared_ptr<Vector> > z_;
203  std::vector<std::shared_ptr<Vector> > r_;
205  std::vector<std::shared_ptr<Vector> > p_;
207  std::vector<double> alpha_;
209  std::vector<double> beta_;
211  std::vector<double> r_nrm2_;
213  std::vector<double> z_r_;
215  std::vector<bool> r_converged_;
218 
220  std::shared_ptr<Vector> diag_;
224  std::vector<std::vector<int> > A_inds_;
226  std::vector<std::vector<double> > shifts_;
228  int nguess_;
229 
230  void setup();
231  void guess();
232  void residual();
233  void products_x();
234  void products_p();
235  void alpha();
236  void update_x();
237  void update_r();
238  void check_convergence();
239  void update_z();
240  void beta();
241  void update_p();
242 
243 public:
244 
245  CGRSolver(std::shared_ptr<RHamiltonian> H);
246  virtual ~CGRSolver();
247 
249  static std::shared_ptr<CGRSolver> build_solver(Options& options,
250  std::shared_ptr<RHamiltonian> H);
251 
252  std::vector<std::shared_ptr<Vector> >& x() { return x_; }
253  std::vector<std::shared_ptr<Vector> >& b() { return b_; }
254 
255  void print_header() const;
256  unsigned long int memory_estimate();
257  void initialize();
258  void solve();
259  void finalize();
260 
261  void set_shifts(const std::vector<std::vector<double> >& shifts) { shifts_ = shifts; }
262  void set_A(SharedMatrix A, const std::vector<std::vector<int> > inds) { A_ = A; A_inds_ = inds; }
263  void set_nguess(int nguess) { nguess_ = nguess; }
264 };
265 
266 class DLRSolver : public RSolver {
267 
268 protected:
269 
270  // => Control parameters <= //
271 
273  int nroot_;
275  double norm_;
281  int nguess_;
282 
283  // => Iteration values <= //
284 
289 
290  // => State values <= //
291 
293  std::vector<std::shared_ptr<Vector> > c_;
295  std::vector<std::vector<double> > E_;
297  std::vector<std::shared_ptr<Vector> > b_;
299  std::vector<std::shared_ptr<Vector> > s_;
303  std::vector<std::vector<int> > A_inds_;
309  std::shared_ptr<Vector> l_;
311  std::vector<std::shared_ptr<Vector> > r_;
313  std::vector<double> n_;
315  std::vector<std::shared_ptr<Vector> > d_;
317  std::shared_ptr<Vector> diag_;
318 
319  // => Run routines <= //
320 
321  // Guess, based on diagonal
322  void guess();
323  // Compute sigma vectors for the given set of b
324  void sigma();
325  // Compute subspace Hamiltonian
326  void subspaceHamiltonian();
327  // Diagonalize subspace Hamiltonian
329  // Find eigenvectors
330  void eigenvecs();
331  // Find eigenvalues
332  void eigenvals();
333  // Find residuals, update convergence
334  void residuals();
335  // Find correctors
336  virtual void correctors();
337  // Orthogonalize/add significant correctors
338  void subspaceExpansion();
339  // Collapse subspace if needed
340  void subspaceCollapse();
341 
342 public:
343 
344  // => Constructors <= //
345 
347  DLRSolver(std::shared_ptr<RHamiltonian> H);
349  virtual ~DLRSolver();
350 
352  static std::shared_ptr<DLRSolver> build_solver(Options& options,
353  std::shared_ptr<RHamiltonian> H);
354 
355  // => Required Methods <= //
356 
357  virtual void print_header() const;
358  virtual unsigned long int memory_estimate();
359  virtual void initialize();
360  void solve();
361  void finalize();
362 
363  // => Accessors <= //
364 
366  const std::vector<std::shared_ptr<Vector> >& eigenvectors() const { return c_; }
368  const std::vector<std::vector<double> >& eigenvalues() const { return E_; }
369 
370  // => Knobs <= //
371 
373  void set_nroot(int nroot) { nroot_ = nroot; }
375  void set_max_subspace(double max_subspace) { max_subspace_ = max_subspace; }
377  void set_min_subspace(double min_subspace) { min_subspace_ = min_subspace; }
379  void set_nguess(int nguess) { nguess_ = nguess; }
381  void set_norm(double norm) { norm_ = norm; }
382 };
383 
384 class RayleighRSolver : public DLRSolver {
385 
386 protected:
387 
389  std::shared_ptr<CGRSolver> cg_;
390 
391  std::string precondition_steps_;
393  std::string quantity_;
394 
395  // Find correctors (Like, the most advanced correctors ever)
396  void correctors();
397 
398 public:
399 
400  // => Constructors <= //
401 
403  RayleighRSolver(std::shared_ptr<RHamiltonian> H);
405  virtual ~RayleighRSolver();
406 
408  static std::shared_ptr<RayleighRSolver> build_solver(Options& options,
409  std::shared_ptr<RHamiltonian> H);
410 
411  // => Required Methods <= //
412 
413  void print_header() const;
414  void initialize();
415  void finalize();
416 
417  void set_precondition_maxiter(int maxiter) { precondition_maxiter_ = maxiter; }
418  void set_precondition_steps(const std::string& steps) { precondition_steps_ = steps; }
419  void set_quantity(const std::string& quantity) { quantity_ = quantity; }
420 };
421 
422 class DLRXSolver : public RSolver {
423 
424 protected:
425 
426  // => Control parameters <= //
427 
429  int nroot_;
431  double norm_;
437  int nguess_;
438 
439  // => Iteration values <= //
440 
445 
446  // => State values <= //
447 
449  std::vector<std::shared_ptr<Vector> > c_;
451  std::vector<std::vector<double> > E_;
453  std::vector<std::shared_ptr<Vector> > b_;
455  std::vector<std::shared_ptr<Vector> > s_;
461  std::shared_ptr<Vector> l_;
463  std::vector<std::shared_ptr<Vector> > r_;
465  std::vector<double> n_;
467  std::vector<std::shared_ptr<Vector> > d_;
469  std::shared_ptr<Vector> diag_;
470 
471  // => Run routines <= //
472 
473  // Guess, based on diagonal
474  void guess();
475  // Compute sigma vectors
476  void sigma();
477  // Compute subspace Hamiltonian
478  void subspaceHamiltonian();
479  // Diagonalize subspace Hamiltonian
481  // Find eigenvectors
482  void eigenvecs();
483  // Find eigenvalues
484  void eigenvals();
485  // Find residuals, update convergence
486  void residuals();
487  // Find correctors
488  void correctors();
489  // Orthogonalize/add significant correctors
490  void subspaceExpansion();
491  // Collapse subspace if needed
492  void subspaceCollapse();
493 
494 public:
495 
496  // => Constructors <= //
497 
499  DLRXSolver(std::shared_ptr<RHamiltonian> H);
501  virtual ~DLRXSolver();
502 
504  static std::shared_ptr<DLRXSolver> build_solver(Options& options,
505  std::shared_ptr<RHamiltonian> H);
506 
507  // => Required Methods <= //
508 
509  void print_header() const;
510  unsigned long int memory_estimate();
511  void initialize();
512  void solve();
513  void finalize();
514 
515  // => Accessors <= //
516 
518  const std::vector<std::shared_ptr<Vector> >& eigenvectors() const { return c_; }
520  const std::vector<std::vector<double> >& eigenvalues() const { return E_; }
521 
522  // => Knobs <= //
523 
525  void set_nroot(int nroot) { nroot_ = nroot; }
527  void set_max_subspace(double max_subspace) { max_subspace_ = max_subspace; }
529  void set_min_subspace(double min_subspace) { min_subspace_ = min_subspace; }
531  void set_nguess(int nguess) { nguess_ = nguess; }
533  void set_norm(double norm) { norm_ = norm; }
534 };
535 
536 // Class for solving UHF stability analysis.
537 class DLUSolver : public USolver {
538 
539 protected:
540 
541  // => Control parameters <= //
542 
544  int nroot_;
546  double norm_;
552  int nguess_;
553 
554  // => Iteration values <= //
555 
560 
561  // => State values <= //
562 
564  std::vector<std::shared_ptr<Vector> > c_;
566  std::vector<std::vector<double> > E_;
568  std::vector<std::shared_ptr<Vector> > b_;
570  std::vector<std::shared_ptr<Vector> > s_;
574  std::vector<std::vector<int> > A_inds_;
580  std::shared_ptr<Vector> l_;
582  std::vector<std::shared_ptr<Vector> > r_;
584  std::vector<double> n_;
586  std::vector<std::shared_ptr<Vector> > d_;
588  std::shared_ptr<Vector> diag_;
590  std::pair< std::shared_ptr<Vector>, std::shared_ptr<Vector> > diag_components;
591 
592  // => Run routines <= //
593 
594  // Guess, based on diagonal
595  void guess();
596  // Compute sigma vectors for the given set of b
597  void sigma();
598  // Compute subspace Hamiltonian
599  void subspaceHamiltonian();
600  // Diagonalize subspace Hamiltonian
602  // Find eigenvectors
603  void eigenvecs();
604  // Find eigenvalues
605  void eigenvals();
606  // Find residuals, update convergence
607  void residuals();
608  // Find correctors
609  virtual void correctors();
610  // Orthogonalize/add significant correctors
611  void subspaceExpansion();
612  // Collapse subspace if needed
613  void subspaceCollapse();
614 
615 public:
616 
617  // => Constructors <= //
618 
620  DLUSolver(std::shared_ptr<UHamiltonian> H);
622  virtual ~DLUSolver();
623 
625  static std::shared_ptr<DLUSolver> build_solver(Options& options,
626  std::shared_ptr<UHamiltonian> H);
627 
628  // => Required Methods <= //
629 
630  virtual void print_header() const;
631  virtual unsigned long int memory_estimate(){ return 0;};
632  virtual void initialize();
633  void solve();
634  void finalize();
635 
636  // => Accessors <= //
637 
639  const std::vector<std::shared_ptr<Vector> >& eigenvectors() const { return c_; }
641  const std::vector<std::vector<double> >& eigenvalues() const { return E_; }
643  std::shared_ptr<Vector> contract_pair(
644  std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > components );
645  void contract_pair(
646  std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > components,
647  std::shared_ptr<Vector> result);
649  std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > expand_pair(
650  std::shared_ptr<Vector> vec);
651  void expand_pair(std::shared_ptr<Vector> vec,
652  std::pair<std::shared_ptr<Vector>, std::shared_ptr<Vector> > result);
653 
654  // => Knobs <= //
655 
657  void set_nroot(int nroot) { nroot_ = nroot; }
659  void set_max_subspace(double max_subspace) { max_subspace_ = max_subspace; }
661  void set_min_subspace(double min_subspace) { min_subspace_ = min_subspace; }
663  void set_nguess(int nguess) { nguess_ = nguess; }
665  void set_norm(double norm) { norm_ = norm; }
666 
667 };
668 
669 
670 }
671 #endif
std::vector< std::shared_ptr< Vector > > p_
Conjugate directions.
Definition: solver.h:205
virtual void correctors()
Definition: solver.cc:2915
virtual unsigned long int memory_estimate()
Estimate of maximum memory usage (in doubles)
Definition: solver.cc:699
const std::vector< std::shared_ptr< Vector > > & eigenvectors() const
Eigenvectors, by state.
Definition: solver.h:518
std::string quantity_
Definition: solver.h:393
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:49
const std::vector< std::vector< double > > & eigenvalues() const
Eigenvalues, by state/irrep.
Definition: solver.h:368
int nsubspace_
The current subspace size.
Definition: solver.h:557
std::shared_ptr< Vector > l_
Subspace eigenvalues (nsubspace)
Definition: solver.h:309
int nguess_
Number of guess vectors to build.
Definition: solver.h:281
Definition: solver.h:537
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:317
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:301
void eigenvals()
Definition: solver.cc:1904
SharedMatrix A_
Delta Subspace Hamiltonian (preconditioner)
Definition: solver.h:572
std::vector< std::shared_ptr< Vector > > s_
Sigma vectors (nsubspace)
Definition: solver.h:570
std::vector< std::vector< double > > shifts_
Shifts (to solve (A-mI)
Definition: solver.h:226
Definition: solver.h:131
unsigned long int memory_estimate()
Estimate of maximum memory usage (in doubles)
Definition: solver.cc:138
SharedMatrix G_
G_ij Subspace Hamiltonian (nsubspace x nsubspace)
Definition: solver.h:457
const std::vector< std::shared_ptr< Vector > > & eigenvectors() const
Eigenvectors, by state.
Definition: solver.h:639
void update_p()
Definition: solver.cc:613
int min_subspace_
Minimum allowed subspace size (after collapse)
Definition: solver.h:279
void eigenvals()
Definition: solver.cc:2817
Definition: solver.h:384
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:533
virtual void initialize()
Definition: solver.cc:708
void set_debug(int debug)
Debug flag (defaults to 0)
Definition: solver.h:92
void eigenvals()
Definition: solver.cc:1022
virtual void initialize()
Definition: solver.cc:2301
SharedMatrix a_
Subspace eigenvectors (nsubspace x nsubspace)
Definition: solver.h:459
std::vector< std::vector< double > > E_
Current eigenvalues (nroots)
Definition: solver.h:295
Definition: solver.h:422
std::vector< std::shared_ptr< Vector > > d_
Correction vectors (nroots)
Definition: solver.h:315
void beta()
Definition: solver.cc:591
void correctors()
Definition: solver.cc:1415
double norm_
Required norm for subspace expansion.
Definition: solver.h:275
void update_x()
Definition: solver.cc:463
double convergence_
Convergence measure at this iteration.
Definition: solver.h:62
void set_shifts(const std::vector< std::vector< double > > &shifts)
Definition: solver.h:261
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:665
std::shared_ptr< UHamiltonian > H_
Reference to underlying UHamiltonian.
Definition: solver.h:163
void alpha()
Definition: solver.cc:437
void set_maxiter(int maxiter)
Set maximum number of iterations (defaults to 100)
Definition: solver.h:86
std::vector< std::vector< int > > A_inds_
A subspace indices.
Definition: solver.h:224
virtual void print_header() const
Definition: solver.cc:2272
int min_subspace_
Minimum allowed subspace size (after collapse)
Definition: solver.h:550
std::vector< std::shared_ptr< Vector > > r_
Residual vectors (nroots)
Definition: solver.h:582
void finalize()
Definition: solver.cc:1410
void initialize()
Definition: solver.cc:1404
Definition: solver.h:38
void set_nroot(int nroot)
Set number of roots (defaults to 1)
Definition: solver.h:373
void finalize()
Definition: solver.cc:1632
std::vector< std::shared_ptr< Vector > > x_
Solution vectors.
Definition: solver.h:197
SharedMatrix G_
G_ij Subspace Hamiltonian (nsubspace x nsubspace)
Definition: solver.h:305
int print_
Print flag, defaults to 1.
Definition: solver.h:45
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:568
Solver()
Default Constructor.
Definition: solver.cc:50
std::vector< std::shared_ptr< Vector > > d_
Correction vectors (nroots)
Definition: solver.h:467
const std::vector< std::vector< double > > & eigenvalues() const
Eigenvalues, by state/irrep.
Definition: solver.h:520
virtual ~RSolver()
Destructor.
Definition: solver.cc:78
int nsubspace_
The current subspace size.
Definition: solver.h:442
void set_print(int print)
Print flag (defaults to 1)
Definition: solver.h:90
void set_A(SharedMatrix A, const std::vector< std::vector< int > > inds)
Definition: solver.h:262
int nconverged_
The number of converged roots.
Definition: solver.h:444
int max_subspace_
Maximum allowed subspace size.
Definition: solver.h:548
std::shared_ptr< Vector > diag_
Diagonal M, for guess and Jacobi preconditioning.
Definition: solver.h:220
int precondition_maxiter_
Definition: solver.h:392
const std::vector< std::shared_ptr< Vector > > & eigenvectors() const
Eigenvectors, by state.
Definition: solver.h:366
void subspaceHamiltonian()
Definition: solver.cc:907
SharedMatrix G_
G_ij Subspace Hamiltonian (nsubspace x nsubspace)
Definition: solver.h:576
std::vector< std::shared_ptr< Vector > > z_
M^-1 x.
Definition: solver.h:201
unsigned long int memory_
Memory available, in doubles, defaults to 0 =&gt; Unlimited storage.
Definition: solver.h:53
SharedMatrix A_
A subspace matrix, for preconditioning.
Definition: solver.h:222
virtual ~CGRSolver()
Definition: solver.cc:97
double norm_
Required norm for subspace expansion.
Definition: solver.h:546
void sigma()
Definition: solver.cc:1678
std::vector< std::shared_ptr< Vector > > b_
B vectors (nsubspace)
Definition: solver.h:297
int max_subspace_
Maximum allowed subspace size.
Definition: solver.h:277
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:60
void set_nguess(int nguess)
Set number of guesses (defaults to 1)
Definition: solver.h:663
void set_max_subspace(double max_subspace)
Set maximum subspace size (defaults to 6)
Definition: solver.h:527
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:590
std::shared_ptr< RHamiltonian > H_
Reference to underlying RHamiltonian.
Definition: solver.h:135
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:64
void set_nroot(int nroot)
Set number of roots (defaults to 1)
Definition: solver.h:525
int nroot_
Number of desired roots.
Definition: solver.h:544
SharedMatrix a_
Subspace eigenvectors (nsubspace x nsubspace)
Definition: solver.h:307
Definition: solver.h:266
void initialize()
Definition: solver.cc:147
int nconverged_
The number of converged roots.
Definition: solver.h:559
void residuals()
Definition: solver.cc:1044
std::vector< std::vector< double > > E_
Current eigenvalues (nroots)
Definition: solver.h:451
void set_max_subspace(double max_subspace)
Set maximum subspace size (defaults to 6)
Definition: solver.h:375
void set_precondition_maxiter(int maxiter)
Definition: solver.h:417
void set_min_subspace(double min_subspace)
Set minimum subspace size, for collapse (defaults to 2)
Definition: solver.h:529
int nguess_
Number of guess vectors to use for subspace preconditioner.
Definition: solver.h:228
std::vector< std::shared_ptr< Vector > > b_
B vectors (nsubspace)
Definition: solver.h:453
int max_subspace_
Maximum allowed subspace size.
Definition: solver.h:433
virtual void solve()=0
void set_min_subspace(double min_subspace)
Set minimum subspace size, for collapse (defaults to 2)
Definition: solver.h:377
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:588
std::shared_ptr< UHamiltonian > H() const
Definition: solver.h:185
std::vector< std::shared_ptr< Vector > > d_
Correction vectors (nroots)
Definition: solver.h:586
SharedMatrix a_
Subspace eigenvectors (nsubspace x nsubspace)
Definition: solver.h:578
USolver(std::shared_ptr< UHamiltonian > H)
Reference to underlying RHamiltonian.
Definition: solver.cc:82
int debug_
Debug flag, defaults to 0.
Definition: solver.h:47
std::vector< bool > r_converged_
Which vectors are converged?
Definition: solver.h:215
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
double norm_
Required norm for subspace expansion.
Definition: solver.h:431
void initialize()
Definition: solver.cc:1562
void set_nguess(int nguess)
Set number of guesses (defaults to 1)
Definition: solver.h:379
virtual void correctors()
Definition: solver.cc:1118
int maxiter_
Maximum number of iterations, defaults to 100.
Definition: solver.h:58
virtual ~DLRXSolver()
Destructor.
Definition: solver.cc:1502
const std::vector< std::vector< double > > & eigenvalues() const
Eigenvalues, by state/irrep.
Definition: solver.h:641
void set_quantity(const std::string &quantity)
Definition: solver.h:419
Definition: solver.h:190
void solve()
Definition: solver.cc:717
std::vector< std::shared_ptr< Vector > > s_
Sigma vectors (nsubspace)
Definition: solver.h:299
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:552
std::vector< double > r_nrm2_
Residual norm.
Definition: solver.h:211
void eigenvecs()
Definition: solver.cc:1862
std::vector< double > n_
Residual vector 2-norms (nroots)
Definition: solver.h:465
std::vector< std::vector< int > > A_inds_
Delta Subspace indices.
Definition: solver.h:303
void set_precondition(const std::string &precondition)
Set precondition type (specific to solver type)
Definition: solver.h:82
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:99
int nconverged_
The number of converged roots.
Definition: solver.h:288
void set_nguess(int nguess)
Definition: solver.h:263
void set_memory(unsigned long int memory)
Set maximum vector storage space (defaults to 0 MB =&gt; Unlimited storage)
Definition: solver.h:84
std::vector< std::shared_ptr< Vector > > b_
Force vectors.
Definition: solver.h:195
void set_precondition_steps(const std::string &steps)
Definition: solver.h:418
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:94
Definition: liboptions.h:360
void guess()
Definition: solver.cc:312
std::vector< std::shared_ptr< Vector > > r_
Residual vectors.
Definition: solver.h:203
int nroot_
Number of desired roots.
Definition: solver.h:429
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:661
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:463
void print_header() const
Definition: solver.cc:1540
virtual unsigned long int memory_estimate()
Estimate of maximum memory usage (in doubles)
Definition: solver.h:631
std::string name_
Name of solver (set by subclasses)
Definition: solver.h:51
std::string precondition_
Preconditioner type.
Definition: solver.h:66
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
std::vector< std::shared_ptr< Vector > > c_
Current eigenvectors (nroots)
Definition: solver.h:449
int nguess_
Number of guess vectors to build.
Definition: solver.h:437
Definition: solver.h:159
void residuals()
Definition: solver.cc:1926
std::vector< std::shared_ptr< Vector > > c_
Current eigenvectors (nroots)
Definition: solver.h:293
int nconverged_
Number of converged vectors.
Definition: solver.h:217
std::shared_ptr< RHamiltonian > H() const
Definition: solver.h:156
void set_convergence(double criteria)
Set convergence criteria (defaults to 1.0E-6)
Definition: solver.h:88
std::vector< std::vector< int > > A_inds_
Delta Subspace indices.
Definition: solver.h:574
std::shared_ptr< Vector > l_
Subspace eigenvalues (nsubspace)
Definition: solver.h:461
std::vector< std::shared_ptr< Vector > > c_
Current eigenvectors (nroots)
Definition: solver.h:564
virtual ~DLRSolver()
Destructor.
Definition: solver.cc:641
int nsubspace_
The current subspace size.
Definition: solver.h:286
void set_max_subspace(double max_subspace)
Set maximum subspace size (defaults to 6)
Definition: solver.h:659
std::vector< std::shared_ptr< Vector > > & b()
Definition: solver.h:253
void guess()
Definition: solver.cc:790
void subspaceExpansion()
Definition: solver.cc:2058
std::string precondition_steps_
Definition: solver.h:391
std::vector< double > alpha_
Alpha values.
Definition: solver.h:207
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:101
void check_convergence()
Definition: solver.cc:503
std::shared_ptr< Vector > diag_
Diagonal of Hamiltonian.
Definition: solver.h:469
int min_subspace_
Minimum allowed subspace size (after collapse)
Definition: solver.h:435
void set_nguess(int nguess)
Set number of guesses (defaults to 1)
Definition: solver.h:531
std::shared_ptr< Vector > l_
Subspace eigenvalues (nsubspace)
Definition: solver.h:580
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:213
void guess()
Definition: solver.cc:2565
void products_p()
Definition: solver.cc:407
Definition: PsiFileImpl.h:39
void set_norm(double norm)
Set norm critera for adding vectors to subspace (defaults to 1.0E-6)
Definition: solver.h:381
std::vector< std::vector< double > > E_
Current eigenvalues (nroots)
Definition: solver.h:566
void eigenvecs()
Definition: solver.cc:2779
DLRXSolver(std::shared_ptr< RHamiltonian > H)
Constructor.
Definition: solver.cc:1491
unsigned long int memory_estimate()
Estimate of maximum memory usage (in doubles)
Definition: solver.cc:1553
void subspaceCollapse()
Definition: solver.cc:3070
std::vector< double > n_
Residual vector 2-norms (nroots)
Definition: solver.h:313
void finalize()
Definition: solver.cc:778
std::shared_ptr< CGRSolver > cg_
Turn an eigenproblem into a linear equations problem.
Definition: solver.h:389
void set_nroot(int nroot)
Set number of roots (defaults to 1)
Definition: solver.h:657
int nroot_
Number of desired roots.
Definition: solver.h:273
void update_r()
Definition: solver.cc:483
std::vector< std::shared_ptr< Vector > > Ap_
Product vectors.
Definition: solver.h:199
std::vector< std::shared_ptr< Vector > > & x()
Definition: solver.h:252
std::vector< double > beta_
Beta values.
Definition: solver.h:209
std::vector< std::shared_ptr< Vector > > s_
Sigma vectors (nsubspace)
Definition: solver.h:455
double criteria_
Convergence criteria, defaults to 1.0E-6.
Definition: solver.h:56
std::vector< std::shared_ptr< Vector > > r_
Residual vectors (nroots)
Definition: solver.h:311
std::vector< double > n_
Residual vector 2-norms (nroots)
Definition: solver.h:584
void subspaceHamiltonian()
Definition: solver.cc:1706
void set_Hamiltonian(std::shared_ptr< RHamiltonian > H)
Definition: solver.h:150
void subspaceHamiltonian()
Definition: solver.cc:2700