BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Lattice3D.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Lattice/Lattice3D.h
6 //! @brief Defines class Lattice.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_SAMPLE_LATTICE_LATTICE3D_H
16 #define BORNAGAIN_SAMPLE_LATTICE_LATTICE3D_H
17 
18 #include "Param/Node/INode.h"
19 #include <heinz/Vectors3D.h>
20 #include <memory>
21 #include <vector>
22 
23 class ISelectionRule;
24 class RotMatrix;
25 
26 //! A Bravais lattice, characterized by three basis vectors, and optionally an ISelectionRule.
27 
28 //! @ingroup samples
29 
30 class Lattice3D : public INode {
31 public:
32  Lattice3D(R3 a, R3 b, R3 c);
33  Lattice3D(const Lattice3D& lattice);
34  ~Lattice3D() override;
35  Lattice3D& operator=(const Lattice3D&) = delete;
36 
37  std::string className() const final { return "Lattice3D"; }
38 
39  //! Creates rotated lattice
40  Lattice3D rotated(const RotMatrix& rotMatrix) const;
41 
42  //! Returns basis vector a
43  R3 basisVectorA() const { return m_a; }
44 
45  //! Returns basis vector b
46  R3 basisVectorB() const { return m_b; }
47 
48  //! Returns basis vector c
49  R3 basisVectorC() const { return m_c; }
50 
51  //! Returns normalized direction corresponding to the given Miller indices
52  R3 getMillerDirection(double h, double k, double l) const;
53 
54  //! Returns the volume of the unit cell
55  double unitCellVolume() const;
56 
57  //! Returns the reciprocal basis vectors
58  void reciprocalLatticeBasis(R3& ra, R3& rb, R3& rc) const;
59 
60  //! Returns the nearest reciprocal lattice point from a given vector
62 
63  //! Returns a list of reciprocal lattice vectors within distance dq of a vector q
64  std::vector<R3> reciprocalLatticeVectorsWithinRadius(R3 q, double dq) const;
65 
66  //! Sets a selection rule for the reciprocal vectors
67  void setSelectionRule(const ISelectionRule& selection_rule);
68 
69 private:
70  void computeReciprocalVectors() const;
71 
72  R3 m_a, m_b, m_c; //!< Basis vectors in real space
73  std::unique_ptr<ISelectionRule> m_selection_rule;
74 
75  mutable R3 m_ra, m_rb, m_rc; //!< Cache of basis vectors in reciprocal space
76 };
77 
78 #endif // BORNAGAIN_SAMPLE_LATTICE_LATTICE3D_H
Defines interface INode.
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:40
Abstract base class for selection rules.
A Bravais lattice, characterized by three basis vectors, and optionally an ISelectionRule.
Definition: Lattice3D.h:30
I3 nearestReciprocalLatticeVectorCoordinates(R3 q) const
Returns the nearest reciprocal lattice point from a given vector.
Definition: Lattice3D.cpp:69
Lattice3D rotated(const RotMatrix &rotMatrix) const
Creates rotated lattice.
Definition: Lattice3D.cpp:38
double unitCellVolume() const
Returns the volume of the unit cell.
Definition: Lattice3D.cpp:56
R3 basisVectorB() const
Returns basis vector b.
Definition: Lattice3D.h:46
R3 m_rc
Cache of basis vectors in reciprocal space.
Definition: Lattice3D.h:75
R3 getMillerDirection(double h, double k, double l) const
Returns normalized direction corresponding to the given Miller indices.
Definition: Lattice3D.cpp:50
void computeReciprocalVectors() const
Definition: Lattice3D.cpp:99
R3 basisVectorC() const
Returns basis vector c.
Definition: Lattice3D.h:49
void setSelectionRule(const ISelectionRule &selection_rule)
Sets a selection rule for the reciprocal vectors.
Definition: Lattice3D.cpp:109
R3 m_c
Basis vectors in real space.
Definition: Lattice3D.h:72
R3 basisVectorA() const
Returns basis vector a.
Definition: Lattice3D.h:43
std::unique_ptr< ISelectionRule > m_selection_rule
Definition: Lattice3D.h:73
Lattice3D & operator=(const Lattice3D &)=delete
~Lattice3D() override
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: Lattice3D.h:37
void reciprocalLatticeBasis(R3 &ra, R3 &rb, R3 &rc) const
Returns the reciprocal basis vectors.
Definition: Lattice3D.cpp:62
std::vector< R3 > reciprocalLatticeVectorsWithinRadius(R3 q, double dq) const
Returns a list of reciprocal lattice vectors within distance dq of a vector q.
Definition: Lattice3D.cpp:75
Lattice3D(R3 a, R3 b, R3 c)
Definition: Lattice3D.cpp:21
Rotation matrix in three dimensions. Represents group SO(3). Internal parameterization based on quate...
Definition: RotMatrix.h:25