BornAgain  1.18.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 scattering at grazing incidence
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 BORNAGAIN_CORE_CORRELATIONS_IPEAKSHAPE_H
16 #define BORNAGAIN_CORE_CORRELATIONS_IPEAKSHAPE_H
17 
19 
20 //! Pure virtual interface class that defines the peak shape of a Bragg peak.
21 //!
22 //! @ingroup samples_internal
23 
24 class IPeakShape : public ISample
25 {
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 {
48 public:
49  IsotropicGaussPeakShape(double max_intensity, double domainsize);
51 
52  IsotropicGaussPeakShape* clone() const override;
53 
54  void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
55 
56  double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
57 
58 private:
59  double evaluate(const kvector_t q) const;
61  double m_domainsize;
62 };
63 
64 //! An isotropic Lorentzian peak shape of a Bragg peak.
65 //!
66 //! @ingroup samples_internal
67 
69 {
70 public:
71  IsotropicLorentzPeakShape(double max_intensity, double domainsize);
73 
74  IsotropicLorentzPeakShape* clone() const override;
75 
76  void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
77 
78  double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
79 
80 private:
81  double evaluate(const kvector_t q) const;
83  double m_domainsize;
84 };
85 
86 //! A peak shape that is Gaussian in the radial direction and
87 //! uses the Mises-Fisher distribution in the angular direction.
88 //!
89 //! @ingroup samples_internal
90 
92 {
93 public:
94  GaussFisherPeakShape(double max_intensity, double radial_size, double kappa);
96 
97  GaussFisherPeakShape* clone() const override;
98 
99  void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
100 
101  double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
102 
103  bool angularDisorder() const override { return true; }
104 
105 private:
108  double m_kappa;
109 };
110 
111 //! A peak shape that is Lorentzian in the radial direction and uses the
112 //! Mises-Fisher distribution in the angular direction.
113 //!
114 //! @ingroup samples_internal
115 
117 {
118 public:
119  LorentzFisherPeakShape(double max_intensity, double radial_size, double kappa);
121 
122  LorentzFisherPeakShape* clone() const override;
123 
124  void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
125 
126  double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
127 
128  bool angularDisorder() const override { return true; }
129 
130 private:
133  double m_kappa;
134 };
135 
136 //! A peak shape that is Gaussian in the radial direction and a convolution of a
137 //! Mises-Fisher distribution with a Mises distribution on the two-sphere.
138 //!
139 //! @ingroup samples_internal
140 
142 {
143 public:
144  MisesFisherGaussPeakShape(double max_intensity, double radial_size, kvector_t zenith,
145  double kappa_1, double kappa_2);
147 
148  MisesFisherGaussPeakShape* clone() const override;
149 
150  void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
151 
152  double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
153 
154  bool angularDisorder() const override { return true; }
155 
156 private:
161 
162  double integrand(double phi) const;
163  mutable double m_theta, m_phi;
164  mutable kvector_t m_ux, m_uy, m_up;
165 };
166 
167 //! A peak shape that is a convolution of a Mises-Fisher distribution with a 3d Gaussian.
168 //!
169 //! @ingroup samples_internal
170 
172 {
173 public:
174  MisesGaussPeakShape(double max_intensity, double radial_size, kvector_t zenith, double kappa);
176 
177  MisesGaussPeakShape* clone() const override;
178 
179  void accept(INodeVisitor* visitor) const override { visitor->visit(this); }
180 
181  double evaluate(const kvector_t q, const kvector_t q_lattice_point) const override;
182 
183  bool angularDisorder() const override { return true; }
184 
185 private:
189  double m_kappa;
190 
191  double integrand(double phi) const;
192  mutable double m_theta, m_phi, m_qr;
193  mutable kvector_t m_ux, m_uy, m_p;
194 };
195 
196 #endif // BORNAGAIN_CORE_CORRELATIONS_IPEAKSHAPE_H
Defines interface class ISample.
A peak shape that is Gaussian in the radial direction and uses the Mises-Fisher distribution in the a...
Definition: IPeakShape.h:92
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:103
GaussFisherPeakShape(double max_intensity, double radial_size, double kappa)
Definition: IPeakShape.cpp:147
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:159
GaussFisherPeakShape * clone() const override
Returns a clone of this ISample object.
Definition: IPeakShape.cpp:154
void accept(INodeVisitor *visitor) const override
Calls the INodeVisitor's visit method.
Definition: IPeakShape.h:99
~GaussFisherPeakShape() override
Visitor interface to visit ISample objects.
Definition: INodeVisitor.h:149
virtual void visit(const BasicLattice *)
Definition: INodeVisitor.h:154
Pure virtual interface 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 ISample object.
IPeakShape()=default
Pure virtual base class for sample components and properties related to scattering.
Definition: ISample.h:28
Class that implements an isotropic Gaussian peak shape of a Bragg peak.
Definition: IPeakShape.h:47
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:111
IsotropicGaussPeakShape * clone() const override
Returns a clone of this ISample object.
Definition: IPeakShape.cpp:100
~IsotropicGaussPeakShape() override
void accept(INodeVisitor *visitor) const override
Calls the INodeVisitor's visit method.
Definition: IPeakShape.h:54
IsotropicGaussPeakShape(double max_intensity, double domainsize)
Definition: IPeakShape.cpp:93
An isotropic Lorentzian peak shape of a Bragg peak.
Definition: IPeakShape.h:69
IsotropicLorentzPeakShape(double max_intensity, double domainsize)
Definition: IPeakShape.cpp:120
IsotropicLorentzPeakShape * clone() const override
Returns a clone of this ISample object.
Definition: IPeakShape.cpp:127
void accept(INodeVisitor *visitor) const override
Calls the INodeVisitor's visit method.
Definition: IPeakShape.h:76
~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:138
A peak shape that is Lorentzian in the radial direction and uses the Mises-Fisher distribution in the...
Definition: IPeakShape.h:117
LorentzFisherPeakShape(double max_intensity, double radial_size, double kappa)
Definition: IPeakShape.cpp:180
~LorentzFisherPeakShape() override
LorentzFisherPeakShape * clone() const override
Returns a clone of this ISample object.
Definition: IPeakShape.cpp:188
void accept(INodeVisitor *visitor) const override
Calls the INodeVisitor's visit method.
Definition: IPeakShape.h:124
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:193
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:128
A peak shape that is Gaussian in the radial direction and a convolution of a Mises-Fisher distributio...
Definition: IPeakShape.h:142
MisesFisherGaussPeakShape * clone() const override
Returns a clone of this ISample object.
Definition: IPeakShape.cpp:223
double integrand(double phi) const
Definition: IPeakShape.cpp:260
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:154
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:229
MisesFisherGaussPeakShape(double max_intensity, double radial_size, kvector_t zenith, double kappa_1, double kappa_2)
Definition: IPeakShape.cpp:213
~MisesFisherGaussPeakShape() override
void accept(INodeVisitor *visitor) const override
Calls the INodeVisitor's visit method.
Definition: IPeakShape.h:150
A peak shape that is a convolution of a Mises-Fisher distribution with a 3d Gaussian.
Definition: IPeakShape.h:172
~MisesGaussPeakShape() override
MisesGaussPeakShape(double max_intensity, double radial_size, kvector_t zenith, double kappa)
Definition: IPeakShape.cpp:273
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:183
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:287
MisesGaussPeakShape * clone() const override
Returns a clone of this ISample object.
Definition: IPeakShape.cpp:282
kvector_t m_zenith
Definition: IPeakShape.h:188
void accept(INodeVisitor *visitor) const override
Calls the INodeVisitor's visit method.
Definition: IPeakShape.h:179
double integrand(double phi) const
Definition: IPeakShape.cpp:308
Metadata of one model node.
Definition: INode.h:37