Mantid
Loading...
Searching...
No Matches
OrientedLattice.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 +
11
13#include <boost/python/class.hpp>
14
18using namespace boost::python;
19
20namespace //<unnamed>
21{
22using namespace Mantid::PythonInterface;
23
25void setU(OrientedLattice &self, const object &data, const bool force) {
26 self.setU(Converters::PyObjectToMatrix(data)(), force);
27}
28
30void setUB(OrientedLattice &self, const object &data) { self.setUB(Converters::PyObjectToMatrix(data)()); }
31
34void setModUB(OrientedLattice &self, const object &data) { self.setModUB(Converters::PyObjectToMatrix(data)()); }
35
39void setUFromVectors(OrientedLattice &self, const object &vec1, const object &vec2) {
41}
42
43Mantid::Kernel::V3D qFromHKL(const OrientedLattice &self, const object &vec) {
45}
46
47Mantid::Kernel::V3D hklFromQ(const OrientedLattice &self, const object &vec) {
49}
50
51Mantid::Kernel::V3D cosFromDir(const OrientedLattice &self, const object &vec) {
53}
54} // namespace
55
58 using return_readonly_numpy = return_value_policy<Policies::MatrixRefToNumpy<Converters::WrapReadOnly>>;
59
60 class_<OrientedLattice, bases<UnitCell>>("OrientedLattice",
61 init<>("Default constructor, with "
62 ":math:`a=b=c=1 \\rm{\\AA}, \\alpha = \\beta = \\gamma = "
63 "90^\\circ`. The :math:`U` matrix is set to the identity matrix."))
64 .def(init<OrientedLattice const &>((arg("other")), "Copy constructor for creating a new oriented lattice."))
65 .def(init<double, double, double>((arg("_a"), arg("_b"), arg("_c")),
66 "Constructor using :math:`a, b, c` (in :math:`\\rm{\\AA}`), "
67 ":math:`\\alpha=\\beta=\\gamma=90^\\circ`. The :math:`U` matrix is "
68 "set to the identity matrix."))
69 .def(init<double, double, double, double, double, double, optional<int>>(
70 (arg("_a"), arg("_b"), arg("_c"), arg("_alpha"), arg("_beta"), arg("_gamma"),
71 arg("Unit") = static_cast<int>(angDegrees)),
72 "Constructor using :math:`a, b, c` (in :math:`\\rm{\\AA}`), "
73 ":math:`\\alpha, \\beta, "
74 "\\gamma` (in degrees or radians). The optional parameter ``Unit`` "
75 "controls the "
76 "units for the angles, and can have the value of ``Degrees`` or "
77 "``Radians``. By default ``Unit`` = ``Degrees``."))
78 .def(init<UnitCell>(arg("uc"), "Constructor from a :class:`~mantid.geometry.UnitCell`. "
79 "The :math:`U` matrix is set to the identity matrix."))
80 .def("getuVector", (&OrientedLattice::getuVector), arg("self"),
81 "Returns the vector along the beam direction when "
82 ":class:`~mantid.geometry.Goniometer` s are at 0. ")
83 .def("getvVector", (&OrientedLattice::getvVector), arg("self"),
84 "Returns the vector along the horizontal plane, perpendicular to "
85 "the beam direction when :class:`~mantid.geometry.Goniometer` s are "
86 "at 0. ")
87 .def("getU", &OrientedLattice::getU, arg("self"), return_readonly_numpy(),
88 "Returns the :math:`U` rotation matrix. This will return a "
89 ":class:`numpy.ndarray` with shape ``(3,3)``.")
90 .def("setU", &setU, (arg("self"), arg("newU"), arg("force") = true),
91 "Set the :math:`U` rotation matrix. This method expects a "
92 ":class:`numpy.ndarray` with shape ``(3,3)``.")
93 .def("getUB", &OrientedLattice::getUB, arg("self"), return_readonly_numpy(),
94 "Returns the :math:`UB` matrix for this oriented lattice. This will "
95 "return "
96 "a :class:`numpy.ndarray` with shape ``(3,3)``.")
97 .def("setUB", &setUB, (arg("self"), arg("newUB")),
98 "Set the :math:`UB` matrix. This methiod will calculate first the "
99 "lattice parameters, then the :math:`B` matrix, and then :math:`U`. "
100 "This method expects a "
101 ":class:`numpy.ndarray` with shape ``(3,3)``. ")
102 .def("getModUB", &OrientedLattice::getModUB, arg("self"), return_readonly_numpy(),
103 "Returns the :math:`ModUB` matrix for this oriented lattice. This "
104 "will "
105 "return "
106 "a :class:`numpy.ndarray` with shape ``(3,3)``.")
107 .def("setModUB", &setModUB, (arg("self"), arg("newModUB")),
108 "Set the :math:`ModUB` matrix. This methiod will calculate first the "
109 "lattice parameters, then the :math:`B` matrix, and then :math:`U`. "
110 "This method expects a "
111 ":class:`numpy.ndarray` with shape ``(3,3)``. ")
112 .def("setUFromVectors", &setUFromVectors, (arg("self"), arg("u"), arg("v")),
113 "Set the :math:`U` rotation matrix using two vectors to define a "
114 "new "
115 "coordinate system. This method with return the new :math:`U` "
116 "matrix "
117 "as a :class:`numpy.ndarray` with shape ``(3,3)``. ")
118 .def("qFromHKL", &qFromHKL, (arg("self"), arg("vec")), ":math:`Q` vector from :math:`HKL` vector")
119 .def("hklFromQ", &hklFromQ, (arg("self"), arg("vec")), ":math:`HKL` value from :math:`Q` vector")
120 .def("cosFromDir", &cosFromDir, (arg("self"), arg("vec")), "Direction cosine from direction vector");
121}
std::vector< T > const * vec
void export_OrientedLattice()
Class to implement UB matrix.
Kernel::V3D cosFromDir(const Kernel::V3D &dir) const
Calculate the direction cosine corresponding to a given direction.
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.
void setModUB(const Kernel::DblMatrix &newModUB)
Sets the Modulation UB matrix.
Kernel::V3D hklFromQ(const Kernel::V3D &Q) const
Calculate the hkl corresponding to a given Q-vector.
void setUB(const Kernel::DblMatrix &newUB)
Sets the UB matrix and recalculates lattice parameters.
const Kernel::DblMatrix & setUFromVectors(const Kernel::V3D &u, const Kernel::V3D &v)
Set the U rotation matrix, to provide the transformation, which translate an arbitrary vector V expre...
const Kernel::DblMatrix & getUB() const
Get the UB matrix.
Kernel::V3D qFromHKL(const Kernel::V3D &hkl) const
Calculate the hkl corresponding to a given Q-vector.
const Kernel::DblMatrix & getModUB() const
const Kernel::DblMatrix & getU() const
Get the U matrix.
Class to implement unit cell of crystals.
Definition UnitCell.h:44
Class for 3D vectors.
Definition V3D.h:34
Takes a Python object and if it supports indexing and is two dimensional it attempts to convert it to...
Takes a Python object and if it supports indexing and is of length 3 then it will attempt to convert ...