BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
LayerRoughness Class Reference

Description

A roughness of interface between two layers.

Based on the article "X-ray reflection and transmission by rough surfaces" by D. K. G. de Boer, Physical Review B 51, 5297 (1995)

Definition at line 29 of file LayerRoughness.h.

Inheritance diagram for LayerRoughness:
[legend]
Collaboration diagram for LayerRoughness:
[legend]

Public Member Functions

 LayerRoughness ()
 
 LayerRoughness (double sigma, double hurstParameter=0, double lateralCorrLength=0)
 Constructor of layer roughness. More...
 
void checkNodeArgs () const
 Raises exception if a parameter value is invalid. More...
 
std::string className () const final
 Returns the class name, to be hard-coded in each leaf class that inherits from INode. More...
 
LayerRoughnessclone () const override
 Returns a clone of this ISampleNode object. More...
 
std::vector< const Material * > containedMaterials () const
 Returns set of unique materials contained in this ISampleNode. More...
 
double corrFunction (R3 k) const
 Correlation function of the roughness profile. More...
 
double hurst () const
 Returns hurst parameter. More...
 
bool isMagnetic () const
 Returns true if there is any magnetic material in this ISampleNode. More...
 
double lateralCorrLength () const
 Returns lateral correlation length. More...
 
virtual const Materialmaterial () const
 Returns nullptr, unless overwritten to return a specific material. More...
 
virtual std::vector< const INode * > nodeChildren () const
 Returns all children. More...
 
std::vector< const INode * > nodeOffspring () const
 Returns all descendants. More...
 
std::vector< ParaMetaparDefs () const final
 Returns the parameter definitions, to be hard-coded in each leaf class. More...
 
std::string pythonConstructor () const
 Creates the Python constructor of this class. More...
 
void setHurstParameter (double hurstParameter)
 Sets hurst parameter. It describes how jagged the surface is. More...
 
void setLatteralCorrLength (double lateralCorrLength)
 Sets lateral correlation length. More...
 
void setSigma (double sigma)
 Sets rms of roughness. More...
 
double sigma () const
 Returns rms of roughness. More...
 
double spectralFunction (R3 kvec) const
 Returns power spectral density of the surface roughness. More...
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py) More...
 

Protected Attributes

std::vector< double > m_P
 

Private Attributes

double m_hurstParameter
 Hurst parameter which describes how jagged the interface, 0<H<=1. More...
 
double m_lateralCorrLength
 lateral correlation length of the roughness More...
 
double m_sigma
 rms of roughness More...
 

Constructor & Destructor Documentation

◆ LayerRoughness() [1/2]

LayerRoughness::LayerRoughness ( double  sigma,
double  hurstParameter = 0,
double  lateralCorrLength = 0 
)

Constructor of layer roughness.

Parameters
sigmarms of the roughness in nanometers
hurstParameterhurst parameter which describes how jagged the interface, dimensionless [0.0, 1.0], where 0.0 gives more spikes, 1.0 more smoothness
lateralCorrLengthlateral correlation length of the roughness in nanometers

Definition at line 25 of file LayerRoughness.cpp.

26  : m_sigma(sigma)
27  , m_hurstParameter(hurstParameter)
29 {
30  RealLimits::nonnegative().check("CorrelationLength", m_lateralCorrLength);
31 }
double m_hurstParameter
Hurst parameter which describes how jagged the interface, 0<H<=1.
double sigma() const
Returns rms of roughness.
double m_lateralCorrLength
lateral correlation length of the roughness
double lateralCorrLength() const
Returns lateral correlation length.
double m_sigma
rms of roughness
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

References RealLimits::check(), m_lateralCorrLength, and RealLimits::nonnegative().

Here is the call graph for this function:

◆ LayerRoughness() [2/2]

LayerRoughness::LayerRoughness ( )

Definition at line 33 of file LayerRoughness.cpp.

34  : LayerRoughness(0, 0, 0)
35 {
36 }

Referenced by clone().

Member Function Documentation

◆ checkNodeArgs()

void INode::checkNodeArgs ( ) const
inherited

Raises exception if a parameter value is invalid.

Definition at line 27 of file INode.cpp.

