BornAgain  1.19.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 reflection and scattering
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)
22  , m_direction(direction)
23  , m_distance(mean_distance)
24  , m_std_dev(std_dev)
25 {
26  setName("InterferenceTwin");
27  if (m_direction.mag2() <= 0.0 || m_distance < 0.0 || m_std_dev < 0.0)
28  throw std::runtime_error(
29  "InterferenceFunctionTwin::validateParameters: mean distance, standard deviation and "
30  "length of direction vector should be positive");
31  registerVector("Direction", &m_direction, "");
34 }
35 
37 {
39  ret->setPositionVariance(m_position_var);
40  return ret;
41 }
42 
44 {
45  return m_direction;
46 }
47 
49 {
50  return m_distance;
51 }
52 
54 {
55  return m_std_dev;
56 }
57 
59 {
60  double q_proj = q.dot(m_direction.unit());
61  return 1.0
62  + std::exp(-q_proj * q_proj * m_std_dev * m_std_dev / 2.0)
63  * std::cos(q_proj * m_distance);
64 }
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.
Abstract base class of interference functions.
void registerVector(const std::string &base_name, kvector_t *p_vec, const std::string &units="nm")
void setName(const std::string &name)
RealParameter & registerParameter(const std::string &name, double *parpointer)
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 final
Calculates the structure factor without Debye-Waller factor.
InterferenceFunctionTwin * clone() const final
Returns a clone of this ISampleNode object.
RealParameter & setNonnegative()
RealParameter & setUnit(const std::string &name)