BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FormFactorSphereGaussianRadius.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/SoftParticle/FormFactorSphereGaussianRadius.cpp
6 //! @brief Implements class FormFactorSphereGaussianRadius.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
16 #include "Fit/Tools/RealLimits.h"
19 
21  : IFormFactorBorn({"FormFactorSphereGaussianRadius",
22  "class_tooltip",
23  {{"MeanRadius", "nm", "para_tooltip", 0, +INF, 0},
24  {"SigmaRadius", "nm", "para_tooltip", 0, +INF, 0}}},
25  P),
26  m_mean(m_P[0]), m_sigma(m_P[1])
27 {
28  m_mean_r3 = calculateMeanR3();
29  onChange();
30 }
31 
33  : FormFactorSphereGaussianRadius(std::vector<double>{mean, sigma})
34 {
35 }
36 
38 {
39  double q2 = std::norm(q.x()) + std::norm(q.y()) + std::norm(q.z());
40  double dw = std::exp(-q2 * m_sigma * m_sigma / 2.0);
41  return dw * exp_I(q.z() * m_mean_r3) * someff::ffSphere(q, m_mean_r3);
42  // TODO: don't center at bottom; revise mesocrystal1.py
43 }
44 
46 {
47  mP_shape = std::make_unique<TruncatedEllipsoid>(m_mean, m_mean, m_mean, 2.0 * m_mean, 0.0);
48 }
49 
51 {
52  return std::pow(m_mean * (m_mean * m_mean + 3.0 * m_sigma * m_sigma), 1.0 / 3.0);
53 }
std::complex< double > complex_t
Definition: Complex.h:20
complex_t exp_I(complex_t z)
Returns exp(I*z), where I is the imaginary unit.
Definition: Complex.h:30
Defines and implements class FormFactorSphereGaussianRadius.
const double INF
Definition: INode.h:24
Defines class RealLimits.
Declares namespace someff with some form factor functions.
Defines class TruncatedEllipsoid.
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:68
T y() const
Returns y-component in cartesian coordinate system.
Definition: BasicVector3D.h:66
T x() const
Returns x-component in cartesian coordinate system.
Definition: BasicVector3D.h:64
A sphere with gaussian radius distribution.
const double & m_mean
This is the mean radius.
double m_mean_r3
This is the radius that gives the mean volume.
void onChange() override final
Action to be taken in inherited class when a parameter has changed.
FormFactorSphereGaussianRadius(const std::vector< double > P)
complex_t evaluate_for_q(cvector_t q) const override final
Returns scattering amplitude for complex scattering wavevector q=k_i-k_f.
Pure virtual base class for Born form factors.
std::unique_ptr< IShape > mP_shape
IShape object, used to retrieve vertices (which may be approximate in the case of round shapes).
complex_t ffSphere(cvector_t q, double R)
Returns the form factor of a sphere of radius R.