28 {
29  size_t nP = m_P.size();
30  if (parDefs().size() != nP) {
31  std::cerr << "BUG in class " << className() << std::endl;
32  std::cerr << "#m_P = " << nP << std::endl;
33  std::cerr << "#PDf = " << parDefs().size() << std::endl;
34  for (const ParaMeta& pm : parDefs())
35  std::cerr << " PDf: " << pm.name << std::endl;
36  ASSERT(0);
37  }
38  ASSERT(parDefs().size() == nP);
39  for (size_t i = 0; i < nP; ++i) {
40  const ParaMeta pm = parDefs()[i];
41 
43  if (pm.vMin == -INF) {
44  ASSERT(pm.vMax == +INF);
45  // nothing to do
46  } else if (pm.vMax == +INF) {
47  ASSERT(pm.vMin == 0);
48  limits = RealLimits::nonnegative();
49  } else {
50  limits = RealLimits::limited(pm.vMin, pm.vMax);
51  }
52  limits.check(pm.name, m_P[i]);
53  }
54 }
#define ASSERT(condition)
Definition: Assert.h:45
const double INF
Definition: INode.h:26
virtual std::vector< ParaMeta > parDefs() const
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: INode.h:51
std::vector< double > m_P
Definition: INode.h:63
virtual std::string className() const =0
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Limits for a real fit parameter.
Definition: RealLimits.h:24
static RealLimits limitless()
Creates an object without bounds (default)
Definition: RealLimits.cpp:139
static RealLimits limited(double left_bound_value, double right_bound_value)
Creates an object bounded from the left and right.
Definition: RealLimits.cpp:134
Metadata of one model parameter.
Definition: INode.h:29
double vMin
Definition: INode.h:33
double vMax
Definition: INode.h:34
std::string name
Definition: INode.h:30

References ASSERT, RealLimits::check(), INode::className(), INF, RealLimits::limited(), RealLimits::limitless(), INode::m_P, ParaMeta::name, RealLimits::nonnegative(), INode::parDefs(), ParaMeta::vMax, and ParaMeta::vMin.

Referenced by BarGauss::BarGauss(), BarLorentz::BarLorentz(), Bipyramid4::Bipyramid4(), Box::Box(), CantellatedCube::CantellatedCube(), Cone::Cone(), ConstantBackground::ConstantBackground(), CosineRippleBox::CosineRippleBox(), CosineRippleGauss::CosineRippleGauss(), CosineRippleLorentz::CosineRippleLorentz(), Cylinder::Cylinder(), DistributionCosine::DistributionCosine(), DistributionGate::DistributionGate(), DistributionGaussian::DistributionGaussian(), DistributionLogNormal::DistributionLogNormal(), DistributionLorentz::DistributionLorentz(), DistributionTrapezoid::DistributionTrapezoid(), Dodecahedron::Dodecahedron(), EllipsoidalCylinder::EllipsoidalCylinder(), FootprintGauss::FootprintGauss(), FootprintSquare::FootprintSquare(), FuzzySphere::FuzzySphere(), GaussSphere::GaussSphere(), HemiEllipsoid::HemiEllipsoid(), HollowSphere::HollowSphere(), HorizontalCylinder::HorizontalCylinder(), Icosahedron::Icosahedron(), LongBoxGauss::LongBoxGauss(), LongBoxLorentz::LongBoxLorentz(), PlatonicOctahedron::PlatonicOctahedron(), PlatonicTetrahedron::PlatonicTetrahedron(), Prism3::Prism3(), Prism6::Prism6(), Profile1DCauchy::Profile1DCauchy(), Profile1DCosine::Profile1DCosine(), Profile1DGate::Profile1DGate(), Profile1DGauss::Profile1DGauss(), Profile1DTriangle::Profile1DTriangle(), Profile1DVoigt::Profile1DVoigt(), Profile2DCauchy::Profile2DCauchy(), Profile2DCone::Profile2DCone(), Profile2DGate::Profile2DGate(), Profile2DGauss::Profile2DGauss(), Profile2DVoigt::Profile2DVoigt(), Pyramid2::Pyramid2(), Pyramid3::Pyramid3(), Pyramid4::Pyramid4(), Pyramid6::Pyramid6(), RotationEuler::RotationEuler(), RotationX::RotationX(), RotationY::RotationY(), RotationZ::RotationZ(), SawtoothRippleBox::SawtoothRippleBox(), SawtoothRippleGauss::SawtoothRippleGauss(), SawtoothRippleLorentz::SawtoothRippleLorentz(), Sphere::Sphere(), Spheroid::Spheroid(), TruncatedCube::TruncatedCube(), TruncatedSphere::TruncatedSphere(), and TruncatedSpheroid::TruncatedSpheroid().

