Mantid
Loading...
Searching...
No Matches
IndexingUtils.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2011 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7/* File: Indexing_Utils.h */
8
9#pragma once
10
11//----------------------------------------------------------------------
12// Includes
13//----------------------------------------------------------------------
15#include "MantidGeometry/DllConfig.h"
16#include "MantidKernel/Logger.h"
17#include "MantidKernel/Matrix.h"
18#include "MantidKernel/V3D.h"
19
20namespace Mantid {
21namespace Geometry {
32class MANTID_GEOMETRY_DLL IndexingUtils {
33public:
36 static double Find_UB(Kernel::DblMatrix &UB, const std::vector<Kernel::V3D> &q_vectors, OrientedLattice &lattice,
37 double required_tolerance, int base_index, size_t num_initial, double degrees_per_step,
38 bool fixAll = false, int iterations = 1);
39
42 static double Find_UB(Kernel::DblMatrix &UB, const std::vector<Kernel::V3D> &q_vectors, double min_d, double max_d,
43 double required_tolerance, int base_index, size_t num_initial, double degrees_per_step);
44
47 static double Find_UB(Kernel::DblMatrix &UB, const std::vector<Kernel::V3D> &q_vectors, double min_d, double max_d,
48 double required_tolerance, double degrees_per_step, int iterations = 4);
49
51 static double Optimize_UB(Kernel::DblMatrix &UB, const std::vector<Kernel::V3D> &hkl_vectors,
52 const std::vector<Kernel::V3D> &q_vectors, std::vector<double> &sigabc);
53
55 static double Optimize_UB(Kernel::DblMatrix &UB, const std::vector<Kernel::V3D> &hkl_vectors,
56 const std::vector<Kernel::V3D> &q_vectors);
57
58 static double Optimize_6dUB(Kernel::DblMatrix &UB, Kernel::DblMatrix &ModUB,
59 const std::vector<Kernel::V3D> &hkl_vectors, const std::vector<Kernel::V3D> &mnp_vectors,
60 const int &ModDim, const std::vector<Kernel::V3D> &q_vectors, std::vector<double> &sigabc,
61 std::vector<double> &sigq);
62
63 static double Optimize_6dUB(Kernel::DblMatrix &UB, Kernel::DblMatrix &ModUB,
64 const std::vector<Kernel::V3D> &hkl_vectors, const std::vector<Kernel::V3D> &mnp_vectors,
65 const int &ModDim, const std::vector<Kernel::V3D> &q_vectors);
66
68 static double Optimize_Direction(Kernel::V3D &best_vec, const std::vector<int> &index_values,
69 const std::vector<Kernel::V3D> &q_vectors);
70
72 static double ScanFor_UB(Kernel::DblMatrix &UB, const std::vector<Kernel::V3D> &q_vectors, const UnitCell &cell,
73 double degrees_per_step, double required_tolerance);
74
76 static size_t ScanFor_Directions(std::vector<Kernel::V3D> &directions, const std::vector<Kernel::V3D> &q_vectors,
77 double min_d, double max_d, double required_tolerance, double degrees_per_step);
78
81 static size_t FFTScanFor_Directions(std::vector<Kernel::V3D> &directions, const std::vector<Kernel::V3D> &q_vectors,
82 double min_d, double max_d, double required_tolerance, double degrees_per_step);
83
86 static double GetMagFFT(const std::vector<Kernel::V3D> &q_vectors, const Kernel::V3D &current_dir, const size_t N,
87 double projections[], double index_factor, double magnitude_fft[]);
88
91 static double GetFirstMaxIndex(const double magnitude_fft[], size_t N, double threshold);
92
95 static bool FormUB_From_abc_Vectors(Kernel::DblMatrix &UB, const std::vector<Kernel::V3D> &directions, size_t a_index,
96 double min_d, double max_d);
97
100 static bool FormUB_From_abc_Vectors(Kernel::DblMatrix &UB, const std::vector<Kernel::V3D> &directions,
101 const std::vector<Kernel::V3D> &q_vectors, double req_tolerance, double min_vol);
102
104 static Kernel::V3D makeCDir(const Kernel::V3D &a_dir, const Kernel::V3D &b_dir, const double c, const double cosAlpha,
105 const double cosBeta, const double cosGamma, const double sinGamma);
106
109 static void DiscardDuplicates(std::vector<Kernel::V3D> &new_list, std::vector<Kernel::V3D> &directions,
110 const std::vector<Kernel::V3D> &q_vectors, double required_tolerance, double len_tol,
111 double ang_tol);
112
114 static void RoundHKL(Kernel::V3D &hkl);
115
117 static void RoundHKLs(std::vector<Kernel::V3D> &hkl_list);
118
120 static bool ValidIndex(const Kernel::V3D &hkl, double tolerance);
121
123 static int NumberOfValidIndexes(const std::vector<Kernel::V3D> &hkls, double tolerance, double &average_error);
124
126 static double IndexingError(const Kernel::DblMatrix &UB, const std::vector<Kernel::V3D> &hkls,
127 const std::vector<Kernel::V3D> &q_vectors);
128
130 static bool CheckUB(const Kernel::DblMatrix &UB);
131
133 static int NumberIndexed(const Kernel::DblMatrix &UB, const std::vector<Kernel::V3D> &q_vectors, double tolerance);
134
137 static int NumberIndexed_1D(const Kernel::V3D &direction, const std::vector<Kernel::V3D> &q_vectors,
138 double tolerance);
139
142 static int NumberIndexed_3D(const Kernel::V3D &a_dir, const Kernel::V3D &b_dir, const Kernel::V3D &c_dir,
143 const std::vector<Kernel::V3D> &q_vectors, double tolerance);
144
146 static int CalculateMillerIndices(const Kernel::DblMatrix &UB, const std::vector<Kernel::V3D> &q_vectors,
147 double tolerance, std::vector<Kernel::V3D> &miller_indices, double &ave_error);
148
150 static bool CalculateMillerIndices(const Kernel::DblMatrix &inverseUB, const Kernel::V3D &q_vector, double tolerance,
151 Kernel::V3D &miller_indices);
152
154 static Kernel::V3D CalculateMillerIndices(const Kernel::DblMatrix &inverseUB, const Kernel::V3D &q_vector);
155
157 static int GetIndexedPeaks_1D(const Kernel::V3D &direction, const std::vector<Kernel::V3D> &q_vectors,
158 double required_tolerance, std::vector<int> &index_vals,
159 std::vector<Kernel::V3D> &indexed_qs, double &fit_error);
160
162 static int GetIndexedPeaks_3D(const Kernel::V3D &direction_1, const Kernel::V3D &direction_2,
163 const Kernel::V3D &direction_3, const std::vector<Kernel::V3D> &q_vectors,
164 double required_tolerance, std::vector<Kernel::V3D> &miller_indices,
165 std::vector<Kernel::V3D> &indexed_qs, double &fit_error);
166
168 static int GetIndexedPeaks(const Kernel::DblMatrix &UB, const std::vector<Kernel::V3D> &q_vectors,
169 double required_tolerance, std::vector<Kernel::V3D> &miller_indices,
170 std::vector<Kernel::V3D> &indexed_qs, double &fit_error);
171
173 static std::vector<Kernel::V3D> MakeHemisphereDirections(int n_steps);
174
177 static std::vector<Kernel::V3D> MakeCircleDirections(int n_steps, const Kernel::V3D &axis, double angle_degrees);
178
181 static int SelectDirection(Kernel::V3D &best_direction, const std::vector<Kernel::V3D> &q_vectors,
182 const std::vector<Kernel::V3D> &direction_list, double plane_spacing,
183 double required_tolerance);
184
186 static bool GetLatticeParameters(const Kernel::DblMatrix &UB, std::vector<double> &lattice_par);
187
188 static int GetModulationVectors(const Kernel::DblMatrix &UB, const Kernel::DblMatrix &ModUB, Kernel::V3D &ModVec1,
189 Kernel::V3D &ModVec2, Kernel::V3D &ModVec3);
190
191 static bool GetModulationVector(const Kernel::DblMatrix &UB, const Kernel::DblMatrix &ModUB, Kernel::V3D &ModVec,
192 const int j);
193
195 static std::string GetLatticeParameterString(const Kernel::DblMatrix &UB);
196
197private:
200};
201
202} // namespace Geometry
203} // namespace Mantid
double tolerance
This class contains static utility methods for indexing peaks and finding the UB matrix.
Definition: IndexingUtils.h:32
static Mantid::Kernel::Logger & g_Log
Static reference to the logger class.
Class to implement UB matrix.
Class to implement unit cell of crystals.
Definition: UnitCell.h:44
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition: Logger.h:52
Class for 3D vectors.
Definition: V3D.h:34
Helper class which provides the Collimation Length for SANS instruments.