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

Description

Two-dimensional Voigt distribution in Fourier space; corresponds to eta*Gauss + (1-eta)*Cauchy.

Definition at line 182 of file Profiles2D.h.

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

Public Member Functions

 Profile2DVoigt (double omega_x, double omega_y, double gamma, double eta)
 
 Profile2DVoigt (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...
 
Profile2DVoigtclone () const override
 
std::unique_ptr< IDistribution2DSamplercreateSampler () const override
 
double decayFT2D (double qx, double qy) const override
 
double decayLengthX () const
 
double decayLengthY () const
 
double delta () const
 Angle in direct space between X- and Y-axis of distribution. More...
 
double eta () const
 
double gamma () const
 
virtual std::vector< const INode * > nodeChildren () const
 Returns all children. More...
 
std::vector< const INode * > nodeOffspring () const
 Returns all descendants. More...
 
double omegaX () const
 
double omegaY () const
 
std::vector< ParaMetaparDefs () const final
 Returns the parameter definitions, to be hard-coded in each leaf class. More...
 
std::string pythonConstructor () const override
 Creates the Python constructor of this class (or derived classes) More...
 
double standardizedFT2D (double qx, double qy) const override
 Fourier transformed distribution for q in X,Y coordinates the original distribution (in real space) is assumed to be normalized: total integral is equal to 1. More...
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py) More...
 

Protected Member Functions

double sumsq (double qx, double qy) const
 

Protected Attributes

const double & m_eta
 
const double & m_gamma
 
const double & m_omega_x
 
const double & m_omega_y
 
std::vector< double > m_P
 

Constructor & Destructor Documentation

◆ Profile2DVoigt() [1/2]

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

Definition at line 199 of file Profiles2D.cpp.

200  : IProfile2D(P)
201  , m_eta(m_P[3])
202 {
203  checkNodeArgs();
204 }
void checkNodeArgs() const
Raises exception if a parameter value is invalid.
Definition: INode.cpp:27
std::vector< double > m_P
Definition: INode.h:63
IProfile2D(const std::vector< double > &PValues)
Definition: Profiles2D.cpp:26
const double & m_eta
Definition: Profiles2D.h:209

References INode::checkNodeArgs().

Referenced by clone().

Here is the call graph for this function:

◆ Profile2DVoigt() [2/2]

Profile2DVoigt::Profile2DVoigt ( double  omega_x,
double  omega_y,
double  gamma,
double  eta 
)

Definition at line 206 of file Profiles2D.cpp.

207  : Profile2DVoigt(std::vector<double>{omega_x, omega_y, gamma, eta})
208 {
209 }
double gamma() const
Definition: Profiles2D.h:39
Profile2DVoigt(std::vector< double > P)
Definition: Profiles2D.cpp:199
double eta() const
Definition: Profiles2D.h:202

References eta(), and IProfile2D::gamma().

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
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::Profile1DGauss(), Profile1DTriangle::Profile1DTriangle(), Profile1DVoigt::Profile1DVoigt(), Profile2DCauchy::Profile2DCauchy(), Profile2DCone::Profile2DCone(), Profile2DGate::Profile2DGate(), Profile2DGauss::Profile2DGauss(), 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 Profile2DVoigt::className ( ) const
inlinefinalvirtual

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

Implements INode.

Definition at line 188 of file Profiles2D.h.

188 { return "Profile2DVoigt"; }

Referenced by pythonConstructor().

◆ clone()

Profile2DVoigt * Profile2DVoigt::clone ( ) const
overridevirtual

Implements IProfile2D.

Definition at line 211 of file Profiles2D.cpp.

212 {
214 }
const double & m_omega_x
Definition: Profiles2D.h:59
const double & m_omega_y
Definition: Profiles2D.h:60
const double & m_gamma
Definition: Profiles2D.h:61

References Profile2DVoigt(), m_eta, IProfile2D::m_gamma, IProfile2D::m_omega_x, and IProfile2D::m_omega_y.

Here is the call graph for this function:

◆ createSampler()

std::unique_ptr< IDistribution2DSampler > Profile2DVoigt::createSampler ( ) const
overridevirtual

Implements IProfile2D.

Definition at line 229 of file Profiles2D.cpp.

230 {
231  // TODO Need to implement 2D Voigt
232 
233  std::ostringstream ostr;
234  ostr << "Profile2DVoigt::createSampler() -> Error in class initialization";
235  ostr << "\n\n Has not been implemented yet...stay tuned!";
236  throw std::runtime_error(ostr.str());
237 }

◆ decayFT2D()

double Profile2DVoigt::decayFT2D ( double  qx,
double  qy 
) const
overridevirtual

