BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
InterferenceFunctionTwin.cpp
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Sample/Aggregate/InterferenceFunctionTwin.cpp
6 //! @brief Implements class InterferenceFunctionTwin.
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 
17 #include <cmath>
18 
19 InterferenceFunctionTwin::InterferenceFunctionTwin(const kvector_t& direction, double mean_distance,
20  double std_dev)
21  : IInterferenceFunction(0), m_direction(direction), m_distance(mean_distance),
22  m_std_dev(std_dev)
23 {
24  setName("InterferenceTwin");
25  if (m_direction.mag2() <= 0.0 || m_distance < 0.0 || m_std_dev < 0.0)
26  throw std::runtime_error(
27  "InterferenceFunctionTwin::validateParameters: mean distance, standard deviation and "
28  "length of direction vector should be positive");
29  registerVector("Direction", &m_direction, "");
32 }
33 
35 {
37  ret->setPositionVariance(m_position_var);
38  return ret;
39 }
40 
42 {
43  return m_direction;
44 }
45 
47 {
48  return m_distance;
49 }
50 
52 {
53  return m_std_dev;
54 }
55 
57 {
58  double q_proj = q.dot(m_direction.unit());
59  return 1.0
60  + std::exp(-q_proj * q_proj * m_std_dev * m_std_dev / 2.0)
61  * std::cos(q_proj * m_distance);
62 }
Defines class InterferenceFunctionTwin.
Defines class RealParameter.
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.
Pure virtual base class of interference functions.
RealParameter & registerParameter(const std::string &name, double *parpointer)
void setName(const std::string &name)
void registerVector(const std::string &base_name, kvector_t *p_vec, const std::string &units="nm")
Interference function for two particles at a mean distance and given standard deviation from each oth...
InterferenceFunctionTwin(const kvector_t &direction, double mean_distance, double std_dev)
double iff_without_dw(const kvector_t q) const override final
Calculates the structure factor without Debye-Waller factor.
InterferenceFunctionTwin * clone() const override final
Returns a clone of this ISample object.
RealParameter & setNonnegative()
RealParameter & setUnit(const std::string &name)