SIRIUS 7.5.0
Electronic structure library and applications
basis_functions_index.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 basis_functions_index.hpp
21 *
22 * \brief Contains definitiona and implementation of sirius::basis_functions_index class.
23 */
24
25#ifndef __BASIS_FUNCTIONS_INDEX_HPP__
26#define __BASIS_FUNCTIONS_INDEX_HPP__
27
28namespace sirius {
29
31{
32 /// Total angular momemtum.
34 /// Projection of the angular momentum.
35 int m;
36 /// Composite index.
37 int lm;
38 /// Order of the radial function for a given l (j).
39 int order;
40 /// Index of local orbital.
42 /// Index of the radial function or beta projector in the case of pseudo potential.
44 bf_index xi{-1};
45
47 : am(am)
48 , m(m)
49 , lm(sf::lm(am.l(), m))
50 , order(order)
51 , idxlo(idxlo)
52 , idxrf(idxrf)
53 {
54 RTE_ASSERT(m >= -am.l() && m <= am.l());
55 RTE_ASSERT(order >= 0);
56 RTE_ASSERT(idxrf >= 0);
57 }
58};
59
60/// A helper class to establish various index mappings for the atomic basis functions.
61/** Atomic basis function is a radial function multiplied by a spherical harmonic:
62 \f[
63 \phi_{\ell m \nu}({\bf r}) = f_{\ell \nu}(r) Y_{\ell m}(\hat {\bf r})
64 \f]
65 Multiple radial functions for each \f$ \ell \f$ channel are allowed. This is reflected by
66 the \f$ \nu \f$ index and called "order".
67 */
69{
70 private:
71 std::vector<basis_function_index_descriptor> vbd_;
72
73 sddk::mdarray<int, 2> index_by_lm_order_;
74
75 int offset_lo_{-1};
76
77 std::vector<int> offset_;
78
80
81 public:
83 {
84 }
85
86 basis_functions_index(radial_functions_index const& indexr__, bool expand_full_j__)
87 : indexr_(indexr__)
88 {
89 if (expand_full_j__) {
90 RTE_THROW("j,mj expansion of the full angular momentum index is not implemented");
91 }
92
93 if (!expand_full_j__) {
94 index_by_lm_order_ = sddk::mdarray<int, 2>(sf::lmmax(indexr_.lmax()), indexr_.max_order());
95 std::fill(index_by_lm_order_.begin(), index_by_lm_order_.end(), -1);
96 /* loop over radial functions */
97 for (auto e : indexr_) {
98
99 /* index of this block starts from the current size of basis functions descriptor */
100 auto size = this->size();
101
102 //if (e.am.s() != 0) {
103 // RTE_THROW("full-j radial function index is not allowed here");
104 //}
105 if (e.idxrf == indexr_.index_of(rf_lo_index(0))) {
106 offset_lo_ = size;
107 }
108 /* angular momentum */
109 auto am = e.am;
110
111 offset_.push_back(size);
112
113 for (int m = -am.l(); m <= am.l(); m++) {
114 vbd_.push_back(basis_function_index_descriptor(am, m, e.order, e.idxlo, e.idxrf));
115 vbd_.back().xi = bf_index(size);
116 /* reverse mapping */
117 index_by_lm_order_(sf::lm(am.l(), m), e.order) = size;
118 size++;
119 }
120 }
121 } else { /* for the full-j expansion */
122 /* several things have to be done here:
123 * - packing of jmj index for l+1/2 and l-1/2 subshells has to be introduced
124 * like existing sf::lm(l, m) function
125 * - indexing within l-shell has to be implemented; l shell now contains 2(2l+1) spin orbitals
126 * - order of s=-1 and s=1 components has to be agreed upon and respected
127 */
128 RTE_THROW("full j is not yet implemented");
129 }
130 }
131 /// Return total number of MT basis functions.
132 inline int size() const
133 {
134 return static_cast<int>(vbd_.size());
135 }
136
137 /// Return size of AW part of basis functions in case of LAPW.
138 inline auto size_aw() const
139 {
140 if (offset_lo_ == -1) {
141 return this->size();
142 } else {
143 return offset_lo_;
144 }
145 }
146
147 /// Return size of local-orbital part of basis functions in case of LAPW.
148 inline auto size_lo() const
149 {
150 if (offset_lo_ == -1) {
151 return 0;
152 } else {
153 return this->size() - offset_lo_;
154 }
155 }
156
157 inline int index_by_l_m_order(int l, int m, int order) const
158 {
159 return index_by_lm_order_(sf::lm(l, m), order);
160 }
161
162 inline int index_by_lm_order(int lm, int order) const
163 {
164 return index_by_lm_order_(lm, order);
165 }
166
167 inline int index_of(rf_index idxrf__) const
168 {
169 return offset_[idxrf__];
170 }
171
172 /// Return descriptor of the given basis function.
173 inline auto const& operator[](int i) const
174 {
175 RTE_ASSERT(i >= 0 && i < this->size());
176 return vbd_[i];
177 }
178
179 inline auto begin() const
180 {
181 return vbd_.begin();
182 }
183
184 inline auto end() const
185 {
186 return vbd_.end();
187 }
188
189 auto const& indexr() const
190 {
191 return indexr_;
192 }
193};
194
195inline auto begin(basis_functions_index const& idx__)
196{
197 return idx__.begin();
198}
199
200inline auto end(basis_functions_index const& idx__)
201{
202 return idx__.end();
203}
204
205}
206
207#endif
Angular momentum quantum number.
auto l() const
Get orbital quantum number l.
A helper class to establish various index mappings for the atomic basis functions.
int size() const
Return total number of MT basis functions.
auto const & operator[](int i) const
Return descriptor of the given basis function.
auto size_aw() const
Return size of AW part of basis functions in case of LAPW.
auto size_lo() const
Return size of local-orbital part of basis functions in case of LAPW.
Radial basis function index.
auto lmax() const
Return maximum angular momentum quantum number.
auto max_order(int l__) const
Return maximum order of the radial functions for a given angular momentum.
int lmmax(int lmax)
Maximum number of combinations for a given .
Definition: specfunc.hpp:44
int lm(int l, int m)
Get composite lm index by angular index l and azimuthal index m.
Definition: specfunc.hpp:50
Namespace of the SIRIUS library.
Definition: sirius.f90:5
strong_type< int, struct __rf_index_tag > rf_index
Radial function index.
strong_type< int, struct __bf_index_tag > bf_index
Basis function index.
angular_momentum am
Total angular momemtum.
int m
Projection of the angular momentum.
rf_index idxrf
Index of the radial function or beta projector in the case of pseudo potential.
rf_lo_index idxlo
Index of local orbital.
int order
Order of the radial function for a given l (j).