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-2013
9  * Copyright (c) 2010-2013, 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 /*! \mainpage ERKALE - DFT from Hel
18  *
19  * \section intro_sec Introduction
20  *
21  * ERKALE is a code for Hartree-Fock and density-functional theory
22  * calculations for atoms and molecules. It uses a Gaussian basis set
23  * for representing the molecular orbitals and the electron density.
24  *
25  * ERKALE is written in C++ and uses the Armadillo template library
26  * for linear algebra operations.
27  *
28  * ERKALE is designed to be as easily maintained and user friendly as
29  * possible, but also to try to be reasonably fast.
30  *
31  *
32  * \section why_another_code Why yet another code?
33  *
34  * I wanted to do some research on the modeling of inelastic x-ray
35  * scattering. This would require low-level access to a quantum
36  * chemical code.
37  *
38  * The code would need to have a gentle learning curve, be reasonably
39  * fast for "production" use - and be free, so that I and others could
40  * use the code anywhere they liked.
41  *
42  * As I did not find suitable existing programs on the market, I
43  * decided to write my own program. This would mean spending more time
44  * in development, although with the benefit of getting to grips with
45  * low level stuff. The decision was made a lot simpler due to the
46  * availability of fast, free libraries for computing electron
47  * repulsion integrals (libint) and exchange-correlation functionals
48  * (libxc), which meant that most of the dull stuff was already done
49  * by others.
50  *
51  * Being free is also important because scientific results need to be
52  * reproducible. The path from equations to results is often very long
53  * in computational science; a working code used to implement the
54  * equations is (at least!) as important as the equations or the
55  * algorithms themselves. To guarantee that the code stays available,
56  * I have chosen the GNU General public license, which is commonly
57  * used in other scientific software as well.
58  *
59  * \author Susi Lehtola
60  * \date 2011/11/25 13:16
61  */
62 
63 
64 
65 #ifndef ERKALE_GLOBAL
66 #define ERKALE_GLOBAL
67 
68 // Disable bounds checking in Armadillo.
69 #ifndef ARMA_NO_DEBUG
70 #define ARMA_NO_DEBUG
71 #endif
72 // Don't use Armadillo wrapper library
73 #ifndef ARMA_DONT_USE_WRAPPER
74 #define ARMA_DONT_USE_WRAPPER
75 #endif
76 // We need BLAS
77 #ifndef ARMA_USE_BLAS
78 #define ARMA_USE_BLAS
79 #endif
80 // and LAPACK
81 #ifndef ARMA_USE_LAPACK
82 #define ARMA_USE_LAPACK
83 #endif
84 
85 // Bohr in Ångström, CODATA 2014 value
86 #define BOHRINANGSTROM 0.52917721067
87 // Ångström in atomic units
88 #define ANGSTROMINBOHR (1/BOHRINANGSTROM)
89 // Atomic unit in eV, http://physics.nist.gov/cgi-bin/cuu/Value?threv
90 #define HARTREEINEV 27.21138505
91 // Atomic unit in debye, http://en.wikipedia.org/wiki/Debye
92 #define AUINDEBYE 0.393430307
93 // Fine structure constant
94 #define FINESTRUCT 7.2973525540510957E-3
95 
96 // Degree in radians
97 #define DEGINRAD (M_PI/180.0)
98 
99 // Initial tolerance, when density-based screening is used
100 #define ROUGHTOL 1e-9
101 // Fine tolance after initial convergence has been achieved (minimum)
102 #define FINETOL  1e-10
103 // When to switch to FINETOL (wrt. rms difference of density matrices)
104 #define TOLCHANGE 1e-5
105 
106 // Tolerance when screening is only wrt absolute value of integrals
107 #define STRICTTOL 1e-16
108 
109 // Shorthands
110 #define COMPLEX1 std::complex<double>(1.0,0.0)
111 #define COMPLEXI std::complex<double>(0.0,1.0)
112 
113 // Error info
114 #define ERROR_INFO() printf("\nError in function %s (file %s, near line %i)\n",__FUNCTION__,__FILE__,__LINE__);
115 // Print out location
116 #define LOC_INFO() {printf("Hello from function %s (file %s, near line %i)\n",__FUNCTION__,__FILE__,__LINE__); fflush(stdout);}
117 
118 // Check that matrix is of wanted size
119 #define MAT_SIZE_CHECK(M,NR,NC) if(M.n_rows != NR || M.n_cols != NC) { \
120     std::ostringstream oss;						\
121     oss << #M << " should be " << NR << " x " << NC << " but is " << M.n_rows << " x " << M.n_cols << "!\n"; \
122       throw std::runtime_error(oss.str());}
123 // Resize matrix if necessary
124 #define MAT_RESIZE(M,NR,NC) if(M.n_rows != NR || M.n_cols != NC) { M.zeros(NR,NC);}
125 
126 #define fprint_copyright(file) \
127   fprintf(file,"(c) Susi Lehtola, 2010-2016.\n");
128 #define print_copyright() fprint_copyright(stdout)
129 
130 #define fprint_license(file) \
131   fprintf(file,"\n%s%s%s%s\n",						\
132 	 "This program is free software; you can redistribute it and/or modify\n", \
133 	 "it under the terms of the GNU General Public License as published by\n", \
134 	 "the Free Software Foundation; either version 2 of the License, or\n", \
135 	 "(at your option) any later version.\n")
136 #define print_license() fprint_license(stdout)
137 
138 #define fprint_hostname(file)				\
139   {char _hname[4096];					\
140   int _herr=gethostname(_hname,4096);			\
141   if(! _herr) fprintf(file,"Running on host %s.\n\n",_hname);	\
142   else fprintf(file,"Error: couldn't get hostname.\n");}
143 #define print_hostname() fprint_hostname(stdout)
144 
145 #endif
146