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

Description

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

Definition at line 87 of file Profiles1D.h.

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

Public Member Functions

 Profile1DGauss (double omega)
 
 Profile1DGauss (std::vector< double > P)
 
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...
 
Profile1DGaussclone () const override
 
std::unique_ptr< IDistribution1DSamplercreateSampler () const override
 
double decayFT (double q) const override
 Returns Fourier transform of the distribution scaled as decay function f(x)/f(0). More...
 
double decayLength () const
 
virtual std::vector< const INode * > nodeChildren () const
 Returns all children. More...
 
std::vector< const INode * > nodeOffspring () const
 Returns all descendants. More...
 
double omega () const
 
std::vector< ParaMetaparDefs () const final
 Returns the parameter definitions, to be hard-coded in each leaf class. More...
 
virtual std::string pythonConstructor () const
 Creates the Python constructor of this class (or derived classes) More...
 
double qSecondDerivative () const override
 Returns the negative of the second order derivative in q space around q=0. More...
 
double standardizedFT (double q) const override
 Returns Fourier transform of the normalized distribution; is a decay function starting at standardizedFT(0)=1. More...
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py) More...
 

Protected Attributes

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

Constructor & Destructor Documentation

◆ Profile1DGauss() [1/2]

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

Definition at line 91 of file Profiles1D.cpp.

92  : IProfile1D(P)
93 {
94  checkNodeArgs();
95 }
void checkNodeArgs() const
Raises exception if a parameter value is invalid.
Definition: INode.cpp:27
IProfile1D(const std::vector< double > &PValues)
Definition: Profiles1D.cpp:33

References INode::checkNodeArgs().

Referenced by clone().

Here is the call graph for this function:

◆ Profile1DGauss() [2/2]

Profile1DGauss::Profile1DGauss ( double  omega)

Definition at line 97 of file Profiles1D.cpp.

98  : Profile1DGauss(std::vector<double>{omega})
99 {
100 }
double omega() const
Definition: Profiles1D.h:41
Profile1DGauss(std::vector< double > P)
Definition: Profiles1D.cpp:91

References IProfile1D::omega().

Here is the call graph for this function:

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

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

Implements INode.

Definition at line 93 of file Profiles1D.h.

93 { return "Profile1DGauss"; }

◆ clone()

Profile1DGauss * Profile1DGauss::clone ( ) const
overridevirtual

Implements IProfile1D.

Definition at line 102 of file Profiles1D.cpp.

103 {
104  return new Profile1DGauss(m_omega);
105 }
const double & m_omega
Definition: Profiles1D.h:54

References Profile1DGauss(), and IProfile1D::m_omega.

Here is the call graph for this function:

◆ createSampler()

std::unique_ptr< IDistribution1DSampler > Profile1DGauss::createSampler ( ) const
overridevirtual

Implements IProfile1D.

Definition at line 124 of file Profiles1D.cpp.

125 {
126  return std::make_unique<Distribution1DGaussSampler>(0.0, m_omega);
127 }

References IProfile1D::m_omega.

◆ decayFT()

double Profile1DGauss::decayFT ( double  q) const
overridevirtual

Returns Fourier transform of the distribution scaled as decay function f(x)/f(0).

Implements IProfile1D.

Definition at line 113 of file Profiles1D.cpp.

114 {
115  double sum_sq = q * q * m_omega * m_omega;
116  return m_omega * std::sqrt(M_TWOPI) * std::exp(-sum_sq / 2.0);
117 }
#define M_TWOPI
Definition: Constants.h:54

References IProfile1D::m_omega, and M_TWOPI.

◆ decayLength()

double IProfile1D::decayLength ( ) const
inlineinherited

Definition at line 42 of file Profiles1D.h.

42 { return m_omega; }

References IProfile1D::m_omega.

◆ 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:

◆ omega()

◆ parDefs()

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

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

Reimplemented from INode.

Definition at line 95 of file Profiles1D.h.

96  {
97  return {{"Omega", "nm", "Half-width", 0, INF, 1.}};
98  }

References INF.

◆ pythonConstructor()

std::string IProfile1D::pythonConstructor ( ) const
virtualinherited

Creates the Python constructor of this class (or derived classes)

Reimplemented in Profile1DVoigt.

Definition at line 39 of file Profiles1D.cpp.

40 {
41  ASSERT(m_P.size() == 1);
42  return Py::Fmt::printFunction(className(), m_omega, "nm");
43 }
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 ASSERT, INode::className(), IProfile1D::m_omega, INode::m_P, and Py::Fmt::printFunction().

Here is the call graph for this function:

◆ qSecondDerivative()

double Profile1DGauss::qSecondDerivative ( ) const
overridevirtual

Returns the negative of the second order derivative in q space around q=0.

Implements IProfile1D.

Definition at line 119 of file Profiles1D.cpp.

120 {
121  return m_omega * m_omega;
122 }

References IProfile1D::m_omega.

◆ standardizedFT()

double Profile1DGauss::standardizedFT ( double  q) const
overridevirtual

Returns Fourier transform of the normalized distribution; is a decay function starting at standardizedFT(0)=1.

Implements IProfile1D.

Definition at line 107 of file Profiles1D.cpp.

108 {
109  double sum_sq = q * q * m_omega * m_omega;
110  return std::exp(-sum_sq / 2.0);
111 }

References IProfile1D::m_omega.

◆ 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_omega

◆ m_P


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