BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
InterferenceFinite3DLattice.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Aggregate/InterferenceFinite3DLattice.cpp
6 //! @brief Implements class InterferenceFinite2DLattice.
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"
18 
19 #include <limits>
20 
22  unsigned N_2, unsigned N_3)
23  : IInterference(0)
24  , m_N_1(N_1)
25  , m_N_2(N_2)
26  , m_N_3(N_3)
27 {
29 }
30 
32 
34 {
35  auto* result = new InterferenceFinite3DLattice(*m_lattice, m_N_1, m_N_2, m_N_3);
36  result->setPositionVariance(m_position_var);
37  return result;
38 }
39 
41 {
42  if (!m_lattice)
43  throw std::runtime_error("InterferenceFinite3DLattice::lattice() -> Error. "
44  "No lattice defined.");
45  return *m_lattice;
46 }
47 
48 std::vector<const INode*> InterferenceFinite3DLattice::nodeChildren() 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->basisVectorA()) / 2.0;
57  const double qbdiv2 = q.dot(m_lattice->basisVectorB()) / 2.0;
58  const double qcdiv2 = q.dot(m_lattice->basisVectorC()) / 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 }
Defines M_PI and some more mathematical constants.
Defines namespace Math.
Defines class InterferenceFinite3DLattice.
Abstract base class of interference functions.
Definition: IInterference.h:24
double m_position_var
Definition: IInterference.h:53
Interference function of a finite 3D lattice.
~InterferenceFinite3DLattice() override
InterferenceFinite3DLattice * clone() const override
InterferenceFinite3DLattice(const Lattice3D &lattice, unsigned N_1, unsigned N_2, unsigned N_3)
void setLattice(const Lattice3D &lattice)
double iff_without_dw(R3 q) const override
Calculates the structure factor without Debye-Waller factor.
std::vector< const INode * > nodeChildren() const override
Returns all children.
std::unique_ptr< Lattice3D > m_lattice
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:30
double Laue(double x, size_t N)
Real Laue function: .
Definition: Functions.cpp:77