SIRIUS 7.5.0
Electronic structure library and applications
paw_field4d.hpp
Go to the documentation of this file.
1// Copyright (c) 2013-2023 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 paw_field4d.hpp
21 *
22 * \brief Contains definition and implementation of PAW_field4D class.
23 */
24
25#ifndef __PAW_FIELD4D_HPP__
26#define __PAW_FIELD4D_HPP__
27
28#include "function3d/spheric_function_set.hpp"
29
30namespace sirius {
31
32/// PAW density and potential storage.
33/** In PAW density and potential are represented with two counterpart: all-electron (AE) and pseudo (PS) */
34template <typename T>
36{
37 private:
38 /// Unit cell.
39 Unit_cell const& uc_;
40 /// Text label of the field.
41 std::string label_;
42 /// All-electron part.
43 std::array<Spheric_function_set<T, paw_atom_index_t>, 4> ae_components_;
44 /// Pseudo-potential part.
45 std::array<Spheric_function_set<T, paw_atom_index_t>, 4> ps_components_;
46 /* copy constructor is forbidden */
47 PAW_field4D(PAW_field4D const& src__) = delete;
48 /* copy assignment operator is forbidden */
49 PAW_field4D& operator=(PAW_field4D const& src__) = delete;
50 public:
51 /// Constructor
52 PAW_field4D(std::string label__, Unit_cell const& uc__, bool is_global__)
53 : uc_{uc__}
54 , label_{label__}
55 {
56 if (!uc__.num_paw_atoms()) {
57 return;
58 }
59
60 auto ptr = (is_global__) ? nullptr : &uc__.spl_num_paw_atoms();
61
62 for (int j = 0; j < uc__.parameters().num_mag_dims() + 1; j++) {
63 ae_components_[j] = Spheric_function_set<T, paw_atom_index_t>(label__ + std::to_string(j), uc__,
64 uc__.paw_atoms(), [&uc__](int ia){return lmax_t(2 * uc__.atom(ia).type().indexr().lmax());}, ptr);
65 ps_components_[j] = Spheric_function_set<T, paw_atom_index_t>(label__ + std::to_string(j), uc__,
66 uc__.paw_atoms(), [&uc__](int ia){return lmax_t(2 * uc__.atom(ia).type().indexr().lmax());}, ptr);
67 }
68 }
69
70 void sync()
71 {
72 for (int j = 0; j < uc_.parameters().num_mag_dims() + 1; j++) {
75 }
76 }
77
78 void zero(int ia__)
79 {
80 for (int j = 0; j < uc_.parameters().num_mag_dims() + 1; j++) {
81 ae_components_[j][ia__].zero(sddk::memory_t::host);
82 ps_components_[j][ia__].zero(sddk::memory_t::host);
83 }
84 }
85
86 void zero()
87 {
88 for (int j = 0; j < uc_.parameters().num_mag_dims() + 1; j++) {
89 ae_components_[j].zero();
90 ps_components_[j].zero();
91 }
92 }
93
94 auto& ae_component(int i__)
95 {
96 return ae_components_[i__];
97 }
98
99 auto const& ae_component(int i__) const
100 {
101 return ae_components_[i__];
102 }
103
104 auto& ps_component(int i__)
105 {
106 return ps_components_[i__];
107 }
108
109 auto const& ps_component(int i__) const
110 {
111 return ps_components_[i__];
112 }
113
114 auto const& unit_cell() const
115 {
116 return uc_;
117 }
118
119 template <typename T_>
120 friend T_
121 inner(PAW_field4D<T_> const& x__, PAW_field4D<T_> const& y__);
122};
123
124template <typename T>
125T
126inner(PAW_field4D<T> const& x__, PAW_field4D<T> const& y__)
127{
128 T result{0};
129 for (int j = 0; j < x__.uc_.parameters().num_mag_dims() + 1; j++) {
130 result += inner(x__.ae_components_[j], y__.ae_components_[j]);
131 result += inner(x__.ps_components_[j], y__.ps_components_[j]);
132 }
133 return result;
134}
135
136
137} // namespace sirius
138
139#endif
PAW density and potential storage.
Definition: paw_field4d.hpp:36
std::array< Spheric_function_set< T, paw_atom_index_t >, 4 > ae_components_
All-electron part.
Definition: paw_field4d.hpp:43
std::array< Spheric_function_set< T, paw_atom_index_t >, 4 > ps_components_
Pseudo-potential part.
Definition: paw_field4d.hpp:45
std::string label_
Text label of the field.
Definition: paw_field4d.hpp:41
Unit_cell const & uc_
Unit cell.
Definition: paw_field4d.hpp:39
PAW_field4D(std::string label__, Unit_cell const &uc__, bool is_global__)
Constructor.
Definition: paw_field4d.hpp:52
Representation of a unit cell.
Definition: unit_cell.hpp:43
int num_paw_atoms() const
Return number of atoms with PAW pseudopotential.
Definition: unit_cell.hpp:161
auto const & spl_num_paw_atoms() const
Get split index of PAW atoms.
Definition: unit_cell.hpp:172
std::enable_if_t< std::is_same< T, real_type< F > >::value, void > inner(::spla::Context &spla_ctx__, sddk::memory_t mem__, spin_range spins__, W const &wf_i__, band_range br_i__, Wave_functions< T > const &wf_j__, band_range br_j__, la::dmatrix< F > &result__, int irow0__, int jcol0__)
Compute inner product between the two sets of wave-functions.
Namespace of the SIRIUS library.
Definition: sirius.f90:5