Mantid
Loading...
Searching...
No Matches
MuonFInteraction.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 +
7//----------------------------------------------------------------------
8// Includes
9//----------------------------------------------------------------------
12#include <cmath>
13
15
16using namespace CurveFitting;
17
18using namespace Kernel;
19
20using namespace API;
21
22DECLARE_FUNCTION(MuonFInteraction)
23
24void MuonFInteraction::init() {
25 declareParameter("Lambda", 0.2, "decay rate");
26 declareParameter("Omega", 0.5, "angular frequency");
27 declareParameter("Beta", 1, "exponent");
28 declareParameter("A", 1, "Amplitude at 0");
29}
30
31void MuonFInteraction::function1D(double *out, const double *xValues, const size_t nData) const {
32 const double lambda = getParameter("Lambda");
33 const double omega = getParameter("Omega");
34 const double beta = getParameter("Beta");
35 const double A = getParameter("A");
36 const double sqrt3 = sqrt(3.0);
37
38 for (size_t i = 0; i < nData; i++) {
39 double A1 = exp(-pow(lambda * xValues[i], beta)) * A / 6;
40 double A2 = cos(sqrt3 * omega * xValues[i]);
41 double A3 = (1.0 - 1.0 / sqrt3) * cos(((3.0 - sqrt3) / 2.0) * omega * xValues[i]);
42 double A4 = (1.0 + 1.0 / sqrt3) * cos(((3.0 + sqrt3) / 2.0) * omega * xValues[i]);
43
44 out[i] = A1 * (3 + A2 + A3 + A4);
45 }
46}
47
48} // namespace Mantid::CurveFitting::Functions
const std::vector< double > * lambda
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
double getParameter(size_t i) const override
Get i-th parameter.
Provide Muon F Interaction fitting function.
void function1D(double *out, const double *xValues, const size_t nData) const override
Function you want to fit to.