Here is the call graph for this function:

◆ className()

std::string LayerRoughness::className ( ) const
inlinefinalvirtual

Returns the class name, to be hard-coded in each leaf class that inherits from INode.

Implements INode.

Definition at line 38 of file LayerRoughness.h.

38 { return "LayerRoughness"; }

◆ clone()

LayerRoughness* LayerRoughness::clone ( ) const
inlineoverridevirtual

Returns a clone of this ISampleNode object.

Implements ISampleNode.

Definition at line 34 of file LayerRoughness.h.

35  {
37  }

References LayerRoughness(), m_hurstParameter, m_lateralCorrLength, and m_sigma.

Referenced by LayerInterface::setRoughness().

Here is the call graph for this function:

◆ containedMaterials()

std::vector< const Material * > ISampleNode::containedMaterials ( ) const
inherited

Returns set of unique materials contained in this ISampleNode.

Definition at line 25 of file ISampleNode.cpp.

26 {
27  std::vector<const Material*> result;
28  if (const Material* p_material = material())
29  result.push_back(p_material);
30  for (const auto* child : nodeChildren()) {
31  if (const auto* sample = dynamic_cast<const ISampleNode*>(child)) {
32  for (const Material* p_material : sample->containedMaterials())
33  result.push_back(p_material);
34  }
35  }
36  return result;
37 }
virtual std::vector< const INode * > nodeChildren() const
Returns all children.
Definition: INode.cpp:56
Abstract base class for sample components and properties related to scattering.
Definition: ISampleNode.h:27
virtual const Material * material() const
Returns nullptr, unless overwritten to return a specific material.
Definition: ISampleNode.h:36
A wrapper for underlying material implementation.
Definition: Material.h:35

References ISampleNode::material(), and INode::nodeChildren().

Referenced by SampleUtils::Multilayer::ContainsCompatibleMaterials(), SampleToPython::initLabels(), and ISampleNode::isMagnetic().

Here is the call graph for this function:

◆ corrFunction()

double LayerRoughness::corrFunction ( R3  k) const

Correlation function of the roughness profile.

Definition at line 57 of file LayerRoughness.cpp.

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 }
constexpr Double_t H()
Definition: TMath.h:140
constexpr Double_t R()
Definition: TMath.h:213

References TMath::H(), m_hurstParameter, m_lateralCorrLength, m_sigma, and TMath::R().

Here is the call graph for this function:

◆ hurst()

double LayerRoughness::hurst ( ) const
inline

Returns hurst parameter.

Definition at line 59 of file LayerRoughness.h.

59 { return m_hurstParameter; }

References m_hurstParameter.

◆ isMagnetic()

bool ISampleNode::isMagnetic ( ) const
inherited

Returns true if there is any magnetic material in this ISampleNode.

Definition at line 39 of file ISampleNode.cpp.

40 {
41  const auto materials = containedMaterials();
42  return std::any_of(materials.cbegin(), materials.cend(),
43  [](const Material* mat) { return mat->isMagneticMaterial(); });
44 }
std::vector< const Material * > containedMaterials() const
Returns set of unique materials contained in this ISampleNode.
Definition: ISampleNode.cpp:25

References ISampleNode::containedMaterials().

Referenced by reSample::make().

Here is the call graph for this function:

◆ lateralCorrLength()

double LayerRoughness::lateralCorrLength ( ) const
inline

Returns lateral correlation length.

Definition at line 67 of file LayerRoughness.h.

67 { return m_lateralCorrLength; }

References m_lateralCorrLength.

Referenced by setLatteralCorrLength().

◆ material()

virtual const Material* ISampleNode::material ( ) const
inlinevirtualinherited

Returns nullptr, unless overwritten to return a specific material.

Reimplemented in Particle, and Layer.

Definition at line 36 of file ISampleNode.h.

36 { return nullptr; }

Referenced by ISampleNode::containedMaterials().

◆ nodeChildren()

◆ nodeOffspring()

std::vector< const INode * > INode::nodeOffspring ( ) const
inherited

Returns all descendants.

