forked from AmbaPant/mantid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
PCRmagRedfield.py
36 lines (28 loc) · 1.15 KB
/
PCRmagRedfield.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
36
# 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 PCRmagRedfield(IFunction1D):
def category(self):
return "Muon\\MuonSpecific"
def init(self):
self.declareParameter("A0", 0.2, 'Amplitude')
self.declareParameter("Delta", 0.2)
self.declareParameter("Nu", 0.2)
def function1D(self, x):
A0 = self.getParameterValue("A0")
Delta = self.getParameterValue("Delta")
Nu = self.getParameterValue("Nu")
W = 2 * np.pi * Delta
Q = (Nu ** 2 + Delta ** 2) * Nu
if Q > 0:
Lambda = Delta ** 4 / Q
else:
Lambda = 0
return A0 * (1./3 + 2./3 * np.exp(- Lambda * x) * np.cos(W * x))
FunctionFactory.subscribe(PCRmagRedfield)