BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Profiles2D.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Correlations/Profiles2D.h
6 //! @brief Defines interface class IProfile2D, 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_PROFILES2D_H
16 #define BORNAGAIN_SAMPLE_CORRELATIONS_PROFILES2D_H
17 
18 #include "Base/Math/Constants.h"
19 #include "Base/Types/ICloneable.h"
20 #include "Param/Node/INode.h"
21 #ifndef SWIG
23 #endif // SWIG
24 
25 #ifndef USER_API
26 
27 //! Interface for two-dimensional distributions in Fourier space.
28 
29 class IProfile2D : public ICloneable, public INode {
30 public:
31  IProfile2D(const std::vector<double>& PValues);
32 
33  IProfile2D* clone() const override = 0;
34 
35  double omegaX() const { return m_omega_x; }
36  double omegaY() const { return m_omega_y; }
37  double decayLengthX() const { return m_omega_x; }
38  double decayLengthY() const { return m_omega_y; }
39  double gamma() const { return m_gamma; }
40 
41  //! Angle in direct space between X- and Y-axis of distribution.
42  double delta() const { return M_PI_2; }
43 
44  //! Fourier transformed distribution for q in X,Y coordinates
45  //! the original distribution (in real space) is assumed to be normalized:
46  //! total integral is equal to 1
47  virtual double standardizedFT2D(double qx, double qy) const = 0;
48  virtual double decayFT2D(double qx, double qy) const = 0;
49 #ifndef SWIG
50  virtual std::unique_ptr<IDistribution2DSampler> createSampler() const = 0;
51 
52  //! Creates the Python constructor of this class (or derived classes)
53  virtual std::string pythonConstructor() const;
54 #endif
55 
56 protected:
57  double sumsq(double qx, double qy) const;
58 
59  const double& m_omega_x;
60  const double& m_omega_y;
61  const double& m_gamma;
62 };
63 
64 #endif // USER_API
65 
66 //! Two-dimensional Cauchy distribution in Fourier space;
67 //! corresponds to a normalized exp(-r) in real space,
68 //! with \f$r=\sqrt{(\frac{x}{\omega_x})^2 + (\frac{y}{\omega_y})^2}\f$.
69 //! @ingroup distributionFT
70 
71 class Profile2DCauchy : public IProfile2D {
72 public:
73  Profile2DCauchy(std::vector<double> P);
74  Profile2DCauchy(double omega_x, double omega_y, double gamma);
75 
76  Profile2DCauchy* clone() const override;
77  std::string className() const final { return "Profile2DCauchy"; }
78  // const auto tooltip = "class_tooltip";
79  std::vector<ParaMeta> parDefs() const final
80  {
81  return {{"OmegaX", "nm", "Half-width along x axis", 0, INF, 1.},
82  {"OmegaY", "nm", "Half-width along y axis", 0, INF, 1.},
83  {"Gamma", "rad",
84  "direct-space orientation with respect to the first lattice vector", -M_PI_2,
85  +M_PI_2, 0}};
86  }
87  double standardizedFT2D(double qx, double qy) const override;
88  double decayFT2D(double qx, double qy) const override;
89 #ifndef SWIG
90  std::unique_ptr<IDistribution2DSampler> createSampler() const override;
91 #endif
92 };
93 
94 //! Two-dimensional Gauss distribution in Fourier space;
95 //! corresponds to normalized exp(-r^2/2) in real space
96 //! with \f$r=\sqrt{(\frac{x}{\omega_x})^2 + (\frac{y}{\omega_y})^2}\f$.
97 //! @ingroup distributionFT
98 
99 class Profile2DGauss : public IProfile2D {
100 public:
101  Profile2DGauss(std::vector<double> P);
102  Profile2DGauss(double omega_x, double omega_y, double gamma);
103 
104  Profile2DGauss* clone() const override;
105  std::string className() const final { return "Profile2DGauss"; }
106  // const auto tooltip = "class_tooltip";
107  std::vector<ParaMeta> parDefs() const final
108  {
109  return {{"OmegaX", "nm", "Half-width along x axis", 0, INF, 1.},
110  {"OmegaY", "nm", "Half-width along y axis", 0, INF, 1.},
111  {"Gamma", "rad",
112  "direct-space orientation with respect to the first lattice vector", -M_PI_2,
113  +M_PI_2, 0}};
114  }
115  double standardizedFT2D(double qx, double qy) const override;
116  double decayFT2D(double qx, double qy) const override;
117 #ifndef SWIG
118  std::unique_ptr<IDistribution2DSampler> createSampler() const override;
119 #endif
120 };
121 
122 //! Two-dimensional gate distribution in Fourier space;
123 //! corresponds to normalized constant if r<1 (and 0 otherwise) in real space,
124 //! with \f$r=\sqrt{(\frac{x}{\omega_x})^2 + (\frac{y}{\omega_y})^2}\f$.
125 //! @ingroup distributionFT
126 
127 class Profile2DGate : public IProfile2D {
128 public:
129  Profile2DGate(std::vector<double> P);
130  Profile2DGate(double omega_x, double omega_y, double gamma);
131 
132  Profile2DGate* clone() const override;
133  std::string className() const final { return "Profile2DGate"; }
134  // const auto tooltip = "class_tooltip";
135  std::vector<ParaMeta> parDefs() const final
136  {
137  return {{"OmegaX", "nm", "Half-width along x axis", 0, INF, 1.},
138  {"OmegaY", "nm", "Half-width along y axis", 0, INF, 1.},
139  {"Gamma", "rad",
140  "direct-space orientation with respect to the first lattice vector", -M_PI_2,
141  +M_PI_2, 0}};
142  }
143  double standardizedFT2D(double qx, double qy) const override;
144  double decayFT2D(double qx, double qy) const override;
145 #ifndef SWIG
146  std::unique_ptr<IDistribution2DSampler> createSampler() const override;
147 #endif
148 };
149 
150 //! Two-dimensional cone distribution in Fourier space;
151 //! corresponds to 1-r if r<1 (and 0 otherwise) in real space
152 //! with \f$r=\sqrt{(\frac{x}{\omega_x})^2 + (\frac{y}{\omega_y})^2}\f$.
153 //! @ingroup distributionFT
154 
155 class Profile2DCone : public IProfile2D {
156 public:
157  Profile2DCone(std::vector<double> P);
158  Profile2DCone(double omega_x, double omega_y, double gamma);
159 
160  Profile2DCone* clone() const override;
161  std::string className() const final { return "Profile2DCone"; }
162  // const auto tooltip = "class_tooltip";
163  std::vector<ParaMeta> parDefs() const final
164  {
165  return {{"OmegaX", "nm", "Half-width along x axis", 0, INF, 1.},
166  {"OmegaY", "nm", "Half-width along y axis", 0, INF, 1.},
167  {"Gamma", "rad",
168  "direct-space orientation with respect to the first lattice vector", -M_PI_2,
169  +M_PI_2, 0}};
170  }
171  double standardizedFT2D(double qx, double qy) const override;
172  double decayFT2D(double qx, double qy) const override;
173 #ifndef SWIG
174  std::unique_ptr<IDistribution2DSampler> createSampler() const override;
175 #endif
176 };
177 
178 //! Two-dimensional Voigt distribution in Fourier space;
179 //! corresponds to eta*Gauss + (1-eta)*Cauchy
180 //! @ingroup distributionFT
181 
182 class Profile2DVoigt : public IProfile2D {
183 public:
184  Profile2DVoigt(std::vector<double> P);
185  Profile2DVoigt(double omega_x, double omega_y, double gamma, double eta);
186 
187  Profile2DVoigt* clone() const override;
188  std::string className() const final { return "Profile2DVoigt"; }
189  // const auto tooltip = "Pseudo-Voigt distribution";
190  std::vector<ParaMeta> parDefs() const final
191  {
192  return {{"OmegaX", "nm", "Half-width along x axis", 0, INF, 1.},
193  {"OmegaY", "nm", "Half-width along y axis", 0, INF, 1.},
194  {"Gamma", "rad",
195  "direct-space orientation with respect to the first lattice vector", -M_PI_2,
196  +M_PI_2, 0},
197  {"Eta", "", "balances between Gauss (eta=0) and Lorentz (eta=1) limiting cases", 0,
198  1, .5}};
199  }
200  double standardizedFT2D(double qx, double qy) const override;
201  double decayFT2D(double qx, double qy) const override;
202  double eta() const { return m_eta; }
203 #ifndef SWIG
204  std::unique_ptr<IDistribution2DSampler> createSampler() const override;
205  std::string pythonConstructor() const override;
206 #endif
207 
208 protected:
209  const double& m_eta;
210 };
211 
212 #endif // BORNAGAIN_SAMPLE_CORRELATIONS_PROFILES2D_H
Defines M_PI and some more mathematical constants.
#define M_PI_2
Definition: Constants.h:45
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 two-dimensional distributions in Fourier space.
Definition: Profiles2D.h:29
const double & m_omega_x
Definition: Profiles2D.h:59
double omegaX() const
Definition: Profiles2D.h:35
IProfile2D(const std::vector< double > &PValues)
Definition: Profiles2D.cpp:26
double sumsq(double qx, double qy) const
Definition: Profiles2D.cpp:41
double delta() const
Angle in direct space between X- and Y-axis of distribution.
Definition: Profiles2D.h:42
IProfile2D * clone() const override=0
const double & m_omega_y
Definition: Profiles2D.h:60
double omegaY() const
Definition: Profiles2D.h:36
virtual std::unique_ptr< IDistribution2DSampler > createSampler() const =0
const double & m_gamma
Definition: Profiles2D.h:61
double gamma() const
Definition: Profiles2D.h:39
virtual double decayFT2D(double qx, double qy) const =0
double decayLengthX() const
Definition: Profiles2D.h:37
virtual std::string pythonConstructor() const
Creates the Python constructor of this class (or derived classes)
Definition: Profiles2D.cpp:34
double decayLengthY() const
Definition: Profiles2D.h:38
virtual double standardizedFT2D(double qx, double qy) const =0
Fourier transformed distribution for q in X,Y coordinates the original distribution (in real space) i...
Two-dimensional Cauchy distribution in Fourier space; corresponds to a normalized exp(-r) in real spa...
Definition: Profiles2D.h:71
std::unique_ptr< IDistribution2DSampler > createSampler() const override
Definition: Profiles2D.cpp:77
Profile2DCauchy(std::vector< double > P)
Definition: Profiles2D.cpp:50
std::vector< ParaMeta > parDefs() const final
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: Profiles2D.h:79
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: Profiles2D.h:77
double decayFT2D(double qx, double qy) const override
Definition: Profiles2D.cpp:71
double standardizedFT2D(double qx, double qy) const override
Fourier transformed distribution for q in X,Y coordinates the original distribution (in real space) i...
Definition: Profiles2D.cpp:66
Profile2DCauchy * clone() const override
Definition: Profiles2D.cpp:61
Two-dimensional cone distribution in Fourier space; corresponds to 1-r if r<1 (and 0 otherwise) in re...
Definition: Profiles2D.h:155
Profile2DCone(std::vector< double > P)
Definition: Profiles2D.cpp:158
double standardizedFT2D(double qx, double qy) const override
Fourier transformed distribution for q in X,Y coordinates the original distribution (in real space) i...
Definition: Profiles2D.cpp:174
std::unique_ptr< IDistribution2DSampler > createSampler() const override
Definition: Profiles2D.cpp:190
Profile2DCone * clone() const override
Definition: Profiles2D.cpp:169
std::vector< ParaMeta > parDefs() const final
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: Profiles2D.h:163
double decayFT2D(double qx, double qy) const override
Definition: Profiles2D.cpp:185
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: Profiles2D.h:161
Two-dimensional gate distribution in Fourier space; corresponds to normalized constant if r<1 (and 0 ...
Definition: Profiles2D.h:127
Profile2DGate(std::vector< double > P)
Definition: Profiles2D.cpp:122
std::unique_ptr< IDistribution2DSampler > createSampler() const override
Definition: Profiles2D.cpp:149
std::vector< ParaMeta > parDefs() const final
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: Profiles2D.h:135
double standardizedFT2D(double qx, double qy) const override
Fourier transformed distribution for q in X,Y coordinates the original distribution (in real space) i...
Definition: Profiles2D.cpp:138
Profile2DGate * clone() const override
Definition: Profiles2D.cpp:133
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: Profiles2D.h:133
double decayFT2D(double qx, double qy) const override
Definition: Profiles2D.cpp:144
Two-dimensional Gauss distribution in Fourier space; corresponds to normalized exp(-r^2/2) in real sp...
Definition: Profiles2D.h:99
double standardizedFT2D(double qx, double qy) const override
Fourier transformed distribution for q in X,Y coordinates the original distribution (in real space) i...
Definition: Profiles2D.cpp:102
double decayFT2D(double qx, double qy) const override
Definition: Profiles2D.cpp:107
Profile2DGauss(std::vector< double > P)
Definition: Profiles2D.cpp:86
Profile2DGauss * clone() const override
Definition: Profiles2D.cpp:97
std::unique_ptr< IDistribution2DSampler > createSampler() const override
Definition: Profiles2D.cpp:113
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: Profiles2D.h:105
std::vector< ParaMeta > parDefs() const final
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: Profiles2D.h:107
Two-dimensional Voigt distribution in Fourier space; corresponds to eta*Gauss + (1-eta)*Cauchy.
Definition: Profiles2D.h:182
std::unique_ptr< IDistribution2DSampler > createSampler() const override
Definition: Profiles2D.cpp:229
double decayFT2D(double qx, double qy) const override
Definition: Profiles2D.cpp:222
const double & m_eta
Definition: Profiles2D.h:209
double standardizedFT2D(double qx, double qy) const override
Fourier transformed distribution for q in X,Y coordinates the original distribution (in real space) i...
Definition: Profiles2D.cpp:216
std::vector< ParaMeta > parDefs() const final
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: Profiles2D.h:190
Profile2DVoigt(std::vector< double > P)
Definition: Profiles2D.cpp:199
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: Profiles2D.h:188
Profile2DVoigt * clone() const override
Definition: Profiles2D.cpp:211
std::string pythonConstructor() const override
Creates the Python constructor of this class (or derived classes)
Definition: Profiles2D.cpp:239
double eta() const
Definition: Profiles2D.h:202