ERKALE
ERKALE - DFT from Hel
 All Classes Functions Variables Friends Pages
settings.h
1 /*
2  * This source code is part of
3  *
4  * E R K A L E
5  * -
6  * DFT from Hel
7  *
8  * Written by Susi Lehtola, 2010-2011
9  * Copyright (c) 2010-2011, Susi Lehtola
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  */
16 
17 
18 
19 #ifndef ERKALE_SETTINGS
20 #define ERKALE_SETTINGS
21 
22 #include "global.h"
23 #include <armadillo>
24 #include <vector>
25 #include <string>
26 
28 typedef struct {
30  std::string name;
32  std::string comment;
34  double val;
35 
37  bool negative;
38 } doubleset_t;
39 
41 typedef struct {
43  std::string name;
45  std::string comment;
47  bool val;
48 } boolset_t;
49 
51 typedef struct {
53  std::string name;
55  std::string comment;
57  int val;
58 
60  bool negative;
61 } intset_t;
62 
64 typedef struct {
66  std::string name;
68  std::string comment;
70  std::string val;
71 } stringset_t;
72 
74 class Settings {
76  std::vector<doubleset_t> dset;
78  std::vector<boolset_t> bset;
80  std::vector<intset_t> iset;
82  std::vector<stringset_t> sset;
83 
84  public:
86  Settings();
88  ~Settings();
89 
91  void add_scf_settings();
93  void add_dft_settings();
94 
96  void add_double(std::string name, std::string comment, double val, bool negative=false);
98  void add_bool(std::string name, std::string comment, bool val);
100  void add_int(std::string name, std::string comment, int val, bool negative=false);
102  void add_string(std::string name, std::string comment, std::string val);
103 
105  void set_double(std::string name, double val);
107  void set_bool(std::string name, bool val);
109  void set_int(std::string name, int val);
111  void set_string(std::string name, std::string val);
112 
114  double get_double(std::string name) const;
116  bool get_bool(std::string name) const;
118  int get_int(std::string name) const;
120  std::string get_string(std::string name) const;
121 
123  arma::vec get_vec(std::string name) const;
125  arma::ivec get_ivec(std::string name) const;
127  arma::uvec get_uvec(std::string name) const;
128 
130  size_t is_double(std::string name) const;
132  size_t is_bool(std::string name) const;
134  size_t is_int(std::string name) const;
136  size_t is_string(std::string name) const;
137 
139  void parse(std::string filename, bool scf=false);
140 
142  void print() const;
143 };
144 
146 doubleset_t gend(std::string name, std::string comment, double val, bool negative);
148 boolset_t genb(std::string name, std::string comment, bool val);
150 intset_t geni(std::string name, std::string comment, int val, bool negative);
152 stringset_t gens(std::string name, std::string comment, std::string val);
153 
154 #endif
std::string comment
A more verbose explanation what the setting does.
Definition: settings.h:32
int get_int(std::string name) const
Get an integer valued setting.
Definition: settings.cpp:315
void add_scf_settings()
Add SCF related settings.
Definition: settings.cpp:36
bool negative
Is the value allowed to be negative?
Definition: settings.h:60
void add_string(std::string name, std::string comment, std::string val)
Add a string valued setting.
Definition: settings.cpp:212
std::vector< stringset_t > sset
String value settings.
Definition: settings.h:82
std::vector< intset_t > iset
Integer value settings.
Definition: settings.h:80
std::string comment
A more verbose explanation what the setting does.
Definition: settings.h:68
bool negative
Is the value allowed to be negative?
Definition: settings.h:37
std::string name
Name of setting.
Definition: settings.h:43
void add_bool(std::string name, std::string comment, bool val)
Add a boolean valued setting.
Definition: settings.cpp:190
void set_bool(std::string name, bool val)
Set a boolean valued setting.
Definition: settings.cpp:240
void parse(std::string filename, bool scf=false)
Parse file containing settings to use. SCF indicates special handling for the method keyword...
Definition: settings.cpp:400
void add_dft_settings()
Add DFT related settings.
Definition: settings.cpp:131
double val
The value of the setting.
Definition: settings.h:34
std::string name
Name of setting.
Definition: settings.h:53
size_t is_string(std::string name) const
Is &quot;name&quot; a setting of string type? Returns index + 1 if found, else 0.
Definition: settings.cpp:391
size_t is_int(std::string name) const
Is &quot;name&quot; a setting of integer type? Returns index + 1 if found, else 0.
Definition: settings.cpp:375
std::vector< boolset_t > bset
Boolean value settings.
Definition: settings.h:78
Settings used for a calculations.
Definition: settings.h:74
size_t is_double(std::string name) const
Is &quot;name&quot; a setting of double type? Returns index + 1 if found, else 0.
Definition: settings.cpp:367
size_t is_bool(std::string name) const
Is &quot;name&quot; a setting of boolean type? Returns index + 1 if found, else 0.
Definition: settings.cpp:383
std::string name
Name of setting.
Definition: settings.h:66
std::string comment
A more verbose explanation what the setting does.
Definition: settings.h:45
void print() const
Print current settings.
Definition: settings.cpp:504
std::string comment
A more verbose explanation what the setting does.
Definition: settings.h:55
std::string get_string(std::string name) const
Get a string valued setting.
Definition: settings.cpp:329
arma::ivec get_ivec(std::string name) const
Get a string setting and parse it as an integer vector.
Definition: settings.cpp:353
bool get_bool(std::string name) const
Get a boolean valued setting.
Definition: settings.cpp:301
void set_string(std::string name, std::string val)
Set a string valued setting.
Definition: settings.cpp:272
~Settings()
Destructor.
Definition: settings.cpp:33
void add_int(std::string name, std::string comment, int val, bool negative=false)
Add an integer valued setting.
Definition: settings.cpp:201
Setting with a boolean value.
Definition: settings.h:41
void add_double(std::string name, std::string comment, double val, bool negative=false)
Add a double valued setting.
Definition: settings.cpp:179
Setting with a string value.
Definition: settings.h:64
std::string name
Name of setting.
Definition: settings.h:30
Setting with an integer value.
Definition: settings.h:51
int val
The value of the setting.
Definition: settings.h:57
void set_double(std::string name, double val)
Set a double valued setting.
Definition: settings.cpp:222
arma::vec get_vec(std::string name) const
Get a string setting and parse it as a vector.
Definition: settings.cpp:343
Setting with a double-type value.
Definition: settings.h:28
Settings()
Constructor.
Definition: settings.cpp:28
double get_double(std::string name) const
Get a double valued setting.
Definition: settings.cpp:287
std::string val
The value of the setting.
Definition: settings.h:70
arma::uvec get_uvec(std::string name) const
Get a string setting and parse it as an unsigned integer vector.
Definition: settings.cpp:363
bool val
The value of the setting.
Definition: settings.h:47
void set_int(std::string name, int val)
Set an integer valued setting.
Definition: settings.cpp:253
std::vector< doubleset_t > dset
Double precision number value settings.
Definition: settings.h:76