MADNESS  0.10.1
electronicstructureparams.h
Go to the documentation of this file.
1 /*
2  This file is part of MADNESS.
3 
4  Copyright (C) 2007,2010 Oak Ridge National Laboratory
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 
20  For more information please contact:
21 
22  Robert J. Harrison
23  Oak Ridge National Laboratory
24  One Bethel Valley Road
25  P.O. Box 2008, MS-6367
26 
27  email: harrisonrj@ornl.gov
28  tel: 865-241-3937
29  fax: 865-572-0680
30 
31  $Id$
32 */
33 #ifndef ELECTRONICSTRUCTUREPARAMS_H_
34 #define ELECTRONICSTRUCTUREPARAMS_H_
35 
36 #include <madness/mra/mra.h>
37 #include <madness/mra/vmra.h>
38 #include <madness/misc/ran.h>
39 #include <madness/misc/misc.h>
40 #include "mentity.h"
41 #include "molecularbasis.h"
42 
43 namespace madness {
44 
46 {
47  // Size of the cubic box (this needs to change)
48  double L;
49  // Number of electrons
50  int nelec;
51  // 1 - LDA; 2 - Hartree-Fock
53  // Low value in the BSH / Coulomb fit
54  double lo;
55  // Spin-polarized
56  bool spinpol;
57  // Periodic system
58  bool periodic;
59  // Maximum number of interations
60  int maxits;
61  // Is source function a nuclear potential or a nuclear charge density?
63  // Thresh
64  double thresh;
65  // Order of wavelets
66  int waveorder;
67  // Max thresh
68  double maxthresh;
69  // Max order of wavelets
71  // Number of empty states
72  int nempty;
73  // Smearing parameter
74  double smear;
75  // Total number of bands
76  int nbands;
77  // Size of k-mesh (hardcoded for 3-d)
79  // Maximum occupation
80  double maxocc;
81  // Read k-points?
82  bool kpoints;
83  // Fractional coordinates?
84  bool fractional;
85  // Maximum size of subspace
86  unsigned int maxsub;
87  // maxrotn
88  double maxrotn;
89  // Solve for canonical orbitals?
90  bool canon;
91  // Don't use solver = 0; full KAIN = 1; k-point KAIN = 2
92  int solver;
93  // k-mesh offset
95  // initial basis set
96  std::string basis;
97  // number of IO nodes
98  int nio;
99  // restart calculation; no restart = 0; restart fully = 1;
100  // restart using only density = 2;
101  int restart;
102  // total amount of electronic charge
103  double ncharge;
104  // width for smearing
105  double swidth;
106  // print matrices
108  // plot orbitals
109  bool plotorbs;
110  // convergence criterion for residual
111  double rcriterion;
112  // do we want our crystal centered?
113  bool centered;
114  // damping factor for step restriction
115  double sd;
116 
117  template <typename Archive>
118  void serialize(Archive& ar) {
119  ar & L & nelec & functional & lo & spinpol &
125  koffset2 & basis & nio & restart & ncharge &
127  centered & sd;
128  }
129 
131  {
132  L = 10.0;
133  nelec = 1;
134  functional = 1;
135  lo = 1e-4;
136  smear = 0.001;
137  spinpol = false;
138  periodic = false;
139  ispotential = false;
140  maxits = 100;
141  thresh = 1e-6;
142  waveorder = 8;
143  maxthresh = 1e-6;
144  maxwaveorder = 8;
145  nempty = 2;
146  ngridk0 = 1; ngridk1 = 1; ngridk2 = 1;
147  maxocc = 2.0;
149  kpoints = false;
150  fractional = false;
151  maxsub = 1;
152  maxrotn = 0.5;
153  canon = true;
154  solver = 1;
155  koffset0 = 0.0;
156  koffset1 = 0.0;
157  koffset2 = 0.0;
158  basis = "sto-3g";
159  nio = 1;
160  restart = 0;
161  ncharge = 0;
162  swidth = 0.001;
163  print_matrices = true;
164  plotorbs = false;
165  rcriterion = 1e-4;
166  centered = true;
167  sd = 0.4;
168  }
169 
170  void read_file(const std::string& filename)
171  {
172  std::ifstream f(filename.c_str());
173  position_stream(f, "dft");
174  std::string s;
175  bool bnelec = false;
176  while (f >> s)
177  {
178  if (s == "end")
179  {
180  break;
181  }
182  else if (s == "nelec")
183  {
184  f >> nelec;
185  bnelec = true;
186  }
187  else if (s == "solver")
188  {
189  f >> solver;
190  }
191  else if (s == "L")
192  {
193  f >> L;
194  }
195  else if (s == "functional")
196  {
197  f >> functional;
198  }
199  else if (s == "basis")
200  {
201  f >> basis;
202  }
203  else if (s == "lo")
204  {
205  f >> lo;
206  }
207  else if (s == "swidth")
208  {
209  f >> swidth;
210  }
211  else if (s == "nio")
212  {
213  f >> nio;
214  }
215  else if (s == "restart") {
216  restart = true;
217  }
218  else if (s == "norestart") {
219  restart = false;
220  }
221  else if (s == "spinpol") {
222  spinpol = true;
223  }
224  else if (s == "nospinpol") {
225  spinpol = false;
226  }
227  else if (s == "canon") {
228  canon = true;
229  }
230  else if (s == "nocanon") {
231  canon = false;
232  }
233  else if (s == "periodic") {
234  periodic = true;
235  }
236  else if (s == "noperiodic") {
237  periodic = false;
238  }
239  else if (s == "usepotential") {
240  ispotential = true;
241  }
242  else if (s == "nousepotential") {
243  ispotential = false;
244  }
245  else if (s == "maxits")
246  {
247  f >> maxits;
248  }
249  else if (s == "maxsub")
250  {
251  f >> maxsub;
252  }
253  else if (s == "maxrotn")
254  {
255  f >> maxrotn;
256  }
257  else if (s == "damping")
258  {
259  f >> sd;
260  }
261  else if (s == "thresh")
262  {
263  f >> maxthresh;
264  thresh = maxthresh;
265  }
266  else if (s == "waveorder")
267  {
268  f >> maxwaveorder;
270  }
271  else if (s == "nempty")
272  {
273  f >> nempty;
274  }
275  else if (s == "kpoints")
276  {
277  std::string tempstr;
278  f >> tempstr;
279  if (tempstr == "true")
280  {
281  kpoints = true;
282  }
283  else if (tempstr == "false")
284  {
285  kpoints = false;
286  }
287  else
288  {
289  MADNESS_EXCEPTION("input error -- kpoints", 0);
290  }
291  }
292  else if (s == "fractional") {
293  fractional = true;
294  }
295  else if (s == "nofractional") {
296  fractional = false;
297  }
298  else if (s == "ngridk")
299  {
300  f >> ngridk0; f >> ngridk1; f >> ngridk2;
301  }
302  else if (s == "koffset")
303  {
304  f >> koffset0; f >> koffset1; f >> koffset2;
305  }
306  else if (s == "print_matrices") {
307  print_matrices = true;
308  }
309  else if (s == "noprint_matrices") {
310  print_matrices = false;
311  }
312  else if (s == "center") {
313  centered = true;
314  }
315  else if (s == "nocenter") {
316  centered = false;
317  }
318  else if (s == "plotorbs") {
319  plotorbs = true;
320  }
321  else if (s == "noplotorbs") {
322  plotorbs = false;
323  }
324  else if (s == "rcriterion")
325  {
326  f >> rcriterion;
327  }
328  else
329  {
330  std::cout << "esolver: unrecognized input keyword " << s << std::endl;
331  MADNESS_EXCEPTION("input error", 0);
332  }
333  }
334  // No spin polarization
335  //if (spinpol = true) MADNESS_EXCEPTION("spinpol not implemented", 0);
336  // nelec is required
337  //if (!bnelec) MADNESS_EXCEPTION("nelec required", 0);
338 // // maximum occupation
339 // maxocc = (spinpol) ? 1.0 : 2.0;
340 // // compute total number of bands
341 // nbands = nelec/maxocc + nempty;
342  // kpoints only for periodic
343  if (kpoints && !periodic)
344  MADNESS_EXCEPTION("input error -- k-points only valid with periodic calculation", 0);
345  }
346 
348  lo = mentity.smallest_length_scale();
349  }
350 };
351 
352 }
353 #endif /* ELECTRONICSTRUCTUREPARAMS_H_ */
Definition: mentity.h:95
double smallest_length_scale() const
Definition: mentity.cc:403
Contracted Gaussian basis.
Definition: madness/chem/molecularbasis.h:465
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition: madness_exception.h:119
Header to declare stuff which has not yet found a home.
Main include file for MADNESS and defines Function interface.
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
NDIM & f
Definition: mra.h:2416
Definition: electronicstructureparams.h:46
int maxwaveorder
Definition: electronicstructureparams.h:70
unsigned int maxsub
Definition: electronicstructureparams.h:86
bool spinpol
Definition: electronicstructureparams.h:56
int nio
Definition: electronicstructureparams.h:98
bool fractional
Definition: electronicstructureparams.h:84
double ncharge
Definition: electronicstructureparams.h:103
double maxthresh
Definition: electronicstructureparams.h:68
bool kpoints
Definition: electronicstructureparams.h:82
double koffset2
Definition: electronicstructureparams.h:94
int ngridk1
Definition: electronicstructureparams.h:78
void set_molecular_info(const MolecularEntity &mentity, const AtomicBasisSet &aobasis)
Definition: electronicstructureparams.h:347
bool ispotential
Definition: electronicstructureparams.h:62
int restart
Definition: electronicstructureparams.h:101
bool canon
Definition: electronicstructureparams.h:90
void serialize(Archive &ar)
Definition: electronicstructureparams.h:118
int maxits
Definition: electronicstructureparams.h:60
double rcriterion
Definition: electronicstructureparams.h:111
int nempty
Definition: electronicstructureparams.h:72
int nelec
Definition: electronicstructureparams.h:50
double koffset1
Definition: electronicstructureparams.h:94
int nbands
Definition: electronicstructureparams.h:76
std::string basis
Definition: electronicstructureparams.h:96
void read_file(const std::string &filename)
Definition: electronicstructureparams.h:170
int waveorder
Definition: electronicstructureparams.h:66
double swidth
Definition: electronicstructureparams.h:105
double smear
Definition: electronicstructureparams.h:74
double sd
Definition: electronicstructureparams.h:115
double lo
Definition: electronicstructureparams.h:54
ElectronicStructureParams()
Definition: electronicstructureparams.h:130
double maxocc
Definition: electronicstructureparams.h:80
double thresh
Definition: electronicstructureparams.h:64
bool plotorbs
Definition: electronicstructureparams.h:109
int functional
Definition: electronicstructureparams.h:52
int ngridk0
Definition: electronicstructureparams.h:78
double L
Definition: electronicstructureparams.h:48
bool centered
Definition: electronicstructureparams.h:113
bool print_matrices
Definition: electronicstructureparams.h:107
int solver
Definition: electronicstructureparams.h:92
bool periodic
Definition: electronicstructureparams.h:58
int ngridk2
Definition: electronicstructureparams.h:78
double maxrotn
Definition: electronicstructureparams.h:88
double koffset0
Definition: electronicstructureparams.h:94
void e()
Definition: test_sig.cc:75
static AtomicBasisSet aobasis
Definition: testperiodicdft.cc:39
Defines operations on vectors of Functions.