BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FormFactorBox.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/HardParticle/FormFactorBox.cpp
6 //! @brief Implements class FormFactorBox.
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 FormFactorBox::FormFactorBox(const std::vector<double> P)
19  : IFormFactorPrism({"Box",
20  "rectangular cuboid",
21  {{"Length", "nm", "side length in x direction", 0, +INF, 0},
22  {"Width", "nm", "side length in y direction", 0, +INF, 0},
23  {"Height", "nm", "side length in z direction", 0, +INF, 0}}},
24  P)
25  , m_length(m_P[0])
26  , m_width(m_P[1])
27  , m_height(m_P[2])
28 {
29  onChange();
30 }
31 
32 FormFactorBox::FormFactorBox(double length, double width, double height)
33  : FormFactorBox(std::vector<double>{length, width, height})
34 {
35 }
36 
38 {
39  complex_t qzHdiv2 = m_height / 2 * q.z();
40  return m_length * m_width * m_height * Math::sinc(m_length / 2 * q.x())
41  * Math::sinc(m_width / 2 * q.y()) * Math::sinc(qzHdiv2) * exp_I(qzHdiv2);
42 }
43 
45  kvector_t translation) const
46 {
47  auto effects = computeSlicingEffects(limits, translation, m_height);
48  FormFactorBox slicedff(m_length, m_width, m_height - effects.dz_bottom - effects.dz_top);
49  return createTransformedFormFactor(slicedff, rot, effects.position);
50 }
51 
53 {
54  double a = m_length / 2;
55  double b = m_width / 2;
56  std::vector<kvector_t> V{{a, b, 0.}, {-a, b, 0.}, {-a, -b, 0.}, {a, -b, 0}};
57  setPrism(true, V);
58 }
std::complex< double > complex_t
Definition: Complex.h:20
complex_t exp_I(complex_t z)
Returns exp(I*z), where I is the imaginary unit.
Definition: Complex.h:30
Defines class FormFactorBox.
Defines functions in namespace Math.
const double INF
Definition: INode.h:25
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:67
T y() const
Returns y-component in cartesian coordinate system.
Definition: BasicVector3D.h:65
T x() const
Returns x-component in cartesian coordinate system.
Definition: BasicVector3D.h:63
A rectangular prism (parallelepiped).
Definition: FormFactorBox.h:23
complex_t evaluate_for_q(cvector_t q) const final
Returns scattering amplitude for complex scattering wavevector q=k_i-k_f.
const double & m_width
Definition: FormFactorBox.h:48
void onChange() final
Action to be taken in inherited class when a parameter has changed.
const double & m_length
Definition: FormFactorBox.h:47
IFormFactor * sliceFormFactor(ZLimits limits, const IRotation &rot, kvector_t translation) const final
Actually slices the form factor or throws an exception.
FormFactorBox(const std::vector< double > P)
const double & m_height
Definition: FormFactorBox.h:49
double height() const final
Definition: FormFactorBox.h:44
static SlicingEffects computeSlicingEffects(ZLimits limits, const kvector_t &position, double height)
Helper method for slicing.
Definition: IBornFF.cpp:66
A prism with a polygonal base, for form factor computation.
void setPrism(bool symmetry_Ci, const std::vector< kvector_t > &vertices)
Abstract base class for all form factors.
Definition: IFormFactor.h:36
static IFormFactor * createTransformedFormFactor(const IFormFactor &formfactor, const IRotation &rot, kvector_t translation)
Definition: IFormFactor.cpp:99
Abstract base class for rotations.
Definition: Rotations.h:28
Class that contains upper and lower limits of the z-coordinate for the slicing of form factors.
Definition: ZLimits.h:45
double sinc(double x)
sinc function:
Definition: Functions.cpp:53
Definition: filesystem.h:81