SIRIUS 7.5.0
Electronic structure library and applications
get_irreducible_reciprocal_mesh.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 get_irreducible_reciprocal_mesh.hpp
21 *
22 * \brief Find the irriducible k-points of the Brillouin zone.
23 */
24
25#ifndef __GET_IRREDUCIBLE_RECIPROCAL_MESH_HPP__
26#define __GET_IRREDUCIBLE_RECIPROCAL_MESH_HPP__
27
29
30namespace sirius {
31
32inline std::tuple<int, std::vector<double>, std::vector<std::array<double, 3>>>
33get_irreducible_reciprocal_mesh(Crystal_symmetry const& sym__, r3::vector<int> k_mesh__, r3::vector<int> is_shift__)
34{
35 using M = std::array<std::array<int, 3>, 3>;
36 std::map<M, int> sym_map;
37
38 for (int isym = 0; isym < sym__.size(); isym++) {
39 M s;
40 for (int x: {0, 1, 2}) {
41 for (int y: {0, 1, 2}) {
42 s[x][y] = sym__[isym].spg_op.R(x, y);
43 }
44 }
45 sym_map[s] = 1;
46 }
47 std::vector<M> sym_list;
48 for (auto it = sym_map.begin(); it != sym_map.end(); it++) {
49 sym_list.push_back(it->first);
50 }
51
52 int nktot = k_mesh__[0] * k_mesh__[1] * k_mesh__[2];
53
54 sddk::mdarray<int, 2> ikgrid(3, nktot);
55 std::vector<int> ikmap(nktot, 0);
56
57 double q[] = {0, 0, 0};
58 int nk = spg_get_stabilized_reciprocal_mesh((int(*)[3])&ikgrid(0, 0),
59 &ikmap[0],
60 &k_mesh__[0],
61 &is_shift__[0],
62 1,
63 static_cast<int>(sym_list.size()),
64 (int(*)[3][3])&sym_list[0],
65 1,
66 (double(*)[3])(&q[0]));
67
68 std::map<int, int> ikcount;
69 for (int ik = 0; ik < nktot; ik++) {
70 if (ikcount.count(ikmap[ik]) == 0) {
71 ikcount[ikmap[ik]] = 0;
72 }
73 ikcount[ikmap[ik]]++;
74 }
75
76 std::vector<double> wk(nk);
77 std::vector<std::array<double, 3>> kp(nk);
78
79 int n{0};
80 for (auto it = ikcount.begin(); it != ikcount.end(); it++) {
81 wk[n] = static_cast<double>(it->second) / nktot;
82 for (int x: {0, 1, 2}) {
83 kp[n][x] = (ikgrid(x, it->first) + is_shift__[x] / 2.0) / k_mesh__[x];
84 }
85 n++;
86 }
87 if (n != nk) {
88 RTE_THROW("wrong number of k-points");
89 }
90
91 return std::make_tuple(nk, wk, kp);
92}
93
94} // namespace sirius
95
96#endif
Contains definition and partial implementation of sirius::Crystal_symmetry class.
Namespace of the SIRIUS library.
Definition: sirius.f90:5