-
Notifications
You must be signed in to change notification settings - Fork 122
/
ThermalNeutronBk2BkExpConvPVoigt.h
203 lines (156 loc) · 6.49 KB
/
ThermalNeutronBk2BkExpConvPVoigt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#ifndef MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPCONVPVOIGT_H_
#define MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPCONVPVOIGT_H_
#include "MantidKernel/System.h"
#include "MantidAPI/IPowderDiffPeakFunction.h"
#include <complex>
namespace Mantid {
namespace CurveFitting {
namespace Functions {
/** ThermalNeutronBk2BkExpConvPVoigt :
Back-to-back exponential convoluted with pseudo Voigt for thermal neutron
and epithermal neutron TOF
It will involve the calculation from peak's miller indices
Copyright © 2012 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport ThermalNeutronBk2BkExpConvPVoigt
: public API::IPowderDiffPeakFunction {
public:
ThermalNeutronBk2BkExpConvPVoigt();
/// Overwrite IFunction base class methods
std::string name() const override {
return "ThermalNeutronBk2BkExpConvPVoigt";
}
const std::string category() const override { return "General"; }
/// Overwrite IPeakFunction base class methods
/*
virtual double centre()const;
virtual double fwhm()const;
virtual void setHeight(const double h);
virtual void setPeakRadius(const int& r);
*/
//--------------- ThermalNeutron peak function special
//---------------------------------------
/// Set Miller Indicies
// virtual void setMillerIndex(int h, int k, int l);
/// Get Miller Index from this peak
// virtual void getMillerIndex(int& h, int &k, int &l);
/// Get peak parameters
double getPeakParameter(std::string) override;
/// Calculate peak parameters (alpha, beta, sigma2..)
void calculateParameters(bool explicitoutput) const override;
/// Core function to calcualte peak values for whole region
// void functionLocal(vector<double>& out, const vector<double> &xValues)
// const;
/// Set up the flag to show whether (from client) cell parameter value changed
/*
void setUnitCellParameterValueChangeFlag(bool changed)
{
m_cellParamValueChanged = changed;
}
*/
/// Override setting a new value to the i-th parameter
void setParameter(size_t i, const double &value,
bool explicitlySet = true) override;
/// Override setting a new value to a parameter by name
void setParameter(const std::string &name, const double &value,
bool explicitlySet = true) override;
/// Set peak's height
// virtual void setHeight(const double h);
/// Get peak's height
// virtual double height()const;
using IFunction1D::function;
void function(std::vector<double> &out,
const std::vector<double> &xValues) const override;
/// Function you want to fit to.
void function1D(double *out, const double *xValues,
const size_t nData) const override;
private:
//----- Overwrite IFunction ------------------------------------------------
/// Fuction local
void functionLocal(double *out, const double *xValues,
const size_t nData) const;
/// Derivative
virtual void functionDerivLocal(API::Jacobian *out, const double *xValues,
const size_t nData);
/// Derivative
void functionDeriv(const API::FunctionDomain &domain,
API::Jacobian &jacobian) override;
/// Overwrite IFunction base class method, which declare function parameters
void init() override;
static int s_peakRadius;
//-------- Private Functions -----------------------------------
/// Calcualte H and Eta
void calHandEta(double sigma2, double gamma, double &H, double &eta) const;
/// Calculate peak center
double calPeakCenter() const;
/// Calculate peak profile I(TOF) = Omega(TOF)
double calOmega(const double x, const double eta, const double N,
const double alpha, const double beta, const double H,
const double sigma2, const double invert_sqrt2sigma,
const bool explicitoutput = false) const;
/// Set 2 functions to be hidden from client
/*
virtual void setCentre(const double c);
virtual void setFwhm(const double w);
*/
//------------------------------------------ Variables
//--------------------------------------
/// BackToBackExponential parameters
mutable double m_Alpha;
mutable double m_Beta;
mutable double m_Sigma2;
mutable double m_Gamma;
/// FWHM
// mutable double m_fwhm;
/// Centre
// mutable double m_centre;
// mutable double m_dcentre;
/// Thermal/Epithermal neutron related
mutable double m_eta;
mutable double m_N;
/// Override setting a new value to the
//----------- For Parallelization -----------------------------------------
///
void interruption_point() const;
/// Set to true to stop execution
mutable bool m_cancel;
/// Set if an exception is thrown, and not caught, within a parallel region
mutable bool m_parallelException;
/// Flag to show whether the unit cell has been calcualted
mutable bool m_dspaceCalculated;
/// Flag to indicate whether there is new parameter value set after
/// calculating parameters
// mutable bool m_newValueSet;
};
/// Shared pointer to ThermalNeutronBk2BkExpConvPVoigt peak/function
typedef boost::shared_ptr<ThermalNeutronBk2BkExpConvPVoigt>
ThermalNeutronBk2BkExpConvPVoigt_sptr;
//--- Public inline function --------------------------------------------------
/** Calculate d = a/sqrt(h**2+k**2+l**2)
inline double calCubicDSpace(double a, int h, int k, int l)
{
// TODO This function will be refactored in future.
double d = a/( sqrt(double(h*h)+double(k*k)+double(l*l)) );
return d;
}
*/
/// Integral for Gamma
// std::complex<double> E1X(std::complex<double> z);
} // namespace Functions
} // namespace CurveFitting
} // namespace Mantid
#endif /* MANTID_CURVEFITTING_THERMALNEUTRONBK2BKEXPCONVPVOIGT_H_ */