15const double TWO_PI = 2. * M_PI;
27 throw std::invalid_argument(
"U is not a proper rotation");
46 throw std::invalid_argument(
"U is not a proper rotation");
60 const double _beta,
const double _gamma,
const DblMatrix &Umatrix,
const int angleunit)
61 :
UnitCell(_a, _b, _c, _alpha, _beta, _gamma, angleunit) {
67 throw std::invalid_argument(
"U is not a proper rotation");
80 throw std::invalid_argument(
"U is not a proper rotation");
110 throw std::invalid_argument(
"U is not a proper rotation");
120 newGstar = newUB.
Tprime() * newUB;
126 throw std::invalid_argument(
"determinant of UB is too close to 0");
137 newModHKL = UBinv *
ModUB;
148 V3D out = UBinv * Q / TWO_PI;
197 V3D buVec = BMatrix * u;
198 V3D bvVec = BMatrix * v;
200 if (buVec.
norm2() < 1e-10)
201 throw std::invalid_argument(
"|B.u|~0");
202 if (bvVec.
norm2() < 1e-10)
203 throw std::invalid_argument(
"|B.v|~0");
206 const auto norm = bwVec.
norm();
209 throw std::invalid_argument(
"u and v are parallel");
223 tau[0][0] = buVec[0];
224 tau[0][1] = bvVec[0];
225 tau[0][2] = bwVec[0];
226 tau[1][0] = buVec[1];
227 tau[1][1] = bvVec[1];
228 tau[1][2] = bwVec[1];
229 tau[2][0] = buVec[2];
230 tau[2][1] = bvVec[2];
231 tau[2][2] = bwVec[2];
243 file->makeGroup(group,
"NXcrystal",
true);
244 file->writeData(
"unit_cell_a", this->
a());
245 file->writeData(
"unit_cell_b", this->
b());
246 file->writeData(
"unit_cell_c", this->
c());
247 file->writeData(
"unit_cell_alpha", this->
alpha());
248 file->writeData(
"unit_cell_beta", this->
beta());
249 file->writeData(
"unit_cell_gamma", this->
gamma());
252 std::vector<int> dims(2, 3);
253 file->writeData(
"orientation_matrix", ub, dims);
263 file->openGroup(group,
"NXcrystal");
264 std::vector<double> ub;
265 file->readData(
"orientation_matrix", ub);
287 throw std::invalid_argument(
"Find_UB(): UB matrix NULL or not 3X3");
320 throw std::invalid_argument(
"GetABC(): UB matrix NULL or not 3X3");
329 a_dir(UB_inverse[0][0], UB_inverse[0][1], UB_inverse[0][2]);
330 b_dir(UB_inverse[1][0], UB_inverse[1][1], UB_inverse[1][2]);
331 c_dir(UB_inverse[2][0], UB_inverse[2][1], UB_inverse[2][2]);
Class to implement UB matrix.
Kernel::V3D getuVector() const
gets a vector along beam direction when goniometers are at 0.
void setU(const Kernel::DblMatrix &newU, const bool force=true)
Sets the U matrix.
Kernel::V3D getvVector() const
gets a vector in the horizontal plane, perpendicular to the beam direction when goniometers are at 0.
OrientedLattice(const Kernel::DblMatrix &Umatrix=Kernel::DblMatrix(3, 3, true))
Default constructor.
void setModUB(const Kernel::DblMatrix &newModUB)
Sets the Modulation UB matrix.
Kernel::V3D hklFromQ(const Kernel::V3D &Q) const
Return hkl from the Q-sample coordinates.
void setUB(const Kernel::DblMatrix &newUB)
Sets the UB matrix and recalculates lattice parameters.
static bool GetABC(const Kernel::DblMatrix &UB, Kernel::V3D &a_dir, Kernel::V3D &b_dir, Kernel::V3D &c_dir)
Get the real space edge vectors a, b, c corresponding to the UB matrix.
bool operator==(const OrientedLattice &other) const
const Kernel::DblMatrix & setUFromVectors(const Kernel::V3D &u, const Kernel::V3D &v)
Create the U matrix from two vectors.
void recalculate() override
Private function, called at initialization or whenever lattice parameters are changed.
const Kernel::DblMatrix & getUB() const
Get the UB matrix.
void loadNexus(::NeXus::File *file, const std::string &group)
Load the lattice to from an open NeXus file.
void saveNexus(::NeXus::File *file, const std::string &group) const
Save the lattice to an open NeXus file.
bool operator!=(const OrientedLattice &other) const
static bool GetUB(Kernel::DblMatrix &UB, const Kernel::V3D &a_dir, const Kernel::V3D &b_dir, const Kernel::V3D &c_dir)
Get the UB matix corresponding to the real space edge vectors a, b, c.
Kernel::V3D qFromHKL(const Kernel::V3D &hkl) const
Return Q-sample coordinates from hkl.
const Kernel::DblMatrix & getModUB() const
const Kernel::DblMatrix & getU() const
Get the U matrix.
void recalculateFromGstar(const Kernel::DblMatrix &NewGstar) override
Make recalculateFrom private.
Class to implement unit cell of crystals.
const Kernel::DblMatrix & getB() const
Get the B-matrix.
double alpha() const
Get lattice parameter.
double c() const
Get lattice parameter.
const Kernel::DblMatrix & getModHKL() const
Get modulation vectors for satellites.
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.
double beta() const
Get lattice parameter.
double a() const
Get lattice parameter.
virtual void recalculate()
Private function, called at initialization or whenever lattice parameters are changed.
double b() const
Get lattice parameter.
Kernel::DblMatrix B
B matrix for a right-handed coordinate system, in Busing-Levy convention.
double gamma() const
Get lattice parameter.
T determinant() const
Calculate the determinant.
T Invert()
LU inversion routine.
Matrix< T > Tprime() const
Transpose the matrix.
bool isRotation() const
Check if a matrix represents a proper rotation @ return :: true/false.
void setRow(const size_t nRow, const std::vector< T > &newRow)
std::vector< T > getVector() const
size_t numRows() const
Return the number of rows in the matrix.
size_t numCols() const
Return the number of columns in the matrix.
bool isOrthogonal() const
Check if a matrix is orthogonal.
double normalize()
Make a normalized vector (return norm value)
constexpr V3D cross_prod(const V3D &v) const noexcept
Cross product (this * argument)
double norm() const noexcept
constexpr double norm2() const noexcept
Vector length squared.