66 using namespace berkeleygw_cell_symmetry_detail;
67 const std::array<Real, 3> length = {std::sqrt(dot(lattice_vectors, 0, 0)),
68 std::sqrt(dot(lattice_vectors, 1, 1)),
69 std::sqrt(dot(lattice_vectors, 2, 2))};
70 if (length[0] <= 0.0 || length[1] <= 0.0 || length[2] <= 0.0)
72 auto cosine = [&](
int first,
int second) {
73 return dot(lattice_vectors, first, second) / (length[first] * length[second]);
75 auto same_length = [&](
int first,
int second) {
76 return close(length[first] / length[second], 1.0);
79 for (
int unique = 0; unique < 3; unique++) {
80 const int first = (unique + 1) % 3;
81 const int second = (unique + 2) % 3;
82 if (same_length(first, second) && close(std::abs(cosine(first, second)), 0.5) &&
83 close(cosine(unique, first), 0.0) && close(cosine(unique, second), 0.0))
87 if (same_length(0, 1) && same_length(1, 2)) {
88 const Real common = cosine(0, 1);
89 if (close(cosine(1, 2), common) && close(cosine(0, 2), common)) {
90 const bool cubic_primitive =
91 close(common, 0.0) || close(common, 0.5) || close(common, -1.0 / 3.0);
92 return !cubic_primitive;
103 const int absolute_index = std::abs(bravais_lattice_index);
104 if (bravais_lattice_index == 0)
106 if (absolute_index >= 1 && absolute_index <= 3)
108 if (absolute_index >= 4 && absolute_index <= 5)
110 if (absolute_index >= 6 && absolute_index <= 14)
112 throw std::runtime_error(
"BerkeleyGW cell_symmetry: unrecognized bravais_lattice_index " +
113 std::to_string(bravais_lattice_index));