31 "An input workspace containing the orientation matrix.");
33 const std::vector<std::string> exts{
".mat",
".ub",
".txt"};
35 "Path to an ISAW-style UB matrix text file.");
40 double latticeParams[6] = {lattice.
a(), lattice.
b(), lattice.
c(), lattice.
alpha(), lattice.
beta(), lattice.
gamma()};
43 if (lattice.
volume() <= 0) {
45 double xA = cos(lattice.
alpha() / 180. * M_PI);
46 double xB = cos(lattice.
beta() / 180. * M_PI);
47 double xC = cos(lattice.
gamma() / 180. * M_PI);
48 Volume = lattice.
a() * lattice.
b() * lattice.
c() * sqrt(1 - xA * xA - xB * xB - xC * xC + 2 * xA * xB * xC);
53 for (
int i = 0; i < 3; i++) {
54 double U = (Volume / latticeParams[i] * lattice_errors[i]);
58 double U = (lattice_errors[3]) * (sin(2 * latticeParams[3] / 180. * M_PI) - sin(latticeParams[3] / 180. * M_PI) *
59 cos(latticeParams[4] / 180 * M_PI) *
60 cos(latticeParams[5] / 180 * M_PI));
62 U = (lattice_errors[4]) *
63 (sin(2 * latticeParams[4] / 180. * M_PI) -
64 sin(latticeParams[4] / 180. * M_PI) * cos(latticeParams[3] / 180 * M_PI) * cos(latticeParams[5] / 180 * M_PI));
66 U = (lattice_errors[5]) *
67 (sin(2 * latticeParams[5] / 180. * M_PI) -
68 sin(latticeParams[5] / 180. * M_PI) * cos(latticeParams[4] / 180 * M_PI) * cos(latticeParams[3] / 180 * M_PI));
82 if (MDWS !=
nullptr) {
83 ws = MDWS->getExperimentInfo(0);
85 ws = std::dynamic_pointer_cast<ExperimentInfo>(ws1);
89 throw std::invalid_argument(
"Must specify either a MatrixWorkspace or a "
90 "PeaksWorkspace or a MDWorkspace.");
92 if (!ws->sample().hasOrientedLattice())
93 throw std::invalid_argument(
"Workspace must have an oriented lattice to save");
98 out.open(Filename.c_str());
110 for (
size_t basis = 0; basis < 3; basis++) {
111 out << setw(11) << setprecision(8) << ub[beam][basis] << setw(12) << setprecision(8) << ub[back][basis]
112 << setw(12) << setprecision(8) << ub[up][basis] <<
" \n";
116 for (
int i = 0; i < 3; i++) {
125 for (
size_t basis = 0; basis < 3; basis++) {
126 out << setw(11) << setprecision(8) << modub[beam][basis] << setw(12) << setprecision(8) << modub[back][basis]
127 << setw(12) << setprecision(8) << modub[up][basis] <<
" \n";
132 out << setw(11) << setprecision(4) << lattice.
a() << setw(12) << setprecision(4) << lattice.
b() << setw(12)
133 << setprecision(4) << lattice.
c() << setw(12) << setprecision(4) << lattice.
alpha() << setw(12)
134 << setprecision(4) << lattice.
beta() << setw(12) << setprecision(4) << lattice.
gamma() << setw(12)
135 << setprecision(4) << lattice.
volume() <<
" \n";
137 out << setw(11) << setprecision(4) << lattice.
errora() << setw(12) << setprecision(4) << lattice.
errorb()
138 << setw(12) << setprecision(4) << lattice.
errorc() << setw(12) << setprecision(4) << lattice.
erroralpha()
139 << setw(12) << setprecision(4) << lattice.
errorbeta() << setw(12) << setprecision(4) << lattice.
errorgamma()
140 << setw(12) << setprecision(4) << ErrorVolume <<
" \n";
144 out <<
"Modulation Vector 1: " << setw(12) << setprecision(4) << lattice.
getdh(0) << setw(12) << setprecision(4)
145 << lattice.
getdk(0) << setw(12) << setprecision(4) << lattice.
getdl(0) <<
" \n";
147 out <<
"Modulation Vector 1 error: " << setw(6) << setprecision(4) << lattice.
getdherr(0) << setw(12)
148 << setprecision(4) << lattice.
getdkerr(0) << setw(12) << setprecision(4) << lattice.
getdlerr(0) <<
" \n";
151 out <<
"Modulation Vector 2: " << setw(12) << setprecision(4) << lattice.
getdh(1) << setw(12) << setprecision(4)
152 << lattice.
getdk(1) << setw(12) << setprecision(4) << lattice.
getdl(1) <<
" \n";
154 out <<
"Modulation Vector 2 error: " << setw(6) << setprecision(4) << lattice.
getdherr(1) << setw(12)
155 << setprecision(4) << lattice.
getdkerr(1) << setw(12) << setprecision(4) << lattice.
getdlerr(1) <<
" \n";
158 out <<
"Modulation Vector 3: " << setw(12) << setprecision(4) << lattice.
getdh(2) << setw(12) << setprecision(4)
159 << lattice.
getdk(2) << setw(12) << setprecision(4) << lattice.
getdl(2) <<
" \n";
161 out <<
"Modulation Vector 3 error: " << setw(6) << setprecision(4) << lattice.
getdherr(2) << setw(12)
162 << setprecision(4) << lattice.
getdkerr(2) << setw(12) << setprecision(4) << lattice.
getdlerr(2) <<
" \n";
166 out <<
"Max Order: " << lattice.
getMaxOrder() <<
" \n";
167 out <<
"Cross Terms: " << lattice.
getCrossTerm() <<
" \n";
173 out <<
"The above matrix is the Transpose of the UB Matrix. ";
174 out <<
"The UB matrix maps the column\n";
175 out <<
"vector (h,k,l ) to the column vector ";
176 out <<
"(q'x,q'y,q'z).\n";
177 out <<
"|Q'|=1/dspacing and its coordinates are a ";
178 out <<
"right-hand coordinate system where\n";
179 out <<
" x is the beam direction and z is vertically ";
180 out <<
"upward.(IPNS convention)\n";
182 out <<
"The above matrix is the Transpose of the UB Matrix and the "
183 "Transpose of ModUB. ";
184 out <<
"The UB matrix together with ModUB maps the column vector "
186 out <<
"to the column vector (q'x,q'y,q'z).\n";
187 out <<
"The columns of ModUB are the coordinates of modulation vectors "
189 out <<
"|Q'|=1/dspacing and its coordinates are a ";
190 out <<
"right-hand coordinate system where";
191 out <<
" x is the beam direction and z is vertically ";
192 out <<
"upward.(IPNS convention)\n";
197 }
catch (exception &s) {
198 throw std::invalid_argument(s.what());
#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.
@ Save
to specify a file to write to, the file may or may not exist
A property class for workspaces.
void init() override
Initialise the properties.
void exec() override
Run the algorithm.
double getErrorVolume(const Geometry::OrientedLattice &lattice)
Class to implement UB matrix.
const Kernel::DblMatrix & getUB() const
Get the UB matrix.
const Kernel::DblMatrix & getModUB() const
double alpha() const
Get lattice parameter.
double erroralpha(const int angleunit=angDegrees) const
Get lattice parameter error.
double a(int nd) const
Get lattice parameter a1-a3 as function of index (0-2)
int getMaxOrder() const
Get max order.
double c() const
Get lattice parameter.
double getdh(int j) const
Get modulation vectors for satellites.
double getdk(int j) const
Get modulation vectors for satellites.
double volume() const
Volume of the direct unit-cell.
bool getCrossTerm() const
Get cross term boolean.
double getdl(int j) const
Get modulation vectors for satellites.
double errorgamma(const int angleunit=angDegrees) const
Get lattice parameter error.
double getdherr(int j) const
Get error of modulation vectors for satellites.
double errorbeta(const int angleunit=angDegrees) const
Get lattice parameter error.
double beta() const
Get lattice parameter.
double getdlerr(int j) const
Get error of modulation vectors for satellites.
double b() const
Get lattice parameter.
double getdkerr(int j) const
Get error of modulation vectors for satellites.
const Kernel::V3D getModVec(int j) const
Get modulation vectors for satellites.
double errorc() const
Get lattice parameter error.
double gamma() const
Get lattice parameter.
double errora() const
Get lattice parameter error.
double errorb() const
Get lattice parameter error.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< ExperimentInfo > ExperimentInfo_sptr
Shared pointer to ExperimentInfo.
std::shared_ptr< MultipleExperimentInfos > MultipleExperimentInfos_sptr
@ Input
An input workspace.