BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Profiles1D.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Correlations/Profiles1D.h
6 //! @brief Defines interface class IProfile1D, 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_PROFILES1D_H
16 #define BORNAGAIN_SAMPLE_CORRELATIONS_PROFILES1D_H
17 
18 #include "Base/Types/ICloneable.h"
19 #include "Param/Node/INode.h"
20 #ifndef SWIG
22 #endif // SWIG
23 
24 #ifndef USER_API
25 
26 //! Interface for a one-dimensional distribution, with normalization adjusted so that
27 //! the Fourier transform standardizedFT(q) is a decay function that starts at standardizedFT(0)=1.
28 
29 class IProfile1D : public ICloneable, public INode {
30 public:
31  IProfile1D(const std::vector<double>& PValues);
32 
33  IProfile1D* clone() const override = 0;
34 
35  //! Returns Fourier transform of the normalized distribution;
36  //! is a decay function starting at standardizedFT(0)=1.
37  virtual double standardizedFT(double q) const = 0;
38  //! Returns Fourier transform of the distribution scaled as decay function f(x)/f(0).
39  virtual double decayFT(double q) const = 0;
40 
41  double omega() const { return m_omega; }
42  double decayLength() const { return m_omega; }
43 
44  //! Returns the negative of the second order derivative in q space around q=0
45  virtual double qSecondDerivative() const = 0;
46 #ifndef SWIG
47  virtual std::unique_ptr<IDistribution1DSampler> createSampler() const = 0;
48 
49  //! Creates the Python constructor of this class (or derived classes)
50  virtual std::string pythonConstructor() const;
51 #endif
52 
53 protected:
54  const double& m_omega;
55 };
56 
57 #endif // USER_API
58 
59 //! Exponential IProfile1D exp(-|omega*x|);
60 //! its Fourier transform standardizedFT(q) is a Cauchy-Lorentzian starting at standardizedFT(0)=1.
61 //! @ingroup distributionFT
62 
63 class Profile1DCauchy : public IProfile1D {
64 public:
65  Profile1DCauchy(std::vector<double> P);
66  Profile1DCauchy(double omega);
67 
68  Profile1DCauchy* clone() const override;
69  std::string className() const final { return "Profile1DCauchy"; }
70  // const auto tooltip = "class_tooltip";
71  std::vector<ParaMeta> parDefs() const final
72  {
73  return {{"Omega", "nm", "Half-width", 0, INF, 1.}};
74  }
75  double standardizedFT(double q) const override;
76  double decayFT(double q) const override;
77  double qSecondDerivative() const override;
78 #ifndef SWIG
79  std::unique_ptr<IDistribution1DSampler> createSampler() const override;
80 #endif
81 };
82 
83 //! Gaussian IProfile1D;
84 //! its Fourier transform standardizedFT(q) is a Gaussian starting at standardizedFT(0)=1.
85 //! @ingroup distributionFT
86 
87 class Profile1DGauss : public IProfile1D {
88 public:
89  Profile1DGauss(std::vector<double> P);
90  Profile1DGauss(double omega);
91 
92  Profile1DGauss* clone() const override;
93  std::string className() const final { return "Profile1DGauss"; }
94  // const auto tooltip = "class_tooltip";
95  std::vector<ParaMeta> parDefs() const final
96  {
97  return {{"Omega", "nm", "Half-width", 0, INF, 1.}};
98  }
99  double standardizedFT(double q) const override;
100  double decayFT(double q) const override;
101  double qSecondDerivative() const override;
102 #ifndef SWIG
103  std::unique_ptr<IDistribution1DSampler> createSampler() const override;
104 #endif
105 };
106 
107 //! Square gate IProfile1D;
108 //! its Fourier transform standardizedFT(q) is a sinc function starting at standardizedFT(0)=1.
109 //! @ingroup distributionFT
110 
111 class Profile1DGate : public IProfile1D {
112 public:
113  Profile1DGate(std::vector<double> P);
114  Profile1DGate(double omega);
115 
116  Profile1DGate* clone() const override;
117  std::string className() const final { return "Profile1DGate"; }
118  // const auto tooltip = "class_tooltip";
119  std::vector<ParaMeta> parDefs() const final
120  {
121  return {{"Omega", "nm", "Half-width", 0, INF, 1.}};
122  }
123  double standardizedFT(double q) const override;
124  double decayFT(double q) const override;
125  double qSecondDerivative() const override;
126 #ifndef SWIG
127  std::unique_ptr<IDistribution1DSampler> createSampler() const override;
128 #endif
129 };
130 
131 //! Triangle IProfile1D [1-|x|/omega if |x|<omega, and 0 otherwise];
132 //! its Fourier transform standardizedFT(q) is a squared sinc function starting at
133 //! standardizedFT(0)=1.
134 //! @ingroup distributionFT
135 
137 public:
138  Profile1DTriangle(std::vector<double> P);
139  Profile1DTriangle(double omega);
140 
141  Profile1DTriangle* clone() const override;
142  std::string className() const final { return "Profile1DTriangle"; }
143  // const auto tooltip = "class_tooltip";
144  std::vector<ParaMeta> parDefs() const final
145  {
146  return {{"Omega", "nm", "Half-width", 0, INF, 1.}};
147  }
148  double standardizedFT(double q) const override;
149  double decayFT(double q) const override;
150  double qSecondDerivative() const override;
151 #ifndef SWIG
152  std::unique_ptr<IDistribution1DSampler> createSampler() const override;
153 #endif
154 };
155 
156 //! IProfile1D consisting of one cosine wave
157 //! [1+cos(pi*x/omega) if |x|<omega, and 0 otherwise];
158 //! its Fourier transform standardizedFT(q) starts at standardizedFT(0)=1.
159 //! @ingroup distributionFT
160 
161 class Profile1DCosine : public IProfile1D {
162 public:
163  Profile1DCosine(std::vector<double> P);
164  Profile1DCosine(double omega);
165 
166  Profile1DCosine* clone() const override;
167  std::string className() const final { return "Profile1DCosine"; }
168  // const auto tooltip = "class_tooltip";
169  std::vector<ParaMeta> parDefs() const final
170  {
171  return {{"Omega", "nm", "Half-width", 0, INF, 1.}};
172  }
173  double standardizedFT(double q) const override;
174  double decayFT(double q) const override;
175  double qSecondDerivative() const override;
176 #ifndef SWIG
177  std::unique_ptr<IDistribution1DSampler> createSampler() const override;
178 #endif
179 };
180 
181 //! IProfile1D that provides a Fourier transform standardizedFT(q) in form
182 //! of a pseudo-Voigt decay function eta*Gauss + (1-eta)*Cauchy, with both components
183 //! starting at 1 for q=0.
184 //! @ingroup distributionFT
185 
186 class Profile1DVoigt : public IProfile1D {
187 public:
188  Profile1DVoigt(std::vector<double> P);
189  Profile1DVoigt(double omega, double eta);
190 
191  Profile1DVoigt* clone() const override;
192  std::string className() const final { return "Profile1DVoigt"; }
193  // const auto tooltip = "Pseudo-Voigt distribution";
194  std::vector<ParaMeta> parDefs() const final
195  {
196  return {{"Omega", "nm", "Half-width", 0, INF, 1.},
197  {"Eta", "", "balances between Gauss (eta=0) and Lorentz (eta=1) limiting cases", 0,
198  1, .5}};
199  }
200  double standardizedFT(double q) const override;
201  double decayFT(double q) const override;
202  double eta() const { return m_eta; }
203  double qSecondDerivative() const override;
204 #ifndef SWIG
205  std::unique_ptr<IDistribution1DSampler> createSampler() const override;
206  std::string pythonConstructor() const override;
207 #endif
208 
209 protected:
210  const double& m_eta;
211 };
212 
213 #endif // BORNAGAIN_SAMPLE_CORRELATIONS_PROFILES1D_H
Defines and implements the standard mix-in ICloneable.
Defines interface class IProfile1D, and children thereof.
Defines interface INode.
const double INF
Definition: INode.h:26
Interface for polymorphic classes that should not be copied, except by explicit cloning.
Definition: ICloneable.h:23
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:40
Interface for a one-dimensional distribution, with normalization adjusted so that the Fourier transfo...
Definition: Profiles1D.h:29
virtual double standardizedFT(double q) const =0
Returns Fourier transform of the normalized distribution; is a decay function starting at standardize...
virtual std::string pythonConstructor() const
Creates the Python constructor of this class (or derived classes)
Definition: Profiles1D.cpp:39
virtual double decayFT(double q) const =0
Returns Fourier transform of the distribution scaled as decay function f(x)/f(0).
double decayLength() const
Definition: Profiles1D.h:42
virtual double qSecondDerivative() const =0
Returns the negative of the second order derivative in q space around q=0.
IProfile1D(const std::vector< double > &PValues)
Definition: Profiles1D.cpp:33
virtual std::unique_ptr< IDistribution1DSampler > createSampler() const =0
const double & m_omega
Definition: Profiles1D.h:54
double omega() const
Definition: Profiles1D.h:41
IProfile1D * clone() const override=0
Exponential IProfile1D exp(-|omega*x|); its Fourier transform standardizedFT(q) is a Cauchy-Lorentzia...
Definition: Profiles1D.h:63
double standardizedFT(double q) const override
Returns Fourier transform of the normalized distribution; is a decay function starting at standardize...
Definition: Profiles1D.cpp:65
double qSecondDerivative() const override
Returns the negative of the second order derivative in q space around q=0.
Definition: Profiles1D.cpp:77
Profile1DCauchy * clone() const override
Definition: Profiles1D.cpp:60
std::unique_ptr< IDistribution1DSampler > createSampler() const override
Definition: Profiles1D.cpp:82
Profile1DCauchy(std::vector< double > P)
Definition: Profiles1D.cpp:49
double decayFT(double q) const override
Returns Fourier transform of the distribution scaled as decay function f(x)/f(0).
Definition: Profiles1D.cpp:71
std::vector< ParaMeta > parDefs() const final
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: Profiles1D.h:71
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: Profiles1D.h:69
IProfile1D consisting of one cosine wave [1+cos(pi*x/omega) if |x|<omega, and 0 otherwise]; its Fouri...
Definition: Profiles1D.h:161
double qSecondDerivative() const override
Returns the negative of the second order derivative in q space around q=0.
Definition: Profiles1D.cpp:244
double decayFT(double q) const override
Returns Fourier transform of the distribution scaled as decay function f(x)/f(0).
Definition: Profiles1D.cpp:239
double standardizedFT(double q) const override
Returns Fourier transform of the normalized distribution; is a decay function starting at standardize...
Definition: Profiles1D.cpp:231
Profile1DCosine * clone() const override
Definition: Profiles1D.cpp:226
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: Profiles1D.h:167
Profile1DCosine(std::vector< double > P)
Definition: Profiles1D.cpp:215
std::unique_ptr< IDistribution1DSampler > createSampler() const override
Definition: Profiles1D.cpp:249
std::vector< ParaMeta > parDefs() const final
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: Profiles1D.h:169
Square gate IProfile1D; its Fourier transform standardizedFT(q) is a sinc function starting at standa...
Definition: Profiles1D.h:111
double decayFT(double q) const override
Returns Fourier transform of the distribution scaled as decay function f(x)/f(0).
Definition: Profiles1D.cpp:154
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: Profiles1D.h:117
double standardizedFT(double q) const override
Returns Fourier transform of the normalized distribution; is a decay function starting at standardize...
Definition: Profiles1D.cpp:149
std::vector< ParaMeta > parDefs() const final
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: Profiles1D.h:119
std::unique_ptr< IDistribution1DSampler > createSampler() const override
Definition: Profiles1D.cpp:164
Profile1DGate(std::vector< double > P)
Definition: Profiles1D.cpp:133
double qSecondDerivative() const override
Returns the negative of the second order derivative in q space around q=0.
Definition: Profiles1D.cpp:159
Profile1DGate * clone() const override
Definition: Profiles1D.cpp:144
Gaussian IProfile1D; its Fourier transform standardizedFT(q) is a Gaussian starting at standardizedFT...
Definition: Profiles1D.h:87
std::vector< ParaMeta > parDefs() const final
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: Profiles1D.h:95
Profile1DGauss(std::vector< double > P)
Definition: Profiles1D.cpp:91
Profile1DGauss * clone() const override
Definition: Profiles1D.cpp:102
double standardizedFT(double q) const override
Returns Fourier transform of the normalized distribution; is a decay function starting at standardize...
Definition: Profiles1D.cpp:107
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: Profiles1D.h:93
std::unique_ptr< IDistribution1DSampler > createSampler() const override
Definition: Profiles1D.cpp:124
double qSecondDerivative() const override
Returns the negative of the second order derivative in q space around q=0.
Definition: Profiles1D.cpp:119
double decayFT(double q) const override
Returns Fourier transform of the distribution scaled as decay function f(x)/f(0).
Definition: Profiles1D.cpp:113
Triangle IProfile1D [1-|x|/omega if |x|<omega, and 0 otherwise]; its Fourier transform standardizedFT...
Definition: Profiles1D.h:136
double decayFT(double q) const override
Returns Fourier transform of the distribution scaled as decay function f(x)/f(0).
Definition: Profiles1D.cpp:195
std::vector< ParaMeta > parDefs() const final
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: Profiles1D.h:144
Profile1DTriangle(std::vector< double > P)
Definition: Profiles1D.cpp:173
double standardizedFT(double q) const override
Returns Fourier transform of the normalized distribution; is a decay function starting at standardize...
Definition: Profiles1D.cpp:189
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: Profiles1D.h:142
std::unique_ptr< IDistribution1DSampler > createSampler() const override
Definition: Profiles1D.cpp:206
double qSecondDerivative() const override
Returns the negative of the second order derivative in q space around q=0.
Definition: Profiles1D.cpp:201
Profile1DTriangle * clone() const override
Definition: Profiles1D.cpp:184
IProfile1D that provides a Fourier transform standardizedFT(q) in form of a pseudo-Voigt decay functi...
Definition: Profiles1D.h:186
Profile1DVoigt * clone() const override
Definition: Profiles1D.cpp:270
double standardizedFT(double q) const override
Returns Fourier transform of the normalized distribution; is a decay function starting at standardize...
Definition: Profiles1D.cpp:275
std::string pythonConstructor() const override
Creates the Python constructor of this class (or derived classes)
Definition: Profiles1D.cpp:303
double decayFT(double q) const override
Returns Fourier transform of the distribution scaled as decay function f(x)/f(0).
Definition: Profiles1D.cpp:281
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: Profiles1D.h:192
Profile1DVoigt(std::vector< double > P)
Definition: Profiles1D.cpp:258
std::vector< ParaMeta > parDefs() const final
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: Profiles1D.h:194
double qSecondDerivative() const override
Returns the negative of the second order derivative in q space around q=0.
Definition: Profiles1D.cpp:288
const double & m_eta
Definition: Profiles1D.h:210
std::unique_ptr< IDistribution1DSampler > createSampler() const override
Definition: Profiles1D.cpp:293
double eta() const
Definition: Profiles1D.h:202