BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Box.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/HardParticle/Box.cpp
6 //! @brief Implements class Box.
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 
16 #include "Base/Math/Functions.h"
17 
18 Box::Box(const std::vector<double> P)
19  : IFormFactorPrism(P)
20  , m_length(m_P[0])
21  , m_width(m_P[1])
22  , m_height(m_P[2])
23 {
24  checkNodeArgs();
25  double a = m_length / 2;
26  double b = m_width / 2;
27  std::vector<R3> V{{a, b, 0.}, {-a, b, 0.}, {-a, -b, 0.}, {a, -b, 0}};
28  setPrism(true, V);
29 }
30 
31 Box::Box(double length, double width, double height)
32  : Box(std::vector<double>{length, width, height})
33 {
34 }
35 
36 complex_t Box::formfactor_at_bottom(C3 q) const
37 {
38  complex_t qzHdiv2 = m_height / 2 * q.z();
39  return m_length * m_width * m_height * Math::sinc(m_length / 2 * q.x())
40  * Math::sinc(m_width / 2 * q.y()) * Math::sinc(qzHdiv2) * exp_I(qzHdiv2);
41 }
Defines class Box.
Defines namespace Math.
A rectangular prism (parallelepiped).
Definition: Box.h:23
double width() const
Definition: Box.h:40
Box(double length, double width, double height)
Definition: Box.cpp:31
const double & m_length
Definition: Box.h:48
const double & m_height
Definition: Box.h:50
double length() const
Definition: Box.h:39
const double & m_width
Definition: Box.h:49
double height() const override
Definition: Box.h:41
complex_t formfactor_at_bottom(C3 q) const override
Definition: Box.cpp:36
A prism with a polygonal base, for form factor computation.
void setPrism(bool symmetry_Ci, const std::vector< R3 > &vertices)
void checkNodeArgs() const
Raises exception if a parameter value is invalid.
Definition: INode.cpp:27
double sinc(double x)
sinc function:
Definition: Functions.cpp:52