TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
brillouin_zone.hpp
Go to the documentation of this file.
1// Copyright (c) 2014-2018 Commissariat à l'énergie atomique et aux énergies alternatives (CEA)
2// Copyright (c) 2014-2018 Centre national de la recherche scientifique (CNRS)
3// Copyright (c) 2018-2023 Simons Foundation
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You may obtain a copy of the License at
16// https://www.gnu.org/licenses/gpl-3.0.txt
17//
18// Authors: Thomas Ayral, Michel Ferrero, Olivier Parcollet, Nils Wentzell
19
24
25#pragma once
26
27#include "./bravais_lattice.hpp"
28#include "../utility/macros.hpp"
29
30#include <fmt/ranges.h>
31#include <h5/h5.hpp>
32#include <nda/nda.hpp>
33
34#include <iostream>
35#include <ranges>
36#include <string>
37
38namespace triqs::lattice {
39
44
46 using k_t = nda::vector<double>;
47
63 public:
65 using value_t = k_t;
66
73
83
85 [[nodiscard]] C2PY_IGNORE bool contains(k_t const &) const { return true; }
86
88 [[nodiscard]] auto const &lattice() const { return lattice_; }
89
91 explicit operator bravais_lattice() const { return lattice_; }
92
94 [[nodiscard]] auto ndim() const { return lattice_.ndim(); }
95
97 [[nodiscard]] matrix_t const &units() const { return k_units_; }
98
100 [[nodiscard]] matrix_t const &reciprocal_matrix() const { return k_units_; }
101
103 [[nodiscard]] matrix_t const &reciprocal_matrix_inv() const { return k_units_inv_; }
104
118 template <typename K> [[nodiscard]] k_t lattice_to_real_coordinates(K const &v) const {
119 return nda::transpose(k_units_)(nda::range::all, nda::range(ndim())) * nda::basic_array_view{v}(nda::range(ndim()));
120 }
121
132 template <typename K> [[nodiscard]] k_t real_to_lattice_coordinates(K const &v_tilde) const {
133 return nda::transpose(k_units_inv_)(nda::range::all, nda::range(ndim())) * nda::basic_array_view{v_tilde}(nda::range(ndim()));
134 }
135
140 bool operator==(brillouin_zone const &bz) const { return reciprocal_matrix() == bz.reciprocal_matrix() && lattice() == bz.lattice(); }
141
149 friend std::ostream &operator<<(std::ostream &sout, brillouin_zone const &bz) {
150 auto str = fmt::format("Brillouin zone in {} dimensions:\n", bz.ndim());
151 str += fmt::format(" Basis vectors: {}\n",
152 std::views::transform(nda::range(bz.ndim()), [&bz](int i) { return bz.units()(i, nda::range(bz.ndim())); }));
153 return sout << str;
154 }
155
160 void serialize(auto &ar) const { ar & lattice_ & k_units_ & k_units_inv_; }
161
166 void deserialize(auto &ar) { ar & lattice_ & k_units_ & k_units_inv_; }
167
169 [[nodiscard]] static std::string hdf5_format() { return "brillouin_zone"; }
170
178 friend void h5_write(h5::group g, std::string const &name, brillouin_zone const &bz);
179
187 friend void h5_read(h5::group g, std::string const &name, brillouin_zone &bz);
188
189 private:
190 bravais_lattice lattice_;
191 matrix_t k_units_ = matrix_t::zeros(3, 3);
192 matrix_t k_units_inv_ = matrix_t::zeros(3, 3);
193 };
194
196
197} // namespace triqs::lattice
Provides a Bravais lattice class.
A Brillouin zone class.
k_t value_t
Value type of a Brillouin Zone.
k_t real_to_lattice_coordinates(K const &v_tilde) const
Transform a vector from the standard basis to the reciprocal lattice basis .
auto const & lattice() const
Get the underlying Bravais lattice.
friend void h5_write(h5::group g, std::string const &name, brillouin_zone const &bz)
Write a triqs::lattice::brillouin_zone to HDF5.
friend void h5_read(h5::group g, std::string const &name, brillouin_zone &bz)
Read a triqs::lattice::brillouin_zone from HDF5.
friend std::ostream & operator<<(std::ostream &sout, brillouin_zone const &bz)
Write a triqs::lattice::brillouin_zone to a std::ostream.
brillouin_zone()
Construct a Brillouin zone for a simple cubic lattice with lattice constant .
static std::string hdf5_format()
Get the HDF5 format tag.
matrix_t const & reciprocal_matrix() const
Get the matrix containing the reciprocal basis vectors as its rows.
void serialize(auto &ar) const
Serialize the Brillouin zone to a generic archive.
void deserialize(auto &ar)
Deserialize the Brillouin from a generic archive.
bool operator==(brillouin_zone const &bz) const
Equal-to comparison operator.
k_t lattice_to_real_coordinates(K const &v) const
Transform a vector from the reciprocal lattice basis to the standard basis .
bool contains(k_t const &) const
Check if a given vector is part of the domain.
matrix_t const & reciprocal_matrix_inv() const
Get the inverse matrix .
auto ndim() const
Get the number of dimensions of the underlying Bravais lattice.
matrix_t const & units() const
Get the matrix containing the reciprocal basis vectors as its rows.
nda::vector< double > k_t
Reciprocal space vector type.
nda::matrix< double > matrix_t
Matrix type for transformations involving real and reciprocal space vectors.
Common macros used in TRIQS.