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

Description

A peak shape that is Gaussian in the radial direction and a convolution of a Mises-Fisher distribution with a Mises distribution on the two-sphere.

Definition at line 145 of file IPeakShape.h.

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

Public Member Functions

 MisesFisherGaussPeakShape (double max_intensity, double radial_size, R3 zenith, double kappa_1, double kappa_2)
 
 ~MisesFisherGaussPeakShape () override
 
bool angularDisorder () const override
 Indicates if the peak shape encodes angular disorder, in which case all peaks in a spherical shell are needed. 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...
 
MisesFisherGaussPeakShapeclone () 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...
 
double peakDistribution (R3 q, R3 q_lattice_point) const override
 Peak shape at q from a reciprocal lattice point at q_lattice_point. 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_kappa_1
 
double m_kappa_2
 
double m_max_intensity
 
double m_radial_size
 
R3 m_zenith
 

Constructor & Destructor Documentation

◆ MisesFisherGaussPeakShape()

MisesFisherGaussPeakShape::MisesFisherGaussPeakShape ( double  max_intensity,
double  radial_size,
R3  zenith,
double  kappa_1,
double  kappa_2 
)

Definition at line 210 of file IPeakShape.cpp.

212  : m_max_intensity(max_intensity)
213  , m_radial_size(radial_size)
214  , m_zenith(zenith.unit())
215  , m_kappa_1(kappa_1)
216  , m_kappa_2(kappa_2)
217 {
218 }

Referenced by clone().

◆ ~MisesFisherGaussPeakShape()

MisesFisherGaussPeakShape::~MisesFisherGaussPeakShape ( )
overridedefault

Member Function Documentation

◆ angularDisorder()

bool MisesFisherGaussPeakShape::angularDisorder ( ) const
inlineoverridevirtual

Indicates if the peak shape encodes angular disorder, in which case all peaks in a spherical shell are needed.

Reimplemented from IPeakShape.

Definition at line 163 of file IPeakShape.h.

163 { return true; }

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

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

Implements INode.

Definition at line 152 of file IPeakShape.h.

152 { return "MisesFisherGaussPeakShape"; }

◆ clone()

MisesFisherGaussPeakShape * MisesFisherGaussPeakShape::clone ( ) const
overridevirtual

Implements IPeakShape.

Definition at line 222 of file IPeakShape.cpp.

223 {
225  m_kappa_2);
226 }
MisesFisherGaussPeakShape(double max_intensity, double radial_size, R3 zenith, double kappa_1, double kappa_2)
Definition: IPeakShape.cpp:210

References MisesFisherGaussPeakShape(), m_kappa_1, m_kappa_2, m_max_intensity, m_radial_size, and m_zenith.

Here is the call graph for this function:

◆ 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> MisesFisherGaussPeakShape::parDefs ( ) const
inlinefinalvirtual

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

Reimplemented from INode.

Definition at line 153 of file IPeakShape.h.

154  {
155  return {{"MaxIntensity", "", "maximum intensity", 0, +INF, -1},
156  {"Radial Size", "nm", "radial size", 0, +INF, -1},
157  {"Kappa1", "", "?", 0, +INF, -1},
158  {"Kappa2", "", "?", 0, +INF, -1}};
159  }

References INF.

◆ peakDistribution()

double MisesFisherGaussPeakShape::peakDistribution ( R3  q,
R3  q_lattice_point 
) const
overridevirtual

Peak shape at q from a reciprocal lattice point at q_lattice_point.

Implements IPeakShape.

Definition at line 228 of file IPeakShape.cpp.

229 {
230  // radial part
231  const double q_r = q.mag();
232  const double q_lat_r = q_lattice_point.mag();
233  const double dq2 = (q_r - q_lat_r) * (q_r - q_lat_r);
234  if (q_lat_r == 0.0 || q_r == 0.0)
235  return m_max_intensity * Gauss3D(dq2, m_radial_size);
236  const double norm_factor = m_radial_size / std::sqrt(M_TWOPI);
237  const double radial_part = norm_factor * std::exp(-dq2 * m_radial_size * m_radial_size / 2.0);
238  // angular part
239  const R3 vy = m_zenith.cross(q_lattice_point);
240  const R3 zxq = m_zenith.cross(q);
241  const R3 up = q_lattice_point.unit();
242  if (vy.mag2() <= 0.0 || zxq.mag2() <= 0.0) {
243  const double x = q.unit().dot(up);
244  const double angular_part = FisherDistribution(x, m_kappa_1);
245  return m_max_intensity * radial_part * angular_part;
246  }
247  const R3 uy = vy.unit();
248  const R3 ux = uy.cross(m_zenith);
249  const R3 q_ortho = q - q.dot(m_zenith) * m_zenith;
250  const double phi0 = std::acos(q_ortho.unit().dot(ux));
251  const double theta = std::acos(q.unit().dot(m_zenith));
252  const double pre_1 = FisherPrefactor(m_kappa_1);
253  const double pre_2 = MisesPrefactor(m_kappa_2);
254  const double integral = RealIntegrator().integrate(
255  [=](double phi) -> double {
256  const R3 u_q = std::sin(theta) * std::cos(phi) * ux
257  + std::sin(theta) * std::sin(phi) * uy + std::cos(theta) * m_zenith;
258  const double fisher = std::exp(m_kappa_1 * (u_q.dot(up) - 1.0));
259  const double mises = std::exp(m_kappa_2 * (std::cos(phi0 - phi) - 1.0));
260  return fisher * mises;
261  },
262  0.0, M_TWOPI);
263  return m_max_intensity * radial_part * pre_1 * pre_2 * integral;
264 }
#define M_TWOPI
Definition: Constants.h:54
To integrate a real function of a real variable.
Definition: IntegratorGK.h:28
double integrate(const std::function< double(double)> &f, double lmin, double lmax)

References RealIntegrator::integrate(), m_kappa_1, m_kappa_2, m_max_intensity, m_radial_size, M_TWOPI, and m_zenith.

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_kappa_1

double MisesFisherGaussPeakShape::m_kappa_1
private

Definition at line 169 of file IPeakShape.h.

Referenced by clone(), and peakDistribution().

◆ m_kappa_2

double MisesFisherGaussPeakShape::m_kappa_2
private

Definition at line 169 of file IPeakShape.h.

Referenced by clone(), and peakDistribution().

◆ m_max_intensity

double MisesFisherGaussPeakShape::m_max_intensity
private

Definition at line 166 of file IPeakShape.h.

Referenced by clone(), and peakDistribution().

◆ m_P

◆ m_radial_size

double MisesFisherGaussPeakShape::m_radial_size
private

Definition at line 167 of file IPeakShape.h.

Referenced by clone(), and peakDistribution().

◆ m_zenith

R3 MisesFisherGaussPeakShape::m_zenith
private

Definition at line 168 of file IPeakShape.h.

Referenced by clone(), and peakDistribution().


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