BornAgain  1.19.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 reflection and scattering
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_SAMPLE_CORRELATIONS_FTDISTRIBUTIONS1D_H
16 #define BORNAGAIN_SAMPLE_CORRELATIONS_FTDISTRIBUTIONS1D_H
17 
18 #include "Base/Types/ICloneable.h"
19 #include "Param/Node/INode.h"
21 
22 #ifndef USER_API
23 
24 //! Interface for a one-dimensional distribution, with normalization adjusted so that
25 //! the Fourier transform evaluate(q) is a decay function that starts at evaluate(0)=1.
26 //! @ingroup distribution_internal
27 
28 class IFTDistribution1D : public ICloneable, public INode {
29 public:
30  IFTDistribution1D(const NodeMeta& meta, const std::vector<double>& PValues);
31 
32  virtual IFTDistribution1D* clone() const = 0;
33 
34  //! Returns Fourier transform of this distribution;
35  //! is a decay function starting at evaluate(0)=1.
36  virtual double evaluate(double q) const = 0;
37 
38  double omega() const { return m_omega; }
39 
40  //! Returns the negative of the second order derivative in q space around q=0
41  virtual double qSecondDerivative() const = 0;
42 
43 #ifndef SWIG
44  virtual std::unique_ptr<IDistribution1DSampler> createSampler() const = 0;
45 #endif
46 
47 protected:
48  const double& m_omega;
49 };
50 
51 #endif // USER_API
52 
53 //! Exponential IFTDistribution1D exp(-|omega*x|);
54 //! its Fourier transform evaluate(q) is a Cauchy-Lorentzian starting at evaluate(0)=1.
55 //! @ingroup distributionFT
56 
58 public:
59  FTDistribution1DCauchy(const std::vector<double> P);
61 
62  FTDistribution1DCauchy* clone() const final;
63  void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
64  double evaluate(double q) const final;
65 
66  double qSecondDerivative() const final;
67 #ifndef SWIG
68  std::unique_ptr<IDistribution1DSampler> createSampler() const final;
69 #endif
70 };
71 
72 //! Gaussian IFTDistribution1D;
73 //! its Fourier transform evaluate(q) is a Gaussian starting at evaluate(0)=1.
74 //! @ingroup distributionFT
75 
77 public:
78  FTDistribution1DGauss(const std::vector<double> P);
80 
81  FTDistribution1DGauss* clone() const final;
82  void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
83  double evaluate(double q) const final;
84 
85  double qSecondDerivative() const final;
86 #ifndef SWIG
87  std::unique_ptr<IDistribution1DSampler> createSampler() const final;
88 #endif
89 };
90 
91 //! Square gate IFTDistribution1D;
92 //! its Fourier transform evaluate(q) is a sinc function starting at evaluate(0)=1.
93 //! @ingroup distributionFT
94 
96 public:
97  FTDistribution1DGate(const std::vector<double> P);
99 
100  FTDistribution1DGate* clone() const final;
101  void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
102  double evaluate(double q) const final;
103 
104  double qSecondDerivative() const final;
105 #ifndef SWIG
106  std::unique_ptr<IDistribution1DSampler> createSampler() const 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 public:
116  FTDistribution1DTriangle(const std::vector<double> P);
118 
119  FTDistribution1DTriangle* clone() const final;
120  void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
121  double evaluate(double q) const final;
122 
123  double qSecondDerivative() const final;
124 #ifndef SWIG
125  std::unique_ptr<IDistribution1DSampler> createSampler() const final;
126 #endif
127 };
128 
129 //! IFTDistribution1D consisting of one cosine wave
130 //! [1+cos(pi*x/omega) if |x|<omega, and 0 otherwise];
131 //! its Fourier transform evaluate(q) starts at evaluate(0)=1.
132 //! @ingroup distributionFT
133 
135 public:
136  FTDistribution1DCosine(const std::vector<double> P);
138 
139  FTDistribution1DCosine* clone() const final;
140  void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
141  double evaluate(double q) const final;
142 
143  double qSecondDerivative() const final;
144 #ifndef SWIG
145  std::unique_ptr<IDistribution1DSampler> createSampler() const final;
146 #endif
147 };
148 
149 //! IFTDistribution1D that provides a Fourier transform evaluate(q) in form
150 //! of a pseudo-Voigt decay function eta*Gauss + (1-eta)*Cauchy, with both components
151 //! starting at 1 for q=0.
152 //! @ingroup distributionFT
153 
155 public:
156  FTDistribution1DVoigt(const std::vector<double> P);
157  FTDistribution1DVoigt(double omega, double eta);
158 
159  FTDistribution1DVoigt* clone() const final;
160  void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
161  double evaluate(double q) const final;
162  double eta() const { return m_eta; }
163 
164  double qSecondDerivative() const final;
165 #ifndef SWIG
166  std::unique_ptr<IDistribution1DSampler> createSampler() const final;
167 #endif
168 
169 protected:
170  const double& m_eta;
171 };
172 
173 #endif // BORNAGAIN_SAMPLE_CORRELATIONS_FTDISTRIBUTIONS1D_H
Defines and implements the standard mix-in ICloneable.
Defines interface class IFTDistribution1D, and children thereof.
Defines interface INode.
Exponential IFTDistribution1D exp(-|omega*x|); its Fourier transform evaluate(q) is a Cauchy-Lorentzi...
double qSecondDerivative() const final
Returns the negative of the second order derivative in q space around q=0.
FTDistribution1DCauchy * clone() const final
void accept(INodeVisitor *visitor) const final
Calls the INodeVisitor's visit method.
std::unique_ptr< IDistribution1DSampler > createSampler() const final
FTDistribution1DCauchy(const std::vector< double > P)
double evaluate(double q) const 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 final
double evaluate(double q) const final
Returns Fourier transform of this distribution; is a decay function starting at evaluate(0)=1.
FTDistribution1DCosine * clone() const final
void accept(INodeVisitor *visitor) const final
Calls the INodeVisitor's visit method.
FTDistribution1DCosine(const std::vector< double > P)
double qSecondDerivative() const 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...
FTDistribution1DGate * clone() const final
FTDistribution1DGate(const std::vector< double > P)
std::unique_ptr< IDistribution1DSampler > createSampler() const final
double qSecondDerivative() const final
Returns the negative of the second order derivative in q space around q=0.
void accept(INodeVisitor *visitor) const final
Calls the INodeVisitor's visit method.
double evaluate(double q) const final
Returns Fourier transform of this distribution; is a decay function starting at evaluate(0)=1.
Gaussian IFTDistribution1D; its Fourier transform evaluate(q) is a Gaussian starting at evaluate(0)=1...
void accept(INodeVisitor *visitor) const final
Calls the INodeVisitor's visit method.
FTDistribution1DGauss(const std::vector< double > P)
std::unique_ptr< IDistribution1DSampler > createSampler() const final
double qSecondDerivative() const final
Returns the negative of the second order derivative in q space around q=0.
FTDistribution1DGauss * clone() const final
double evaluate(double q) const 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...
double qSecondDerivative() const final
Returns the negative of the second order derivative in q space around q=0.
FTDistribution1DTriangle(const std::vector< double > P)
FTDistribution1DTriangle * clone() const final
void accept(INodeVisitor *visitor) const final
Calls the INodeVisitor's visit method.
double evaluate(double q) const final
Returns Fourier transform of this distribution; is a decay function starting at evaluate(0)=1.
std::unique_ptr< IDistribution1DSampler > createSampler() const final
IFTDistribution1D that provides a Fourier transform evaluate(q) in form of a pseudo-Voigt decay funct...
double evaluate(double q) const final
Returns Fourier transform of this distribution; is a decay function starting at evaluate(0)=1.
double qSecondDerivative() const final
Returns the negative of the second order derivative in q space around q=0.
void accept(INodeVisitor *visitor) const final
Calls the INodeVisitor's visit method.
FTDistribution1DVoigt * clone() const final
std::unique_ptr< IDistribution1DSampler > createSampler() const final
FTDistribution1DVoigt(const std::vector< double > P)
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 ISampleNode objects.
Definition: INodeVisitor.h:146
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49
Metadata of one model node.
Definition: INode.h:38