SIRIUS 7.5.0
Electronic structure library and applications
typedefs.hpp
Go to the documentation of this file.
1// Copyright (c) 2013-2018 Anton Kozhevnikov, Thomas Schulthess
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without modification, are permitted provided that
5// the following conditions are met:
6//
7// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
8// following disclaimer.
9// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
10// and the following disclaimer in the documentation and/or other materials provided with the distribution.
11//
12// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
13// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
14// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
15// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
17// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
20/** \file typedefs.hpp
21 *
22 * \brief Contains typedefs, enums and simple descriptors.
23 */
24
25#ifndef __TYPEDEFS_HPP__
26#define __TYPEDEFS_HPP__
27
28#include <cstdlib>
29#include <complex>
30#include <cstdint>
31#include <vector>
32#include <array>
33#include <limits>
34#include <map>
35#include <algorithm>
36#include <type_traits>
37
38namespace sirius {
39
40// define type traits that return real type
41// general case for real type
42template <typename T>
43struct Real {using type = T;};
44
45// special case for complex type
46template <typename T>
47struct Real<std::complex<T>> {using type = T;};
48
49template <typename T>
50using real_type = typename Real<T>::type;
51
52template <class T>
53constexpr bool is_real_v = std::is_same<T, real_type<T>>::value;
54
55/// Spin-blocks of the Hamiltonian.
56enum class spin_block_t
57{
58 /// Non-magnetic case.
59 nm,
60
61 /// Up-up block.
62 uu,
63
64 /// Down-donw block.
65 dd,
66
67 ///Up-down block.
68 ud,
69
70 /// Down-up block.
71 du
72};
73
74/// Type of electronic structure methods.
76{
77 /// Full potential linearized augmented plane waves with local orbitals.
79
80 /// Pseudopotential (ultrasoft, norm-conserving, PAW).
82};
83
84/// Type of a function domain.
86{
87 /// Spatial domain.
88 spatial,
89 /// Spectral domain.
91};
92
93/// Type of relativity treatment in the case of LAPW.
94enum class relativity_t
95{
96 none,
97
98 koelling_harmon,
99
100 zora,
101
102 iora,
103
104 dirac
105};
106
107inline relativity_t get_relativity_t(std::string name__)
108{
109 std::transform(name__.begin(), name__.end(), name__.begin(), ::tolower);
110 std::map<std::string, relativity_t> const m = {
111 {"none", relativity_t::none},
112 {"koelling_harmon", relativity_t::koelling_harmon},
113 {"zora", relativity_t::zora},
114 {"iora", relativity_t::iora},
115 {"dirac", relativity_t::dirac}
116 };
117
118 if (m.count(name__) == 0) {
119 std::stringstream s;
120 s << "get_relativity_t(): wrong label of the relativity_t enumerator: " << name__;
121 throw std::runtime_error(s.str());
122 }
123 return m.at(name__);
124}
125
126/// Describes radial solution.
128{
129 /// Principal quantum number.
130 int n;
131
132 /// Angular momentum quantum number.
133 int l;
134
135 /// Order of energy derivative.
136 int dme;
137
138 /// Energy of the solution.
139 double enu;
140
141 /// Automatically determine energy.
143
144 bool new_enu_found{false};
145};
146
147inline std::ostream& operator<<(std::ostream& out, radial_solution_descriptor const& rsd)
148{
149 out << "{l: " << rsd.l << ", n: " << rsd.n << ", enu: " << rsd.enu
150 << ", dme: " << rsd.dme << ", auto: " << rsd.auto_enu << "}";
151 return out;
152}
153
154/// Set of radial solution descriptors, used to construct augmented waves or local orbitals.
155typedef std::vector<radial_solution_descriptor> radial_solution_descriptor_set;
156
157/// Descriptor of an atom in a list of nearest neighbours for each atom.
158/** See sirius::Unit_cell::find_nearest_neighbours() for the details of usage. */
160{
161 /// Index of the neighbouring atom.
163
164 /// Translation in fractional coordinates.
165 std::array<int, 3> translation;
166
167 /// Distance from the central atom.
168 double distance;
169
170 /// Vector connecting central atom with the neighbour in Cartesian coordinates.
171 std::array<double, 3> rc;
172};
173
175{
176 double a;
177 double b;
178 double c;
179 double alpha;
180 double beta;
181 double gamma;
182};
183
184/// Descriptor of the local-orbital part of the LAPW+lo basis.
186{
187 /// Index of atom.
188 uint16_t ia;
189
190 /// Index of orbital quantum number \f$ \ell \f$.
191 uint8_t l;
192
193 /// Combined lm index.
194 uint16_t lm;
195
196 /// Order of the local orbital radial function for the given orbital quantum number \f$ \ell \f$.
197 /** All radial functions for the given orbital quantum number \f$ \ell \f$ are ordered in the following way:
198 * augmented radial functions come first followed by the local orbital radial function. */
199 uint8_t order;
200
201 /// Index of the local orbital radial function.
202 uint8_t idxrf;
203};
204
205template <typename T>
207{
208 T* ptr{nullptr};
209 int lmmax{0};
210 int nrmtmax{0};
211 int num_atoms{0};
212
214 {
215 }
216
217 spheric_function_set_ptr_t(T* ptr__, int lmmax__, int nrmtmax__, int num_atoms__)
218 : ptr{ptr__}
219 , lmmax{lmmax__}
220 , nrmtmax{nrmtmax__}
221 , num_atoms{num_atoms__}
222 {
223 }
224};
225
226template <typename T>
228{
229 T* ptr{nullptr};
230 int size_x{0};
231 int size_y{0};
232 int size_z{0};
233 /* if offset_z is negative, FFT buffer is not distributed */
234 /* if offset_z >= 0. FFT buffer is treated as distributed and size_z is a local size along z-dimension */
235 int offset_z{0};
236
238 {
239 }
240
241 smooth_periodic_function_ptr_t(T* ptr__, int size_x__, int size_y__, int size_z__, int offset_z__)
242 : ptr{ptr__}
243 , size_x{size_x__}
244 , size_y{size_y__}
245 , size_z{size_z__}
246 , offset_z{offset_z__}
247 {
248 }
249};
250
251/// Describe external pointers to periodic function.
252/** In case when data is allocated by the calling code, the pointers to muffin-tin and real-space grids
253 can be passed to Periodic_function to avoid allocation on the SIRIUS side.*/
254template <typename T>
256{
259
261 {
262 }
263
265 : mt{mt__}
266 , rg{rg__}
267 {
268 }
269};
270
271}
272
273#endif // __TYPEDEFS_HPP__
std::enable_if_t< std::is_same< T, real_type< F > >::value, void > transform(::spla::Context &spla_ctx__, sddk::memory_t mem__, la::dmatrix< F > const &M__, int irow0__, int jcol0__, real_type< F > alpha__, Wave_functions< T > const &wf_in__, spin_index s_in__, band_range br_in__, real_type< F > beta__, Wave_functions< T > &wf_out__, spin_index s_out__, band_range br_out__)
Apply linear transformation to the wave-functions.
Namespace of the SIRIUS library.
Definition: sirius.f90:5
std::ostream & operator<<(std::ostream &out, hbar &&b)
Inject horisontal bar to ostream.
relativity_t
Type of relativity treatment in the case of LAPW.
Definition: typedefs.hpp:95
electronic_structure_method_t
Type of electronic structure methods.
Definition: typedefs.hpp:76
@ full_potential_lapwlo
Full potential linearized augmented plane waves with local orbitals.
@ pseudopotential
Pseudopotential (ultrasoft, norm-conserving, PAW).
std::vector< radial_solution_descriptor > radial_solution_descriptor_set
Set of radial solution descriptors, used to construct augmented waves or local orbitals.
Definition: typedefs.hpp:155
function_domain_t
Type of a function domain.
Definition: typedefs.hpp:86
@ spectral
Spectral domain.
@ spatial
Spatial domain.
spin_block_t
Spin-blocks of the Hamiltonian.
Definition: typedefs.hpp:57
@ du
Down-up block.
@ dd
Down-donw block.
@ ud
Up-down block.
@ uu
Up-up block.
@ nm
Non-magnetic case.
Descriptor of the local-orbital part of the LAPW+lo basis.
Definition: typedefs.hpp:186
uint8_t l
Index of orbital quantum number .
Definition: typedefs.hpp:191
uint8_t order
Order of the local orbital radial function for the given orbital quantum number .
Definition: typedefs.hpp:199
uint8_t idxrf
Index of the local orbital radial function.
Definition: typedefs.hpp:202
uint16_t ia
Index of atom.
Definition: typedefs.hpp:188
uint16_t lm
Combined lm index.
Definition: typedefs.hpp:194
Descriptor of an atom in a list of nearest neighbours for each atom.
Definition: typedefs.hpp:160
std::array< double, 3 > rc
Vector connecting central atom with the neighbour in Cartesian coordinates.
Definition: typedefs.hpp:171
double distance
Distance from the central atom.
Definition: typedefs.hpp:168
std::array< int, 3 > translation
Translation in fractional coordinates.
Definition: typedefs.hpp:165
int atom_id
Index of the neighbouring atom.
Definition: typedefs.hpp:162
Describe external pointers to periodic function.
Definition: typedefs.hpp:256
Describes radial solution.
Definition: typedefs.hpp:128
double enu
Energy of the solution.
Definition: typedefs.hpp:139
int auto_enu
Automatically determine energy.
Definition: typedefs.hpp:142
int n
Principal quantum number.
Definition: typedefs.hpp:130
int l
Angular momentum quantum number.
Definition: typedefs.hpp:133
int dme
Order of energy derivative.
Definition: typedefs.hpp:136