BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FTDecay1D.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Correlations/FTDecay1D.cpp
6 //! @brief Implements class FTDistribution2DCauchy.
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 <algorithm>
18 
19 // ************************************************************************** //
20 // interface IIFTDecayFunction1D
21 // ************************************************************************** //
22 
23 IFTDecayFunction1D::IFTDecayFunction1D(const NodeMeta& meta, const std::vector<double>& PValues)
24  : INode(nodeMetaUnion({{"DecayLength", "nm", "half width", 0, INF, 1.}}, meta), PValues),
25  m_decay_length(m_P[0])
26 {
27 }
28 
29 // ************************************************************************** //
30 // class FTDecayFunction1DCauchy
31 // ************************************************************************** //
32 
34  : IFTDecayFunction1D({"FTDecayFunction1DCauchy", "class_tooltip", {}}, P)
35 {
36 }
37 
39  : FTDecayFunction1DCauchy(std::vector<double>{decay_length})
40 {
41 }
42 
44 {
46 }
47 
48 double FTDecayFunction1DCauchy::evaluate(double q) const
49 {
50  double sum_sq = q * q * m_decay_length * m_decay_length;
51  return m_decay_length * 2.0 / (1.0 + sum_sq);
52 }
53 
54 // ************************************************************************** //
55 // class FTDecayFunction1DGauss
56 // ************************************************************************** //
57 
59  : IFTDecayFunction1D({"FTDecayFunction1DGauss", "class_tooltip", {}}, P)
60 {
61 }
62 
64  : FTDecayFunction1DGauss(std::vector<double>{decay_length})
65 {
66 }
67 
69 {
71 }
72 
73 double FTDecayFunction1DGauss::evaluate(double q) const
74 {
75  double sum_sq = q * q * m_decay_length * m_decay_length;
76  return m_decay_length * std::sqrt(M_TWOPI) * std::exp(-sum_sq / 2.0);
77 }
78 
79 // ************************************************************************** //
80 // class FTDecayFunction1DTriangle
81 // ************************************************************************** //
82 
84  : IFTDecayFunction1D({"FTDecayFunction1DTriangle", "class_tooltip", {}}, P)
85 {
86 }
87 
89  : FTDecayFunction1DTriangle(std::vector<double>{decay_length})
90 {
91 }
92 
94 {
96 }
97 
99 {
100  double sincqw2 = MathFunctions::sinc(q * m_decay_length / 2.0);
101  return m_decay_length * sincqw2 * sincqw2;
102 }
103 
104 // ************************************************************************** //
105 // class FTDecayFunction1DVoigt
106 // ************************************************************************** //
107 
110  {"FTDecayFunction1DVoigt",
111  "class_tooltip",
112  {{"Eta", "", "balances between Gauss (eta=0) and Cauchy (eta=1) limiting cases", -INF,
113  +INF, 0}}},
114  P),
115  m_eta(m_P[0])
116 {
117 }
118 
119 FTDecayFunction1DVoigt::FTDecayFunction1DVoigt(double decay_length, double eta)
120  : FTDecayFunction1DVoigt(std::vector<double>{decay_length, eta})
121 {
122 }
123 
125 {
127 }
128 
129 double FTDecayFunction1DVoigt::evaluate(double q) const
130 {
131  double sum_sq = q * q * m_decay_length * m_decay_length;
132  return m_eta * m_decay_length * std::sqrt(M_TWOPI) * std::exp(-sum_sq / 2.0)
133  + (1.0 - m_eta) * m_decay_length * 2.0 / (1.0 + sum_sq);
134 }
Defines classes IFTDecayFunction1D, IFTDecayFunction2D,.
NodeMeta nodeMetaUnion(const std::vector< ParaMeta > &base, const NodeMeta &other)
Definition: INode.cpp:24
const double INF
Definition: INode.h:24
#define M_TWOPI
Definition: MathConstants.h:49
Defines namespace MathFunctions.
One-dimensional Cauchy decay function in reciprocal space; corresponds to exp(-|x|/decay_length) in r...
Definition: FTDecay1D.h:44
double evaluate(double q) const final
Definition: FTDecay1D.cpp:48
FTDecayFunction1DCauchy(const std::vector< double > P)
Definition: FTDecay1D.cpp:33
FTDecayFunction1DCauchy * clone() const
Definition: FTDecay1D.cpp:43
One-dimensional Gauss decay function in reciprocal space; corresponds to exp[-x^2/(2*decay_length^2)]...
Definition: FTDecay1D.h:58
double evaluate(double q) const final
Definition: FTDecay1D.cpp:73
FTDecayFunction1DGauss(const std::vector< double > P)
Definition: FTDecay1D.cpp:58
FTDecayFunction1DGauss * clone() const
Definition: FTDecay1D.cpp:68
One-dimensional triangle decay function in reciprocal space; corresponds to 1-|x|/decay_length if |x|...
Definition: FTDecay1D.h:72
FTDecayFunction1DTriangle * clone() const
Definition: FTDecay1D.cpp:93
FTDecayFunction1DTriangle(const std::vector< double > P)
Definition: FTDecay1D.cpp:83
double evaluate(double q) const final
Definition: FTDecay1D.cpp:98
One-dimensional pseudo-Voigt decay function in reciprocal space; corresponds to eta*Gauss + (1-eta)*C...
Definition: FTDecay1D.h:86
double evaluate(double q) const final
Definition: FTDecay1D.cpp:129
FTDecayFunction1DVoigt(const std::vector< double > P)
Definition: FTDecay1D.cpp:108
const double & m_eta
Definition: FTDecay1D.h:97
FTDecayFunction1DVoigt * clone() const
Definition: FTDecay1D.cpp:124
Interface for a one-dimensional decay function, with evaluate(q) returning the Fourier transform,...
Definition: FTDecay1D.h:28
IFTDecayFunction1D(const NodeMeta &meta, const std::vector< double > &PValues)
Definition: FTDecay1D.cpp:23
const double & m_decay_length
Definition: FTDecay1D.h:37
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49
double sinc(double x)
sinc function:
Metadata of one model node.
Definition: INode.h:37