24 const double maxkappa = std::log(1.0 / std::numeric_limits<double>::epsilon()) / 2.0;
25 const double maxkappa2 = std::log(std::numeric_limits<double>::max());
30 return 1.0 / (4.0 *
M_PI);
34 return 2.0 *
prefactor * std::exp(kappa * (x - 1.0));
36 return prefactor * std::exp(kappa * x) / std::sinh(kappa);
42 return 1.0 / (4.0 *
M_PI);
45 return kappa / 2.0 /
M_PI;
47 return kappa * std::exp(kappa) / 4.0 /
M_PI / std::sinh(kappa);
54 return 1.0 / (2.0 *
M_PI);
57 return std::sqrt(kappa / 2.0 /
M_PI) / (1.0 + 1.0 / (8.0 * kappa));
63 double Gauss3D(
double q2,
double domainsize)
65 double norm_factor = std::pow(domainsize / std::sqrt(
M_TWOPI), 3.0);
66 double exponent = -q2 * domainsize * domainsize / 2.0;
67 return norm_factor * std::exp(exponent);
72 double lorentz1 = domainsize / (1.0 + q2 * domainsize * domainsize) /
M_PI;
73 return domainsize * lorentz1 * lorentz1;
94 : m_max_intensity(max_intensity), m_domainsize(domainsize)
107 double q_norm = q.
mag2();
113 return evaluate(q - q_lattice_point);
121 : m_max_intensity(max_intensity), m_domainsize(domainsize)
134 double q_norm = q.
mag2();
140 return evaluate(q - q_lattice_point);
148 : m_max_intensity(max_intensity), m_radial_size(radial_size), m_kappa(kappa)
161 double q_r = q.
mag();
162 double q_lat_r = q_lattice_point.
mag();
163 double dq2 = (q_r - q_lat_r) * (q_r - q_lat_r);
168 double angular_part = 1.0;
169 if (q_r * q_lat_r > 0.0) {
170 double dot_norm = q.
dot(q_lattice_point) / q_r / q_lat_r;
182 : m_max_intensity(max_intensity), m_radial_size(radial_size), m_kappa(kappa)
195 double q_r = q.
mag();
196 double q_lat_r = q_lattice_point.
mag();
197 double dq2 = (q_r - q_lat_r) * (q_r - q_lat_r);
201 double angular_part = 1.0;
202 if (q_r * q_lat_r > 0.0) {
203 double dot_norm = q.
dot(q_lattice_point) / q_r / q_lat_r;
216 : m_max_intensity(max_intensity), m_radial_size(radial_size), m_zenith(zenith.unit()),
217 m_kappa_1(kappa_1), m_kappa_2(kappa_2)
232 double q_r = q.
mag();
233 double q_lat_r = q_lattice_point.
mag();
234 double dq2 = (q_r - q_lat_r) * (q_r - q_lat_r);
235 if (q_lat_r == 0.0 || q_r == 0.0)
265 double vonmises = std::exp(
m_kappa_2 * (std::cos(
m_phi - phi) - 1.0));
266 return fisher * vonmises;
275 : m_max_intensity(max_intensity), m_radial_size(radial_size), m_zenith(zenith.unit()),
292 double dq2 = (q - q_lattice_point).mag2();
296 m_p = q_lattice_point;
313 double dq2 = (q_rot -
m_p).mag2();
315 double vonmises = std::exp(
m_kappa * (std::cos(
m_phi - phi) - 1.0));
316 return gauss * vonmises;
Defines the interface IPeakShape and subclasses.
Defines classes RealIntegrator, ComplexIntegrator.
Defines M_PI and some more mathematical constants.
Defines namespace MathFunctions.
double mag2() const
Returns magnitude squared of the vector.
auto dot(const BasicVector3D< U > &v) const
Returns dot product of vectors (antilinear in the first [=self] argument).
BasicVector3D< T > unit() const
Returns unit vector in direction of this. Throws for null vector.
double mag() const
Returns magnitude of the vector.
auto cross(const BasicVector3D< U > &v) const
Returns cross product of vectors (linear in both arguments).
A peak shape that is Gaussian in the radial direction and uses the Mises-Fisher distribution in the a...
GaussFisherPeakShape(double max_intensity, double radial_size, double kappa)
double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override
Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point.
GaussFisherPeakShape * clone() const override
Returns a clone of this ISample object.
~GaussFisherPeakShape() override
Pure virtual base class for sample components and properties related to scattering.
Class that implements an isotropic Gaussian peak shape of a Bragg peak.
double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override
Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point.
IsotropicGaussPeakShape * clone() const override
Returns a clone of this ISample object.
~IsotropicGaussPeakShape() override
IsotropicGaussPeakShape(double max_intensity, double domainsize)
An isotropic Lorentzian peak shape of a Bragg peak.
IsotropicLorentzPeakShape(double max_intensity, double domainsize)
IsotropicLorentzPeakShape * clone() const override
Returns a clone of this ISample object.
~IsotropicLorentzPeakShape() override
double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override
Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point.
A peak shape that is Lorentzian in the radial direction and uses the Mises-Fisher distribution in the...
LorentzFisherPeakShape(double max_intensity, double radial_size, double kappa)
~LorentzFisherPeakShape() override
LorentzFisherPeakShape * clone() const override
Returns a clone of this ISample object.
double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override
Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point.
A peak shape that is Gaussian in the radial direction and a convolution of a Mises-Fisher distributio...
MisesFisherGaussPeakShape * clone() const override
Returns a clone of this ISample object.
double integrand(double phi) const
double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override
Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point.
MisesFisherGaussPeakShape(double max_intensity, double radial_size, kvector_t zenith, double kappa_1, double kappa_2)
~MisesFisherGaussPeakShape() override
A peak shape that is a convolution of a Mises-Fisher distribution with a 3d Gaussian.
~MisesGaussPeakShape() override
MisesGaussPeakShape(double max_intensity, double radial_size, kvector_t zenith, double kappa)
double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override
Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point.
MisesGaussPeakShape * clone() const override
Returns a clone of this ISample object.
double integrand(double phi) const
To integrate a real function of a real variable.
double integrate(const std::function< double(double)> &f, double lmin, double lmax)
double Bessel_I0(double x)
Modified Bessel function of the first kind and order 0.
static constexpr double gauss
double Cauchy3D(double q2, double domainsize)
double FisherPrefactor(double kappa)
double Gauss3D(double q2, double domainsize)
double MisesPrefactor(double kappa)
double FisherDistribution(double x, double kappa)