BornAgain  1.18.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 scattering at grazing incidence
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 
17 #include "Base/Types/Exceptions.h"
20 
21 #include <limits>
22 
24  unsigned N_1, unsigned N_2,
25  unsigned N_3)
26  : IInterferenceFunction(0), m_N_1(N_1), m_N_2(N_2), m_N_3(N_3)
27 {
28  setName("InterferenceFinite3DLattice");
30 }
31 
33 
35 {
37  ret->setPositionVariance(m_position_var);
38  return ret;
39 }
40 
42 {
43  if (!mP_lattice)
44  throw std::runtime_error("InterferenceFunctionFinite3DLattice::lattice() -> Error. "
45  "No lattice defined.");
46  return *mP_lattice;
47 }
48 
49 std::vector<const INode*> InterferenceFunctionFinite3DLattice::getChildren() const
50 {
51  return std::vector<const INode*>() << mP_lattice;
52 }
53 
55 {
56  using MathFunctions::Laue;
57  const double qadiv2 = q.dot(mP_lattice->getBasisVectorA()) / 2.0;
58  const double qbdiv2 = q.dot(mP_lattice->getBasisVectorB()) / 2.0;
59  const double qcdiv2 = q.dot(mP_lattice->getBasisVectorC()) / 2.0;
60  const double ampl = Laue(qadiv2, m_N_1) * Laue(qbdiv2, m_N_2) * Laue(qcdiv2, m_N_3);
61  return ampl * ampl / (m_N_1 * m_N_2 * m_N_3);
62 }
63 
65 {
66  mP_lattice = std::make_unique<Lattice>(lattice);
68 }
Defines many exception classes in namespace Exceptionss.
Defines class InterferenceFunctionFinite3DLattice.
Defines M_PI and some more mathematical constants.
Defines namespace MathFunctions.
Defines class RealParameter.
auto dot(const BasicVector3D< U > &v) const
Returns dot product of vectors (antilinear in the first [=self] argument).
Pure virtual base class of interference functions.
void registerChild(INode *node)
Definition: INode.cpp:58
void setName(const std::string &name)
Interference function of a finite 3D lattice.
InterferenceFunctionFinite3DLattice(const Lattice &lattice, unsigned N_1, unsigned N_2, unsigned N_3)
double iff_without_dw(const kvector_t q) const override final
Calculates the structure factor without Debye-Waller factor.
std::vector< const INode * > getChildren() const override final
Returns a vector of children (const).
InterferenceFunctionFinite3DLattice * clone() const override final
Returns a clone of this ISample object.
unsigned m_N_3
Size of the finite lattice in lattice units.
A lattice with three basis vectors.
Definition: Lattice.h:28
double Laue(const double x, size_t N)
Real Laue function: .