BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
IPeakShape.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/Correlations/IPeakShape.h
6 //! @brief Defines the interface IPeakShape and subclasses.
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 
15 #ifndef USER_API
16 #ifndef BORNAGAIN_SAMPLE_CORRELATIONS_IPEAKSHAPE_H
17 #define BORNAGAIN_SAMPLE_CORRELATIONS_IPEAKSHAPE_H
18 
20 
21 //! Abstract base class class that defines the peak shape of a Bragg peak.
22 //!
23 //! @ingroup samples_internal
24 
25 class IPeakShape : public ISampleNode {
26 public:
27  IPeakShape() = default;
28  IPeakShape(const NodeMeta& meta, const std::vector<double>& PValues);
29 
30  virtual ~IPeakShape();
31 
32  virtual IPeakShape* clone() const = 0;
33 
34  //! Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point
35  virtual double evaluate(const kvector_t q, const kvector_t q_lattice_point) const = 0;
36 
37  //! Indicates if the peak shape encodes angular disorder, in which case all peaks in a
38  //! spherical shell are needed
39  virtual bool angularDisorder() const { return false; }
40 };
41 
42 //! Class that implements an isotropic Gaussian peak shape of a Bragg peak.
43 //!
44 //! @ingroup samples_internal
45 
47 public:
48  IsotropicGaussPeakShape(double max_intensity, double domainsize);
50 
51  IsotropicGaussPeakShape* clone() const override;
52 
53  void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
54 
55  double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
56 
57 private:
58  double evaluate(const kvector_t q) const;
60  double m_domainsize;
61 };
62 
63 //! An isotropic Lorentzian peak shape of a Bragg peak.
64 //!
65 //! @ingroup samples_internal
66 
68 public:
69  IsotropicLorentzPeakShape(double max_intensity, double domainsize);
71 
72  IsotropicLorentzPeakShape* clone() const override;
73 
74  void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
75 
76  double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
77 
78 private:
79  double evaluate(const kvector_t q) const;
81  double m_domainsize;
82 };
83 
84 //! A peak shape that is Gaussian in the radial direction and
85 //! uses the Mises-Fisher distribution in the angular direction.
86 //!
87 //! @ingroup samples_internal
88 
90 public:
91  GaussFisherPeakShape(double max_intensity, double radial_size, double kappa);
93 
94  GaussFisherPeakShape* clone() const override;
95 
96  void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
97 
98  double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
99 
100  bool angularDisorder() const override { return true; }
101 
102 private:
105  double m_kappa;
106 };
107 
108 //! A peak shape that is Lorentzian in the radial direction and uses the
109 //! Mises-Fisher distribution in the angular direction.
110 //!
111 //! @ingroup samples_internal
112 
114 public:
115  LorentzFisherPeakShape(double max_intensity, double radial_size, double kappa);
117 
118  LorentzFisherPeakShape* clone() const override;
119 
120  void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
121 
122  double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
123 
124  bool angularDisorder() const override { return true; }
125 
126 private:
129  double m_kappa;
130 };
131 
132 //! A peak shape that is Gaussian in the radial direction and a convolution of a
133 //! Mises-Fisher distribution with a Mises distribution on the two-sphere.
134 //!
135 //! @ingroup samples_internal
136 
138 public:
139  MisesFisherGaussPeakShape(double max_intensity, double radial_size, kvector_t zenith,
140  double kappa_1, double kappa_2);
142 
143  MisesFisherGaussPeakShape* clone() const override;
144 
145  void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
146 
147  double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
148 
149  bool angularDisorder() const override { return true; }
150 
151 private:
156 
157  double integrand(double phi) const;
158  mutable double m_theta, m_phi;
159  mutable kvector_t m_ux, m_uy, m_up;
160 };
161 
162 //! A peak shape that is a convolution of a Mises-Fisher distribution with a 3d Gaussian.
163 //!
164 //! @ingroup samples_internal
165 
167 public:
168  MisesGaussPeakShape(double max_intensity, double radial_size, kvector_t zenith, double kappa);
170 
171  MisesGaussPeakShape* clone() const override;
172 
173  void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
174 
175  double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
176 
177  bool angularDisorder() const override { return true; }
178 
179 private:
183  double m_kappa;
184 
185  double integrand(double phi) const;
186  mutable double m_theta, m_phi, m_qr;
187  mutable kvector_t m_ux, m_uy, m_p;
188 };
189 
190 #endif // BORNAGAIN_SAMPLE_CORRELATIONS_IPEAKSHAPE_H
191 #endif // USER_API
Defines interface class ISampleNode.
A peak shape that is Gaussian in the radial direction and uses the Mises-Fisher distribution in the a...
Definition: IPeakShape.h:89
bool angularDisorder() const override
Indicates if the peak shape encodes angular disorder, in which case all peaks in a spherical shell ar...
Definition: IPeakShape.h:100
GaussFisherPeakShape(double max_intensity, double radial_size, double kappa)
Definition: IPeakShape.cpp:146
double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override
Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point.
Definition: IPeakShape.cpp:158
GaussFisherPeakShape * clone() const override
Returns a clone of this ISampleNode object.
Definition: IPeakShape.cpp:153
void accept(INodeVisitor *visitor) const override
Calls the INodeVisitor's visit method.
Definition: IPeakShape.h:96
~GaussFisherPeakShape() override
Visitor interface to visit ISampleNode objects.
Definition: INodeVisitor.h:146
virtual void visit(const BasicLattice2D *)
Definition: INodeVisitor.h:151
Abstract base class class that defines the peak shape of a Bragg peak.
Definition: IPeakShape.h:25
virtual double evaluate(const kvector_t q, const kvector_t q_lattice_point) const =0
Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point.
virtual bool angularDisorder() const
Indicates if the peak shape encodes angular disorder, in which case all peaks in a spherical shell ar...
Definition: IPeakShape.h:39
virtual ~IPeakShape()
virtual IPeakShape * clone() const =0
Returns a clone of this ISampleNode object.
IPeakShape()=default
Abstract base class for sample components and properties related to scattering.
Definition: ISampleNode.h:28
Class that implements an isotropic Gaussian peak shape of a Bragg peak.
Definition: IPeakShape.h:46
double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override
Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point.
Definition: IPeakShape.cpp:110
IsotropicGaussPeakShape * clone() const override
Returns a clone of this ISampleNode object.
Definition: IPeakShape.cpp:99
~IsotropicGaussPeakShape() override
void accept(INodeVisitor *visitor) const override
Calls the INodeVisitor's visit method.
Definition: IPeakShape.h:53
IsotropicGaussPeakShape(double max_intensity, double domainsize)
Definition: IPeakShape.cpp:92
An isotropic Lorentzian peak shape of a Bragg peak.
Definition: IPeakShape.h:67
IsotropicLorentzPeakShape(double max_intensity, double domainsize)
Definition: IPeakShape.cpp:119
IsotropicLorentzPeakShape * clone() const override
Returns a clone of this ISampleNode object.
Definition: IPeakShape.cpp:126
void accept(INodeVisitor *visitor) const override
Calls the INodeVisitor's visit method.
Definition: IPeakShape.h:74
~IsotropicLorentzPeakShape() override
double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override
Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point.
Definition: IPeakShape.cpp:137
A peak shape that is Lorentzian in the radial direction and uses the Mises-Fisher distribution in the...
Definition: IPeakShape.h:113
LorentzFisherPeakShape(double max_intensity, double radial_size, double kappa)
Definition: IPeakShape.cpp:179
~LorentzFisherPeakShape() override
LorentzFisherPeakShape * clone() const override
Returns a clone of this ISampleNode object.
Definition: IPeakShape.cpp:187
void accept(INodeVisitor *visitor) const override
Calls the INodeVisitor's visit method.
Definition: IPeakShape.h:120
double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override
Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point.
Definition: IPeakShape.cpp:192
bool angularDisorder() const override
Indicates if the peak shape encodes angular disorder, in which case all peaks in a spherical shell ar...
Definition: IPeakShape.h:124
A peak shape that is Gaussian in the radial direction and a convolution of a Mises-Fisher distributio...
Definition: IPeakShape.h:137
MisesFisherGaussPeakShape * clone() const override
Returns a clone of this ISampleNode object.
Definition: IPeakShape.cpp:225
double integrand(double phi) const
Definition: IPeakShape.cpp:262
bool angularDisorder() const override
Indicates if the peak shape encodes angular disorder, in which case all peaks in a spherical shell ar...
Definition: IPeakShape.h:149
double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override
Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point.
Definition: IPeakShape.cpp:231
MisesFisherGaussPeakShape(double max_intensity, double radial_size, kvector_t zenith, double kappa_1, double kappa_2)
Definition: IPeakShape.cpp:212
~MisesFisherGaussPeakShape() override
void accept(INodeVisitor *visitor) const override
Calls the INodeVisitor's visit method.
Definition: IPeakShape.h:145
A peak shape that is a convolution of a Mises-Fisher distribution with a 3d Gaussian.
Definition: IPeakShape.h:166
~MisesGaussPeakShape() override
MisesGaussPeakShape(double max_intensity, double radial_size, kvector_t zenith, double kappa)
Definition: IPeakShape.cpp:275
bool angularDisorder() const override
Indicates if the peak shape encodes angular disorder, in which case all peaks in a spherical shell ar...
Definition: IPeakShape.h:177
double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override
Evaluates the peak shape at q from a reciprocal lattice point at q_lattice_point.
Definition: IPeakShape.cpp:291
MisesGaussPeakShape * clone() const override
Returns a clone of this ISampleNode object.
Definition: IPeakShape.cpp:286
kvector_t m_zenith
Definition: IPeakShape.h:182
void accept(INodeVisitor *visitor) const override
Calls the INodeVisitor's visit method.
Definition: IPeakShape.h:173
double integrand(double phi) const
Definition: IPeakShape.cpp:312
Metadata of one model node.
Definition: INode.h:38