BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
InterferenceFunctionFinite3DLattice.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Aggregate/InterferenceFunctionFinite3DLattice.cpp
6 //! @brief Implements class InterferenceFunctionFinite2DLattice.
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 "Base/Math/Constants.h"
17 #include "Base/Math/Functions.h"
19 
20 #include <limits>
21 
23  unsigned N_1, unsigned N_2,
24  unsigned N_3)
25  : IInterferenceFunction(0), m_N_1(N_1), m_N_2(N_2), m_N_3(N_3)
26 {
27  setName("InterferenceFinite3DLattice");
29 }
30 
32 
34 {
36  ret->setPositionVariance(m_position_var);
37  return ret;
38 }
39 
41 {
42  if (!m_lattice)
43  throw std::runtime_error("InterferenceFunctionFinite3DLattice::lattice() -> Error. "
44  "No lattice defined.");
45  return *m_lattice;
46 }
47 
48 std::vector<const INode*> InterferenceFunctionFinite3DLattice::getChildren() const
49 {
50  return std::vector<const INode*>() << m_lattice;
51 }
52 
54 {
55  using Math::Laue;
56  const double qadiv2 = q.dot(m_lattice->getBasisVectorA()) / 2.0;
57  const double qbdiv2 = q.dot(m_lattice->getBasisVectorB()) / 2.0;
58  const double qcdiv2 = q.dot(m_lattice->getBasisVectorC()) / 2.0;
59  const double ampl = Laue(qadiv2, m_N_1) * Laue(qbdiv2, m_N_2) * Laue(qcdiv2, m_N_3);
60  return ampl * ampl / (m_N_1 * m_N_2 * m_N_3);
61 }
62 
64 {
65  m_lattice = std::make_unique<Lattice3D>(lattice);
66  registerChild(m_lattice.get());
67 }
Defines M_PI and some more mathematical constants.
Defines functions in namespace Math.
Defines class InterferenceFunctionFinite3DLattice.
Defines class RealParameter.
auto dot(const BasicVector3D< U > &v) const
Returns dot product of vectors (antilinear in the first [=self] argument).
Abstract base class of interference functions.
void registerChild(INode *node)
Definition: INode.cpp:57
void setName(const std::string &name)
Interference function of a finite 3D lattice.
double iff_without_dw(const kvector_t q) const override
Calculates the structure factor without Debye-Waller factor.
InterferenceFunctionFinite3DLattice * clone() const override
Returns a clone of this ISampleNode object.
InterferenceFunctionFinite3DLattice(const Lattice3D &lattice, unsigned N_1, unsigned N_2, unsigned N_3)
std::vector< const INode * > getChildren() const override
Returns a vector of children.
unsigned m_N_3
Size of the finite lattice in lattice units.
A Bravais lattice, characterized by three basis vectors, and optionally an ISelectionRule.
Definition: Lattice3D.h:29
double Laue(const double x, size_t N)
Real Laue function: .
Definition: Functions.cpp:76