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