12#include <gsl/gsl_sf_erf.h>
20using namespace CurveFitting;
31 declareParameter(
"Dtt1", 1.0);
32 declareParameter(
"Dtt1t", 1.0);
33 declareParameter(
"Dtt2t", 1.0);
34 declareParameter(
"Zero", 0.0);
35 declareParameter(
"Zerot", 0.0);
37 declareParameter(
"Width", 1.0);
38 declareParameter(
"Tcross", 1.0);
53 for (
size_t i = 0; i < nData; ++i) {
73 size_t nData = out.size();
75 for (
size_t i = 0; i < nData; ++i) {
91 for (
size_t i = 0; i < nData; ++i) {
93 double x = xValues[i];
94 double n = 0.5 * gsl_sf_erfc(width * (tcross - 1 /
x));
95 double u = width * (tcross - 1 /
x);
97 double deriv_dtt1 =
n *
x;
98 double deriv_dtt1t = (1 -
n) *
x;
99 double deriv_dtt2t = (
n - 1) /
x;
100 double deriv_zero =
n;
101 double deriv_zerot = (1 -
n);
103 -(zero + dtt1 *
x - zerot - dtt1t *
x + dtt2t /
x) * exp(-u * u) / sqrt(M_PI) * (tcross - 1 /
x);
104 double deriv_tcross = -(zero + dtt1 *
x - zerot - dtt1t *
x + dtt2t /
x) * exp(-u * u) / sqrt(M_PI) * width;
107 out->
set(i, 0, deriv_dtt1);
108 out->
set(i, 1, deriv_dtt1t);
109 out->
set(i, 2, deriv_dtt2t);
110 out->
set(i, 3, deriv_zero);
111 out->
set(i, 4, deriv_zerot);
112 out->
set(i, 5, deriv_width);
113 out->
set(i, 6, deriv_tcross);
122 "ThermalNeutronDtoTOFFunction.");
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
Represents the Jacobian in IFitFunction::functionDeriv.
virtual void set(size_t iY, size_t iP, double value)=0
Set a value to a Jacobian matrix element.
double getParameter(size_t i) const override
Get i-th parameter.
ThermalNeutronDtoTOFFunction : TODO: DESCRIPTION.
void functionDeriv1D(API::Jacobian *out, const double *xValues, const size_t nData) override
Derivative.
void function1D(double *out, const double *xValues, const size_t nData) const override
Override.
void functionDerivLocal(API::Jacobian *, const double *, const size_t)
Derivative.
Marks code as not implemented yet.
double calThermalNeutronTOF(double dh, double dtt1, double dtt1t, double dtt2t, double zero, double zerot, double width, double tcross)
Calcualte TOF from d-spacing value for thermal neutron.