Mantid
Loading...
Searching...
No Matches
ActivationK.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin
6// SPDX - License - Identifier: GPL - 3.0 +
7//----------------------------------------------------------------------
8// Includes
9//----------------------------------------------------------------------
13
14#include <cmath>
15
17
18using namespace CurveFitting;
19
20using namespace Kernel;
21
22using namespace API;
23
24using namespace CurveFitting::MuonHelper;
25
26DECLARE_FUNCTION(ActivationK)
27
28void ActivationK::init() {
29 declareParameter("AttemptRate", 1000.0, "coefficient for attempt rate");
30 declareParameter("Barrier", 1000.0, "coefficient for barrier energy");
31}
32
33void ActivationK::function1D(double *out, const double *xValues, const size_t nData) const {
34 const double attemptRate = getParameter("AttemptRate");
35 const double barrier = getParameter("Barrier");
36 const double meVConv = 1.0;
37
38 for (size_t i = 0; i < nData; i++) {
39 out[i] = getActivationFunc(xValues[i], attemptRate, barrier, meVConv);
40 }
41}
42
43void ActivationK::functionDeriv1D(Jacobian *out, const double *xValues, const size_t nData) {
44 const double attemptRate = getParameter("AttemptRate");
45 const double barrier = getParameter("Barrier");
46 const double meVConv = 1.0;
47
48 for (size_t i = 0; i < nData; i++) {
49 double diffAR = getAttemptRateDiff(xValues[i], barrier, meVConv);
50 double diffBarrier = getBarrierDiff(xValues[i], attemptRate, barrier, meVConv);
51 out->set(i, 0, diffAR);
52 out->set(i, 1, diffBarrier);
53 }
54}
55
56} // namespace Mantid::CurveFitting::Functions
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
Represents the Jacobian in IFitFunction::functionDeriv.
Definition: Jacobian.h:22
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.
Provide Activation fit function for data in Kelvin interface to IFunction.
Definition: ActivationK.h:28
void functionDeriv1D(API::Jacobian *out, const double *xValues, const size_t nData) override
Derivatives of function with respect to active parameters.
Definition: ActivationK.cpp:43
void function1D(double *out, const double *xValues, const size_t nData) const override
Function you want to fit to.
Definition: ActivationK.cpp:33
double MANTID_CURVEFITTING_DLL getAttemptRateDiff(double xValue, const double barrier, const double unitMultipy)
Definition: MuonHelpers.cpp:38
double MANTID_CURVEFITTING_DLL getBarrierDiff(double xValue, const double attemptRate, const double barrier, const double unitMultipy)
Definition: MuonHelpers.cpp:42
double MANTID_CURVEFITTING_DLL getActivationFunc(double xValue, const double attemptRate, const double barrier, const double unitMultipy)
Definition: MuonHelpers.cpp:34