92 std::vector<ConventionalCell> result;
94 size_t num_lattices = 15;
95 for (
size_t i = 0; i < num_lattices; i++) {
100 temp.emplace_back(info);
136 const std::string ¢ering,
bool allowPermutations) {
137 std::vector<ConventionalCell> result;
139 std::vector<DblMatrix> UB_list;
140 if (allowPermutations) {
141 double angle_tolerance = 2.0;
142 double length_factor = 1.05;
146 UB_list.emplace_back(UB);
149 for (
auto &k : UB_list) {
150 std::vector<ConventionalCell> temp =
GetCellsUBOnly(k, cell_type, centering, allowPermutations);
152 for (
auto &cell : temp)
183 const std::string ¢ering,
bool allowPermutations) {
184 std::vector<ConventionalCell> result;
186 std::vector<double> lat_par;
190 ReducedCell rcell(i, lat_par[0], lat_par[1], lat_par[2], lat_par[3], lat_par[4], lat_par[5]);
194 result.emplace_back(cell_info);
222 double min_error = 1e20;
224 std::vector<double> l_params;
225 std::vector<DblMatrix> UB_list;
226 if (allowPermutations) {
227 double angle_tolerance = 2.0;
228 double length_factor = 1.05;
232 UB_list.emplace_back(UB);
234 for (
auto &ub : UB_list) {
237 form_0 =
ReducedCell(0, l_params[0], l_params[1], l_params[2], l_params[3], l_params[4], l_params[5]);
239 form =
ReducedCell(form_num, l_params[0], l_params[1], l_params[2], l_params[3], l_params[4], l_params[5]);
242 if (
error < min_error) {
262 const auto removeRangeBegin =
263 std::remove_if(list.begin(), list.end(), [level](
const auto &cell) { return cell.GetError() > level; });
264 list.erase(removeRangeBegin, list.end());
282 throw std::invalid_argument(
"GetCellBestError(): list is empty");
286 double min_error = 1.0e20;
288 bool min_found =
false;
289 for (
const auto &cell : list) {
291 double error = cell.GetError();
300 throw std::invalid_argument(
"GetCellBestError(): no allowed form with min error");
340 std::vector<DblMatrix> result;
342 V3D a, b, c, a_vec, b_vec, c_vec,
343 m_a_vec, m_b_vec, m_c_vec;
345 V3D a_temp, b_temp, c_temp,
346 m_a_temp, m_b_temp, m_c_temp;
350 m_a_vec = a_vec * (-1.0);
351 m_b_vec = b_vec * (-1.0);
352 m_c_vec = c_vec * (-1.0);
356 V3D reflections[4][3] = {
357 {a_vec, b_vec, c_vec}, {m_a_vec, m_b_vec, c_vec}, {m_a_vec, b_vec, m_c_vec}, {a_vec, m_b_vec, m_c_vec}};
366 double alpha = b_vec.
angle(c_vec) * 180.0 / M_PI;
367 double beta = c_vec.
angle(a_vec) * 180.0 / M_PI;
368 double gamma = a_vec.
angle(b_vec) * 180.0 / M_PI;
369 double angles[4] = {90.0, gamma, beta, alpha};
371 for (
size_t row = 0; row < 4; row++) {
372 if (
fabs(angles[row] - 90.0) < angle_tolerance)
374 a_temp = reflections[row][0];
375 b_temp = reflections[row][1];
376 c_temp = reflections[row][2];
381 m_a_temp = a_temp * (-1.0);
382 m_b_temp = b_temp * (-1.0);
383 m_c_temp = c_temp * (-1.0);
385 V3D permutations[6][3] = {{a_temp, b_temp, c_temp}, {m_a_temp, c_temp, b_temp}, {b_temp, c_temp, a_temp},
386 {m_b_temp, a_temp, c_temp}, {c_temp, a_temp, b_temp}, {m_c_temp, b_temp, a_temp}};
388 for (
auto &permutation : permutations) {
396 result.emplace_back(temp_UB);
423 while (!done && i < list.size()) {
424 if (list[i].GetFormNum() == form_num)
427 if (list[i].GetError() > new_error)
434 list.emplace_back(info);
static const std::string BRAVAIS_CENTERING[15]
static const std::string BRAVAIS_TYPE[15]
Instances of this class represent information about a selected conventional cell based on a specified...
std::string GetCellType() const
get the cell type name, as named in the ReducedCell class
size_t GetFormNum() const
get the form number for this conventional cell
double GetError() const
get the error in the scalars for this form
static bool GetLatticeParameters(const Kernel::DblMatrix &UB, std::vector< double > &lattice_par)
Get the lattice parameters for the specified orientation matrix.
static bool GetABC(const Kernel::DblMatrix &UB, Kernel::V3D &a_dir, Kernel::V3D &b_dir, Kernel::V3D &c_dir)
Get the real space edge vectors a, b, c corresponding to the UB matrix.
static bool GetUB(Kernel::DblMatrix &UB, const Kernel::V3D &a_dir, const Kernel::V3D &b_dir, const Kernel::V3D &c_dir)
Get the UB matix corresponding to the real space edge vectors a, b, c.
Instances of this class represent information about reduced cell types including the transformation r...
std::string GetCellType() const
Get the cell type of this form.
static const std::string HEXAGONAL()
double WeightedDistance(const ReducedCell &other) const
Get the maximum absolute weighted difference between the scalars for the specifed ReducedCellInfo obj...
static const std::string MONOCLINIC()
static const std::string RHOMBOHEDRAL()
static const std::string CUBIC()
static const std::string F_CENTERED()
static const std::string TRICLINIC()
static const std::string R_CENTERED()
std::string GetCentering() const
Get centering assigned to this form.
static const std::string TETRAGONAL()
static const std::string ORTHORHOMBIC()
static const std::string P_CENTERED()
static const std::string I_CENTERED()
static const std::string C_CENTERED()
static void AddIfBest(std::vector< ConventionalCell > &list, ConventionalCell &info)
Add conventional cell to list if it has the least error for its form num.
static std::vector< ConventionalCell > GetCells(const Kernel::DblMatrix &UB, bool best_only, bool allowPermutations=false)
Get list of all possible conventional cells for UB, regardless of errors, using this UB,...
static std::vector< Kernel::DblMatrix > GetRelatedUBs(const Kernel::DblMatrix &UB, double factor, double angle_tolerance)
Get list of related cells obtained by reflecting pairs of sides with nearly a 90 degree angle between...
static void RemoveHighErrorForms(std::vector< ConventionalCell > &list, double level)
Remove cells from list that have scalar errors above the specified level.
static ConventionalCell GetCellBestError(const std::vector< ConventionalCell > &list, bool use_triclinic)
Get the cell from the list with the smallest error, possibly excluding triclinic cells.
static std::vector< ConventionalCell > GetCellsUBOnly(const Kernel::DblMatrix &UB, const std::string &cell_type, const std::string ¢ering, bool allowPermutations=false)
Get list of conventional cells for UB with specified type and centering, using ONLY this UB,...
static ConventionalCell GetCellForForm(const Kernel::DblMatrix &UB, size_t form_num, bool allowPermutations=false)
Get the best conventional cell for the form number, using the specified UB, and three related "almost...
double angle(const V3D &) const
Angle between this and another vector.
double norm() const noexcept