-
Notifications
You must be signed in to change notification settings - Fork 122
/
DecoupAsymPowderMagRot.cpp
56 lines (44 loc) · 1.77 KB
/
DecoupAsymPowderMagRot.cpp
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
56
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidCurveFitting/Functions/DecoupAsymPowderMagRot.h"
#include "MantidAPI/FunctionFactory.h"
#include "MantidCurveFitting/MuonHelpers.h"
#include <cmath>
namespace Mantid::CurveFitting::Functions {
using namespace CurveFitting;
using namespace Kernel;
using namespace API;
using namespace CurveFitting::MuonHelper;
DECLARE_FUNCTION(DecoupAsymPowderMagRot)
void DecoupAsymPowderMagRot::init() {
declareParameter("Asymmetry", 1.0, "a scaling parameter for the overall asymmetry");
declareParameter("CharField", 1.0, "the characteristic field");
}
void DecoupAsymPowderMagRot::function1D(double *out, const double *xValues, const size_t nData) const {
const double asym = getParameter("Asymmetry");
const double charField = getParameter("CharField");
for (size_t i = 0; i < nData; i++) {
auto A_z = getAz(xValues[i], charField);
out[i] = asym * (1 - A_z);
}
}
void DecoupAsymPowderMagRot::functionDeriv1D(Jacobian *out, const double *xValues, const size_t nData) {
const double charField = getParameter("CharField");
for (size_t i = 0; i < nData; i++) {
double diffasym = 1 - getAz(xValues[i], charField);
double diffAz = getDiffAz(xValues[i], charField);
if (!std::isfinite(diffasym)) {
diffasym = 0.0;
}
out->set(i, 0, diffasym);
out->set(i, 1, diffAz);
}
}
} // namespace Mantid::CurveFitting::Functions