BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FTDistributions1D.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Correlations/FTDistributions1D.h
6 //! @brief Defines interface class IFTDistribution1D, and children thereof
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 
15 #ifndef BORNAGAIN_CORE_CORRELATIONS_FTDISTRIBUTIONS1D_H
16 #define BORNAGAIN_CORE_CORRELATIONS_FTDISTRIBUTIONS1D_H
17 
18 #include "Base/Types/ICloneable.h"
19 #include "Param/Node/INode.h"
21 
22 //! Interface for a one-dimensional distribution, with normalization adjusted so that
23 //! the Fourier transform evaluate(q) is a decay function that starts at evaluate(0)=1.
24 //! @ingroup distribution_internal
25 
26 class IFTDistribution1D : public ICloneable, public INode
27 {
28 public:
29  IFTDistribution1D(const NodeMeta& meta, const std::vector<double>& PValues);
30 
31  virtual IFTDistribution1D* clone() const = 0;
32 
33  //! Returns Fourier transform of this distribution;
34  //! is a decay function starting at evaluate(0)=1.
35  virtual double evaluate(double q) const = 0;
36 
37  double omega() const { return m_omega; }
38 
39  //! Returns the negative of the second order derivative in q space around q=0
40  virtual double qSecondDerivative() const = 0;
41 
42 #ifndef SWIG
43  virtual std::unique_ptr<IDistribution1DSampler> createSampler() const = 0;
44 #endif
45 
46 protected:
47  const double& m_omega;
48 };
49 
50 //! Exponential IFTDistribution1D exp(-|omega*x|);
51 //! its Fourier transform evaluate(q) is a Cauchy-Lorentzian starting at evaluate(0)=1.
52 //! @ingroup distributionFT
53 
55 {
56 public:
57  FTDistribution1DCauchy(const std::vector<double> P);
59 
60  FTDistribution1DCauchy* clone() const override final;
61  void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
62  double evaluate(double q) const override final;
63 
64  double qSecondDerivative() const override final;
65 #ifndef SWIG
66  std::unique_ptr<IDistribution1DSampler> createSampler() const override final;
67 #endif
68 };
69 
70 //! Gaussian IFTDistribution1D;
71 //! its Fourier transform evaluate(q) is a Gaussian starting at evaluate(0)=1.
72 //! @ingroup distributionFT
73 
75 {
76 public:
77  FTDistribution1DGauss(const std::vector<double> P);
79 
80  FTDistribution1DGauss* clone() const override final;
81  void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
82  double evaluate(double q) const override final;
83 
84  double qSecondDerivative() const override final;
85 #ifndef SWIG
86  std::unique_ptr<IDistribution1DSampler> createSampler() const override final;
87 #endif
88 };
89 
90 //! Square gate IFTDistribution1D;
91 //! its Fourier transform evaluate(q) is a sinc function starting at evaluate(0)=1.
92 //! @ingroup distributionFT
93 
95 {
96 public:
97  FTDistribution1DGate(const std::vector<double> P);
99 
100  FTDistribution1DGate* clone() const override final;
101  void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
102  double evaluate(double q) const override final;
103 
104  double qSecondDerivative() const override final;
105 #ifndef SWIG
106  std::unique_ptr<IDistribution1DSampler> createSampler() const override final;
107 #endif
108 };
109 
110 //! Triangle IFTDistribution1D [1-|x|/omega if |x|<omega, and 0 otherwise];
111 //! its Fourier transform evaluate(q) is a squared sinc function starting at evaluate(0)=1.
112 //! @ingroup distributionFT
113 
115 {
116 public:
117  FTDistribution1DTriangle(const std::vector<double> P);
119 
120  FTDistribution1DTriangle* clone() const override final;
121  void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
122  double evaluate(double q) const override final;
123 
124  double qSecondDerivative() const override final;
125 #ifndef SWIG
126  std::unique_ptr<IDistribution1DSampler> createSampler() const override final;
127 #endif
128 };
129 
130 //! IFTDistribution1D consisting of one cosine wave
131 //! [1+cos(pi*x/omega) if |x|<omega, and 0 otherwise];
132 //! its Fourier transform evaluate(q) starts at evaluate(0)=1.
133 //! @ingroup distributionFT
134 
136 {
137 public:
138  FTDistribution1DCosine(const std::vector<double> P);
140 
141  FTDistribution1DCosine* clone() const override final;
142  void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
143  double evaluate(double q) const override final;
144 
145  double qSecondDerivative() const override final;
146 #ifndef SWIG
147  std::unique_ptr<IDistribution1DSampler> createSampler() const override final;
148 #endif
149 };
150 
151 //! IFTDistribution1D that provides a Fourier transform evaluate(q) in form
152 //! of a pseudo-Voigt decay function eta*Gauss + (1-eta)*Cauchy, with both components
153 //! starting at 1 for q=0.
154 //! @ingroup distributionFT
155 
157 {
158 public:
159  FTDistribution1DVoigt(const std::vector<double> P);
160  FTDistribution1DVoigt(double omega, double eta);
161 
162  FTDistribution1DVoigt* clone() const override final;
163  void accept(INodeVisitor* visitor) const override final { visitor->visit(this); }
164  double evaluate(double q) const override final;
165  double eta() const { return m_eta; }
166 
167  double qSecondDerivative() const override final;
168 #ifndef SWIG
169  std::unique_ptr<IDistribution1DSampler> createSampler() const override final;
170 #endif
171 
172 protected:
173  const double& m_eta;
174 };
175 
176 #endif // BORNAGAIN_CORE_CORRELATIONS_FTDISTRIBUTIONS1D_H
Defines and implements the standard mix-in ICloneable.
Defines interface class IFTDistribution1D, and children thereof.
Defines class INode.
Exponential IFTDistribution1D exp(-|omega*x|); its Fourier transform evaluate(q) is a Cauchy-Lorentzi...
void accept(INodeVisitor *visitor) const override final
Calls the INodeVisitor's visit method.
FTDistribution1DCauchy * clone() const override final
double qSecondDerivative() const override final
Returns the negative of the second order derivative in q space around q=0.
std::unique_ptr< IDistribution1DSampler > createSampler() const override final
FTDistribution1DCauchy(const std::vector< double > P)
double evaluate(double q) const override final
Returns Fourier transform of this distribution; is a decay function starting at evaluate(0)=1.
IFTDistribution1D consisting of one cosine wave [1+cos(pi*x/omega) if |x|<omega, and 0 otherwise]; it...
std::unique_ptr< IDistribution1DSampler > createSampler() const override final
FTDistribution1DCosine * clone() const override final
void accept(INodeVisitor *visitor) const override final
Calls the INodeVisitor's visit method.
double evaluate(double q) const override final
Returns Fourier transform of this distribution; is a decay function starting at evaluate(0)=1.
FTDistribution1DCosine(const std::vector< double > P)
double qSecondDerivative() const override final
Returns the negative of the second order derivative in q space around q=0.
Square gate IFTDistribution1D; its Fourier transform evaluate(q) is a sinc function starting at evalu...
double evaluate(double q) const override final
Returns Fourier transform of this distribution; is a decay function starting at evaluate(0)=1.
double qSecondDerivative() const override final
Returns the negative of the second order derivative in q space around q=0.
void accept(INodeVisitor *visitor) const override final
Calls the INodeVisitor's visit method.
FTDistribution1DGate(const std::vector< double > P)
std::unique_ptr< IDistribution1DSampler > createSampler() const override final
FTDistribution1DGate * clone() const override final
Gaussian IFTDistribution1D; its Fourier transform evaluate(q) is a Gaussian starting at evaluate(0)=1...
FTDistribution1DGauss(const std::vector< double > P)
void accept(INodeVisitor *visitor) const override final
Calls the INodeVisitor's visit method.
FTDistribution1DGauss * clone() const override final
double qSecondDerivative() const override final
Returns the negative of the second order derivative in q space around q=0.
std::unique_ptr< IDistribution1DSampler > createSampler() const override final
double evaluate(double q) const override final
Returns Fourier transform of this distribution; is a decay function starting at evaluate(0)=1.
Triangle IFTDistribution1D [1-|x|/omega if |x|<omega, and 0 otherwise]; its Fourier transform evaluat...
FTDistribution1DTriangle * clone() const override final
FTDistribution1DTriangle(const std::vector< double > P)
void accept(INodeVisitor *visitor) const override final
Calls the INodeVisitor's visit method.
double evaluate(double q) const override final
Returns Fourier transform of this distribution; is a decay function starting at evaluate(0)=1.
std::unique_ptr< IDistribution1DSampler > createSampler() const override final
double qSecondDerivative() const override final
Returns the negative of the second order derivative in q space around q=0.
IFTDistribution1D that provides a Fourier transform evaluate(q) in form of a pseudo-Voigt decay funct...
void accept(INodeVisitor *visitor) const override final
Calls the INodeVisitor's visit method.
FTDistribution1DVoigt * clone() const override final
double evaluate(double q) const override final
Returns Fourier transform of this distribution; is a decay function starting at evaluate(0)=1.
double qSecondDerivative() const override final
Returns the negative of the second order derivative in q space around q=0.
FTDistribution1DVoigt(const std::vector< double > P)
std::unique_ptr< IDistribution1DSampler > createSampler() const override final
Interface for polymorphic classes that should not be copied, except by explicit cloning.
Definition: ICloneable.h:25
Interface for a one-dimensional distribution, with normalization adjusted so that the Fourier transfo...
virtual IFTDistribution1D * clone() const =0
virtual double qSecondDerivative() const =0
Returns the negative of the second order derivative in q space around q=0.
IFTDistribution1D(const NodeMeta &meta, const std::vector< double > &PValues)
virtual std::unique_ptr< IDistribution1DSampler > createSampler() const =0
const double & m_omega
double omega() const
virtual double evaluate(double q) const =0
Returns Fourier transform of this distribution; is a decay function starting at evaluate(0)=1.
Visitor interface to visit ISample objects.
Definition: INodeVisitor.h:149
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49
Metadata of one model node.
Definition: INode.h:37