Implements IProfile2D.

Definition at line 222 of file Profiles2D.cpp.

223 {
224  double sum_sq = qx * qx * m_omega_x * m_omega_x + qy * qy * m_omega_y * m_omega_y;
225  return M_TWOPI * m_omega_x * m_omega_y
226  * (m_eta * std::exp(-sum_sq / 2.0) + (1.0 - m_eta) * std::pow(1.0 + sum_sq, -1.5));
227 }
#define M_TWOPI
Definition: Constants.h:54

References m_eta, IProfile2D::m_omega_x, IProfile2D::m_omega_y, and M_TWOPI.

◆ decayLengthX()

double IProfile2D::decayLengthX ( ) const
inlineinherited

Definition at line 37 of file Profiles2D.h.

37 { return m_omega_x; }

References IProfile2D::m_omega_x.

◆ decayLengthY()

double IProfile2D::decayLengthY ( ) const
inlineinherited

Definition at line 38 of file Profiles2D.h.

38 { return m_omega_y; }

References IProfile2D::m_omega_y.

◆ delta()

double IProfile2D::delta ( ) const
inlineinherited

Angle in direct space between X- and Y-axis of distribution.

Definition at line 42 of file Profiles2D.h.

42 { return M_PI_2; }
#define M_PI_2
Definition: Constants.h:45

References M_PI_2.

Referenced by Interference2DParaCrystal::FTPDF().

◆ eta()

double Profile2DVoigt::eta ( ) const
inline

Definition at line 202 of file Profiles2D.h.

202 { return m_eta; }

References m_eta.

Referenced by Profile2DVoigt().

◆ gamma()

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

◆ omegaX()

double IProfile2D::omegaX ( ) const
inlineinherited

Definition at line 35 of file Profiles2D.h.

35 { return m_omega_x; }

References IProfile2D::m_omega_x.

◆ omegaY()

double IProfile2D::omegaY ( ) const
inlineinherited

Definition at line 36 of file Profiles2D.h.

36 { return m_omega_y; }

References IProfile2D::m_omega_y.

◆ parDefs()

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

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

Reimplemented from INode.

Definition at line 190 of file Profiles2D.h.

191  {
192  return {{"OmegaX", "nm", "Half-width along x axis", 0, INF, 1.},
193  {"OmegaY", "nm", "Half-width along y axis", 0, INF, 1.},
194  {"Gamma", "rad",
195  "direct-space orientation with respect to the first lattice vector", -M_PI_2,
196  +M_PI_2, 0},
197  {"Eta", "", "balances between Gauss (eta=0) and Lorentz (eta=1) limiting cases", 0,
198  1, .5}};
199  }

References INF, and M_PI_2.

◆ pythonConstructor()

std::string Profile2DVoigt::pythonConstructor ( ) const
overridevirtual

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

Reimplemented from IProfile2D.

Definition at line 239 of file Profiles2D.cpp.

240 {
241  ASSERT(m_P.size() == 4);
242  return Py::Fmt::printFunction(
243  className(), {{m_omega_x, "nm"}, {m_omega_y, "nm"}, {m_gamma, "rad"}, {m_eta, ""}});
244 }
std::string className() const final
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Definition: Profiles2D.h:188
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, className(), m_eta, IProfile2D::m_gamma, IProfile2D::m_omega_x, IProfile2D::m_omega_y, INode::m_P, and Py::Fmt::printFunction().

Here is the call graph for this function:

◆ standardizedFT2D()

double Profile2DVoigt::standardizedFT2D ( double  qx,
double  qy 
) const
overridevirtual

Fourier transformed distribution for q in X,Y coordinates the original distribution (in real space) is assumed to be normalized: total integral is equal to 1.

Implements IProfile2D.

Definition at line 216 of file Profiles2D.cpp.

217 {
218  double sum_sq = sumsq(qx, qy);
219  return m_eta * std::exp(-sum_sq / 2) + (1.0 - m_eta) * std::pow(1.0 + sum_sq, -1.5);
220 }
double sumsq(double qx, double qy) const
Definition: Profiles2D.cpp:41

References m_eta, and IProfile2D::sumsq().

Here is the call graph for this function:

◆ sumsq()

double IProfile2D::sumsq ( double  qx,
double  qy 
) const
protectedinherited

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

const double& Profile2DVoigt::m_eta
protected

Definition at line 209 of file Profiles2D.h.

Referenced by clone(), decayFT2D(), eta(), pythonConstructor(), and standardizedFT2D().

◆ m_gamma

◆ m_omega_x

◆ m_omega_y

◆ m_P


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