Mantid
Loading...
Searching...
No Matches
UnitCell.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
10#include "MantidKernel/V3D.h"
11
12#include <algorithm>
13#include <cfloat>
14#include <iomanip>
15#include <ios>
16#include <stdexcept>
17
18#include <boost/lexical_cast.hpp>
19
20namespace Mantid::Geometry {
23
26UnitCell::UnitCell() : da(6), ra(6), errorda(6), G(3, 3), Gstar(3, 3), B(3, 3), ModHKL(3, 3), errorModHKL(3, 3) {
27 da[0] = da[1] = da[2] = 1.;
28 da[3] = da[4] = da[5] = M_PI_2;
29 errorda[0] = errorda[1] = errorda[2] = errorda[3] = errorda[4] = errorda[5] = 0.0;
30 MaxOrder = 0;
31 CrossTerm = false;
33}
34
38UnitCell::UnitCell(double _a, double _b, double _c)
39 : da(6), ra(6), errorda(6), G(3, 3), Gstar(3, 3), B(3, 3), ModHKL(3, 3), errorModHKL(3, 3) {
40 da[0] = _a;
41 da[1] = _b;
42 da[2] = _c;
43 // Angles are 90 degrees in radians ->Pi/2
44 da[3] = da[4] = da[5] = M_PI_2;
45 errorda[0] = errorda[1] = errorda[2] = errorda[3] = errorda[4] = errorda[5] = 0.0;
46 MaxOrder = 0;
47 CrossTerm = false;
49}
50
55UnitCell::UnitCell(double _a, double _b, double _c, double _alpha, double _beta, double _gamma, const int angleunit)
56 : da(6), ra(6), errorda(6), G(3, 3), Gstar(3, 3), B(3, 3), ModHKL(3, 3), errorModHKL(3, 3) {
57 da[0] = _a;
58 da[1] = _b;
59 da[2] = _c;
60 // Angle transformed in radians
61 if (angleunit == angDegrees) {
62 da[3] = deg2rad * _alpha;
63 da[4] = deg2rad * _beta;
64 da[5] = deg2rad * _gamma;
65 } else {
66 da[3] = _alpha;
67 da[4] = _beta;
68 da[5] = _gamma;
69 }
70 errorda[0] = errorda[1] = errorda[2] = errorda[3] = errorda[4] = errorda[5] = 0.0;
71 MaxOrder = 0;
72 CrossTerm = false;
74}
75
79double UnitCell::a1() const { return da[0]; }
80
84double UnitCell::a2() const { return da[1]; }
85
90double UnitCell::a3() const { return da[2]; }
94double UnitCell::a(int nd) const {
95 if (nd < 0 || nd > 2)
96 throw(std::invalid_argument("lattice parameter index can change from 0 to 2 "));
97 return da[nd];
98}
99
103double UnitCell::alpha1() const { return da[3]; }
104
108double UnitCell::alpha2() const { return da[4]; }
109
113double UnitCell::alpha3() const { return da[5]; }
114
118double UnitCell::a() const { return da[0]; }
119
123double UnitCell::b() const { return da[1]; }
124
128double UnitCell::c() const { return da[2]; }
129
133double UnitCell::alpha() const { return da[3] * rad2deg; }
134
138double UnitCell::beta() const { return da[4] * rad2deg; }
139
143double UnitCell::gamma() const { return da[5] * rad2deg; }
144
148double UnitCell::b1() const { return ra[0]; }
149
153double UnitCell::b2() const { return ra[1]; }
154
158double UnitCell::b3() const { return ra[2]; }
159
163double UnitCell::beta1() const { return ra[3]; }
164
168double UnitCell::beta2() const { return ra[4]; }
169
173double UnitCell::beta3() const { return ra[5]; }
174
178double UnitCell::astar() const { return ra[0]; }
179
183double UnitCell::bstar() const { return ra[1]; }
184
188double UnitCell::cstar() const { return ra[2]; }
189
193double UnitCell::alphastar() const { return ra[3] * rad2deg; }
194
198double UnitCell::betastar() const { return ra[4] * rad2deg; }
199
203double UnitCell::gammastar() const { return ra[5] * rad2deg; }
204
208double UnitCell::errora() const { return errorda[0]; }
209
213double UnitCell::errorb() const { return errorda[1]; }
214
218double UnitCell::errorc() const { return errorda[2]; }
219
225double UnitCell::erroralpha(const int angleunit) const {
226 if (angleunit == angDegrees) {
227 return errorda[3] * rad2deg;
228 } else {
229 return errorda[3];
230 }
231}
232
239double UnitCell::errorbeta(const int angleunit) const {
240 if (angleunit == angDegrees) {
241 return errorda[4] * rad2deg;
242 } else {
243 return errorda[4];
244 }
245}
246
252double UnitCell::errorgamma(const int angleunit) const {
253 if (angleunit == angDegrees) {
254 return errorda[5] * rad2deg;
255 } else {
256 return errorda[5];
257 }
258}
259
264double UnitCell::errorvolume() const {
265 // From latcon.py by Art Schultz
266 double V = volume();
267 double delta_V_alphaV = 0.0;
268 if (erroralpha() > 0.0) {
269 double alpha1 = alpha() - 0.5 * erroralpha();
270 double Va1 = UnitCell(a(), b(), c(), alpha1, beta(), gamma()).volume();
271 double alpha2 = alpha() + 0.5 * erroralpha();
272 double Va2 = UnitCell(a(), b(), c(), alpha2, beta(), gamma()).volume();
273 delta_V_alphaV = (Va2 - Va1) / V;
274 }
275
276 double delta_V_betaV = 0.0;
277 if (errorbeta() > 0.0) {
278 double beta1 = beta() - 0.5 * errorbeta();
279 double Va1 = UnitCell(a(), b(), c(), alpha(), beta1, gamma()).volume();
280 double beta2 = beta() + 0.5 * errorbeta();
281 double Va2 = UnitCell(a(), b(), c(), alpha(), beta2, gamma()).volume();
282 delta_V_betaV = (Va2 - Va1) / V;
283 }
284
285 double delta_V_gammaV = 0.0;
286 if (errorgamma() > 0.0) {
287 double gamma1 = gamma() - 0.5 * errorgamma();
288 double Va1 = UnitCell(a(), b(), c(), alpha(), beta(), gamma1).volume();
289 double gamma2 = gamma() + 0.5 * errorgamma();
290 double Va2 = UnitCell(a(), b(), c(), alpha(), beta(), gamma2).volume();
291 delta_V_gammaV = (Va2 - Va1) / V;
292 }
293
294 return V * sqrt(std::pow(errora() / a(), 2) + std::pow(errorb() / b(), 2) + std::pow(errorc() / c(), 2) +
295 std::pow(delta_V_alphaV, 2) + std::pow(delta_V_betaV, 2) + std::pow(delta_V_gammaV, 2));
296}
297
303void UnitCell::set(double _a, double _b, double _c, double _alpha, double _beta, double _gamma, const int angleunit) {
304 da[0] = _a;
305 da[1] = _b;
306 da[2] = _c;
307 if (angleunit == angDegrees) {
308 da[3] = deg2rad * _alpha;
309 da[4] = deg2rad * _beta;
310 da[5] = deg2rad * _gamma;
311 } else {
312 da[3] = _alpha;
313 da[4] = _beta;
314 da[5] = _gamma;
315 }
316 recalculate();
317}
318
325void UnitCell::setError(double _aerr, double _berr, double _cerr, double _alphaerr, double _betaerr, double _gammaerr,
326 const int angleunit) {
327 errorda[0] = _aerr;
328 errorda[1] = _berr;
329 errorda[2] = _cerr;
330 if (angleunit == angDegrees) {
331 errorda[3] = deg2rad * _alphaerr;
332 errorda[4] = deg2rad * _betaerr;
333 errorda[5] = deg2rad * _gammaerr;
334 } else {
335 errorda[3] = _alphaerr;
336 errorda[4] = _betaerr;
337 errorda[5] = _gammaerr;
338 }
339}
340
353void UnitCell::setModHKL(double _dh1, double _dk1, double _dl1, double _dh2, double _dk2, double _dl2, double _dh3,
354 double _dk3, double _dl3) {
355 ModHKL[0][0] = _dh1;
356 ModHKL[1][0] = _dk1;
357 ModHKL[2][0] = _dl1;
358 ModHKL[0][1] = _dh2;
359 ModHKL[1][1] = _dk2;
360 ModHKL[2][1] = _dl2;
361 ModHKL[0][2] = _dh3;
362 ModHKL[1][2] = _dk3;
363 ModHKL[2][2] = _dl3;
364}
365
370void UnitCell::setModHKL(const DblMatrix &newModHKL) { ModHKL = newModHKL; }
371
376void UnitCell::setErrorModHKL(const DblMatrix &newErrorModHKL) { errorModHKL = newErrorModHKL; }
377
390void UnitCell::setErrorModHKL(double _dh1err, double _dk1err, double _dl1err, double _dh2err, double _dk2err,
391 double _dl2err, double _dh3err, double _dk3err, double _dl3err) {
392 errorModHKL[0][0] = _dh1err;
393 errorModHKL[1][0] = _dk1err;
394 errorModHKL[2][0] = _dl1err;
395 errorModHKL[0][1] = _dh2err;
396 errorModHKL[1][1] = _dk2err;
397 errorModHKL[2][1] = _dl2err;
398 errorModHKL[0][2] = _dh3err;
399 errorModHKL[1][2] = _dk3err;
400 errorModHKL[2][2] = _dl3err;
401}
402
409void UnitCell::setModVec1(double _dh1, double _dk1, double _dl1) {
410 ModHKL[0][0] = _dh1;
411 ModHKL[1][0] = _dk1;
412 ModHKL[2][0] = _dl1;
413}
414
421void UnitCell::setModVec2(double _dh2, double _dk2, double _dl2) {
422 ModHKL[0][1] = _dh2;
423 ModHKL[1][1] = _dk2;
424 ModHKL[2][1] = _dl2;
425}
426
433void UnitCell::setModVec3(double _dh3, double _dk3, double _dl3) {
434 ModHKL[0][2] = _dh3;
435 ModHKL[1][2] = _dk3;
436 ModHKL[2][2] = _dl3;
437}
438
443void UnitCell::setModVec1(const V3D &newModVec) {
444 ModHKL[0][0] = newModVec[0];
445 ModHKL[1][0] = newModVec[1];
446 ModHKL[2][0] = newModVec[2];
447}
448
453void UnitCell::setModVec2(const V3D &newModVec) {
454 ModHKL[0][1] = newModVec[0];
455 ModHKL[1][1] = newModVec[1];
456 ModHKL[2][1] = newModVec[2];
457}
458
463void UnitCell::setModVec3(const V3D &newModVec) {
464 ModHKL[0][2] = newModVec[0];
465 ModHKL[1][2] = newModVec[1];
466 ModHKL[2][2] = newModVec[2];
467}
468
476void UnitCell::setModerr(int i, double _dherr, double _dkerr, double _dlerr) {
477 errorModHKL[0][i] = _dherr;
478 errorModHKL[1][i] = _dkerr;
479 errorModHKL[2][i] = _dlerr;
480}
481
488void UnitCell::setModerr1(double _dh1err, double _dk1err, double _dl1err) {
489 errorModHKL[0][0] = _dh1err;
490 errorModHKL[1][0] = _dk1err;
491 errorModHKL[2][0] = _dl1err;
492}
493
500void UnitCell::setModerr2(double _dh2err, double _dk2err, double _dl2err) {
501 errorModHKL[0][1] = _dh2err;
502 errorModHKL[1][1] = _dk2err;
503 errorModHKL[2][1] = _dl2err;
504}
505
512void UnitCell::setModerr3(double _dh3err, double _dk3err, double _dl3err) {
513 errorModHKL[0][2] = _dh3err;
514 errorModHKL[1][2] = _dk3err;
515 errorModHKL[2][2] = _dl3err;
516}
517
522void UnitCell::setMaxOrder(int MaxO) { MaxOrder = MaxO; }
523
528void UnitCell::setCrossTerm(bool CT) { CrossTerm = CT; }
529
535const Kernel::V3D UnitCell::getModVec(int j) const { return V3D(getdh(j), getdk(j), getdl(j)); }
536
542const Kernel::V3D UnitCell::getVecErr(int j) const { return V3D(getdherr(j), getdkerr(j), getdlerr(j)); }
543
549
555double UnitCell::getdh(int j) const { return ModHKL[0][j]; }
556
562double UnitCell::getdk(int j) const { return ModHKL[1][j]; }
563
569double UnitCell::getdl(int j) const { return ModHKL[2][j]; }
570
576double UnitCell::getdherr(int j) const { return errorModHKL[0][j]; }
577
583double UnitCell::getdkerr(int j) const { return errorModHKL[1][j]; }
584
590double UnitCell::getdlerr(int j) const { return errorModHKL[2][j]; }
591
596int UnitCell::getMaxOrder() const { return MaxOrder; }
597
602bool UnitCell::getCrossTerm() const { return CrossTerm; }
603
606void UnitCell::seta(double _a) {
607 da[0] = _a;
608 recalculate();
609}
612void UnitCell::setErrora(double _aerr) { errorda[0] = _aerr; }
613
616void UnitCell::setb(double _b) {
617 da[1] = _b;
618 recalculate();
619}
622void UnitCell::setErrorb(double _berr) { errorda[1] = _berr; }
625void UnitCell::setc(double _c) {
626 da[2] = _c;
627 recalculate();
628}
631void UnitCell::setErrorc(double _cerr) { errorda[2] = _cerr; }
636void UnitCell::setalpha(double _alpha, const int angleunit) {
637 if (angleunit == angDegrees)
638 da[3] = deg2rad * _alpha;
639 else
640 da[3] = _alpha;
641 recalculate();
642}
647void UnitCell::setErroralpha(double _alphaerr, const int angleunit) {
648 if (angleunit == angDegrees)
649 errorda[3] = deg2rad * _alphaerr;
650 else
651 errorda[3] = _alphaerr;
652}
657void UnitCell::setbeta(double _beta, const int angleunit) {
658 if (angleunit == angDegrees)
659 da[4] = deg2rad * _beta;
660 else
661 da[4] = _beta;
662 recalculate();
663}
664
669void UnitCell::setErrorbeta(double _betaerr, const int angleunit) {
670 if (angleunit == angDegrees)
671 errorda[4] = deg2rad * _betaerr;
672 else
673 errorda[4] = _betaerr;
674}
675
680void UnitCell::setgamma(double _gamma, const int angleunit) {
681 if (angleunit == angDegrees)
682 da[5] = deg2rad * _gamma;
683 else
684 da[5] = _gamma;
685 recalculate();
686}
687
692void UnitCell::setErrorgamma(double _gammaerr, const int angleunit) {
693 if (angleunit == angDegrees)
694 errorda[5] = deg2rad * _gammaerr;
695 else
696 errorda[5] = _gammaerr;
697}
698
700double UnitCell::d(double h, double k, double l) const { return 1.0 / dstar(V3D(h, k, l)); }
701
703double UnitCell::d(const V3D &hkl) const { return 1.0 / dstar(hkl); }
704
706double UnitCell::dstar(double h, double k, double l) const {
707 return dstar(V3D(h, k, l)); // create a V3D vector h,k,l
708}
709
711double UnitCell::dstar(const V3D &hkl) const {
712 V3D Q = B * hkl; // transform into $AA^-1$
713 return Q.norm();
714}
715
718double UnitCell::recAngle(double h1, double k1, double l1, double h2, double k2, double l2, const int angleunit) const {
719 V3D Q1(h1, k1, l1), Q2(h2, k2, l2);
720 double E, ang;
721 Q1 = Gstar * Q1;
722 E = Q1.scalar_prod(Q2);
723 double temp = E / dstar(h1, k1, l1) / dstar(h2, k2, l2);
724 if (temp > 1)
725 ang = 0.;
726 else if (temp < -1)
727 ang = M_PI;
728 else
729 ang = acos(temp);
730 if (angleunit == angDegrees)
731 return rad2deg * ang;
732 else
733 return ang;
734}
735
737double UnitCell::volume() const {
738 double volume = G.determinant();
739 return sqrt(volume);
740}
741
743double UnitCell::recVolume() const {
744 double recvolume = Gstar.determinant();
745 return sqrt(recvolume);
746}
747
750const Kernel::DblMatrix &UnitCell::getG() const { return G; }
751
755
758const Kernel::DblMatrix &UnitCell::getB() const { return B; }
759
762const Kernel::DblMatrix &UnitCell::getBinv() const { return Binv; }
763
767 if ((da[3] > da[4] + da[5]) || (da[4] > da[3] + da[5]) || (da[5] > da[4] + da[3])) {
768 throw std::invalid_argument("Invalid angles");
769 }
770 calculateG();
773 calculateB();
774}
775
777 G[0][0] = da[0] * da[0];
778 G[1][1] = da[1] * da[1];
779 G[2][2] = da[2] * da[2];
780 G[0][1] = da[0] * da[1] * cos(da[5]);
781 G[0][2] = da[0] * da[2] * cos(da[4]);
782 G[1][2] = da[1] * da[2] * cos(da[3]);
783 G[1][0] = G[0][1];
784 G[2][0] = G[0][2];
785 G[2][1] = G[1][2];
786}
787
790 // Reciprocal metrix tensor is simply the inverse of the direct one
791 double det = G.determinant();
792 if (det == 0) {
793 throw std::range_error("UnitCell not properly initialized");
794 }
795 Gstar = G;
796 if (Gstar.Invert() == 0) {
797 throw std::range_error("UnitCell not properly initialized");
798 }
799}
800
803 ra[0] = sqrt(Gstar[0][0]); // a*
804 ra[1] = sqrt(Gstar[1][1]); // b*
805 ra[2] = sqrt(Gstar[2][2]); // c*
806 auto acosThreshold = [](double x) { return std::abs(x) > 1e-15 ? acos(x) : M_PI_2; };
807 ra[3] = acosThreshold(Gstar[1][2] / ra[1] / ra[2]); // alpha*
808 ra[4] = acosThreshold(Gstar[0][2] / ra[0] / ra[2]); // beta*
809 ra[5] = acosThreshold(Gstar[0][1] / ra[0] / ra[1]); // gamma*
810}
811
814 // B matrix using a right handed coordinate system with b1 along x and y in
815 // the (b1,b2) plane.
816 // This is the convention in Busing and Levy.
817 // | b1 b2cos(beta3) b3cos(beta2) |
818 // | 0 b2sin(beta3) -b3sin(beta2)cos(alpha1) |
819 // | 0 0 1/a3 |
820 B[0][0] = ra[0];
821 B[0][1] = ra[1] * cos(ra[5]);
822 B[0][2] = ra[2] * cos(ra[4]);
823 B[1][0] = 0.;
824 B[1][1] = ra[1] * sin(ra[5]);
825 B[1][2] = -ra[2] * sin(ra[4]) * cos(da[3]);
826 B[2][0] = 0.;
827 B[2][1] = 0.;
828 B[2][2] = 1. / da[2];
829
831 Binv = B;
832 Binv.Invert();
833}
834
837 if (NewGstar.numRows() != 3 || NewGstar.numCols() != 3) {
838 std::ostringstream msg;
839 msg << "UnitCell::recalculateFromGstar - Expected a 3x3 matrix but was "
840 "given a "
841 << NewGstar.numRows() << "x" << NewGstar.numCols();
842 throw std::invalid_argument(msg.str());
843 }
844
845 if (NewGstar[0][0] * NewGstar[1][1] * NewGstar[2][2] <= 0.)
846 throw std::invalid_argument("NewGstar");
847 Gstar = NewGstar;
849 G = Gstar;
850 G.Invert();
851 da[0] = sqrt(G[0][0]); // a
852 da[1] = sqrt(G[1][1]); // b
853 da[2] = sqrt(G[2][2]); // c
854 da[3] = acos(G[1][2] / da[1] / da[2]); // alpha
855 da[4] = acos(G[0][2] / da[0] / da[2]); // beta
856 da[5] = acos(G[0][1] / da[0] / da[1]); // gamma
857 calculateB();
858}
859
860bool UnitCell::operator==(const UnitCell &other) const {
861 return da == other.da; // da error not used in comparison
862}
863bool UnitCell::operator!=(const UnitCell &other) const { return !this->operator==(other); }
864
865std::ostream &operator<<(std::ostream &out, const UnitCell &unitCell) {
866 // always show the lattice constants
867 out << "Lattice Parameters:" << std::fixed << std::setprecision(6) << std::setw(12) << unitCell.a() << std::fixed
868 << std::setprecision(6) << std::setw(12) << unitCell.b() << std::fixed << std::setprecision(6) << std::setw(12)
869 << unitCell.c() << std::fixed << std::setprecision(6) << std::setw(12) << unitCell.alpha() << std::fixed
870 << std::setprecision(6) << std::setw(12) << unitCell.beta() << std::fixed << std::setprecision(6) << std::setw(12)
871 << unitCell.gamma() << std::fixed << std::setprecision(6) << " " << std::setw(12) << unitCell.volume();
872
873 // write out the uncertainty if there is a positive one somewhere
874 if ((unitCell.errora() > 0) || (unitCell.errorb() > 0) || (unitCell.errorc() > 0) || (unitCell.erroralpha() > 0) ||
875 (unitCell.errorbeta() > 0) || (unitCell.errorgamma() > 0))
876 out << "\nParameter Errors :" << std::fixed << std::setprecision(6) << std::setw(12) << unitCell.errora()
877 << std::fixed << std::setprecision(6) << std::setw(12) << unitCell.errorb() << std::fixed
878 << std::setprecision(6) << std::setw(12) << unitCell.errorc() << std::fixed << std::setprecision(6)
879 << std::setw(12) << unitCell.erroralpha() << std::fixed << std::setprecision(6) << std::setw(12)
880 << unitCell.errorbeta() << std::fixed << std::setprecision(6) << std::setw(12) << unitCell.errorgamma()
881 << std::fixed << std::setprecision(6) << std::setw(12) << unitCell.errorvolume();
882
883 return out;
884}
885
886std::string unitCellToStr(const UnitCell &unitCell) {
887 std::ostringstream stream;
888 stream << std::setprecision(9);
889
890 stream << unitCell.a() << " " << unitCell.b() << " " << unitCell.c() << " " << unitCell.alpha() << " "
891 << unitCell.beta() << " " << unitCell.gamma();
892
893 return stream.str();
894}
895
896UnitCell strToUnitCell(const std::string &unitCellString) {
897
899
900 std::vector<double> components;
901 components.reserve(cellTokens.size());
902 std::transform(cellTokens.cbegin(), cellTokens.cend(), std::back_inserter(components),
903 [](const auto &token) { return boost::lexical_cast<double>(token); });
904
905 switch (components.size()) {
906 case 3:
907 return UnitCell(components[0], components[1], components[2]);
908 case 6:
909 return UnitCell(components[0], components[1], components[2], components[3], components[4], components[5]);
910 default:
911 throw std::runtime_error("Failed to parse unit cell input string: " + unitCellString);
912 }
913}
914
915} // namespace Mantid::Geometry
Class to implement unit cell of crystals.
Definition: UnitCell.h:44
double astar() const
Get reciprocal lattice parameter.
Definition: UnitCell.cpp:178
double betastar() const
Get reciprocal lattice parameter.
Definition: UnitCell.cpp:198
const Kernel::DblMatrix & getB() const
Get the B-matrix.
Definition: UnitCell.cpp:758
double alpha() const
Get lattice parameter.
Definition: UnitCell.cpp:133
UnitCell()
Default constructor.
Definition: UnitCell.cpp:26
double erroralpha(const int angleunit=angDegrees) const
Get lattice parameter error.
Definition: UnitCell.cpp:225
void set(double _a, double _b, double _c, double _alpha, double _beta, double _gamma, const int angleunit=angDegrees)
Set lattice parameters.
Definition: UnitCell.cpp:303
bool operator==(const UnitCell &other) const
Definition: UnitCell.cpp:860
double b2() const
Get reciprocal lattice parameter.
Definition: UnitCell.cpp:153
const Kernel::DblMatrix & getGstar() const
Get the reciprocal metric tensor.
Definition: UnitCell.cpp:754
std::vector< double > errorda
Error in lattice parameters (in and radians)
Definition: UnitCell.h:170
double a(int nd) const
Get lattice parameter a1-a3 as function of index (0-2)
Definition: UnitCell.cpp:94
int getMaxOrder() const
Get max order.
Definition: UnitCell.cpp:596
double c() const
Get lattice parameter.
Definition: UnitCell.cpp:128
const Kernel::DblMatrix & getModHKL() const
Get modulation vectors for satellites.
Definition: UnitCell.cpp:548
void setModerr3(double _dh3err, double _dk3err, double _dl3err)
Set modulation vectors for satellites.
Definition: UnitCell.cpp:512
double getdh(int j) const
Get modulation vectors for satellites.
Definition: UnitCell.cpp:555
const Kernel::V3D getVecErr(int j) const
Get errors for modulation vectors for satellites.
Definition: UnitCell.cpp:542
Kernel::DblMatrix Binv
Inverse of the B matrix.
Definition: UnitCell.h:195
double getdk(int j) const
Get modulation vectors for satellites.
Definition: UnitCell.cpp:562
double volume() const
Volume of the direct unit-cell.
Definition: UnitCell.cpp:737
void setModVec2(double _dh2, double _dk2, double _dl2)
Set modulation vectors for satellites.
Definition: UnitCell.cpp:421
double gammastar() const
Get reciprocal lattice parameter.
Definition: UnitCell.cpp:203
double alpha2() const
Get lattice parameter.
Definition: UnitCell.cpp:108
double a2() const
Get lattice parameter.
Definition: UnitCell.cpp:84
bool getCrossTerm() const
Get cross term boolean.
Definition: UnitCell.cpp:602
double getdl(int j) const
Get modulation vectors for satellites.
Definition: UnitCell.cpp:569
void setModerr1(double _dh1err, double _dk1err, double _dl1err)
Set modulation vectors for satellites.
Definition: UnitCell.cpp:488
double d(double h, double k, double l) const
Return d-spacing ( ) for a given h,k,l coordinate.
Definition: UnitCell.cpp:700
double errorgamma(const int angleunit=angDegrees) const
Get lattice parameter error.
Definition: UnitCell.cpp:252
double getdherr(int j) const
Get error of modulation vectors for satellites.
Definition: UnitCell.cpp:576
void setbeta(double _beta, const int angleunit=angDegrees)
Set lattice parameter.
Definition: UnitCell.cpp:657
double errorbeta(const int angleunit=angDegrees) const
Get lattice parameter error.
Definition: UnitCell.cpp:239
void setErrorc(double _cerr)
Set lattice parameter error.
Definition: UnitCell.cpp:631
void setalpha(double _alpha, const int angleunit=angDegrees)
Set lattice parameter.
Definition: UnitCell.cpp:636
Kernel::DblMatrix errorModHKL
Definition: UnitCell.h:199
void setModHKL(double _dh1, double _dk1, double _dl1, double _dh2, double _dk2, double _dl2, double _dh3, double _dk3, double _dl3)
Set modulation vectors for satellites.
Definition: UnitCell.cpp:353
double beta() const
Get lattice parameter.
Definition: UnitCell.cpp:138
void setError(double _aerr, double _berr, double _cerr, double _alphaerr, double _betaerr, double _gammaerr, const int angleunit=angDegrees)
Set lattice parameter errors.
Definition: UnitCell.cpp:325
void setgamma(double _gamma, const int angleunit=angDegrees)
Set lattice parameter.
Definition: UnitCell.cpp:680
double bstar() const
Get reciprocal lattice parameter.
Definition: UnitCell.cpp:183
double a() const
Get lattice parameter.
Definition: UnitCell.cpp:118
void setErrorgamma(double _gammaerr, const int angleunit=angDegrees)
Set lattice parameter error.
Definition: UnitCell.cpp:692
void calculateReciprocalLattice()
Private function to calculate reciprocal lattice parameters.
Definition: UnitCell.cpp:802
void setErroralpha(double _alphaerr, const int angleunit=angDegrees)
Set lattice parameter error.
Definition: UnitCell.cpp:647
std::vector< double > da
Lattice parameter a,b,c,alpha,beta,gamma (in and radians)
Definition: UnitCell.h:166
std::vector< double > ra
Reciprocal lattice parameters (in and radians)
Definition: UnitCell.h:168
void setErrorbeta(double _betaerr, const int angleunit=angDegrees)
Set lattice parameter error.
Definition: UnitCell.cpp:669
double a3() const
Get lattice parameter.
Definition: UnitCell.cpp:90
double beta1() const
Get reciprocal lattice parameter.
Definition: UnitCell.cpp:163
virtual void recalculate()
Private function, called at initialization or whenever lattice parameters are changed.
Definition: UnitCell.cpp:766
double getdlerr(int j) const
Get error of modulation vectors for satellites.
Definition: UnitCell.cpp:590
Kernel::DblMatrix G
Metric tensor.
Definition: UnitCell.h:177
void setErrorModHKL(const Kernel::DblMatrix &newErrorModHKL)
Set modulation vectors for satellites.
Definition: UnitCell.cpp:376
Kernel::DblMatrix ModHKL
Definition: UnitCell.h:197
void setModerr(int i, double _dherr, double _dkerr, double _dlerr)
Set modulation vectors for satellites.
Definition: UnitCell.cpp:476
const Kernel::DblMatrix & getBinv() const
Get the inverse of the B-matrix.
Definition: UnitCell.cpp:762
const Kernel::DblMatrix & getG() const
Get the metric tensor.
Definition: UnitCell.cpp:750
Kernel::DblMatrix Gstar
Reciprocal lattice tensor.
Definition: UnitCell.h:184
void setErrorb(double _berr)
Set lattice parameter error.
Definition: UnitCell.cpp:622
bool operator!=(const UnitCell &other) const
Definition: UnitCell.cpp:863
double alpha1() const
Get lattice parameter.
Definition: UnitCell.cpp:103
void setModVec3(double _dh3, double _dk3, double _dl3)
Set modulation vectors for satellites.
Definition: UnitCell.cpp:433
double recVolume() const
Volume of the reciprocal lattice.
Definition: UnitCell.cpp:743
void calculateB()
Private function to calculate B matrix.
Definition: UnitCell.cpp:813
double b() const
Get lattice parameter.
Definition: UnitCell.cpp:123
double getdkerr(int j) const
Get error of modulation vectors for satellites.
Definition: UnitCell.cpp:583
double beta3() const
Get reciprocal lattice parameter.
Definition: UnitCell.cpp:173
double alphastar() const
Get reciprocal lattice parameter.
Definition: UnitCell.cpp:193
void setb(double _b)
Set lattice parameter.
Definition: UnitCell.cpp:616
const Kernel::V3D getModVec(int j) const
Get modulation vectors for satellites.
Definition: UnitCell.cpp:535
void calculateGstar()
Private function to calculate Gstar matrix.
Definition: UnitCell.cpp:789
double errorc() const
Get lattice parameter error.
Definition: UnitCell.cpp:218
double dstar(double h, double k, double l) const
Return d*=1/d ( ) for a given h,k,l coordinate.
Definition: UnitCell.cpp:706
double b1() const
Get reciprocal lattice parameter.
Definition: UnitCell.cpp:148
void setCrossTerm(bool CT)
Set modulation vectors for satellites.
Definition: UnitCell.cpp:528
double recAngle(double h1, double k1, double l1, double h2, double k2, double l2, const int angleunit=angDegrees) const
Calculate the angle in degrees or radians between two reciprocal vectors (h1,k1,l1) and (h2,...
Definition: UnitCell.cpp:718
double alpha3() const
Get lattice parameter.
Definition: UnitCell.cpp:113
double errorvolume() const
Get lattice parameter error.
Definition: UnitCell.cpp:264
virtual void recalculateFromGstar(const Kernel::Matrix< double > &NewGstar)
Recalculate lattice from reciprocal metric tensor (Gstar=transpose(UB)*UB)
Definition: UnitCell.cpp:836
void setErrora(double _aerr)
Set lattice parameter error.
Definition: UnitCell.cpp:612
void setModVec1(double _dh1, double _dk1, double _dl1)
Set modulation vectors for satellites.
Definition: UnitCell.cpp:409
void setc(double _c)
Set lattice parameter.
Definition: UnitCell.cpp:625
void setMaxOrder(int MaxO)
Set modulation vectors for satellites.
Definition: UnitCell.cpp:522
double beta2() const
Get reciprocal lattice parameter.
Definition: UnitCell.cpp:168
double cstar() const
Get reciprocal lattice parameter.
Definition: UnitCell.cpp:188
Kernel::DblMatrix B
B matrix for a right-handed coordinate system, in Busing-Levy convention.
Definition: UnitCell.h:191
double a1() const
Get lattice parameter.
Definition: UnitCell.cpp:79
void setModerr2(double _dh2err, double _dk2err, double _dl2err)
Set modulation vectors for satellites.
Definition: UnitCell.cpp:500
double b3() const
Get reciprocal lattice parameter.
Definition: UnitCell.cpp:158
double gamma() const
Get lattice parameter.
Definition: UnitCell.cpp:143
double errora() const
Get lattice parameter error.
Definition: UnitCell.cpp:208
void seta(double _a)
Set lattice parameter.
Definition: UnitCell.cpp:606
double errorb() const
Get lattice parameter error.
Definition: UnitCell.cpp:213
T determinant() const
Calculate the determinant.
Definition: Matrix.cpp:1048
T Invert()
LU inversion routine.
Definition: Matrix.cpp:924
size_t numRows() const
Return the number of rows in the matrix.
Definition: Matrix.h:144
size_t numCols() const
Return the number of columns in the matrix.
Definition: Matrix.h:147
@ TOK_IGNORE_EMPTY
ignore empty tokens
std::size_t size() const noexcept
Get the total number of tokens.
ConstIterator cend() const
Const iterator referring to the past-the-end element in the container.
ConstIterator cbegin() const
Const iterator referring to first element in the container.
Class for 3D vectors.
Definition: V3D.h:34
double norm() const noexcept
Definition: V3D.h:263
constexpr double deg2rad
Defines units/enum for Crystal work.
Definition: AngleUnits.h:20
constexpr double rad2deg
Radians to degrees conversion factor.
Definition: AngleUnits.h:23
MANTID_GEOMETRY_DLL UnitCell strToUnitCell(const std::string &unitCellString)
Definition: UnitCell.cpp:896
MANTID_GEOMETRY_DLL std::string unitCellToStr(const UnitCell &unitCell)
Definition: UnitCell.cpp:886
MANTID_GEOMETRY_DLL std::ostream & operator<<(std::ostream &stream, const PointGroup &self)
Returns a streamed representation of the PointGroup object.
Definition: PointGroup.cpp:312