forked from AmbaPant/mantid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
TFMuonium.py
55 lines (47 loc) · 2.08 KB
/
TFMuonium.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# 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 TFMuonium(IFunction1D):
def category(self):
return "Muon\\MuonSpecific"
def init(self):
self.declareParameter("A0", 0.5, 'Amplitude')
self.declareParameter("Field", 5, 'B-field (G)')
self.declareParameter(
"A", 600, 'Isotropic hyperfine coupling constant (MHz)')
self.declareParameter("Phi", 0.0, 'Phase')
def function1D(self, x):
A0 = self.getParameterValue("A0")
B = self.getParameterValue("Field")
A = self.getParameterValue("A")
phi = self.getParameterValue("Phi")
gm = 0.01355342
ge = 2.8024
fcut = 10**32
chi = (gm + ge) * B / A
diff = (ge - gm) / (gm + ge)
delta = chi / np.sqrt(1 + chi ** 2)
E1 = A / 4 * (1 + 2 * diff * chi)
E2 = A / 4 * (- 1 + 2 * np.sqrt(1 + chi ** 2))
E3 = A / 4 * (1 - 2 * diff * chi)
E4 = A / 4 * (- 1 - 2 * np.sqrt(1 + chi ** 2))
w12 = 2 * np.pi * (E1 - E2)
w14 = 2 * np.pi * (E1 - E4)
w34 = 2 * np.pi * (E3 - E4)
w23 = 2 * np.pi * (E2 - E3)
a12 = 1 / (1 + (w12 / (2 * np.pi * fcut)) ** 2)
a14 = 1 / (1 + (w14 / (2 * np.pi * fcut)) ** 2)
a34 = 1 / (1 + (w34 / (2 * np.pi * fcut)) ** 2)
a23 = 1 / (1 + (w23 / (2 * np.pi * fcut)) ** 2)
Term1 = (1 + delta) * a12 * np.cos(w12 * x + phi)
Term2 = (1 - delta) * a14 * np.cos(w14 * x + phi)
Term3 = (1 + delta) * a34 * np.cos(w34 * x + phi)
Term4 = (1 - delta) * a23 * np.cos(w23 * x + phi)
return A0 * 0.25 * (Term1 + Term2 + Term3 + Term4)
FunctionFactory.subscribe(TFMuonium)