29#ifndef __LATTICE_HPP__
30#define __LATTICE_HPP__
38 return dot(
transpose(lat_vec__), lat_vec__);
48 auto mt1 = dot(dot(
transpose(R__), mt), R__);
49 for (
int i: {0, 1, 2}) {
50 for (
int j: {0, 1, 2}) {
51 diff = std::max(diff, std::abs(mt1(i, j) - mt(i, j)));
58find_lat_sym(r3::matrix<double>
const& lat_vec__,
double tol__,
double* mt_error__ =
nullptr)
60 std::vector<r3::matrix<int>> lat_sym;
64 double mt_error_max{0};
76 r3::matrix<int> R({{i00, i01, i02}, {i10, i11, i12}, {i20, i21, i22}});
78 if (std::abs(R.det()) == 1) {
80 mt_error_max = std::max(mt_error_max, mt_error);
82 if (mt_error < tol__) {
97 *mt_error__ = mt_error_max;
100 if (lat_sym.size() == 0 || lat_sym.size() > 48) {
102 s <<
"wrong number of lattice symmetries: " << lat_sym.size() << std::endl
103 <<
" lattice vectors : " << lat_vec__ << std::endl
104 <<
" tolerance : " << tol__ << std::endl
105 <<
" metric tensor error : " << mt_error_max;
110 for (
auto& R1: lat_sym) {
111 for (
auto& R2: lat_sym) {
112 auto R3 = r3::dot(R1, R2);
113 if (std::find(lat_sym.begin(), lat_sym.end(), R3) == lat_sym.end()) {
115 s <<
"lattice symmetries do not form a group" << std::endl;
116 for (
auto& R: lat_sym) {
117 s <<
" sym.op : " << R <<
", metric tensor error : " <<
metric_tensor_error(lat_vec__, R) << std::endl;
119 s <<
"R1 : " << R1 << std::endl;
120 s <<
"R2 : " << R2 << std::endl;
121 s <<
"R1 * R2 : " << R3 <<
" is not in group" << std::endl;
122 s <<
"metric tensor tolerance : " << tol__;
auto transpose(matrix< T > src)
Return transpose of the matrix.
Namespace of the SIRIUS library.
auto metric_tensor(r3::matrix< double > const &lat_vec__)
Compute a metric tensor.
double metric_tensor_error(r3::matrix< double > const &lat_vec__, r3::matrix< int > const &R__)
Compute error of the symmetry-transformed metric tensor.
Simple classes and functions to work with vectors and matrices of the R^3 space.
Eror and warning handling during run-time execution.