Mantid
Loading...
Searching...
No Matches
ThermalNeutronBk2BkExpBeta.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::CurveFitting;
18
19using namespace Mantid::API;
20
22
23using namespace CurveFitting;
24
26
27//----------------------------------------------------------------------------------------------
31 declareParameter("Width", 1.0);
32 declareParameter("Tcross", 1.0);
33
34 declareParameter("Beta0", 0.0);
35 declareParameter("Beta1", 0.0);
36 declareParameter("Beta0t", 0.0);
37 declareParameter("Beta1t", 0.0);
38}
39
40//----------------------------------------------------------------------------------------------
43void ThermalNeutronBk2BkExpBeta::function1D(double *out, const double *xValues, const size_t nData) const {
44 double width = getParameter("Width");
45 double tcross = getParameter("Tcross");
46 double beta0 = getParameter("Beta0");
47 double beta1 = getParameter("Beta1");
48 double beta0t = getParameter("Beta0t");
49 double beta1t = getParameter("Beta1t");
50
51 for (size_t i = 0; i < nData; ++i) {
52 out[i] = corefunction(xValues[i], width, tcross, beta0, beta1, beta0t, beta1t);
53 }
54}
55
59 calNumericalDeriv(domain, jacobian);
60}
61
62//----------------------------------------------------------------------------------------------
65double ThermalNeutronBk2BkExpBeta::corefunction(double dh, double width, double tcross, double beta0, double beta1,
66 double beta0t, double beta1t) const {
67 double n = 0.5 * gsl_sf_erfc(width * (tcross - 1.0 / dh));
68 double beta = 1.0 / (n * (beta0 + beta1 * dh) + (1.0 - n) * (beta0t - beta1t / dh));
69
70 return beta;
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.
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.
ThermalNeutronBk2BkExpBETA : Function to calculate Beta of Bk2Bk Exponential function from Thermal Ne...
void function1D(double *out, const double *xValues, const size_t nData) const override
Override.
double corefunction(double dh, double width, double tcross, double beta0, double beta1, double beta0t, double beta1t) 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.