CheMPS2
ConvergenceScheme.cpp
1 /*
2  CheMPS2: a spin-adapted implementation of DMRG for ab initio quantum chemistry
3  Copyright (C) 2013-2016 Sebastian Wouters
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 #include <stdlib.h>
21 #include <assert.h>
22 
23 #include "ConvergenceScheme.h"
24 
25 CheMPS2::ConvergenceScheme::ConvergenceScheme( const int num_instructions ){
26 
27  this->num_instructions = num_instructions;
28 
29  assert( num_instructions > 0 );
30  num_D = new int[ num_instructions ];
31  energy_convergence = new double[ num_instructions ];
32  num_max_sweeps = new int[ num_instructions ];
33  noise_prefac = new double[ num_instructions ];
34  dvdson_rtol = new double[ num_instructions ];
35 
36 }
37 
39 
40  delete [] num_D;
41  delete [] energy_convergence;
42  delete [] num_max_sweeps;
43  delete [] noise_prefac;
44  delete [] dvdson_rtol;
45 
46 }
47 
48 int CheMPS2::ConvergenceScheme::get_number() const{ return num_instructions; }
49 
50 void CheMPS2::ConvergenceScheme::set_instruction( const int instruction, const int D, const double energy_conv, const int max_sweeps, const double noise_prefactor, const double davidson_rtol ){
51 
52  assert( instruction >= 0 );
53  assert( instruction < num_instructions );
54  assert( D > 0 );
55  assert( energy_conv > 0.0 );
56  assert( max_sweeps > 0 );
57  assert( davidson_rtol > 0.0 );
58 
59  num_D[ instruction ] = D;
60  energy_convergence[ instruction ] = energy_conv;
61  num_max_sweeps[ instruction ] = max_sweeps;
62  noise_prefac[ instruction ] = noise_prefactor;
63  dvdson_rtol[ instruction ] = davidson_rtol;
64 
65 }
66 
67 int CheMPS2::ConvergenceScheme::get_D( const int instruction ) const{ return num_D[ instruction ]; }
68 
69 double CheMPS2::ConvergenceScheme::get_energy_conv( const int instruction ) const{ return energy_convergence[ instruction ]; }
70 
71 int CheMPS2::ConvergenceScheme::get_max_sweeps( const int instruction ) const{ return num_max_sweeps[ instruction ]; }
72 
73 double CheMPS2::ConvergenceScheme::get_noise_prefactor( const int instruction ) const{ return noise_prefac[ instruction ]; }
74 
75 double CheMPS2::ConvergenceScheme::get_dvdson_rtol( const int instruction ) const{ return dvdson_rtol[ instruction ]; }
76 
77 
virtual ~ConvergenceScheme()
Destructor.
double get_energy_conv(const int instruction) const
Get the energy convergence threshold for a particular instruction.
double get_noise_prefactor(const int instruction) const
Get the noise prefactor for a particular instruction.
void set_instruction(const int instruction, const int D, const double energy_conv, const int max_sweeps, const double noise_prefactor, const double davidson_rtol)
Set an instruction.
int get_D(const int instruction) const
Get the number of renormalized states for a particular instruction.
int get_number() const
Get the number of instructions.
int get_max_sweeps(const int instruction) const
Get the maximum number of sweeps for a particular instruction.
double get_dvdson_rtol(const int instruction) const
Get the Davidson residual tolerance for a particular instruction.
ConvergenceScheme(const int num_instructions)
Constructor.