Mantid
Loading...
Searching...
No Matches
StaticKuboToyabeTimesGausDecay.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
9#include <cmath>
10
12
13using namespace CurveFitting;
14
15using namespace Kernel;
16
17using namespace API;
18
19DECLARE_FUNCTION(StaticKuboToyabeTimesGausDecay)
20
22 declareParameter("A", 1.0, "Amplitude at time 0");
23 declareParameter("Delta", 0.2, "StaticKuboToyabe decay rate");
24 declareParameter("Sigma", 0.2, "Gaus decay rate");
25}
26
27void StaticKuboToyabeTimesGausDecay::function1D(double *out, const double *xValues, const size_t nData) const {
28 const double A = getParameter("A");
29 const double D = getParameter("Delta");
30 const double S = getParameter("Sigma");
31
32 // Precalculate squares
33 const double D2 = pow(D, 2);
34 const double S2 = pow(S, 2);
35
36 // Precalculate constants
37 const double C1 = 2.0 / 3;
38 const double C2 = 1.0 / 3;
39
40 for (size_t i = 0; i < nData; i++) {
41 double x2 = pow(xValues[i], 2);
42 out[i] = A * (exp(-(x2 * D2) / 2) * (1 - x2 * D2) * C1 + C2) * exp(-S2 * x2);
43 }
44}
45} // namespace Mantid::CurveFitting::Functions
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
double getParameter(size_t i) const override
Get i-th parameter.
void function1D(double *out, const double *xValues, const size_t nData) const override
Function you want to fit to.