/
MuMinusExpTF.py
35 lines (28 loc) · 1.33 KB
/
MuMinusExpTF.py
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
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2019 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 +
# pylint: disable=invalid-name, anomalous-backslash-in-string, attribute-defined-outside-init
from mantid.api import IFunction1D, FunctionFactory
import numpy as np
class MuMinusExpTF(IFunction1D):
def category(self):
return "Muon\\MuonSpecific"
def init(self):
self.declareParameter("A", 1)
self.declareParameter("Lambda", 0.1, "Decay rate of oscillating term")
self.declareParameter("N0", 1)
self.declareParameter("Tau", 5.0)
self.declareParameter("Phi", 0.3, "Phase")
self.declareParameter("Nu", 0.2, "Oscillating frequency (MHz)")
def function1D(self, x):
A = self.getParameterValue("A")
Lambda = self.getParameterValue("Lambda")
N0 = self.getParameterValue("N0")
tau = self.getParameterValue("Tau")
phi = self.getParameterValue("Phi")
nu = self.getParameterValue("Nu")
return N0 * np.exp(-x / tau) * (1 + A * np.exp(-Lambda * x) * np.cos(2 * np.pi * nu * x + phi))
FunctionFactory.subscribe(MuMinusExpTF)