MADNESS 0.10.1
PNOParameters.h
Go to the documentation of this file.
1/*
2 * PNOParameters.h
3 *
4 * Created on: Sep. 9, 2019
5 * Author: jsk
6 */
7
8#ifndef PNOPARAMETERS_H_
9#define PNOPARAMETERS_H_
10
11#include <vector>
12#include <map>
14
15namespace madness {
16
18inline std::string type(const PairType& n){ return "PairType";}
19std::ostream& operator << (std::ostream& os, const PairType& en);
20std::istream& operator >> (std::istream& os, PairType& en);
22inline std::string type(const EnergyType& n){ return "EnergyType";}
23std::ostream& operator << (std::ostream& os, const EnergyType& en);
24std::istream& operator >> (std::istream& os, EnergyType& en);
26inline std::string type(const GuessType& n){ return "GuessType";}
27std::ostream& operator << (std::ostream& os, const GuessType& en);
28std::istream& operator >> (std::istream& is, GuessType& en);
29
31public:
32
33 template<typename T>
34 T assign_from_string(const std::string& string)const{
35 T result;
36 std::stringstream ss(string);
37 ss >> result;
38 return result;
39 }
40
44
48
53
59
61 initialize<int>("rank_increase", 15 , "maximum rank to increase in every macroiteration");
62 initialize<int>("chunk", 100 , "chunk of functions operated on in parallel when G or K is applied (prevent memory shortage)");
63 initialize<bool>("debug",false, "debug mode");
64 initialize<std::size_t>("freeze",0, "frozen core approximation");
65 initialize<int>("maxrank", 999, "maximal pno rank for all pairs");
66 initialize<std::string>("guesstype","exop", "the guesstype: exop (recommended, multiply polynomial excitation operators onto the occupied orbitals), empty (don't compute a guess), scf (use the ao basis from the SCF solver), partial_wave (create s,p,d ..., type functions and place on atoms), predefined (same as partial_wave but for predefined sets) ");
67 initialize<std::string>("exop", "multipole", "this string defines which excitation operators can be used, use 'dipole', 'dipole+', 'quadrupole', 'ocopole', or 'multipole', need to set guesstype to 'exop' which is the default ");
68 initialize<bool>("exop_trigo", true, "use trigonometric excitation operators ( x --> sin(x) ");
69 initialize<std::string>("partial_wave", "", "atom centered partial wave guess of format like 'h-2s1p-o-3s2p1d', need to set guesstype to 'partial_wave' and adaptive_solver to 'none' ");
70 initialize<std::string>("predefined", "", "predefined partial wave guesses of type pvxz with x=d,t,q,5,6, need to set guesstype to 'predefined' and adaptive_solver to 'none'");
71 initialize<int>("maxiter_t",100, "maximal number of iterations in the amplitude solver");
72 initialize<int>("maxiter_micro",10, "Maximum of iterations for every cycle in the adaptive solver");
73 initialize<int>("maxiter_macro",10, "Maximum of iterations of cycles in the adaptive solver");
74 initialize<double>("tpno", 1.e-8, "PNO cutoff threshold");
75 initialize<double>("tpno_tight",1.e-10, "PNO cutoff for the first iteration");
76 initialize<bool>("canonicalize_pno",true, "canonicalize the pnos before the amplitude solver");
77 initialize<double>("thresh", 1.e-3, "MRA threshold");
78 initialize<double>("econv_micro",1.e-3, "Energy convergence for microiterations (Greens function based optimization) in adaptive solver");
79 initialize<double>("econv_pairs",1.e-4, "ENergy convergence for individual pairs in adaptive solver. Converged pairs are frozen automatically");
80 initialize<double>("econv_macro",1.e-3, "Energy convergence for macroiterations in adaptive solver, no effect if adaptive_solver is deactivated");
81 initialize<double>("dconv",1.e-1, "convergence of every PNO in the Green's function solver");
82 initialize<double>("op_thresh",1.e-6, "MRA operator thresh");
83 initialize<std::string>("restart","none", "restart pairs of this type, use 'mp2', 'cispd', 'all' or 'none' ");
84 initialize<std::string>("no_compute","none", "do not compute the pairs of this type, use 'mp2', 'cispd', 'all' or 'none' ");
85 initialize<std::string>("no_opt","none", "do not optimize the pnos of this type, use 'mp2', 'cispd', 'all' or 'none' ");
86 initialize<std::string>("no_guess","none", "guess for this type will be empty, use 'mp2', 'cispd', 'all' or 'none' ");
87 initialize<std::string>("adaptive_solver","all", "Use adaptive solver for those pairs, use 'mp2', 'cispd', 'all' or 'none', works only in combination with guesstype 'exop' ");
88 initialize<bool>("kain", true, "use KAIN solver in amplitude solver");
89 initialize<std::size_t>("kain_subspace", 5 , "subspace size of the KAIN solver (amplitudes)");
90 initialize<bool>("f12",true, "use explicit correlation");
91 initialize<int> ("cispd_number", -1, "CIS(D) excitation numbers, to read in correct functions" );
92 initialize<double> ("cispd_energy", 0.0, "CIS energy" );
93 initialize<std::string> ("freeze_pairs", "none", "frozen pairs will not be optimized: Expected format 'a b c d' will freeze pairs ab and cd");
94 initialize<std::vector<int> >("freeze_pairs_of_orbital",std::vector<int>(), " All pairs which originate from this orbital will not be optimized");
95 initialize<std::vector<int> >("active_pairs_of_orbital",std::vector<int>(), " All pairs which originate from this orbital will not be frozen all other pairs will, if this vector is not empty");
96 initialize<bool>("no_opt_in_first_iteration", false, "Do not optimize in the first iteration (then the potentials do not have to be evaluated, use this for large guesses)");
97 initialize<std::string>("exchange", "full", "approximate exchange with 'neglect' or xc functional -> same syntax as moldft");
98 initialize<bool>("save_pnos",true, "Save the OBS-PNOs to a file, before and after orthonormalization.");
99 initialize<bool>("diagonal", false, "Compute only diagonal PNOs");
100 }
101
103
104 // auto determine freeze parameter for the first two shells
105 // deactivate by setting freeze 0 or any other value in the input file
106 size_t freeze = 0;
107 for(const Atom& atom: molecule.get_atoms()){
108 if (atom.atomic_number < 3){
109 // no frozen core for H and He
110 }else if(atom.atomic_number < 11){
111 freeze += 1;
112 }else if(atom.atomic_number < 19){
113 freeze += 5;
114 }
115 // beyond this point the parameter is better set manually
116 }
117 set_derived_value("freeze", freeze);
118
119 set_derived_value("no_guess", get<std::string >("no_compute"));
120 set_derived_value("restart", get<std::string>("no_compute"));
121 set_derived_value("tpno_tight", 0.01*tpno());
122
123 // set default values for adaptive solver
124 if(adaptive_solver()){
125 const std::string gt = "exop";
126 const std::string ex = "multipole";
127 set_derived_value("guesstype", gt);
128 set_derived_value("exop", ex);
129 set_derived_value("econv_macro", thresh());
130 set_derived_value("econv_micro", thresh());
131 set_derived_value("econv_pairs", 0.1*thresh());
132 }
133
134 }
135
136 std::vector<std::pair<int,int> > freeze_pairs()const{
137 const std::string str=get<std::string >("freeze_pairs");
138 std::vector<std::pair<int,int> > result;
139 if (str=="none"){
140 return result;
141 }
142 std::stringstream ss(str);
143 int i,j;
144 while(ss>>i){
145 ss>>j;
146 result.push_back(std::make_pair(i,j));
147 }
148 return result;
149 }
150 bool diagonal()const {return get<bool>("diagonal");}
151 bool save_pnos()const { return get<bool >("save_pnos");}
152 std::string exchange()const {return get<std::string>("exchange");}
153 bool exop_trigo()const { return get<bool >("exop_trigo");}
154 int rank_increase()const { return get<int >("rank_increase");}
155 int chunk()const { return get<int >("chunk");}
156 std::vector<std::vector<double> > protocol()const { return get<std::vector<std::vector<double> > >("protocol");}
157 bool debug()const { return get<bool >("debug");}
158 std::size_t freeze()const { return get<std::size_t >("freeze");}
159 int maxrank()const { return get<int >("maxrank");}
160 GuessType guesstype()const { return assign_from_string<GuessType>(get<std::string >("guesstype"));}
161 std::string exop()const { return get<std::string >("exop");}
162 std::map<std::string, std::vector<int> >partial_wave(const std::string& key = "partial_wave")const {
163 // return format atom-name, vector of numbers giving S, P, D, ... functions
164 std::string str=get<std::string >(key);
165 std::transform(str.begin(), str.end(), str.begin(), ::tolower);
166 // madness parameter format does not allow blancs so we use '-' and transform them here
167 std::replace(str.begin(), str.end(), '-', ' ');
168 // expected input format: atom-name-3s2p1d atom-name-XsYpZd...
169 std::stringstream ss(str);
170 std::string symbol, pw_string;
171 std::map<std::string, std::vector<int> > result;
172 while(ss>>symbol){
173 ss>>pw_string;
174 std::vector<int> numbers(pw_string.size()/2);
175 std::vector<char> control = {'s', 'p', 'd', 'f', 'g', 'h', 'i', 'k'};
176 for (size_t i=0; i<pw_string.size()/2; ++i){
177 char l = pw_string[2*i+1];
178 char n = pw_string[2*i];
179 MADNESS_ASSERT(l==control[i]);
180 numbers[i]=(n-'0'); // need to convert ascii to int
181 }
182 result[symbol] = numbers;
183 }
184 return result;
185 }
186 std::string predefined_guess()const{ return get<std::string >("predefined");}
187 int maxiter()const { return maxiter_micro();}
188 int maxiter_t()const { return get<int >("maxiter_t");}
189 double tpno()const { return get<double >("tpno");}
190 double tpno_tight()const { return get<double >("tpno_tight");}
191 bool canonicalize_pno()const { return get<bool >("canonicalize_pno");}
192 double thresh()const { return get<double >("thresh");}
193 double dconv()const { return get<double >("dconv");}
194 double op_thresh()const { return get<double >("op_thresh");}
195 PairType restart()const {return assign_from_string<PairType>(get<std::string >("restart"));}
196 PairType no_compute()const { return assign_from_string<PairType>(get<std::string >("no_compute"));}
197 PairType no_opt()const { return assign_from_string<PairType>(get<std::string >("no_opt"));}
198 PairType no_guess()const { return assign_from_string<PairType>(get<std::string >("no_guess"));}
199 bool kain()const { return get<bool >("kain");}
200 std::size_t kain_subspace()const { return get<std::size_t >("kain_subspace");}
201 bool f12()const { return get<bool >("f12");}
202 std::vector<std::pair<int,double> > cispd()const {
203 // workaround new madness data format, can only do one excitation energy each run for now
204 const int number = get<int >("cispd_number");
205 const double energy = get<double >("cispd_energy");
206 if (number < 0){
207 return std::vector<std::pair<int,double> >();
208 }
209 else{
210 return std::vector<std::pair<int,double> >(1,std::make_pair(number, energy));
211 }
212 }
213 std::vector<int> freeze_pairs_of_orbital()const { return get<std::vector<int> >("freeze_pairs_of_orbital");}
214 std::vector<int> active_pairs_of_orbital()const { return get<std::vector<int> >("active_pairs_of_orbital");}
215 PairType adaptive_solver()const { return assign_from_string<PairType>(get<std::string >("adaptive_solver"));}
216 double econv()const { return econv_micro();}
217 double econv_pairs()const { return get<double >("econv_pairs");}
218 double econv_micro()const { return get<double >("econv_micro");}
219 double econv_macro()const { return get<double >("econv_macro");}
220 int maxiter_micro()const { return get<int >("maxiter_micro");}
221 int maxiter_macro()const { return get<int >("maxiter_macro");}
222 bool no_opt_in_first_iteration()const { return get<bool >("no_opt_in_first_iteration");}
223
224
225};
226
228public:
232
233 F12Parameters(World& world, const commandlineparser& parser, const PNOParameters& param, const std::string& TAG="pno") : PNOParameters(param){
236 }
237
238
240 initialize<bool>("abs_c",true, " use auxilliary basis on f12Q[Kf12] part of energy (only if energytype is HYLLERAAS_ENERGYTYPE). If switched off the part neglected!");
241 initialize<bool>("abs_u",false, " use auxilliary basis on f12QUe part of energy (only if energytype is HYLLERAAS_ENERGYTYPE). If switched off the part is computed in full (recommended) ");
242 initialize<double>("cabs_thresh",1.e-4, " thresh for auxbasis part in f12 energy ");
243 initialize<std::string>("energytype", "projected", " the energytype is 'projected' or 'hylleraas' functional projected energies do not need auxilliary bases for the evaluation of the f12 energy. It's recommended to use projected_energies! For Hylleraas type you need to specify an auxbas from file OR internal");
244 initialize<double>("gamma",1.4, "The f12 length scale");
245 initialize<std::string>("auxbas", "none", "atom centered partial wave guess of format like 'h-2s1p-o-3s2p1d' ");
246 initialize<std::string>("auxbas_file", "none", " use external comp. aux. basis in addition to the pnos as auxbasis. Give the filename as parameter. Give the auxbas in turbomole format. Don't use contractions. If a file is specified the auxbas parameter has no effect");
247 }
248
249 bool f12()const { return get<bool >("f12");}
250 bool abs_c()const { return get<bool >("abs_c");}
251 bool abs_u()const { return get<bool >("abs_u");}
252 double cabs_thresh()const { return get<double >("cabs_thresh");}
253 std::string auxbas_file()const {
254 return get<std::string >("auxbas_file");
255 }
257 std::string key = get<std::string>("energytype");
258 std::transform(key.begin(), key.end(), key.begin(), ::tolower);
259 std::stringstream ss(key);
261 ss >> result;
263 return result;
264 }
265 double gamma()const { return get<double >("gamma");}
266 std::map<std::string,std::vector<int> > auxbas()const {
267 return partial_wave("auxbas");
268 }
269
271 if(energytype() == HYLLERAAS_ENERGYTYPE) set_derived_value("abs_c", true);
272 if(energytype() == HYLLERAAS_ENERGYTYPE) set_derived_value("abs_u", false);
273 set_derived_value("cabs_thresh", thresh());
274 }
275
276};
277
278} /* namespace madness */
279
280#endif /* PNOPARAMETERS_H_ */
Definition molecule.h:58
Definition PNOParameters.h:227
void initialize_f12_parameters()
Definition PNOParameters.h:239
F12Parameters(World &world, const commandlineparser &parser, const PNOParameters &param, const std::string &TAG="pno")
Definition PNOParameters.h:233
bool abs_c() const
Definition PNOParameters.h:250
F12Parameters(const PNOParameters &param)
Definition PNOParameters.h:229
double cabs_thresh() const
Definition PNOParameters.h:252
void set_derived_values()
Definition PNOParameters.h:270
EnergyType energytype() const
Definition PNOParameters.h:256
double gamma() const
Definition PNOParameters.h:265
bool abs_u() const
Definition PNOParameters.h:251
std::map< std::string, std::vector< int > > auxbas() const
Definition PNOParameters.h:266
std::string auxbas_file() const
Definition PNOParameters.h:253
bool f12() const
Definition PNOParameters.h:249
Definition molecule.h:124
Definition PNOParameters.h:30
std::string exop() const
Definition PNOParameters.h:161
std::vector< std::vector< double > > protocol() const
Definition PNOParameters.h:156
bool save_pnos() const
Definition PNOParameters.h:151
std::size_t freeze() const
Definition PNOParameters.h:158
PairType no_compute() const
Definition PNOParameters.h:196
void set_derived_values(const Molecule &molecule)
Definition PNOParameters.h:102
double dconv() const
Definition PNOParameters.h:193
bool canonicalize_pno() const
Definition PNOParameters.h:191
GuessType guesstype() const
Definition PNOParameters.h:160
double tpno_tight() const
Definition PNOParameters.h:190
bool exop_trigo() const
Definition PNOParameters.h:153
int maxiter() const
Definition PNOParameters.h:187
PairType no_guess() const
Definition PNOParameters.h:198
void initialize_pno_parameters()
Definition PNOParameters.h:60
std::map< std::string, std::vector< int > > partial_wave(const std::string &key="partial_wave") const
Definition PNOParameters.h:162
double econv() const
Definition PNOParameters.h:216
PNOParameters(World &world, const commandlineparser &parser, const std::string &TAG="pno")
Definition PNOParameters.h:49
int maxiter_macro() const
Definition PNOParameters.h:221
PairType no_opt() const
Definition PNOParameters.h:197
T assign_from_string(const std::string &string) const
Definition PNOParameters.h:34
PNOParameters()
Definition PNOParameters.h:41
PNOParameters(World &world, const commandlineparser &parser, const Molecule &molecule, const std::string &TAG="pno")
Definition PNOParameters.h:54
std::vector< int > freeze_pairs_of_orbital() const
Definition PNOParameters.h:213
PNOParameters(const QCCalculationParametersBase &param)
Definition PNOParameters.h:45
std::string predefined_guess() const
Definition PNOParameters.h:186
std::vector< std::pair< int, double > > cispd() const
Definition PNOParameters.h:202
bool diagonal() const
Definition PNOParameters.h:150
std::vector< int > active_pairs_of_orbital() const
Definition PNOParameters.h:214
PairType restart() const
Definition PNOParameters.h:195
bool f12() const
Definition PNOParameters.h:201
double op_thresh() const
Definition PNOParameters.h:194
double tpno() const
Definition PNOParameters.h:189
int chunk() const
Definition PNOParameters.h:155
int maxiter_micro() const
Definition PNOParameters.h:220
bool kain() const
Definition PNOParameters.h:199
double econv_micro() const
Definition PNOParameters.h:218
int rank_increase() const
Definition PNOParameters.h:154
int maxrank() const
Definition PNOParameters.h:159
double thresh() const
Definition PNOParameters.h:192
std::vector< std::pair< int, int > > freeze_pairs() const
Definition PNOParameters.h:136
bool debug() const
Definition PNOParameters.h:157
PairType adaptive_solver() const
Definition PNOParameters.h:215
double econv_macro() const
Definition PNOParameters.h:219
bool no_opt_in_first_iteration() const
Definition PNOParameters.h:222
std::size_t kain_subspace() const
Definition PNOParameters.h:200
std::string exchange() const
Definition PNOParameters.h:152
double econv_pairs() const
Definition PNOParameters.h:217
int maxiter_t() const
Definition PNOParameters.h:188
class for holding the parameters for calculation
Definition QCCalculationParametersBase.h:290
virtual void read_input_and_commandline_options(World &world, const commandlineparser &parser, const std::string tag)
Definition QCCalculationParametersBase.h:325
void set_derived_value(const std::string &key, const T &value)
Definition QCCalculationParametersBase.h:403
A parallel world class.
Definition world.h:132
double(* energy)()
Definition derivatives.cc:58
auto T(World &world, response_space &f) -> response_space
Definition global_functions.cc:34
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition madness_exception.h:134
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
std::ostream & operator<<(std::ostream &os, const particle< PDIM > &p)
Definition lowrankfunction.h:397
EnergyType
Definition PNOParameters.h:21
@ HYLLERAAS_ENERGYTYPE
Definition PNOParameters.h:21
@ UNKNOWN_ENERGYTYPE
Definition PNOParameters.h:21
@ PROJECTED_ENERGYTYPE
Definition PNOParameters.h:21
GuessType
Definition PNOParameters.h:25
@ PSI4_GUESSTYPE
Definition PNOParameters.h:25
@ EXOP_GUESSTYPE
Definition PNOParameters.h:25
@ SCF_GUESSTYPE
Definition PNOParameters.h:25
@ FROM_FILE_GUESSTYPE
Definition PNOParameters.h:25
@ PREDEFINED_GUESSTYPE
Definition PNOParameters.h:25
@ UNKNOWN_GUESSTYPE
Definition PNOParameters.h:25
@ EMPTY_GUESSTYPE
Definition PNOParameters.h:25
@ PARTIAL_WAVE_GUESSTYPE
Definition PNOParameters.h:25
std::istream & operator>>(std::istream &is, PairType &en)
Definition PNOParameters.cpp:24
std::string type(const PairType &n)
Definition PNOParameters.h:18
PairType
Definition PNOParameters.h:17
@ UNKNOWN_PAIRTYPE
Definition PNOParameters.h:17
@ CISPD_PAIRTYPE
Definition PNOParameters.h:17
@ MP2_PAIRTYPE
Definition PNOParameters.h:17
@ ALL_PAIRTYPE
Definition PNOParameters.h:17
@ NONE_PAIRTYPE
Definition PNOParameters.h:17
very simple command line parser
Definition commandlineparser.h:15
InputParameters param
Definition tdse.cc:203
static Molecule molecule
Definition testperiodicdft.cc:38