BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
LayerRoughness.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Interface/LayerRoughness.cpp
6 //! @brief Implements class LayerRoughness.
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 
16 #include "Base/Math/Constants.h"
17 #include "Base/Py/PyFmt.h"
18 #include "Fit/Param/RealLimits.h"
19 
20 //! Constructor of layer roughness.
21 //! @param sigma: rms of the roughness in nanometers
22 //! @param hurstParameter: hurst parameter which describes how jagged the interface,
23 //! dimensionless [0.0, 1.0], where 0.0 gives more spikes, 1.0 more smoothness
24 //! @param lateralCorrLength: lateral correlation length of the roughness in nanometers
25 LayerRoughness::LayerRoughness(double sigma, double hurstParameter, double lateralCorrLength)
26  : m_sigma(sigma)
27  , m_hurstParameter(hurstParameter)
28  , m_lateralCorrLength(lateralCorrLength)
29 {
30  RealLimits::nonnegative().check("CorrelationLength", m_lateralCorrLength);
31 }
32 
34  : LayerRoughness(0, 0, 0)
35 {
36 }
37 
38 /* ************************************************************************* */
39 //! Power spectral density of the surface roughness is a result of two-dimensional
40 //! Fourier transform of the correlation function of the roughness profile.
41 //!
42 //! Based on the article
43 //! D.K.G. de Boer, Physical review B, Volume 51, Number 8, 15 February 1995
44 //! "X-ray reflection and transmission by rough surfaces"
45 /* ************************************************************************* */
46 double LayerRoughness::spectralFunction(const R3 kvec) const
47 {
48  double H = m_hurstParameter;
49  double clength2 = m_lateralCorrLength * m_lateralCorrLength;
50  double Qpar2 = kvec.x() * kvec.x() + kvec.y() * kvec.y();
51  return 4.0 * M_PI * H * m_sigma * m_sigma * clength2
52  * std::pow((1.0 + Qpar2 * clength2), (-1 - H));
53 }
54 
55 //! Correlation function of the roughness profile
56 
57 double LayerRoughness::corrFunction(const R3 k) const
58 {
59  double H = m_hurstParameter;
60  double clength = m_lateralCorrLength;
61  double R = sqrt(k.x() * k.x() + k.y() * k.y());
62  return m_sigma * m_sigma * std::exp(-1.0 * std::pow(R / clength, 2. * H));
63 }
64 
66 {
68  "LayerRoughness", {{m_sigma, ""}, {m_hurstParameter, ""}, {m_lateralCorrLength, "nm"}});
69 }
Defines M_PI and some more mathematical constants.
#define M_PI
Definition: Constants.h:44
Defines class LayerRoughness.
Defines namespace pyfmt.
Defines class RealLimits.
A roughness of interface between two layers.
double spectralFunction(R3 kvec) const
Returns power spectral density of the surface roughness.
double m_hurstParameter
Hurst parameter which describes how jagged the interface, 0<H<=1.
double m_lateralCorrLength
lateral correlation length of the roughness
double m_sigma
rms of roughness
std::string pythonConstructor() const
Creates the Python constructor of this class.
double corrFunction(R3 k) const
Correlation function of the roughness profile.
void check(const std::string &name, double value) const
Throws if value is outside limits. Parameter 'name' is for exception message.
Definition: RealLimits.cpp:170
static RealLimits nonnegative()
Creates an object which can have only positive values with 0. included.
Definition: RealLimits.cpp:124
std::string printFunction(const std::string &name, const std::vector< std::pair< double, std::string >> &arguments)
Print a function in the form "<name>(<arguments>)". arguments will be processed by printArguments(),...
Definition: PyFmt.cpp:168
constexpr Double_t H()
Definition: TMath.h:140
constexpr Double_t R()
Definition: TMath.h:213