VMPS++
Loading...
Searching...
No Matches
ParamReturner.h
Go to the documentation of this file.
1#ifndef PARAMRETURNER
2#define PARAMRETURNER
3
4#include "ParamHandler.h"
5#include "DmrgTypedefs.h"
7
9{
10public:
11
13
14 ParamReturner (const std::map<string,std::any> &defaults_input)
15 :defaults(defaults_input)
16 {}
17
19
20 DMRG::CONTROL::DYN get_DmrgDynParam (const vector<Param> &params={}) const;
21 DMRG::CONTROL::GLOB get_DmrgGlobParam (const vector<Param> &params={}) const;
23
25
26 VUMPS::CONTROL::DYN get_VumpsDynParam (const vector<Param> &params={}) const;
27 VUMPS::CONTROL::GLOB get_VumpsGlobParam (const vector<Param> &params={}) const;
29
30private:
31
33 std::map<string,std::any> defaults;
34};
35
37get_DmrgGlobParam (const vector<Param> &params) const
38{
40 if (TRIVIALLY_CONSTRUCTED) {return out;} //Return defaults from DmrgTypedefs
41
42 ParamHandler P(params,defaults);
43 out.min_halfsweeps = P.get<size_t>("min_halfsweeps");
44 out.max_halfsweeps = P.get<size_t>("max_halfsweeps");
45 out.Minit = P.get<size_t>("Minit");
46 out.Qinit = P.get<size_t>("Qinit");
47 out.Mlimit = P.get<size_t>("Mlimit");
48 out.tol_eigval = P.get<double>("tol_eigval");
49 out.tol_state = P.get<double>("tol_state");
50 out.savePeriod = P.get<size_t>("savePeriod");
51 out.CONVTEST = P.get<DMRG::CONVTEST::OPTION>("CONVTEST");
52 out.CALC_S_ON_EXIT = P.get<bool>("CALC_S_ON_EXIT");
53 return out;
54}
55
57get_DmrgDynParam (const vector<Param> &params) const
58{
60 if (TRIVIALLY_CONSTRUCTED) {return out;} //Return defaults from DmrgTypedefs
61
62 ParamHandler P(params,defaults);
63
64 double tmp1 = P.get<double>("max_alpha");
65 size_t lim = P.get<size_t>("lim_alpha");
66 out.max_alpha_rsvd = [tmp1,lim] (size_t i) {return (i<lim)? tmp1:0.;};
67
68 tmp1 = P.get<double>("min_alpha");
69 out.min_alpha_rsvd = [tmp1,lim] (size_t i) {return (i<lim)? tmp1:0.;};
70
71 tmp1 = P.get<double>("eps_svd");
72 out.eps_svd = [tmp1] (size_t i) {return tmp1;};
73
74 size_t tmp2 = P.get<size_t>("Mincr_abs");
75 out.Mincr_abs = [tmp2] (size_t i) {return tmp2;};
76
77 tmp2 = P.get<size_t>("Mincr_per");
78 out.Mincr_per = [tmp2] (size_t i) {return tmp2;};
79
80 tmp1 = P.get<double>("Mincr_rel");
81 out.Mincr_rel = [tmp1] (size_t i) {return tmp1;};
82
83 tmp2 = P.get<size_t>("min_Nsv");
84 out.min_Nsv = [tmp2] (size_t i) {return tmp2;};
85
86 int tmp3 = P.get<int>("max_Nrich");
87 out.max_Nrich = [tmp3] (size_t i) {return tmp3;};
88
89// out.iteration = P.get<function<DMRG::ITERATION::OPTION(size_t)> >("iteration");
90
91 return out;
92}
93
95get_VumpsGlobParam (const vector<Param> &params) const
96{
97 VUMPS::CONTROL::GLOB out; return out; //For now return the default values in every case. Change this if the parameters are in the models.
98 if (TRIVIALLY_CONSTRUCTED) {return out;} //Return defaults from VumpsTypedefs
99
100 ParamHandler P(params,defaults);
101 out.min_iterations = P.get<size_t>("min_iterations");
102 out.max_iterations = P.get<size_t>("max_iterations");
103 out.Minit = P.get<size_t>("Minit");
104 out.Qinit = P.get<size_t>("Qinit");
105 out.Mlimit = P.get<size_t>("Mlimit");
106 out.tol_eigval = P.get<double>("tol_eigval");
107 out.tol_var = P.get<double>("tol_var");
108 out.tol_state = P.get<double>("tol_state");
109 out.savePeriod = P.get<size_t>("savePeriod");
110 return out;
111}
112
114get_VumpsDynParam (const vector<Param> &params) const
115{
116 VUMPS::CONTROL::DYN out; return out; //For now return the default values in every case. Change this if the parameters are in the models.
117 if (TRIVIALLY_CONSTRUCTED) {return out;} //Return defaults from VumpsTypedefs
118
119 ParamHandler P(params,defaults);
120
121 size_t tmp1 = P.get<double>("max_deltaM");
122 size_t lim = P.get<size_t>("lim_deltaM");
123 out.max_deltaM = [tmp1,lim] (size_t i) {return (i<lim)? tmp1:0.;};
124
125 size_t tmp2 = P.get<size_t>("Mincr_abs");
126 out.Mincr_abs = [tmp2] (size_t i) {return tmp2;};
127
128 tmp1 = P.get<double>("Mincr_rel");
129 out.Mincr_rel = [tmp1] (size_t i) {return tmp1;};
130
131 return out;
132}
133
134#endif
VUMPS::CONTROL::GLOB get_VumpsGlobParam(const vector< Param > &params={}) const
Definition: ParamReturner.h:95
std::map< string, std::any > defaults
Definition: ParamReturner.h:33
VUMPS::CONTROL::DYN get_VumpsDynParam(const vector< Param > &params={}) const
bool TRIVIALLY_CONSTRUCTED
Definition: ParamReturner.h:32
ParamReturner(const std::map< string, std::any > &defaults_input)
Definition: ParamReturner.h:14
DMRG::CONTROL::DYN get_DmrgDynParam(const vector< Param > &params={}) const
Definition: ParamReturner.h:57
DMRG::CONTROL::GLOB get_DmrgGlobParam(const vector< Param > &params={}) const
Definition: ParamReturner.h:37
function< double(size_t)> eps_svd
Definition: DmrgTypedefs.h:399
function< int(size_t)> max_Nrich
Definition: DmrgTypedefs.h:405
function< size_t(size_t)> Mincr_per
Definition: DmrgTypedefs.h:403
function< size_t(size_t)> Mincr_abs
Definition: DmrgTypedefs.h:401
function< double(size_t)> max_alpha_rsvd
Definition: DmrgTypedefs.h:397
function< size_t(size_t)> min_Nsv
Definition: DmrgTypedefs.h:404
function< double(size_t)> Mincr_rel
Definition: DmrgTypedefs.h:402
function< double(size_t)> min_alpha_rsvd
Definition: DmrgTypedefs.h:398
DMRG::CONVTEST::OPTION CONVTEST
Definition: DmrgTypedefs.h:387
function< size_t(size_t)> max_deltaM
function< double(size_t)> Mincr_rel
function< size_t(size_t)> Mincr_abs