BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
InterferenceTwin.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Aggregate/InterferenceTwin.cpp
6 //! @brief Implements class InterferenceTwin.
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/Param/RealLimits.h"
17 #include <cmath>
18 
19 InterferenceTwin::InterferenceTwin(const R3& direction, double mean_distance, double std_dev)
20  : IInterference(0)
21  , m_direction(direction)
22  , m_distance(mean_distance)
23  , m_std_dev(std_dev)
24 {
25  if (m_direction.mag2() <= 0.0 || m_distance < 0.0 || m_std_dev < 0.0)
26  throw std::runtime_error(
27  "InterferenceTwin::validateParameters: mean distance, standard deviation and "
28  "length of direction vector should be positive");
31 }
32 
34 {
35  auto* result = new InterferenceTwin(m_direction, m_distance, m_std_dev);
36  result->setPositionVariance(m_position_var);
37  return result;
38 }
39 
41 {
42  return m_direction;
43 }
44 
46 {
47  return m_distance;
48 }
49 
51 {
52  return m_std_dev;
53 }
54 
55 double InterferenceTwin::iff_without_dw(const R3 q) const
56 {
57  double q_proj = q.dot(m_direction.unit());
58  return 1.0
59  + std::exp(-q_proj * q_proj * m_std_dev * m_std_dev / 2.0)
60  * std::cos(q_proj * m_distance);
61 }
Defines class InterferenceTwin.
Defines class RealLimits.
Abstract base class of interference functions.
Definition: IInterference.h:24
double m_position_var
Definition: IInterference.h:53
Interference function for two particles at a mean distance and given standard deviation from each oth...
double iff_without_dw(R3 q) const override
Calculates the structure factor without Debye-Waller factor.
InterferenceTwin * clone() const override
double meanDistance() const
double stdDev() const
InterferenceTwin(const R3 &direction, double mean_distance, double std_dev)
void check(const std::string &name, double value) const
Throws if value is outside limits. Parameter 'name' is for exception message.
Definition: RealLimits.cpp:170
static RealLimits nonnegative()
Creates an object which can have only positive values with 0. included.
Definition: RealLimits.cpp:124