30#include <fmt/ranges.h>
41namespace triqs::lattice {
49 using r_t = nda::vector<double>;
111 [[nodiscard]]
auto index()
const {
return index_; }
114 [[nodiscard]]
auto const &
lattice()
const {
return *bl_ptr_; }
120 explicit operator r_t()
const {
124 return *(rval_ = bl_ptr_->lattice_to_real_coordinates(index_));
133 [[deprecated(
"() is deprecated for a cyclat::mesh_point_t. Use [] instead")]]
double operator()(
int d)
const {
return r_t(*
this)[d]; }
152 EXPECTS(*bl_ptr_ == *(pt.bl_ptr_));
153 return {index_ + pt.index_, bl_ptr_};
164 EXPECTS(*bl_ptr_ == *(pt.bl_ptr_));
165 return {index_ - pt.index_, bl_ptr_};
181 friend std::ostream &
operator<<(std::ostream &sout,
point_t const &pt) {
return sout << static_cast<r_t>(pt); }
186 mutable std::optional<r_t> rval_ = {};
206 std::vector<std::string> atom_orb_name = {});
212 [[nodiscard]]
int ndim()
const {
return ndim_; }
218 [[nodiscard]]
long n_orbitals()
const {
return static_cast<long>(atom_orb_pos_.size()); }
240 return nda::transpose(units_)(nda::range::all, nda::range(
ndim())) * nda::basic_array_view{v}(nda::range(
ndim()));
254 return nda::transpose(units_inv_)(nda::range::all, nda::range(
ndim())) * nda::basic_array_view{v_tilde}(nda::range(
ndim()));
282 auto str = fmt::format(
"Bravais Lattice in {} dimensions with {} orbital(s):\n", bl.
ndim(), bl.
n_orbitals());
283 str += fmt::format(
" Basis vectors: {}\n",
284 std::views::transform(nda::range(bl.
ndim()), [&bl](
int i) { return bl.units()(i, nda::range(bl.ndim())); }));
286 str += fmt::format(
" Orbital names: {}\n", bl.
orbital_names());
294 void serialize(
auto &ar)
const { ar & ndim_ & units_ & atom_orb_pos_ & atom_orb_name_; }
300 void deserialize(
auto &ar) { ar & ndim_ & units_ & atom_orb_pos_ & atom_orb_name_; }
303 [[nodiscard]]
static std::string
hdf5_format() {
return "bravais_lattice"; }
324 matrix_t units_ = matrix_t::zeros(3, 3);
325 matrix_t units_inv_ = matrix_t::zeros(3, 3);
326 std::vector<r_t> atom_orb_pos_;
327 std::vector<std::string> atom_orb_name_;
Backward-compatibility umbrella header pulling in the nda array library.
Lattice point of a Bravais lattice.
point_t operator-(point_t const &pt) const
Subtract two lattice points and .
point_t operator+(point_t const &pt) const
Add two lattice points and .
double operator()(int d) const
Get the coordinate of the corresponding lattice vector .
auto index() const
Get the index vector of the lattice point.
point_t()=default
Default constructor leaves the lattice point uninitialized, i.e. belonging to no Bravais lattice.
point_t operator-() const
Invert the lattice point .
double operator[](int i) const
Get the coordinate of the corresponding lattice vector .
auto const & lattice() const
Get the underlying Bravais lattice.
point_t(index_t const &n, bravais_lattice const *bl_ptr)
Construct a lattice point with a given index vector on the given Bravais lattice.
friend std::ostream & operator<<(std::ostream &sout, point_t const &pt)
Write a lattice point to a std::ostream.
long n_orbitals() const
Get the number of atomic orbitals in the unit cell.
friend std::ostream & operator<<(std::ostream &sout, bravais_lattice const &bl)
Write a triqs::lattice::bravais_lattice to a std::ostream.
point_t to_point(index_t const &n) const
Convert an index vector to a lattice point.
r_t real_to_lattice_coordinates(R const &v_tilde) const
Transform a vector from the standard basis to the lattice basis .
bool operator==(bravais_lattice const &bl) const
Equal-to comparison operator.
std::array< long, 3 > index_t
Index type for lattice points on the Bravais lattice.
auto const & orbital_names() const
Get the list of orbital names.
r_t lattice_to_real_coordinates(R const &v) const
Transform a vector from the lattice basis to the standard basis .
int ndim() const
Get the number of dimensions of the Bravais lattice.
auto const & orbital_positions() const
Get the list of atomic orbital positions .
bool contains(r_t const &) const
Check if a given vector is part of the domain.
void deserialize(auto &ar)
Deserialize the Bravais lattice from a generic archive.
bravais_lattice()
Construct a simple cubic lattice with lattice constant .
friend void h5_write(h5::group g, std::string const &name, bravais_lattice const &bl)
Write a triqs::lattice::bravais_lattice to HDF5.
friend void h5_read(h5::group g, std::string const &name, bravais_lattice &bl)
Read a triqs::lattice::bravais_lattice from HDF5.
static std::string hdf5_format()
Get the HDF5 format tag.
void serialize(auto &ar) const
Serialize the Bravais lattice to a generic archive.
matrix_t const & units() const
Get the matrix containing basis vectors as its rows.
nda::matrix< double > matrix_t
Matrix type for transformations involving real and reciprocal space vectors.
nda::vector< double > r_t
Real space vector type.
Common macros used in TRIQS.