BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IProfileRipple.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/HardParticle/IProfileRipple.cpp
6 //! @brief Implements class ISawtoothRipple.
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 
17 #include "Sample/Shapes/Box.h"
20 
21 // ************************************************************************** //
22 // interface IProfileRipple
23 // ************************************************************************** //
24 
25 IProfileRipple::IProfileRipple(const NodeMeta& meta, const std::vector<double>& PValues)
26  : IFormFactorBorn(nodeMetaUnion({{"Length", "nm", "Characteristic length", 0, INF, 1.},
27  {"Width", "nm", "Width", 0, INF, 1.},
28  {"Height", "nm", "Height", 0, INF, 1.}},
29  meta),
30  PValues),
31  m_length(m_P[0]), m_width(m_P[1]), m_height(m_P[2])
32 {
33 }
34 
36 {
37  return (m_width + m_length) / 4.0;
38 }
39 
41 {
42  return factor_x(q.x()) * factor_yz(q.y(), q.z());
43 }
44 
45 // ************************************************************************** //
46 // interface IProfileRectangularRipple
47 // ************************************************************************** //
48 
50  const std::vector<double>& PValues)
51  : IProfileRipple(meta, PValues)
52 {
53  onChange();
54 }
55 
56 //! Complex form factor.
58 {
59  return ripples::profile_yz_bar(qy, qz, m_width, m_height);
60 }
61 
63 {
64  mP_shape = std::make_unique<Box>(m_length, m_width, m_height);
65 }
66 
67 // ************************************************************************** //
68 // interface ICosineRipple
69 // ************************************************************************** //
70 
71 ICosineRipple::ICosineRipple(const NodeMeta& meta, const std::vector<double>& PValues)
72  : IProfileRipple(meta, PValues)
73 {
74  onChange();
75 }
76 
77 //! Complex form factor.
79 {
81 }
82 
84 {
85  mP_shape = std::make_unique<RippleCosine>(m_length, m_width, m_height);
86 }
87 
88 // ************************************************************************** //
89 // interface ISawtoothRipple
90 // ************************************************************************** //
91 
92 ISawtoothRipple::ISawtoothRipple(const NodeMeta& meta, const std::vector<double>& PValues)
94  nodeMetaUnion({{"AsymmetryLength", "nm", "Asymmetry of width", -INF, INF, 0.}}, meta),
95  PValues),
96  m_asymmetry(m_P[3])
97 {
98  onChange();
99 }
100 
101 //! Complex form factor.
103 {
105 }
106 
108 {
109  mP_shape = std::make_unique<RippleSawtooth>(m_length, m_width, m_height, m_asymmetry);
110 }
Defines class Box.
std::complex< double > complex_t
Definition: Complex.h:20
NodeMeta nodeMetaUnion(const std::vector< ParaMeta > &base, const NodeMeta &other)
Definition: INode.cpp:24
const double INF
Definition: INode.h:24
Defines interface classes IProfileRipple, ICosineRipple, ISawtoothRipple.
Defines class RippleCosine.
Defines class RippleSawtooth.
Declares computations in namespace ripples.
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:68
T y() const
Returns y-component in cartesian coordinate system.
Definition: BasicVector3D.h:66
T x() const
Returns x-component in cartesian coordinate system.
Definition: BasicVector3D.h:64
ICosineRipple(const NodeMeta &meta, const std::vector< double > &PValues)
complex_t factor_yz(complex_t qy, complex_t qz) const final
Complex form factor.
virtual void onChange() override final
Action to be taken in inherited class when a parameter has changed.
Pure virtual base class for Born form factors.
std::unique_ptr< IShape > mP_shape
IShape object, used to retrieve vertices (which may be approximate in the case of round shapes).
virtual void onChange() override final
Action to be taken in inherited class when a parameter has changed.
complex_t factor_yz(complex_t qy, complex_t qz) const final
Complex form factor.
IProfileRectangularRipple(const NodeMeta &meta, const std::vector< double > &PValues)
Base class for form factors with a cosine ripple profile in the yz plane.
virtual complex_t factor_yz(complex_t qy, complex_t qz) const =0
const double & m_length
const double & m_width
virtual complex_t factor_x(complex_t qx) const =0
IProfileRipple(const NodeMeta &meta, const std::vector< double > &PValues)
double radialExtension() const override final
Returns the (approximate in some cases) radial size of the particle of this form factor's shape.
complex_t evaluate_for_q(cvector_t q) const override final
Returns scattering amplitude for complex scattering wavevector q=k_i-k_f.
const double & m_height
const double & m_asymmetry
ISawtoothRipple(const NodeMeta &meta, const std::vector< double > &PValues)
complex_t factor_yz(complex_t qy, complex_t qz) const final
Complex form factor.
virtual void onChange() override final
Action to be taken in inherited class when a parameter has changed.
complex_t profile_yz_cosine(complex_t qy, complex_t qz, double width, double height)
Complex form factor of triangular ripple.
Definition: Ripples.cpp:46
complex_t profile_yz_bar(complex_t qy, complex_t qz, double width, double height)
Complex form factor of rectangular ripple (bar).
Definition: Ripples.cpp:36
complex_t profile_yz_triangular(complex_t qy, complex_t qz, double width, double height, double asymmetry)
Complex form factor of triangular ripple.
Definition: Ripples.cpp:73
Metadata of one model node.
Definition: INode.h:37