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) {
44 return self.qFromHKL(Converters::PyObjectToV3D(vec)());
45}
46
47Mantid::Kernel::V3D hklFromQ(const OrientedLattice &self, const object &vec) {
48 return self.hklFromQ(Converters::PyObjectToV3D(vec)());
49}
50} // namespace
51
54 using return_readonly_numpy = return_value_policy<Policies::MatrixRefToNumpy<Converters::WrapReadOnly>>;
55
56 class_<OrientedLattice, bases<UnitCell>>("OrientedLattice",
57 init<>("Default constructor, with "
58 ":math:`a=b=c=1 \\rm{\\AA}, \\alpha = \\beta = \\gamma = "
59 "90^\\circ`. The :math:`U` matrix is set to the identity matrix."))
60 .def(init<OrientedLattice const &>((arg("other")), "Copy constructor for creating a new oriented lattice."))
61 .def(init<double, double, double>((arg("_a"), arg("_b"), arg("_c")),
62 "Constructor using :math:`a, b, c` (in :math:`\\rm{\\AA}`), "
63 ":math:`\\alpha=\\beta=\\gamma=90^\\circ`. The :math:`U` matrix is "
64 "set to the identity matrix."))
65 .def(init<double, double, double, double, double, double, optional<int>>(
66 (arg("_a"), arg("_b"), arg("_c"), arg("_alpha"), arg("_beta"), arg("_gamma"),
67 arg("Unit") = static_cast<int>(angDegrees)),
68 "Constructor using :math:`a, b, c` (in :math:`\\rm{\\AA}`), "
69 ":math:`\\alpha, \\beta, "
70 "\\gamma` (in degrees or radians). The optional parameter ``Unit`` "
71 "controls the "
72 "units for the angles, and can have the value of ``Degrees`` or "
73 "``Radians``. By default ``Unit`` = ``Degrees``."))
74 .def(init<UnitCell>(arg("uc"), "Constructor from a :class:`~mantid.geometry.UnitCell`. "
75 "The :math:`U` matrix is set to the identity matrix."))
76 .def("getuVector", (&OrientedLattice::getuVector), arg("self"),
77 "Returns the vector along the beam direction when "
78 ":class:`~mantid.geometry.Goniometer` s are at 0. ")
79 .def("getvVector", (&OrientedLattice::getvVector), arg("self"),
80 "Returns the vector along the horizontal plane, perpendicular to "
81 "the beam direction when :class:`~mantid.geometry.Goniometer` s are "
82 "at 0. ")
83 .def("getU", &OrientedLattice::getU, arg("self"), return_readonly_numpy(),
84 "Returns the :math:`U` rotation matrix. This will return a "
85 ":class:`numpy.ndarray` with shape ``(3,3)``.")
86 .def("setU", &setU, (arg("self"), arg("newU"), arg("force") = true),
87 "Set the :math:`U` rotation matrix. This method expects a "
88 ":class:`numpy.ndarray` with shape ``(3,3)``.")
89 .def("getUB", &OrientedLattice::getUB, arg("self"), return_readonly_numpy(),
90 "Returns the :math:`UB` matrix for this oriented lattice. This will "
91 "return "
92 "a :class:`numpy.ndarray` with shape ``(3,3)``.")
93 .def("setUB", &setUB, (arg("self"), arg("newUB")),
94 "Set the :math:`UB` matrix. This methiod will calculate first the "
95 "lattice parameters, then the :math:`B` matrix, and then :math:`U`. "
96 "This method expects a "
97 ":class:`numpy.ndarray` with shape ``(3,3)``. ")
98 .def("getModUB", &OrientedLattice::getModUB, arg("self"), return_readonly_numpy(),
99 "Returns the :math:`ModUB` matrix for this oriented lattice. This "
100 "will "
101 "return "
102 "a :class:`numpy.ndarray` with shape ``(3,3)``.")
103 .def("setModUB", &setModUB, (arg("self"), arg("newModUB")),
104 "Set the :math:`ModUB` matrix. This methiod will calculate first the "
105 "lattice parameters, then the :math:`B` matrix, and then :math:`U`. "
106 "This method expects a "
107 ":class:`numpy.ndarray` with shape ``(3,3)``. ")
108 .def("setUFromVectors", &setUFromVectors, (arg("self"), arg("u"), arg("v")),
109 "Set the :math:`U` rotation matrix using two vectors to define a "
110 "new "
111 "coordinate system. This method with return the new :math:`U` "
112 "matrix "
113 "as a :class:`numpy.ndarray` with shape ``(3,3)``. ")
114 .def("qFromHKL", &qFromHKL, (arg("self"), arg("vec")), ":math:`Q` vector from :math:`HKL` vector")
115 .def("hklFromQ", &hklFromQ, (arg("self"), arg("vec")), ":math:`HKL` value from :math:`Q` vector");
116}
void export_OrientedLattice()
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.
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.
const Kernel::DblMatrix & setUFromVectors(const Kernel::V3D &u, const Kernel::V3D &v)
Create the U matrix from two vectors.
const Kernel::DblMatrix & getUB() const
Get the UB matrix.
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.
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 ...
Definition: PyObjectToV3D.h:22