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

Description

Gaussian beam footprint.

Beam width is the full width at half maximum.

Definition at line 25 of file FootprintGauss.h.

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

Public Member Functions

 FootprintGauss (double width_ratio)
 
 FootprintGauss (std::vector< double > P)
 
double calculate (double alpha) const override
 Calculate footprint correction coefficient from the beam incident angle alpha. 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...
 
FootprintGaussclone () const override
 
std::string name () const override
 
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...
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py) More...
 
double widthRatio () const
 

Protected Attributes

std::vector< double > m_P
 
const double & m_width_ratio
 

Private Member Functions

void initialize ()
 Beam to sample width ratio. More...
 

Constructor & Destructor Documentation

◆ FootprintGauss() [1/2]

FootprintGauss::FootprintGauss ( std::vector< double >  P)

Definition at line 19 of file FootprintGauss.cpp.

20  : IFootprintFactor(P)
21 {
22  checkNodeArgs();
23 }
IFootprintFactor(const std::vector< double > &PValues)
void checkNodeArgs() const
Raises exception if a parameter value is invalid.
Definition: INode.cpp:27

References INode::checkNodeArgs().

Referenced by clone().

Here is the call graph for this function:

◆ FootprintGauss() [2/2]

FootprintGauss::FootprintGauss ( double  width_ratio)

Definition at line 25 of file FootprintGauss.cpp.

26  : FootprintGauss(std::vector<double>{width_ratio})
27 {
28 }
FootprintGauss(std::vector< double > P)

Member Function Documentation

◆ calculate()

double FootprintGauss::calculate ( double  alpha) const
overridevirtual

Calculate footprint correction coefficient from the beam incident angle alpha.

Implements IFootprintFactor.

Definition at line 35 of file FootprintGauss.cpp.

36 {
37  if (alpha < 0.0 || alpha > M_PI_2)
38  return 0.0;
39  if (widthRatio() == 0.0)
40  return 1.0;
41  const double arg = std::sin(alpha) * M_SQRT1_2 / widthRatio();
42  return Math::erf(arg);
43 }
#define M_PI_2
Definition: Constants.h:45
#define M_SQRT1_2
Definition: Constants.h:51
double widthRatio() const
double erf(double arg)
Error function of real-valued argument.
Definition: Functions.cpp:88

References Math::erf(), M_PI_2, M_SQRT1_2, and IFootprintFactor::widthRatio().

Here is the call graph for this function:

◆ 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
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
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(), 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 FootprintGauss::className ( ) const
inlinefinalvirtual

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

Implements INode.

Definition at line 31 of file FootprintGauss.h.

31 { return "FootprintGauss"; }

◆ clone()

FootprintGauss * FootprintGauss::clone ( ) const
overridevirtual

Implements IFootprintFactor.

Definition at line 30 of file FootprintGauss.cpp.

31 {
32  return new FootprintGauss(m_width_ratio);
33 }
const double & m_width_ratio

References FootprintGauss(), and IFootprintFactor::m_width_ratio.

Here is the call graph for this function:

◆ initialize()

void IFootprintFactor::initialize ( )
privateinherited

Beam to sample width ratio.

◆ name()

std::string FootprintGauss::name ( ) const
inlineoverridevirtual

Implements IFootprintFactor.

Definition at line 41 of file FootprintGauss.h.

41 { return "FootprintGauss"; }

◆ 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 }
virtual std::vector< const INode * > nodeChildren() const
Returns all children.
Definition: INode.cpp:56

References INode::nodeChildren().

Here is the call graph for this function:

◆ parDefs()

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

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

Reimplemented from INode.

Definition at line 33 of file FootprintGauss.h.

34  {
35  return {{"BeamToSampleWidthRatio", "", "ratio of beam width to sample width", 0, INF, 1.}};
36  }

References INF.

◆ transferToCPP()

virtual void ICloneable::transferToCPP ( )
inlinevirtualinherited

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

Definition at line 32 of file ICloneable.h.

◆ widthRatio()

double IFootprintFactor::widthRatio ( ) const
inlineinherited

Definition at line 34 of file IFootprintFactor.h.

34 { return m_width_ratio; }

References IFootprintFactor::m_width_ratio.

Referenced by calculate(), and FootprintSquare::calculate().

Member Data Documentation

◆ m_P

◆ m_width_ratio

const double& IFootprintFactor::m_width_ratio
protectedinherited

Definition at line 42 of file IFootprintFactor.h.

Referenced by clone(), FootprintSquare::clone(), and IFootprintFactor::widthRatio().


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