/
Redfield.py
32 lines (24 loc) · 1.12 KB
/
Redfield.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
# 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
from mantid.kernel import PhysicalConstants
import numpy as np
from math import pi
class Redfield(IFunction1D):
def category(self):
return "Muon\\MuonModelling"
def init(self):
self.declareParameter("Hloc", 0.1, "Local magnetic field (G)")
self.declareParameter("Tau", 0.1, "Correlation time of muon spins (microsec)")
def function1D(self, x):
Hloc = self.getParameterValue("Hloc")
tau = self.getParameterValue("Tau")
gmu = PhysicalConstants.MuonGyromagneticRatio
gama = 2 * pi * gmu
return 2 * np.power((gama * Hloc), 2) * tau / (1 + np.power((gama * x * tau), 2))
FunctionFactory.subscribe(Redfield)