Mantid
Loading...
Searching...
No Matches
Framework
CurveFitting
src
Functions
ThermalNeutronBk2BkExpSigma.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 +
7
#include "
MantidCurveFitting/Functions/ThermalNeutronBk2BkExpSigma.h
"
8
#include "
MantidAPI/FunctionFactory.h
"
9
10
#include <cmath>
11
#include <gsl/gsl_sf_erf.h>
12
13
using namespace
std
;
14
15
using namespace
Mantid
;
16
17
using namespace
Mantid::API
;
18
19
using namespace
Mantid::CurveFitting
;
20
21
namespace
Mantid::CurveFitting::Functions
{
22
23
using namespace
CurveFitting;
24
25
DECLARE_FUNCTION
(
ThermalNeutronBk2BkExpSigma
)
26
27
//----------------------------------------------------------------------------------------------
30
void
ThermalNeutronBk2BkExpSigma
::init() {
31
declareParameter(
"Sig0"
, 0.0);
32
declareParameter(
"Sig1"
, 0.0);
33
declareParameter(
"Sig2"
, 0.0);
34
}
35
36
//----------------------------------------------------------------------------------------------
39
void
ThermalNeutronBk2BkExpSigma::function1D
(
double
*out,
const
double
*xValues,
const
size_t
nData)
const
{
40
double
sig0 =
getParameter
(
"Sig0"
);
41
double
sig1 =
getParameter
(
"Sig1"
);
42
double
sig2 =
getParameter
(
"Sig2"
);
43
44
double
sig0sq = sig0 * sig0;
45
double
sig1sq = sig1 * sig1;
46
double
sig2sq = sig2 * sig2;
47
48
for
(
size_t
i = 0; i < nData; ++i) {
49
out[i] =
corefunction
(xValues[i], sig0sq, sig1sq, sig2sq);
50
}
51
}
52
55
void
ThermalNeutronBk2BkExpSigma::functionDeriv
(
const
FunctionDomain
&domain,
Jacobian
&jacobian) {
56
calNumericalDeriv
(domain, jacobian);
57
}
58
59
//----------------------------------------------------------------------------------------------
62
double
ThermalNeutronBk2BkExpSigma::corefunction
(
double
dh,
double
sig0sq,
double
sig1sq,
double
sig2sq)
const
{
63
double
sigma2 = sig0sq + sig1sq * dh * dh + sig2sq * pow(dh, 4);
64
if
(sigma2 <= 0.0) {
65
throw
runtime_error(
"Sigma^2 cannot be equal to or less than Zero!"
);
66
}
67
68
double
sigma
= sqrt(sigma2);
69
70
return
sigma
;
71
}
72
73
}
// namespace Mantid::CurveFitting::Functions
FunctionFactory.h
DECLARE_FUNCTION
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
Definition
FunctionFactory.h:151
sigma
double sigma
Definition
GetAllEi.cpp:156
ThermalNeutronBk2BkExpSigma.h
Mantid::API::FunctionDomain
Base class that represents the domain of a function.
Definition
FunctionDomain.h:31
Mantid::API::IFunction::calNumericalDeriv
void calNumericalDeriv(const FunctionDomain &domain, Jacobian &jacobian)
Calculate numerical derivatives.
Definition
IFunction.cpp:1106
Mantid::API::Jacobian
Represents the Jacobian in IFitFunction::functionDeriv.
Definition
Jacobian.h:22
Mantid::API::ParamFunction::getParameter
double getParameter(size_t i) const override
Get i-th parameter.
Definition
ParamFunction.cpp:62
Mantid::CurveFitting::Functions::ThermalNeutronBk2BkExpSigma
ThermalNeutronBk2BkExpSIGMA : Function to calculate Sigma of Bk2Bk Exponential function from Thermal ...
Definition
ThermalNeutronBk2BkExpSigma.h:21
Mantid::CurveFitting::Functions::ThermalNeutronBk2BkExpSigma::function1D
void function1D(double *out, const double *xValues, const size_t nData) const override
Override.
Definition
ThermalNeutronBk2BkExpSigma.cpp:39
Mantid::CurveFitting::Functions::ThermalNeutronBk2BkExpSigma::corefunction
double corefunction(double dh, double sig0sq, double sig1sq, double sig2sq) const
Core function (inline) to calcualte TOF_h from d-spacing.
Definition
ThermalNeutronBk2BkExpSigma.cpp:62
Mantid::CurveFitting::Functions::ThermalNeutronBk2BkExpSigma::functionDeriv
void functionDeriv(const API::FunctionDomain &domain, API::Jacobian &jacobian) override
Derivative to overwrite.
Definition
ThermalNeutronBk2BkExpSigma.cpp:55
Mantid::API
Definition
AbsorptionCorrection.h:20
Mantid::CurveFitting::Functions
Definition
VesuvioCalculateGammaBackground.h:23
Mantid::CurveFitting
Definition
IFunction1D.h:19
Mantid
Helper class which provides the Collimation Length for SANS instruments.
Definition
AbsorptionCorrection.h:18
std
STL namespace.
Generated by
1.9.8