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 
32 #include <madness/world/MADworld.h>
33 #include <madness/mra/mra.h>
34 #include <madness/tensor/tensor.h>
35 #include <fstream>
36 #include "xcfunctional.h"
37 
38 using namespace madness;
39 
40 struct xcfunc_data_point
41 {
42   double rhoa, rhob;
43   double sigmaaa, sigmaab, sigmabb;
44   double zk;
45   double vrhoa, vrhob;
46   double vsigmaaa, vsigmaab, vsigmabb;
47   double v2rhoa2, v2rhoab, v2rhob2;
48 };
49 
test_lda(World & world)50 void test_lda(World& world)
51 {
52     XCfunctional xcfunc;
53     xcfunc.initialize("LDA RHOTOL 1e-12 RHOMIN 1e-12", false, world);
54 
55     /*
56 
57       generated WITHOUT libxc
58 
59 100 -887.752 -5.88809
60 10 -42.0542 -2.78016
61 1 -2.01597 -1.32674
62 0.1 -0.0981113 -0.64225
63 0.01 -0.00485142 -0.316006
64 0.001 -0.000242858 -0.157725
65 0.0001 -1.22083e-05 -0.0793057
66 1e-05 -6.10474e-07 -0.0397809
67 1e-06 -3.01609e-08 -0.0197451
68 1e-07 -1.46896e-09 -0.00966166
69 1e-08 -7.06144e-11 -0.00466261
70 1e-09 -3.35942e-12 -0.00222473
71 1e-10 -1.58607e-13 -0.00105256
72 1e-11 -7.44811e-15 -0.000494995
73 1e-12 -3.48465e-16 -0.000231817
74 1e-13 -1.38544e-16 -0.000184377
75 1e-14 -1.38544e-16 -0.000184377
76 1e-15 -1.38544e-16 -0.000184377
77 
78      */
79 
80     const long N = 18;
81     Tensor<double> rho(N);
82     double x = 100.0;
83     for (int i=0; i<18; i++) {
84         rho[i] = x;
85         x *= 0.1;
86     }
87 
88     std::vector<Tensor<double>> t {rho};
89 
90     Tensor<double> e = xcfunc.exc(t);
91     std::vector<Tensor<double>> v = xcfunc.vxc(t, 0);
92 
93     for (int i=0; i<N; i++) {
94         print(rho[i], e[i], v[0][i]);
95     }
96 }
97 
main(int argc,char ** argv)98 int main(int argc, char** argv) {
99     madness::initialize(argc, argv);
100 
101     madness::World world(SafeMPI::COMM_WORLD);
102     world.gop.fence();
103 
104     test_lda(world);
105 
106     madness::finalize();
107     return 0;
108 }
109