BornAgain  1.19.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 reflection and scattering
4 //
5 //! @file Sample/HardParticle/IProfileRipple.cpp
6 //! @brief Implements interface 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  : IBornFF(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])
32  , m_width(m_P[1])
33  , m_height(m_P[2])
34 {
35 }
36 
38 {
39  return (m_width + m_length) / 4.0;
40 }
41 
43 {
44  return factor_x(q.x()) * factor_yz(q.y(), q.z());
45 }
46 
47 // ************************************************************************************************
48 // interface IProfileRectangularRipple
49 // ************************************************************************************************
50 
52  const std::vector<double>& PValues)
53  : IProfileRipple(meta, PValues)
54 {
55  onChange();
56 }
57 
58 //! Complex form factor.
60 {
61  return ripples::profile_yz_bar(qy, qz, m_width, m_height);
62 }
63 
65 {
66  m_shape3D = std::make_unique<Box>(m_length, m_width, m_height);
67 }
68 
69 // ************************************************************************************************
70 // interface ICosineRipple
71 // ************************************************************************************************
72 
73 ICosineRipple::ICosineRipple(const NodeMeta& meta, const std::vector<double>& PValues)
74  : IProfileRipple(meta, PValues)
75 {
76  onChange();
77 }
78 
79 //! Complex form factor.
81 {
83 }
84 
86 {
87  m_shape3D = std::make_unique<RippleCosine>(m_length, m_width, m_height);
88 }
89 
90 // ************************************************************************************************
91 // interface ISawtoothRipple
92 // ************************************************************************************************
93 
94 ISawtoothRipple::ISawtoothRipple(const NodeMeta& meta, const std::vector<double>& PValues)
96  nodeMetaUnion({{"AsymmetryLength", "nm", "Asymmetry of width", -INF, INF, 0.}}, meta),
97  PValues)
98  , m_asymmetry(m_P[3])
99 {
100  onChange();
101 }
102 
103 //! Complex form factor.
105 {
107 }
108 
110 {
111  m_shape3D = std::make_unique<RippleSawtooth>(m_length, m_width, m_height, m_asymmetry);
112 }
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:23
const double INF
Definition: INode.h:25
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: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
Abstract base class for Born form factors.
Definition: IBornFF.h:41
std::unique_ptr< IShape3D > m_shape3D
IShape3D object, used to retrieve vertices (which may be approximate in the case of round shapes).
Definition: IBornFF.h:77
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() final
Action to be taken in inherited class when a parameter has changed.
virtual void onChange() 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
double radialExtension() const final
Returns the (approximate in some cases) radial size of the particle of this form factor's shape.
const double & m_length
const double & m_width
virtual complex_t factor_x(complex_t qx) const =0
complex_t evaluate_for_q(cvector_t q) const final
Returns scattering amplitude for complex scattering wavevector q=k_i-k_f.
IProfileRipple(const NodeMeta &meta, const std::vector< double > &PValues)
const double & m_height
const double & m_asymmetry
ISawtoothRipple(const NodeMeta &meta, const std::vector< double > &PValues)
virtual void onChange() 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.
complex_t profile_yz_cosine(complex_t qy, complex_t qz, double width, double height)
Complex form factor of cosine ripple.
Definition: Ripples.cpp:45
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:72
Metadata of one model node.
Definition: INode.h:38