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 +
9
10#include <cmath>
11#include <gsl/gsl_sf_erf.h>
12
13using namespace std;
14
15using namespace Mantid;
16
17using namespace Mantid::API;
18
19using namespace Mantid::CurveFitting;
20
22
23using namespace CurveFitting;
24
26
27//----------------------------------------------------------------------------------------------
31 declareParameter("Sig0", 0.0);
32 declareParameter("Sig1", 0.0);
33 declareParameter("Sig2", 0.0);
34}
35
36//----------------------------------------------------------------------------------------------
39void 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
56 calNumericalDeriv(domain, jacobian);
57}
58
59//----------------------------------------------------------------------------------------------
62double 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
#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.
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.