MADNESS  0.10.1
DFParameters.h
Go to the documentation of this file.
1 
2 /// \file DFParameters
3 /// \brief Input parameters for a Dirac Fock calculation.
4 
5 #ifndef MADNESS_APPS_DFPARAMS_H_INCLUDED
6 #define MADNESS_APPS_DFPARAMS_H_INCLUDED
7 
9 
10 namespace madness {
11 
12  struct DFParameters{
13  // List of input parameters
14  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16  // If you add something here, don't forget to add it to serializable!
17  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
18  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
19  std::string archive; ///< Name of input archive to read in ground state
20  int job; ///< Indicates the type of job to do
21  ///< Values | Job
22  ///< --------------------------------------------------------------
23  ///< 0 | Dirac Fock on occupied orbitals only (Default)
24  ///< --------------------------------------------------------------
25  ///< Add more values here
26  ///<
27  int max_iter; ///< Maximum number of iterations
28  double small; ///< Minimum length scale to be resolved
29  double thresh; ///< Accuracy criterion when truncating
30  int k; ///< Number of legendre polynomials in scaling basis
31  bool kain; ///< Turns on KAIN nonlinear solver
32  int maxsub; ///< Sets maximum subspace size for KAIN
33  double maxrotn; ///< maximum step allowed by kain
34  bool restart; ///< Indicates this is a restarted DF job
35  int nucleus; ///< Indicates which nucleus model to use (1 for fermi, anything else for Gaussian)
36  bool do_save; ///< Whether or not to save after each iteration. Defaults to true. Turn off with 'no_save'
37  std::string savefile; ///< Gives the file to save the archive each iteration Default: DFrestartdata (in working directory)
38  int lb_iter; ///< How many iterations to load balance (after the initial load balancing)
39  bool nwchem; ///< Indicates archive given is actually an nwchem file for starting the job
40  bool lineplot; ///< Whether or not to make lineplots at the end of the job
41  bool no_compute; ///< If true, will skip all computation
42  double bohr_rad; ///< bohr radius in fm (default: 52917.7211)
43  int min_iter; ///< minimum number of iterations (default: 2)
44  bool Krestricted; ///< Calculation should be performed in Kramers-restricted manner (default: false)
45  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
46  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
47  // If you add something here, don't forget to add it to serializable!
48  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
49  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
50 
51  template<typename Archive>
52  void serialize(Archive& ar){
54  }
55 
56  // Default constructor
58  : job(0)
59  , max_iter(20)
60  , small(1e-5)
61  , thresh(1e-6)
62  , k(8)
63  , kain(false)
64  , maxsub(10)
65  , maxrotn(0.25)
66  , restart(false)
67  , nucleus(0)
68  , do_save(true)
69  , savefile("DFrestartdata")
70  , lb_iter(20)
71  , nwchem(false)
72  , lineplot(false)
73  , no_compute(false)
74  , bohr_rad(52917.7211)
75  , min_iter(2)
76  , Krestricted(false)
77  {}
78 
79  // Initializes DFParameters using the contents of file \c filename
80  void read_file(const std::string& filename){
81  std::ifstream f(filename.c_str());
82  read(f);
83  }
84 
85  // Initializes DFParameters using the contents of stream \c f
86  void read(std::istream& f){
87  position_stream(f, "DiracFock");
88  std::string s;
89 
90  while(f >> s){
91  if(s == "end"){
92  break;
93  }
94  else if (s == "archive"){
95  f >> archive;
96  }
97  else if (s == "job"){
98  f >> job;
99  }
100  else if (s == "max_iter"){
101  f >> max_iter;
102  }
103  else if (s == "small"){
104  f >> small;
105  }
106  else if (s == "thresh"){
107  f >> thresh;
108  }
109  else if (s == "k"){
110  f >> k;
111  }
112  else if (s == "kain"){
113  kain = true;
114  }
115  else if (s == "maxsub"){
116  f >> maxsub;
117  }
118  else if (s == "maxrotn"){
119  f >> maxrotn;
120  }
121  else if (s == "restart"){
122  restart = true;
123  }
124  else if (s == "nucleus"){
125  f >> nucleus;
126  }
127  else if (s == "no_save"){
128  do_save = false;
129  }
130  else if (s == "savefile"){
131  f >> savefile;
132  }
133  else if (s == "lb_iter"){
134  f >> lb_iter;
135  }
136  else if (s == "nwchem"){
137  nwchem = true;
138  }
139  else if (s == "lineplot"){
140  lineplot = true;
141  }
142  else if (s == "no_compute"){
143  no_compute = true;
144  }
145  else if (s == "bohr_rad"){
146  f >> bohr_rad;
147  }
148  else if (s == "min_iter"){
149  f >> min_iter;
150  }
151  else if (s == "Krestricted"){
152  Krestricted = true;
153  }
154  else{
155  std::cout << "Dirac Fock: unrecognized input keyword " << s << std::endl;
156  MADNESS_EXCEPTION("input error", 0);
157  }
158  }
159  } // end read()
160 
161  // Prints all information
162  void print_params() const{
163  madness::print("\n Input Dirac Fock Parameters");
164  madness::print(" -------------------------");
165  madness::print(" Initial Guess File:", archive);
166  madness::print(" Job:", job);
167  madness::print(" Refinement Threshold:", thresh);
168  madness::print(" k:", k);
169  madness::print("Smallest Resolved Length Scale:", small);
170  madness::print(" Max Iterations:", max_iter);
171  madness::print(" Use KAIN Solver:", kain);
172  if(kain) madness::print(" KAIN Solver Subspace Size:", maxsub);
173  madness::print(" Save:", do_save);
174  madness::print(" save file:", savefile);
175  if(nucleus == 1){
176  madness::print(" Nucleus: fermi");
177  }
178  else{
179  madness::print(" Nucleus: gaussian");
180  }
181  madness::print(" Kramers restriction:", Krestricted);
182  madness::print(" Do Lineplots:", lineplot);
183  }
184  };
185 
186 }
187 #endif
188 
189 //kthxbye
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition: madness_exception.h:119
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
static const char * filename
Definition: legendre.cc:96
std::istream & position_stream(std::istream &f, const std::string &tag, bool rewind=true)
Definition: position_stream.cc:37
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition: print.h:225
NDIM & f
Definition: mra.h:2416
Definition: DFParameters.h:12
bool no_compute
If true, will skip all computation.
Definition: DFParameters.h:41
int k
Number of legendre polynomials in scaling basis.
Definition: DFParameters.h:30
void read(std::istream &f)
Definition: DFParameters.h:86
double maxrotn
maximum step allowed by kain
Definition: DFParameters.h:33
double small
Minimum length scale to be resolved.
Definition: DFParameters.h:28
bool kain
Turns on KAIN nonlinear solver.
Definition: DFParameters.h:31
bool restart
Indicates this is a restarted DF job.
Definition: DFParameters.h:34
int lb_iter
How many iterations to load balance (after the initial load balancing)
Definition: DFParameters.h:38
int min_iter
minimum number of iterations (default: 2)
Definition: DFParameters.h:43
std::string archive
Name of input archive to read in ground state.
Definition: DFParameters.h:19
int max_iter
Maximum number of iterations.
Definition: DFParameters.h:27
bool lineplot
Whether or not to make lineplots at the end of the job.
Definition: DFParameters.h:40
bool Krestricted
Definition: DFParameters.h:44
void serialize(Archive &ar)
Definition: DFParameters.h:52
double thresh
Accuracy criterion when truncating.
Definition: DFParameters.h:29
void print_params() const
Definition: DFParameters.h:162
std::string savefile
Gives the file to save the archive each iteration Default: DFrestartdata (in working directory)
Definition: DFParameters.h:37
double bohr_rad
bohr radius in fm (default: 52917.7211)
Definition: DFParameters.h:42
int job
Definition: DFParameters.h:20
void read_file(const std::string &filename)
Definition: DFParameters.h:80
bool nwchem
Indicates archive given is actually an nwchem file for starting the job.
Definition: DFParameters.h:39
int nucleus
Indicates which nucleus model to use (1 for fermi, anything else for Gaussian)
Definition: DFParameters.h:35
DFParameters()
Definition: DFParameters.h:57
bool do_save
Whether or not to save after each iteration. Defaults to true. Turn off with 'no_save'.
Definition: DFParameters.h:36
int maxsub
Sets maximum subspace size for KAIN.
Definition: DFParameters.h:32
void e()
Definition: test_sig.cc:75