-
Notifications
You must be signed in to change notification settings - Fork 122
/
DiffSphere.h
177 lines (124 loc) · 4.91 KB
/
DiffSphere.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
#ifndef MANTID_DIFFSPHERE_H_
#define MANTID_DIFFSPHERE_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "DeltaFunction.h"
#include "MantidAPI/ParamFunction.h"
#include "MantidAPI/IFunction1D.h"
#include "MantidAPI/FunctionDomain.h"
#include "MantidAPI/Jacobian.h"
#include "MantidAPI/ImmutableCompositeFunction.h"
#include "DeltaFunction.h"
namespace Mantid
{
namespace CurveFitting
{
/**
@author Jose Borreguero, NScD
@date 11/14/2011
Copyright © 2007-8 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
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 ElasticDiffSphere : public DeltaFunction
{
public:
/// Constructor
ElasticDiffSphere();
/// Destructor
virtual ~ElasticDiffSphere() {};
/// overwrite IFunction base class methods
virtual std::string name() const { return "ElasticDiffSphere"; }
virtual const std::string category() const { return "QENS"; }
/// A rescaling of the peak intensity
double HeightPrefactor() const;
/// overwrite IFunction base class method, which declare function parameters
virtual void init();
};
/// structure to hold info on Volino's coefficients
struct xnlc {
double x;
size_t n;
size_t l;
};
/// simple structure to hold a linear interpolation of factor J around its numerical divergence point
struct linearJ {
double slope;
double intercept;
};
/* Class representing the inelastic portion of the DiffSphere algorithm.
* Contains the 98 Lorentzians.
*/
class DLLExport InelasticDiffSphere : public API::ParamFunction, public API::IFunction1D
{
public:
InelasticDiffSphere();
virtual ~InelasticDiffSphere() {}
/// overwrite IFunction base class methods
virtual void init();
/// overwrite IFunction base class methods
virtual std::string name()const{return "InelasticDiffSphere"; }
/// overwrite IFunction base class methods
virtual const std::string category() const { return "QENS"; }
/// Calculate the (2l+1)*A_{n,l} coefficients for each Lorentzian
std::vector< double > LorentzianCoefficients( double a ) const;
protected:
virtual void function1D( double* out, const double* xValues, const size_t nData ) const;
private:
/// initialize the Xnl coefficients
void initXnlCoeff();
/// initialize the m_alpha coefficients
void initAlphaCoeff();
/// initialize the list of parameters for A_{n,l} linear interpolation around the indeterminacy point
void initLinJlist();
/// xnl coefficients
std::vector< xnlc > m_xnl;
/// certain coefficients invariant during fitting
std::vector< double > m_alpha;
/// maximum value of l in xnlist
size_t m_lmax;
/// linear interpolation zone around the numerical divergence of factor J
double m_divZone;
/// Plank's constant divided by \f$ 2\pi \f$, in units of meV*THz
double m_hbar;
/// list of linearized J values
std::vector< linearJ > m_linearJlist;
}; // end of class InelasticDiffSphere
class DLLExport DiffSphere : public API::ImmutableCompositeFunction
{
public:
/// Destructor
~DiffSphere() {};
/// overwrite IFunction base class methods
std::string name()const{ return "DiffSphere"; }
/// overwrite IFunction base class methods
virtual const std::string category() const { return "QENS"; }
/// overwrite IFunction base class methods
virtual int version() const { return 1; }
/// Propagate an attribute to member functions
virtual void trickleDownAttribute( const std::string& name );
/// Override parent definition
virtual void declareAttribute(const std::string & name,const API::IFunction::Attribute & defaultValue );
/// Override parent definition
virtual void setAttribute( const std::string& attName, const Attribute& att );
/// overwrite IFunction base class method, which declare function parameters
virtual void init();
private:
boost::shared_ptr<ElasticDiffSphere> m_elastic; //elastic intensity of the DiffSphere structure factor
boost::shared_ptr<InelasticDiffSphere> m_inelastic; //inelastic intensity of the DiffSphere structure factor
};
} // namespace CurveFitting
} // namespace Mantid
#endif /*MANTID_DIFFSPHERE_H_*/