BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FormFactorSphereLogNormalRadius.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/SoftParticle/FormFactorSphereLogNormalRadius.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 
20 
22  size_t n_samples)
23  : IBornFF({"FormFactorSphereLogNormalRadius",
24  "class_tooltip",
25  {{"MeanRadius", "nm", "para_tooltip", 0, +INF, 0},
26  {"ScaleParameter", "", "para_tooltip", -INF, +INF, 0}}},
27  P)
28  , m_mean(m_P[0])
29  , m_scale_param(m_P[1])
30  , m_n_samples(n_samples)
31 {
32 
33  DistributionLogNormal distri(m_mean, m_scale_param);
34  m_radii.clear();
35  m_probabilities.clear();
36  for (ParameterSample& sample : distri.equidistantSamples(m_n_samples)) {
37  m_radii.push_back(sample.value);
38  m_probabilities.push_back(sample.weight);
39  }
40 
41  onChange();
42 }
43 
45  size_t n_samples)
46  : FormFactorSphereLogNormalRadius(std::vector<double>{mean, scale_param}, n_samples)
47 {
48 }
49 
51 {
53 }
54 
56 {
57  complex_t result = 0;
58  for (size_t i = 0; i < m_radii.size(); ++i)
59  result += someff::ffSphere(q, m_radii[i]) * m_probabilities[i];
60  return result;
61 }
62 
64 {
65  m_shape3D = std::make_unique<TruncatedEllipsoid>(m_mean, m_mean, m_mean, 2.0 * m_mean, 0.0);
66 }
std::complex< double > complex_t
Definition: Complex.h:20
Defines classes representing one-dimensional distributions.
Defines and implements class FormFactorSphereLogNormalRadius.
const double INF
Definition: INode.h:25
Defines class ParameterSample.
Declares namespace someff with some form factor functions.
Defines class TruncatedEllipsoid.
Log-normal distribution.
A sphere with log normal radius distribution.
void onChange() final
Action to be taken in inherited class when a parameter has changed.
FormFactorSphereLogNormalRadius * clone() const final
Returns a clone of this ISampleNode object.
FormFactorSphereLogNormalRadius(const std::vector< double > P, size_t n_samples=0)
complex_t evaluate_for_q(cvector_t q) const final
Returns scattering amplitude for complex scattering wavevector q=k_i-k_f.
Abstract base class for Born form factors.
Definition: IBornFF.h:41
std::unique_ptr< IShape3D > m_shape3D
IShape3D object, used to retrieve vertices (which may be approximate in the case of round shapes).
Definition: IBornFF.h:77
A parameter value with a weight, as obtained when sampling from a distribution.
complex_t ffSphere(cvector_t q, double R)
Returns the form factor of a sphere of radius R.
Definition: filesystem.h:81