Octopus
base.hpp
Go to the documentation of this file.
1#ifndef PSEUDO_BASE_HPP
2#define PSEUDO_BASE_HPP
3
4/*
5 Copyright (C) 2018 Xavier Andrade
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
22#include <rapidxml.hpp>
23#include <sstream>
24#include <string>
25#include <vector>
26
27#define MAX_L 10
28#define INVALID_L 333
29
30namespace pseudopotential {
31
32enum class type {
33 ULTRASOFT = 30,
34 SEMILOCAL = 31,
35 KLEINMAN_BYLANDER = 32,
36 PAW = 33
37};
38
39enum class status {
40 SUCCESS = 0,
41 FILE_NOT_FOUND = 455,
42 FORMAT_NOT_SUPPORTED = 456,
43 UNKNOWN_FORMAT = 457,
44 UNSUPPORTED_TYPE_ULTRASOFT = 458,
45 UNSUPPORTED_TYPE_PAW = 459,
46 UNSUPPORTED_TYPE = 460
47};
48
49enum class format {
50 FILE_NOT_FOUND = 773,
51 UNKNOWN = 774,
52 UPF1 = 775,
53 UPF2 = 776,
54 QSO = 777,
55 PSML = 778,
56 PSF = 779,
57 CPI = 780,
58 FHI = 781,
59 HGH = 782,
60 PSP8 = 783
61};
62
63// these values match libxc convention
64enum class exchange {
65 UNKNOWN = -2,
66 ANY = -1,
67 NONE = 0,
68 LDA = 1,
69 PBE = 101,
70 PBE_SOL = 116,
71 B88 = 106
72};
73
74enum class correlation {
75 UNKNOWN = -2,
76 ANY = -1,
77 NONE = 0,
78 LDA_PZ = 9,
79 LDA_PW = 12,
80 LDA_XC_TETER93 = 20,
81 PBE = 130,
82 PBE_SOL = 133,
83 LYP = 131
84};
85
86class base {
87
88public:
89 virtual ~base() {}
90 virtual pseudopotential::type type() const { return type_; }
91 virtual int lmax() const { return lmax_; }
92
93 // Pure virtual functions
94 virtual pseudopotential::format format() const = 0;
95 virtual int size() const = 0;
96 virtual std::string description() const = 0;
97 virtual std::string symbol() const = 0;
98 virtual int atomic_number() const = 0;
99 virtual double mass() const = 0;
100 virtual double valence_charge() const = 0;
101 virtual int llocal() const = 0;
102 virtual int nchannels() const = 0;
103 virtual double mesh_spacing() const = 0;
104 virtual int mesh_size() const = 0;
105 virtual void local_potential(std::vector<double> &potential) const = 0;
106 virtual int nprojectors() const = 0;
107 virtual int nprojectors_per_l(int l) const = 0;
108 virtual void projector(int l, int i, std::vector<double> &proj) const = 0;
109 virtual double d_ij(int l, int i, int j) const = 0;
110 virtual bool has_radial_function(int l) const = 0;
111 virtual void radial_function(int l, std::vector<double> &function) const = 0;
112 virtual void radial_potential(int l, std::vector<double> &function) const = 0;
113
114 virtual void grid(std::vector<double> &val) const {
115 val.resize(mesh_size());
116 for (unsigned ii = 0; ii < val.size(); ii++)
117 val[ii] = ii * mesh_spacing();
118 }
119
120 virtual void grid_weights(std::vector<double> &val) const {
121 val.resize(mesh_size());
122 for (unsigned ii = 1; ii < val.size() - 1; ii++)
123 val[ii] = mesh_spacing();
124 val[0] = 0.5 * mesh_spacing();
125 val[val.size() - 1] = 0.5 * mesh_spacing();
126 }
127
128 // Functions for things that might not be provided
129 virtual int nquad() const { return 0; }
130 virtual double rquad() const { return 0.0; }
131 virtual bool has_nlcc() const { return false; }
132 virtual void nlcc_density(std::vector<double> &density) const {
133 density.clear();
134 }
135 virtual void beta(int index, int &l, std::vector<double> &proj) const {
136 l = 0;
137 proj.clear();
138 }
139 virtual void dnm_zero(int nbeta,
140 std::vector<std::vector<double>> &dnm) const {
141 dnm.clear();
142 }
143 virtual bool has_rinner() const { return false; }
144 virtual void rinner(std::vector<double> &val) const { val.clear(); }
145 virtual void qnm(int index, int &l1, int &l2, int &n, int &m,
146 std::vector<double> &val) const {
147 val.clear();
148 }
149 virtual void qfcoeff(int index, int ltot, std::vector<double> &val) const {
150 val.clear();
151 }
152 virtual bool has_density() const { return false; }
153 virtual void density(std::vector<double> &val) const { val.clear(); }
154 virtual int nwavefunctions() const { return 0; }
155 virtual void wavefunction(int index, int &n, int &l, double &occ,
156 std::vector<double> &val) const {
157 val.clear();
158 }
159 virtual pseudopotential::exchange exchange() const {
160 return pseudopotential::exchange::UNKNOWN;
161 }
162 virtual pseudopotential::correlation correlation() const {
163 return pseudopotential::correlation::UNKNOWN;
164 }
165
166 virtual bool has_total_angular_momentum() const { return false; }
167 virtual int projector_2j(int l, int ic) const {
168 return 0;
169 } // returns j multiplied by 2
170 virtual int wavefunction_2j(int ii) const {
171 return 0;
172 } // returns j multiplied by 2
173
174protected:
175 std::string filename_;
176
177 template <typename Type> static Type value(const rapidxml::xml_base<> *node) {
178 assert(node);
179 std::istringstream stst(node->value());
180 Type value;
181 stst >> value;
182 return value;
183 }
184
185 pseudopotential::type type_;
186 int lmax_;
187};
188
189} // namespace pseudopotential
190
191
192#endif
if write to the Free Software Franklin Fifth USA !If the compiler accepts long Fortran it is better to use that and build all the preprocessor definitions in one line In !this the debuggers will provide the right line numbers !If the compiler accepts line number then CARDINAL and ACARDINAL !will put them just a new line or a ampersand plus a new line !These macros should be used in macros that span several lines They should by !put immedialty before a line where a compilation error might occur and at the !end of the macro !Note that the cardinal and newline words are substituted by the program !preprocess pl by the ampersand and by a real new line just before compilation !The assertions are ignored if the code is compiled in not debug when !prints out the assertion string
Definition: global.h:46
integer, parameter, public density
Definition: quantity.F90:146
integer, parameter, public mass
Definition: quantity.F90:146
ptrdiff_t l
Definition: operate_inc.c:12
ptrdiff_t i
Definition: operate_inc.c:12
ptrdiff_t j
Definition: operate_inc.c:12
const int *restrict index
Definition: operate_inc.c:13