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_qij_integrals() const { return false; }
153 virtual double q_ij(int l, int i, int j) const { return 0.0; }
154 virtual bool has_radial_augmentation() const { return false; }
155 virtual bool radial_augmentation_has_angular_channels() const { return false; }
156 virtual int radial_augmentation_lmax() const { return -1; }
157 virtual void radial_augmentation(int i, int j, int ltot,
158 std::vector<double> &val) const {
159 val.clear();
160 }
161 // PAW-specific data. Only PAW datasets provide these; every other reader
162 // inherits the empty defaults below.
163 virtual bool has_paw() const { return false; }
164 // Number of PAW partial waves (== number of projectors for a PAW set).
165 virtual int paw_nwavefunctions() const { return 0; }
166 // All-electron / pseudo partial waves phi_i / phi~_i (true radial function,
167 // r-factor already divided out), one per projector channel.
168 virtual void paw_ae_wavefunction(int index, std::vector<double> &val) const {
169 val.clear();
170 }
171 virtual void paw_ps_wavefunction(int index, std::vector<double> &val) const {
172 val.clear();
173 }
174 virtual bool has_paw_ae_nlcc() const { return false; }
175 // All-electron core density n_c(r) (raw density, no r factor).
176 virtual void paw_ae_nlcc(std::vector<double> &val) const { val.clear(); }
177 // All-electron local (ionic) potential v_AE(r) in Hartree.
178 virtual void paw_ae_vlocal(std::vector<double> &val) const { val.clear(); }
179 // Reference occupations, one per partial wave.
180 virtual void paw_occupations(std::vector<double> &val) const { val.clear(); }
181 // Augmentation multipole moments, flattened (nwfc x nwfc x (lmax_aug+1)).
182 virtual void paw_multipoles(std::vector<double> &val) const { val.clear(); }
183 virtual int paw_augmentation_lmax() const { return -1; }
184 // Compensation-charge shape identifier ("PSQ", "BESSEL", "GAUSS", ...).
185 virtual std::string paw_augmentation_shape() const { return ""; }
186 // Frozen-core reference energy in Hartree (0 if not provided).
187 virtual double paw_core_energy() const { return 0.0; }
188 // Radius of the PAW augmentation sphere in bohr (0 if not provided).
189 virtual double paw_cutoff_radius() const { return 0.0; }
190
191 virtual bool has_density() const { return false; }
192 virtual void density(std::vector<double> &val) const { val.clear(); }
193 virtual int nwavefunctions() const { return 0; }
194 virtual void wavefunction(int index, int &n, int &l, double &occ,
195 std::vector<double> &val) const {
196 val.clear();
197 }
198 virtual pseudopotential::exchange exchange() const {
199 return pseudopotential::exchange::UNKNOWN;
200 }
201 virtual pseudopotential::correlation correlation() const {
202 return pseudopotential::correlation::UNKNOWN;
203 }
204
205 virtual bool has_total_angular_momentum() const { return false; }
206 virtual int projector_2j(int l, int ic) const {
207 return 0;
208 } // returns j multiplied by 2
209 virtual int wavefunction_2j(int ii) const {
210 return 0;
211 } // returns j multiplied by 2
212
213protected:
214 std::string filename_;
215
216 template <typename Type> static Type value(const rapidxml::xml_base<> *node) {
217 assert(node);
218 std::istringstream stst(node->value());
219 Type value;
220 stst >> value;
221 return value;
222 }
223
224 pseudopotential::type type_;
225 int lmax_;
226};
227
228} // namespace pseudopotential
229
230
231#endif
if write to the Free Software Franklin Fifth USA !The assertions are ignored if the code is compiled in not debug when !prints out the assertion string
Definition: global.h:32
ptrdiff_t l
ptrdiff_t i
ptrdiff_t j
const int *restrict index
Definition: operate_inc.c:30