Definition at line 61 of file INode.cpp.

62 {
63  std::vector<const INode*> result;
64  result.push_back(this);
65  for (const auto* child : nodeChildren()) {
66  for (const auto* p : child->nodeOffspring())
67  result.push_back(p);
68  }
69  return result;
70 }

References INode::nodeChildren().

Here is the call graph for this function:

◆ parDefs()

std::vector<ParaMeta> LayerRoughness::parDefs ( ) const
inlinefinalvirtual

Returns the parameter definitions, to be hard-coded in each leaf class.

Reimplemented from INode.

Definition at line 39 of file LayerRoughness.h.

40  {
41  return {{"Sigma", "", "roughness amplitude", 0, +INF, 0},
42  {"Hurst", "", "Power law exponent??", 0, +INF, 0},
43  {"CorrLength", "nm", "lateral correlation length", 0, +INF, 0}};
44  }

References INF.

◆ pythonConstructor()

std::string LayerRoughness::pythonConstructor ( ) const

Creates the Python constructor of this class.

Definition at line 65 of file LayerRoughness.cpp.

66 {
68  "LayerRoughness", {{m_sigma, ""}, {m_hurstParameter, ""}, {m_lateralCorrLength, "nm"}});
69 }
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

References m_hurstParameter, m_lateralCorrLength, m_sigma, and Py::Fmt::printFunction().

Here is the call graph for this function:

◆ setHurstParameter()

void LayerRoughness::setHurstParameter ( double  hurstParameter)
inline

Sets hurst parameter. It describes how jagged the surface is.

Definition at line 57 of file LayerRoughness.h.

57 { m_hurstParameter = hurstParameter; }

References m_hurstParameter.

◆ setLatteralCorrLength()

void LayerRoughness::setLatteralCorrLength ( double  lateralCorrLength)
inline

Sets lateral correlation length.

Definition at line 62 of file LayerRoughness.h.

63  {
65  }

References lateralCorrLength(), and m_lateralCorrLength.

Here is the call graph for this function:

◆ setSigma()

void LayerRoughness::setSigma ( double  sigma)
inline

Sets rms of roughness.

Definition at line 52 of file LayerRoughness.h.

52 { m_sigma = sigma; }

References m_sigma, and sigma().

Here is the call graph for this function:

◆ sigma()

double LayerRoughness::sigma ( ) const
inline

◆ spectralFunction()

double LayerRoughness::spectralFunction ( R3  kvec) const

Returns power spectral density of the surface roughness.

Power spectral density of the surface roughness is a result of two-dimensional Fourier transform of the correlation function of the roughness profile.

Based on the article D.K.G. de Boer, Physical review B, Volume 51, Number 8, 15 February 1995 "X-ray reflection and transmission by rough surfaces"

Definition at line 46 of file LayerRoughness.cpp.

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 }
#define M_PI
Definition: Constants.h:44

References TMath::H(), m_hurstParameter, m_lateralCorrLength, M_PI, and m_sigma.

Referenced by RoughMultiLayerContribution::compute(), and reSample::crossCorrSpectralFun().

Here is the call graph for this function:

◆ transferToCPP()

virtual void ICloneable::transferToCPP ( )
inlinevirtualinherited

Used for Python overriding of clone (see swig/tweaks.py)

Definition at line 32 of file ICloneable.h.

Member Data Documentation

◆ m_hurstParameter

double LayerRoughness::m_hurstParameter
private

Hurst parameter which describes how jagged the interface, 0<H<=1.

Definition at line 76 of file LayerRoughness.h.

Referenced by clone(), corrFunction(), hurst(), pythonConstructor(), setHurstParameter(), and spectralFunction().

◆ m_lateralCorrLength

double LayerRoughness::m_lateralCorrLength
private

lateral correlation length of the roughness

Definition at line 77 of file LayerRoughness.h.

Referenced by LayerRoughness(), clone(), corrFunction(), lateralCorrLength(), pythonConstructor(), setLatteralCorrLength(), and spectralFunction().

◆ m_P

◆ m_sigma

double LayerRoughness::m_sigma
private

rms of roughness

Definition at line 75 of file LayerRoughness.h.

Referenced by clone(), corrFunction(), pythonConstructor(), setSigma(), sigma(), and spectralFunction().


The documentation for this class was generated from the following files: