49 double const latticeParams[6] = {lattice.
a(), lattice.
b(), lattice.
c(),
51 double const lattice_errors[6] = {lattice.
errora(), lattice.
errorb(), lattice.
errorc(),
53 if (lattice.
volume() <= 0) {
55 double xA = cos(lattice.
alpha() / 180. * M_PI);
56 double xB = cos(lattice.
beta() / 180. * M_PI);
57 double xC = cos(lattice.
gamma() / 180. * M_PI);
58 Volume = lattice.
a() * lattice.
b() * lattice.
c() * sqrt(1 - xA * xA - xB * xB - xC * xC + 2 * xA * xB * xC);
63 for (
int i = 0; i < 3; i++) {
64 double U = (Volume / latticeParams[i] * lattice_errors[i]);
68 double U = (lattice_errors[3]) * (sin(2 * latticeParams[3] / 180. * M_PI) - sin(latticeParams[3] / 180. * M_PI) *
69 cos(latticeParams[4] / 180 * M_PI) *
70 cos(latticeParams[5] / 180 * M_PI));
72 U = (lattice_errors[4]) *
73 (sin(2 * latticeParams[4] / 180. * M_PI) -
74 sin(latticeParams[4] / 180. * M_PI) * cos(latticeParams[3] / 180 * M_PI) * cos(latticeParams[5] / 180 * M_PI));
76 U = (lattice_errors[5]) *
77 (sin(2 * latticeParams[5] / 180. * M_PI) -
78 sin(latticeParams[5] / 180. * M_PI) * cos(latticeParams[4] / 180 * M_PI) * cos(latticeParams[3] / 180 * M_PI));
92 if (expInfoMD !=
nullptr && expInfoMD->getNumExperimentInfo() > 0) {
93 expInfo = expInfoMD->getExperimentInfo(0);
95 expInfo = std::dynamic_pointer_cast<ExperimentInfo>(ws);
99 throw std::invalid_argument(
"Must specify either a MatrixWorkspace or a "
100 "PeaksWorkspace or a MDWorkspace.");
102 if (!expInfo->sample().hasOrientedLattice())
103 throw std::invalid_argument(
"Workspace must have an oriented lattice to save");
112 auto peakWs = std::dynamic_pointer_cast<PeaksWorkspace>(ws);
113 if (peakWs !=
nullptr) {
114 gonioR = peakWs->getPeak(0).getGoniometerMatrix();
116 gonioR = expInfo->run().getGoniometer().getR();
119 modub = gonioR * modub;
125 out.open(Filename.c_str());
132 for (
size_t basis = 0; basis < 3; basis++) {
133 out << setw(11) << setprecision(8) << ub[beam][basis] << setw(12) << setprecision(8) << ub[back][basis]
134 << setw(12) << setprecision(8) << ub[up][basis] <<
" \n";
138 for (
int i = 0; i < 3; i++) {
147 for (
size_t basis = 0; basis < 3; basis++) {
148 out << setw(11) << setprecision(8) << modub[beam][basis] << setw(12) << setprecision(8) << modub[back][basis]
149 << setw(12) << setprecision(8) << modub[up][basis] <<
" \n";
154 out << setw(11) << setprecision(4) << lattice.
a() << setw(12) << setprecision(4) << lattice.
b() << setw(12)
155 << setprecision(4) << lattice.
c() << setw(12) << setprecision(4) << lattice.
alpha() << setw(12)
156 << setprecision(4) << lattice.
beta() << setw(12) << setprecision(4) << lattice.
gamma() << setw(12)
157 << setprecision(4) << lattice.
volume() <<
" \n";
159 out << setw(11) << setprecision(4) << lattice.
errora() << setw(12) << setprecision(4) << lattice.
errorb()
160 << setw(12) << setprecision(4) << lattice.
errorc() << setw(12) << setprecision(4) << lattice.
erroralpha()
161 << setw(12) << setprecision(4) << lattice.
errorbeta() << setw(12) << setprecision(4) << lattice.
errorgamma()
162 << setw(12) << setprecision(4) << ErrorVolume <<
" \n";
166 out <<
"Modulation Vector 1: " << setw(12) << setprecision(4) << lattice.
getdh(0) << setw(12) << setprecision(4)
167 << lattice.
getdk(0) << setw(12) << setprecision(4) << lattice.
getdl(0) <<
" \n";
169 out <<
"Modulation Vector 1 error: " << setw(6) << setprecision(4) << lattice.
getdherr(0) << setw(12)
170 << setprecision(4) << lattice.
getdkerr(0) << setw(12) << setprecision(4) << lattice.
getdlerr(0) <<
" \n";
173 out <<
"Modulation Vector 2: " << setw(12) << setprecision(4) << lattice.
getdh(1) << setw(12) << setprecision(4)
174 << lattice.
getdk(1) << setw(12) << setprecision(4) << lattice.
getdl(1) <<
" \n";
176 out <<
"Modulation Vector 2 error: " << setw(6) << setprecision(4) << lattice.
getdherr(1) << setw(12)
177 << setprecision(4) << lattice.
getdkerr(1) << setw(12) << setprecision(4) << lattice.
getdlerr(1) <<
" \n";
180 out <<
"Modulation Vector 3: " << setw(12) << setprecision(4) << lattice.
getdh(2) << setw(12) << setprecision(4)
181 << lattice.
getdk(2) << setw(12) << setprecision(4) << lattice.
getdl(2) <<
" \n";
183 out <<
"Modulation Vector 3 error: " << setw(6) << setprecision(4) << lattice.
getdherr(2) << setw(12)
184 << setprecision(4) << lattice.
getdkerr(2) << setw(12) << setprecision(4) << lattice.
getdlerr(2) <<
" \n";
188 out <<
"Max Order: " << lattice.
getMaxOrder() <<
" \n";
189 out <<
"Cross Terms: " << lattice.
getCrossTerm() <<
" \n";
195 out <<
"The above matrix is the Transpose of the UB Matrix. ";
196 out <<
"The UB matrix maps the column\n";
197 out <<
"vector (h,k,l ) to the column vector ";
198 out <<
"(q'x,q'y,q'z).\n";
199 out <<
"|Q'|=1/dspacing and its coordinates are a ";
200 out <<
"right-hand coordinate system where\n";
201 out <<
" x is the beam direction and z is vertically ";
202 out <<
"upward.(IPNS convention)\n";
204 out <<
"The above matrix is the Transpose of the UB Matrix and the "
205 "Transpose of ModUB. ";
206 out <<
"The UB matrix together with ModUB maps the column vector "
208 out <<
"to the column vector (q'x,q'y,q'z).\n";
209 out <<
"The columns of ModUB are the coordinates of modulation vectors "
211 out <<
"|Q'|=1/dspacing and its coordinates are a ";
212 out <<
"right-hand coordinate system where";
213 out <<
" x is the beam direction and z is vertically ";
214 out <<
"upward.(IPNS convention)\n";
219 }
catch (exception &s) {
220 throw std::invalid_argument(s.what());