/
MuonFInteraction.cpp
48 lines (38 loc) · 1.67 KB
/
MuonFInteraction.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidCurveFitting/Functions/MuonFInteraction.h"
#include "MantidAPI/FunctionFactory.h"
#include <cmath>
namespace Mantid::CurveFitting::Functions {
using namespace CurveFitting;
using namespace Kernel;
using namespace API;
DECLARE_FUNCTION(MuonFInteraction)
void MuonFInteraction::init() {
declareParameter("Lambda", 0.2, "decay rate");
declareParameter("Omega", 0.5, "angular frequency");
declareParameter("Beta", 1, "exponent");
declareParameter("A", 1, "Amplitude at 0");
}
void MuonFInteraction::function1D(double *out, const double *xValues, const size_t nData) const {
const double lambda = getParameter("Lambda");
const double omega = getParameter("Omega");
const double beta = getParameter("Beta");
const double A = getParameter("A");
const double sqrt3 = sqrt(3.0);
for (size_t i = 0; i < nData; i++) {
double A1 = exp(-pow(lambda * xValues[i], beta)) * A / 6;
double A2 = cos(sqrt3 * omega * xValues[i]);
double A3 = (1.0 - 1.0 / sqrt3) * cos(((3.0 - sqrt3) / 2.0) * omega * xValues[i]);
double A4 = (1.0 + 1.0 / sqrt3) * cos(((3.0 + sqrt3) / 2.0) * omega * xValues[i]);
out[i] = A1 * (3 + A2 + A3 + A4);
}
}
} // namespace Mantid::CurveFitting::Functions