File: Profiles1D.h

package info (click to toggle)
bornagain 23.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,956 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 356; ruby: 173; xml: 130; makefile: 45; ansic: 24
file content (193 lines) | stat: -rw-r--r-- 6,455 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      Sample/Correlation/Profiles1D.h
//! @brief     Defines class interface IProfile1D, and children thereof.
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
//  ************************************************************************************************

#ifndef BORNAGAIN_SAMPLE_CORRELATION_PROFILES1D_H
#define BORNAGAIN_SAMPLE_CORRELATION_PROFILES1D_H

#include "Base/Type/ICloneable.h"
#include "Param/Node/INode.h"

#ifndef SWIG
#include "Sample/Correlation/IDistribution1DSampler.h"
#endif // SWIG


//! Interface for a one-dimensional distribution, with normalization adjusted so that
//! the Fourier transform standardizedFT(q) is a decay function that starts at standardizedFT(0)=1.

class IProfile1D : public ICloneable, public INode {
public:
    IProfile1D(const std::vector<double>& PValues);

    std::vector<ParaMeta> parDefs() const override { return {{"Omega", "nm"}}; }

    //! Returns Fourier transform of the normalized distribution;
    //! is a decay function starting at standardizedFT(0)=1.
    virtual double standardizedFT(double q) const = 0;
    //! Returns Fourier transform of the distribution scaled as decay function f(x)/f(0).
    virtual double decayFT(double q) const = 0;

    double omega() const { return m_omega; }
    double decayLength() const { return m_omega; }

    //! Returns the negative of the second order derivative in q space around q=0
    virtual double qSecondDerivative() const = 0;
#ifndef SWIG
    IProfile1D* clone() const override = 0;

    virtual std::unique_ptr<IDistribution1DSampler> createSampler() const = 0;

    //! Creates the Python constructor of this class (or derived classes)
    virtual std::string pythonConstructor() const;
#endif

    std::string validate() const override;

protected:
    const double& m_omega; //!< half-width
};


//! Exponential IProfile1D exp(-|omega*x|);
//! its Fourier transform standardizedFT(q) is a Cauchy-Lorentzian starting at standardizedFT(0)=1.

class Profile1DCauchy : public IProfile1D {
public:
    Profile1DCauchy(std::vector<double> P);
    Profile1DCauchy(double omega);

    std::string className() const final { return "Profile1DCauchy"; }
    double standardizedFT(double q) const override;
    double decayFT(double q) const override;
    double qSecondDerivative() const override;

#ifndef SWIG
    Profile1DCauchy* clone() const override;

    std::unique_ptr<IDistribution1DSampler> createSampler() const override;
#endif
};

//! Gaussian IProfile1D;
//! its Fourier transform standardizedFT(q) is a Gaussian starting at standardizedFT(0)=1.

class Profile1DGauss : public IProfile1D {
public:
    Profile1DGauss(std::vector<double> P);
    Profile1DGauss(double omega);

    std::string className() const final { return "Profile1DGauss"; }
    double standardizedFT(double q) const override;
    double decayFT(double q) const override;
    double qSecondDerivative() const override;

#ifndef SWIG
    Profile1DGauss* clone() const override;

    std::unique_ptr<IDistribution1DSampler> createSampler() const override;
#endif
};

//! Square gate IProfile1D;
//! its Fourier transform standardizedFT(q) is a sinc function starting at standardizedFT(0)=1.

class Profile1DGate : public IProfile1D {
public:
    Profile1DGate(std::vector<double> P);
    Profile1DGate(double omega);

    std::string className() const final { return "Profile1DGate"; }
    double standardizedFT(double q) const override;
    double decayFT(double q) const override;
    double qSecondDerivative() const override;

#ifndef SWIG
    Profile1DGate* clone() const override;

    std::unique_ptr<IDistribution1DSampler> createSampler() const override;
#endif
};

//! Triangle IProfile1D [1-|x|/omega if |x|<omega, and 0 otherwise];
//! its Fourier transform standardizedFT(q) is a squared sinc function starting at
//! standardizedFT(0)=1.

class Profile1DTriangle : public IProfile1D {
public:
    Profile1DTriangle(std::vector<double> P);
    Profile1DTriangle(double omega);

    std::string className() const final { return "Profile1DTriangle"; }
    double standardizedFT(double q) const override;
    double decayFT(double q) const override;
    double qSecondDerivative() const override;

#ifndef SWIG
    Profile1DTriangle* clone() const override;

    std::unique_ptr<IDistribution1DSampler> createSampler() const override;
#endif
};

//! IProfile1D consisting of one cosine wave
//! [1+cos(pi*x/omega) if |x|<omega, and 0 otherwise];
//! its Fourier transform standardizedFT(q) starts at standardizedFT(0)=1.

class Profile1DCosine : public IProfile1D {
public:
    Profile1DCosine(std::vector<double> P);
    Profile1DCosine(double omega);

    std::string className() const final { return "Profile1DCosine"; }
    double standardizedFT(double q) const override;
    double decayFT(double q) const override;
    double qSecondDerivative() const override;

#ifndef SWIG
    Profile1DCosine* clone() const override;

    std::unique_ptr<IDistribution1DSampler> createSampler() const override;
#endif
};

//! IProfile1D that provides a Fourier transform standardizedFT(q) in form
//! of a pseudo-Voigt decay function eta*Gauss + (1-eta)*Cauchy, with both components
//! starting at 1 for q=0.

class Profile1DVoigt : public IProfile1D {
public:
    Profile1DVoigt(std::vector<double> P);
    Profile1DVoigt(double omega, double eta);

    std::string className() const final { return "Profile1DVoigt"; }
    std::vector<ParaMeta> parDefs() const final { return {{"Omega", "nm"}, {"Eta", ""}}; }
    double standardizedFT(double q) const override;
    double decayFT(double q) const override;
    double eta() const { return m_eta; }
    double qSecondDerivative() const override;

#ifndef SWIG
    Profile1DVoigt* clone() const override;

    std::unique_ptr<IDistribution1DSampler> createSampler() const override;
    std::string pythonConstructor() const override;
#endif

    std::string validate() const override;

protected:
    const double& m_eta; //!< balances between Gauss (eta=0) and Lorentz (eta=1)
};

#endif // BORNAGAIN_SAMPLE_CORRELATION_PROFILES1D_H