forked from AmbaPant/mantid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
StandardSC.py
42 lines (34 loc) · 1.68 KB
/
StandardSC.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
# 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
from mantid.kernel import PhysicalConstants as const
class StandardSC(IFunction1D):
def category(self):
return "Muon\\MuonGeneric"
def init(self):
self.declareParameter(
"A0", 0.16, 'Amplitude of interal field oscillation')
self.declareParameter("Sigma", 0.2, 'Gaussian decay rate')
self.declareParameter("FieldSC", 300.0, 'Internal Field (G)')
self.declareParameter("FieldBG", 300.0, 'External Field (G)')
self.declareParameter("Phi", 0.0, 'Phase')
self.declareParameter(
"Abg", 0.1, 'Amplitude of external field oscillation')
def function1D(self, x):
A0 = self.getParameterValue("A0")
sigma = self.getParameterValue("Sigma")
FieldSC = self.getParameterValue("FieldSC")
FieldBG = self.getParameterValue("FieldBG")
phi = self.getParameterValue("Phi")
Abg = self.getParameterValue("Abg")
gamma_mu = const.MuonGyromagneticRatio
omegaSC = FieldSC * gamma_mu * 2 * np.pi
omegaBG = FieldBG * gamma_mu * 2 * np.pi
return A0 * np.exp(- 0.5 * sigma * sigma * x * x) * np.cos(omegaSC * x + phi) + Abg * np.cos(omegaBG * x + phi)
FunctionFactory.subscribe(StandardSC)