BornAgain  1.18.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 scattering at grazing incidence
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  : IFormFactorBorn({"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]), m_scale_param(m_P[1]), m_n_samples(n_samples)
29 {
30 
31  DistributionLogNormal distri(m_mean, m_scale_param);
32  m_radii.clear();
33  m_probabilities.clear();
34  for (ParameterSample& sample : distri.equidistantSamples(m_n_samples)) {
35  m_radii.push_back(sample.value);
36  m_probabilities.push_back(sample.weight);
37  }
38 
39  onChange();
40 }
41 
43  size_t n_samples)
44  : FormFactorSphereLogNormalRadius(std::vector<double>{mean, scale_param}, n_samples)
45 {
46 }
47 
49 {
51 }
52 
54 {
55  complex_t result = 0;
56  for (size_t i = 0; i < m_radii.size(); ++i)
57  result += someff::ffSphere(q, m_radii[i]) * m_probabilities[i];
58  return result;
59 }
60 
62 {
63  mP_shape = std::make_unique<TruncatedEllipsoid>(m_mean, m_mean, m_mean, 2.0 * m_mean, 0.0);
64 }
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:24
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() override final
Action to be taken in inherited class when a parameter has changed.
FormFactorSphereLogNormalRadius * clone() const override final
Returns a clone of this ISample object.
FormFactorSphereLogNormalRadius(const std::vector< double > P, size_t n_samples=0)
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).
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.