Mantid
Loading...
Searching...
No Matches
DecoupAsymPowderMagLong.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin
6// SPDX - License - Identifier: GPL - 3.0 +
7//----------------------------------------------------------------------
8// Includes
9//----------------------------------------------------------------------
13
14#include <cmath>
15
17
18using namespace CurveFitting;
19
20using namespace Kernel;
21
22using namespace API;
23
24using namespace CurveFitting::MuonHelper;
25
26DECLARE_FUNCTION(DecoupAsymPowderMagLong)
27
29 declareParameter("Asymmetry", 1.0, "a scaling parameter for the overall asymmetry");
30 declareParameter("CharField", 1.0, "the characteristic field");
31}
32
33void DecoupAsymPowderMagLong::function1D(double *out, const double *xValues, const size_t nData) const {
34 const double asym = getParameter("Asymmetry");
35 const double charField = getParameter("CharField");
36
37 for (size_t i = 0; i < nData; i++) {
38 auto A_z = getAz(xValues[i], charField);
39 out[i] = asym * A_z;
40 }
41}
42
43void DecoupAsymPowderMagLong::functionDeriv1D(Jacobian *out, const double *xValues, const size_t nData) {
44 const double charField = getParameter("CharField");
45
46 for (size_t i = 0; i < nData; i++) {
47 double diffasym = getAz(xValues[i], charField);
48 double diffAz = getDiffAz(xValues[i], charField);
49 if (!std::isfinite(diffasym)) {
50 diffasym = 0.0;
51 }
52 out->set(i, 0, diffasym);
53 out->set(i, 1, diffAz);
54 }
55}
56} // namespace Mantid::CurveFitting::Functions
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
Represents the Jacobian in IFitFunction::functionDeriv.
Definition: Jacobian.h:22
virtual void set(size_t iY, size_t iP, double value)=0
Set a value to a Jacobian matrix element.
double getParameter(size_t i) const override
Get i-th parameter.
Provide Decoupling of asymmetry in the ordered state of a powdered magnet for fitting function interf...
void functionDeriv1D(API::Jacobian *out, const double *xValues, const size_t nData) override
Derivatives of function with respect to active parameters.
void function1D(double *out, const double *xValues, const size_t nData) const override
Function you want to fit to.
double MANTID_CURVEFITTING_DLL getDiffAz(double xValue, const double charField)
Definition: MuonHelpers.cpp:23
double MANTID_CURVEFITTING_DLL getAz(double xValue, const double charField)
Definition: MuonHelpers.cpp:15