13#include <boost/python/class.hpp>
14#include <boost/python/enum.hpp>
15#include <boost/python/operators.hpp>
16#include <boost/python/scope.hpp>
17#include <boost/python/self.hpp>
33void recalculateFromGstar(
UnitCell &self,
const object &values) {
39std::string __str__implementation(
const UnitCell &self) {
41 ss <<
"UnitCell with lattice parameters:";
42 ss <<
" a = " << self.
a();
43 ss <<
" b = " << self.
b();
44 ss <<
" c = " << self.
c();
46 ss <<
" alpha = " << self.
alpha();
47 ss <<
" beta = " << self.
beta();
48 ss <<
" gamma = " << self.
gamma();
54std::string __repr__implementation(
const UnitCell &self) {
57 ss << self.
a() <<
", ";
58 ss << self.
b() <<
", ";
59 ss << self.
c() <<
", ";
61 ss << self.
alpha() <<
", ";
62 ss << self.
beta() <<
", ";
72 enum_<AngleUnits>(
"AngleUnits").value(
"Degrees",
angDegrees).value(
"Radians",
angRadians).export_values();
75 using return_readonly_numpy = return_value_policy<Policies::MatrixRefToNumpy<Converters::WrapReadOnly>>;
77 class_<UnitCell>(
"UnitCell", init<>(
"Default constructor, with "
78 ":math:`a=b=c=1 \\rm{\\AA}, \\alpha = \\beta = \\gamma = 90^\\circ`"))
79 .def(init<UnitCell const &>((arg(
"self"), arg(
"other")),
"Copy constructor for creating a new unit cell."))
80 .def(init<double, double, double>((arg(
"self"), arg(
"_a"), arg(
"_b"), arg(
"_c")),
81 "Constructor using :math:`a, b, c` (in :math:`\\rm{\\AA}`), "
82 ":math:`\\alpha=\\beta=\\gamma=90^\\circ`"))
83 .def(init<
double,
double,
double,
double,
double,
double, optional<int>>(
84 (arg(
"self"), arg(
"_a"), arg(
"_b"), arg(
"_c"), arg(
"_alpha"), arg(
"_beta"), arg(
"_gamma"),
87 ":math:`a, b, c` (in :math:`\\rm{\\AA}`), :math:`\\alpha, \\beta, "
89 "degrees or radians). The optional parameter ``Unit`` controls the "
90 "units for the angles, and can have the value of ``Degrees`` or "
91 "``Radians``. By default ``Unit`` = ``Degrees``."))
93 "Returns the length of the :math:`a` direction of the unit cell in "
94 ":math:`\\rm{\\AA}`.")
96 "Returns the length of the :math:`a_{1} = a` direction of the unit "
98 "This is an alias for :func:`~mantid.geometry.UnitCell.a`. ")
100 "Returns the length of the :math:`a_{2} = b` direction of the unit "
102 "This is an alias for :func:`~mantid.geometry.UnitCell.b`. ")
104 "Returns the length of the :math:`a_{2} = c` direction of the unit "
106 "This is an alias for :func:`~mantid.geometry.UnitCell.c`. ")
108 "Returns the :math:`\\alpha` angle for this unit cell in degrees.")
110 "Returns the :math:`\\alpha_{1} = \\alpha` angle of the unit cell "
112 "See also :func:`~mantid.geometry.UnitCell.alpha`. ")
114 "Returns the :math:`\\alpha_{2} = \\beta` angle of the unit cell in "
116 "See also :func:`~mantid.geometry.UnitCell.beta`. ")
118 "Returns the :math:`\\alpha_{3} = \\gamma` angle of the unit cell "
120 "See also :func:`~mantid.geometry.UnitCell.gamma`. ")
122 "Returns the reciprocal :math:`\\alpha` angle for this unit cell in "
125 "Returns the length of the reciprocal :math:`a` direction for this "
126 "unit cell in reciprocal :math:`\\rm{\\AA}`.")
128 "Returns the length of the :math:`b` direction of the unit cell in "
129 ":math:`\\rm{\\AA}`.")
131 "Returns the length of the :math:`b_{1} = a^{*}` direction of the "
133 "cell. This is an alias for "
134 ":func:`~mantid.geometry.UnitCell.astar`. ")
136 "Returns the length of the :math:`b_{2} = b^{*}` direction of the "
138 "cell. This is an alias for "
139 ":func:`~mantid.geometry.UnitCell.bstar`. ")
141 "Returns the length of the :math:`b_{3} = c^{*}` direction of the "
143 "cell. This is an alias for "
144 ":func:`~mantid.geometry.UnitCell.cstar`. ")
146 "Returns the :math:`\\beta` angle for this unit cell in degrees.")
148 "Returns the :math:`\\beta_{1} = \\alpha^{*}` angle of the unit "
150 "radians. See also :func:`~mantid.geometry.UnitCell.alphastar`. ")
152 "Returns the :math:`\\beta_{2} = \\beta^{*}` angle of the unit cell "
154 "See also :func:`~mantid.geometry.UnitCell.betastar`. ")
156 "Returns the :math:`\\beta_{3} = \\gamma^{*}` angle of the unit "
158 "radians. See also :func:`~mantid.geometry.UnitCell.gammastar`. ")
160 "Returns the :math:`\\beta^{*}` angle for this unit cell in "
163 "Returns the length of the :math:`b^{*}` direction for this "
164 "unit cell in reciprocal :math:`\\rm{\\AA}`.")
166 "Returns the length of the :math:`c` direction of the unit cell in "
167 ":math:`\\rm{\\AA}`.")
169 "Returns the length of the :math:`c^{*}` direction for this "
170 "unit cell in reciprocal :math:`\\rm{\\AA}`.")
172 (arg(
"self"), arg(
"h"), arg(
"k"), arg(
"l")),
173 "Returns :math:`d`-spacing for a given H, K, L coordinate in "
174 ":math:`\\rm{\\AA}`.")
176 "Returns :math:`d`-spacing for a given H, K, L coordinate in "
177 ":math:`\\rm{\\AA}`.")
179 (arg(
"self"), arg(
"h"), arg(
"k"), arg(
"l")),
180 "Returns :math:`d^{*} = 1/d` for a given H, K, L coordinate in "
181 ":math:`\\rm{\\AA}^{3}`.")
183 "Returns the error in the :math:`a` unit cell length.")
185 "Returns the error in the :math:`b` unit cell length.")
187 "Returns the error in the :math:`c` unit cell length.")
189 (arg(
"self"), arg(
"Unit") =
static_cast<int>(
angDegrees)),
190 "Returns the error in the :math:`\\alpha` angle of the unit cell.")
192 (arg(
"self"), arg(
"Unit") =
static_cast<int>(
angDegrees)),
193 "Returns the error in :math:`\\beta` angle of the unit cell.")
195 (arg(
"self"), arg(
"Unit") =
static_cast<int>(
angDegrees)),
196 "Returns the error in :math:`\\gamma` angle of the unit cell.")
198 "Returns the :math:`\\gamma` angle for this unit cell in degrees.")
200 "Returns the :math:`\\gamma^{*}` angle for this unit cell in "
204 (arg(
"self"), arg(
"h1"), arg(
"k1"), arg(
"l1"), arg(
"h2"), arg(
"k2"), arg(
"l2"),
206 "Returns the angle in reciprocal space between vectors given by "
207 "(:math:`h_1, k_1, l_1`) and (:math:`h_2, k_2, l_2`) (in "
208 "degrees or radians). The optional parameter ``Unit`` controls "
209 "the units for the angles, and can have the value of ``Degrees`` or "
210 "``Radians``. By default Unit = Degrees")
212 "Return the volume of the reciprocal unit cell (in "
213 ":math:`\\rm{\\AA}^{-3}`)")
214 .def(
"set", (
void (
UnitCell::*)(
double,
double,
double,
double,
double,
double,
int const)) &
UnitCell::set,
215 (arg(
"self"), arg(
"_a"), arg(
"_b"), arg(
"_c"), arg(
"_alpha"), arg(
"_beta"), arg(
"_gamma"),
217 "Set the parameters of the unit cell. Angles can be set in either"
218 "degrees or radians using the ``Unit`` parameter (0 = degrees, "
221 "Set the length of the :math:`a` direction of the unit cell.")
223 (arg(
"self"), arg(
"_alpha"), arg(
"Unit") =
static_cast<int>(
angDegrees)),
224 "Set the :math:`\\alpha` angle of the unit cell. The angle can be "
226 "either in degrees or radians using the ``Unit`` parameter.")
228 "Set the length of the :math:`b` direction of the unit cell.")
230 (arg(
"self"), arg(
"_beta"), arg(
"Unit") =
static_cast<int>(
angDegrees)),
231 "Set the :math:`\\beta` angle of the unit cell. The angle can be "
233 "either in degrees or radians using the ``Unit`` parameter.")
235 "Set the length of the :math:`c` direction of the unit cell.")
237 (arg(
"self"), arg(
"_gamma"), arg(
"Unit") =
static_cast<int>(
angDegrees)),
238 "Set the :math:`\\gamma` angle of the unit cell. The angle can be "
240 "either in degrees or radians using the ``Unit`` parameter.")
243 (arg(
"self"), arg(
"_aerr"), arg(
"_berr"), arg(
"_cerr"), arg(
"_alphaerr"), arg(
"_betaerr"), arg(
"_gammaerr"),
245 "Set the errors in the unit cell parameters.")
247 "Set the error in the length of the :math:`a` direction of the unit "
250 (arg(
"self"), arg(
"_alphaerr"), arg(
"Unit") =
static_cast<int>(
angDegrees)),
251 "Set the error in the :math:`\\alpha` angle of the unit cell.")
253 "Set the error in the length of the :math:`b` direction of the unit "
256 (arg(
"self"), arg(
"_betaerr"), arg(
"Unit") =
static_cast<int>(
angDegrees)),
257 "Set the error in the :math:`\\beta` angle of the unit cell using "
259 "``Unit`` parameter.")
261 "Set the error in the length of the :math:`c` direction of the unit "
264 (arg(
"self"), arg(
"_gammaerr"), arg(
"Unit") =
static_cast<int>(
angDegrees)),
265 "Set the error in the :math:`\\gamma` angle of the unit cell using "
267 "``Unit`` parameter.")
269 "Set the first modulated structure vector")
271 "Set the second modulated structure vector")
273 "Set the third modulated structure vector")
276 "Return the volume of the unit cell (in :math:`\\rm{\\AA}{^3}`)")
277 .def(
"getG", &
UnitCell::getG, arg(
"self"), return_readonly_numpy(),
278 "Returns the metric tensor for the unit cell. This will return a "
279 ":class:`numpy.ndarray` with shape ``(3,3)``.")
281 "Returns the metric tensor for the reciprocal unit cell. This will "
282 "return a :class:`numpy.ndarray` with shape ``(3,3)``.")
283 .def(
"getB", &
UnitCell::getB, arg(
"self"), return_readonly_numpy(),
284 "Returns the :math:`B` matrix for this unit cell. This will be in a "
285 "right-handed coordinate system and using the Busing-Levy "
286 "convention. This will return a :class:`numpy.ndarray` with shape "
289 "Returns the inverse of the :math:`B` matrix for this unit cell."
290 "This will return a :class:`numpy.ndarray` with shape ``(3,3)``. "
291 "See also :func:`~mantid.geometry.UnitCell.getB`.")
293 "Returns the :math:`ModHKL` matrix for this unit cell. This will be "
295 "right-handed coordinate system and using the Busing-Levy "
296 "convention. This will return a :class:`numpy.ndarray` with shape "
299 "Returns the number of modulation vectors. This will return an "
301 .def(
"getModVec", &
UnitCell::getModVec, (arg(
"self"), arg(
"i")),
"Returns the ith modulation vector")
302 .def(
"recalculateFromGstar", &recalculateFromGstar, (arg(
"self"), arg(
"NewGstar")),
303 "Recalculate the unit cell parameters from a metric tensor. This "
304 "method accepts a :class:`numpy.ndarray` with shape ``(3,3)``.")
305 .def(
"__str__", &__str__implementation)
306 .def(
"__repr__", &__repr__implementation);
Class to implement unit cell of crystals.
double astar() const
Get reciprocal lattice parameter.
double betastar() const
Get reciprocal lattice parameter.
const Kernel::DblMatrix & getB() const
Get the B-matrix.
double alpha() const
Get lattice parameter.
double erroralpha(const int angleunit=angDegrees) const
Get lattice parameter error.
void set(double _a, double _b, double _c, double _alpha, double _beta, double _gamma, const int angleunit=angDegrees)
Set lattice parameters.
double b2() const
Get reciprocal lattice parameter.
const Kernel::DblMatrix & getGstar() const
Get the reciprocal metric tensor.
double a(int nd) const
Get lattice parameter a1-a3 as function of index (0-2)
int getMaxOrder() const
Get max order.
double c() const
Get lattice parameter.
const Kernel::DblMatrix & getModHKL() const
Get modulation vectors for satellites.
double volume() const
Volume of the direct unit-cell.
void setModVec2(double _dh2, double _dk2, double _dl2)
Set modulation vectors for satellites.
double gammastar() const
Get reciprocal lattice parameter.
double alpha2() const
Get lattice parameter.
double a2() const
Get lattice parameter.
double d(double h, double k, double l) const
Return d-spacing ( ) for a given h,k,l coordinate.
double errorgamma(const int angleunit=angDegrees) const
Get lattice parameter error.
void setbeta(double _beta, const int angleunit=angDegrees)
Set lattice parameter.
double errorbeta(const int angleunit=angDegrees) const
Get lattice parameter error.
void setErrorc(double _cerr)
Set lattice parameter error.
void setalpha(double _alpha, const int angleunit=angDegrees)
Set lattice parameter.
double beta() const
Get lattice parameter.
void setError(double _aerr, double _berr, double _cerr, double _alphaerr, double _betaerr, double _gammaerr, const int angleunit=angDegrees)
Set lattice parameter errors.
void setgamma(double _gamma, const int angleunit=angDegrees)
Set lattice parameter.
double bstar() const
Get reciprocal lattice parameter.
double a() const
Get lattice parameter.
void setErrorgamma(double _gammaerr, const int angleunit=angDegrees)
Set lattice parameter error.
void setErroralpha(double _alphaerr, const int angleunit=angDegrees)
Set lattice parameter error.
void setErrorbeta(double _betaerr, const int angleunit=angDegrees)
Set lattice parameter error.
double a3() const
Get lattice parameter.
double beta1() const
Get reciprocal lattice parameter.
const Kernel::DblMatrix & getBinv() const
Get the inverse of the B-matrix.
const Kernel::DblMatrix & getG() const
Get the metric tensor.
void setErrorb(double _berr)
Set lattice parameter error.
double alpha1() const
Get lattice parameter.
void setModVec3(double _dh3, double _dk3, double _dl3)
Set modulation vectors for satellites.
double recVolume() const
Volume of the reciprocal lattice.
double b() const
Get lattice parameter.
double beta3() const
Get reciprocal lattice parameter.
double alphastar() const
Get reciprocal lattice parameter.
void setb(double _b)
Set lattice parameter.
const Kernel::V3D getModVec(int j) const
Get modulation vectors for satellites.
double errorc() const
Get lattice parameter error.
double dstar(double h, double k, double l) const
Return d*=1/d ( ) for a given h,k,l coordinate.
double b1() const
Get reciprocal lattice parameter.
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,...
double alpha3() const
Get lattice parameter.
virtual void recalculateFromGstar(const Kernel::Matrix< double > &NewGstar)
Recalculate lattice from reciprocal metric tensor (Gstar=transpose(UB)*UB)
void setErrora(double _aerr)
Set lattice parameter error.
void setModVec1(double _dh1, double _dk1, double _dl1)
Set modulation vectors for satellites.
void setc(double _c)
Set lattice parameter.
void setMaxOrder(int MaxO)
Set modulation vectors for satellites.
double beta2() const
Get reciprocal lattice parameter.
double cstar() const
Get reciprocal lattice parameter.
double a1() const
Get lattice parameter.
double b3() const
Get reciprocal lattice parameter.
double gamma() const
Get lattice parameter.
double errora() const
Get lattice parameter error.
void seta(double _a)
Set lattice parameter.
double errorb() const
Get lattice parameter error.
constexpr double deg2rad
Defines units/enum for Crystal work.
constexpr double rad2deg
Radians to degrees conversion factor.
AngleUnits
Flag for angle units used in UnitCell class.
Takes a Python object and if it supports indexing and is two dimensional it attempts to convert it to...