29 "Input Peaks Workspace");
31 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
32 mustBePositive->setLower(0.0);
34 auto moreThan2Int = std::make_shared<BoundedValidator<int>>();
35 moreThan2Int->setLower(2);
37 auto reasonable_angle = std::make_shared<BoundedValidator<double>>();
38 reasonable_angle->setLower(5.0);
39 reasonable_angle->setUpper(175.0);
42 this->
declareProperty(
"a", -1.0, mustBePositive,
"Lattice parameter a");
43 this->
declareProperty(
"b", -1.0, mustBePositive,
"Lattice parameter b");
44 this->
declareProperty(
"c", -1.0, mustBePositive,
"Lattice parameter c");
45 this->
declareProperty(
"alpha", -1.0, reasonable_angle,
"Lattice parameter alpha");
46 this->
declareProperty(
"beta", -1.0, reasonable_angle,
"Lattice parameter beta");
47 this->
declareProperty(
"gamma", -1.0, reasonable_angle,
"Lattice parameter gamma");
48 this->
declareProperty(
"NumInitial", 15, moreThan2Int,
"Number of Peaks to Use on First Pass(15)");
49 this->
declareProperty(
"Tolerance", 0.15, mustBePositive,
"Indexing Tolerance (0.15)");
50 this->
declareProperty(
"FixParameters",
false,
"Do not optimise the UB after finding the orientation");
69 double degrees_per_step = 1.5;
73 throw std::runtime_error(
"Could not read the peaks workspace");
75 const int n_peaks = ws->getNumberPeaks();
77 std::vector<V3D> q_vectors;
78 q_vectors.reserve(n_peaks);
80 for (
int i = 0; i < n_peaks; i++)
81 q_vectors.emplace_back(ws->getPeak(i).getQSampleFrame());
93 g_log.
notice(std::string(
"Found Invalid UB...peaks used might not be linearly independent"));
100 "New UB will index %1d Peaks out of %1d with tolerance "
105 double calc_a = lattice.
a();
106 double calc_b = lattice.
b();
107 double calc_c = lattice.
c();
108 double calc_alpha = lattice.
alpha();
109 double calc_beta = lattice.
beta();
110 double calc_gamma = lattice.
gamma();
115 "Lattice Parameters (Refined - Input): %11.6f "
116 "%11.6f %11.6f %11.6f %11.6f %11.6f",
117 calc_a - a, calc_b - b, calc_c - c, calc_alpha - alpha, calc_beta - beta, calc_gamma - gamma);
119 ws->mutableSample().setOrientedLattice(std::make_unique<OrientedLattice>(lattice));
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
A property class for workspaces.
void exec() override
Run the algorithm.
void init() override
Initialise the properties.
static double Find_UB(Kernel::DblMatrix &UB, const std::vector< Kernel::V3D > &q_vectors, OrientedLattice &lattice, double required_tolerance, int base_index, size_t num_initial, double degrees_per_step, bool fixAll=false, int iterations=1)
Find the UB matrix that most nearly indexes the specified qxyz values given the lattice parameters.
static bool CheckUB(const Kernel::DblMatrix &UB)
Check that the specified UB is reasonable for an orientation matrix.
static int NumberIndexed(const Kernel::DblMatrix &UB, const std::vector< Kernel::V3D > &q_vectors, double tolerance)
Calculate the number of Q vectors that are mapped to integer indices by UB.
Class to implement UB matrix.
double alpha() const
Get lattice parameter.
double a(int nd) const
Get lattice parameter a1-a3 as function of index (0-2)
double c() const
Get lattice parameter.
double beta() const
Get lattice parameter.
double b() const
Get lattice parameter.
double gamma() const
Get lattice parameter.
void notice(const std::string &msg)
Logs at notice level.
std::shared_ptr< IPeaksWorkspace > IPeaksWorkspace_sptr
shared pointer to Mantid::API::IPeaksWorkspace
@ InOut
Both an input & output workspace.