Mantid
Loading...
Searching...
No Matches
ActivationmeV.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//----------------------------------------------------------------------
14
15#include <cmath>
16
18
19using namespace CurveFitting;
20
21using namespace Kernel;
22
23using namespace API;
24
25using namespace CurveFitting::MuonHelper;
26
27DECLARE_FUNCTION(ActivationmeV)
28
29void ActivationmeV::init() {
30 declareParameter("AttemptRate", 1000.0, "coefficient for attempt rate");
31 declareParameter("Barrier", 1000.0, "coefficient for barrier energy");
32}
33
34void ActivationmeV::function1D(double *out, const double *xValues, const size_t nData) const {
35 const double attemptRate = getParameter("AttemptRate");
36 const double barrier = getParameter("Barrier");
37 const double meVConv = PhysicalConstants::meVtoKelvin;
38
39 for (size_t i = 0; i < nData; i++) {
40 out[i] = getActivationFunc(xValues[i], attemptRate, barrier, meVConv);
41 }
42}
43
44void ActivationmeV::functionDeriv1D(Jacobian *out, const double *xValues, const size_t nData) {
45 const double attemptRate = getParameter("AttemptRate");
46 const double barrier = getParameter("Barrier");
47 const double meVConv = PhysicalConstants::meVtoKelvin;
48
49 for (size_t i = 0; i < nData; i++) {
50 double diffAR = getAttemptRateDiff(xValues[i], barrier, meVConv);
51 double diffBarrier = getBarrierDiff(xValues[i], attemptRate, barrier, meVConv);
52 out->set(i, 0, diffAR);
53 out->set(i, 1, diffBarrier);
54 }
55}
56
57} // 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 meV interface to IFunction.
Definition: ActivationmeV.h:28
void function1D(double *out, const double *xValues, const size_t nData) const override
Function you want to fit to.
void functionDeriv1D(API::Jacobian *out, const double *xValues, const size_t nData) override
Derivatives of function with respect to active parameters.
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
static constexpr double meVtoKelvin
1 meV in Kelvin.