Mantid
Loading...
Searching...
No Matches
ElasticIsoRotDiff.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
11#include "MantidKernel/Logger.h"
12
13#include <boost/math/special_functions/bessel.hpp>
14#include <cmath>
15#include <limits>
16
18
19namespace {
20Mantid::Kernel::Logger g_log("IsoRotDiff");
21}
22
24
25DECLARE_FUNCTION(ElasticIsoRotDiff)
26
27
31 // parameter "Height" declared in parent DeltaFunction constructor
32 // declareParameter("Height", 1.0);
33 declareParameter("Radius", 0.98, "Radius of rotation (Angstroms)");
34 declareAttribute("Q", API::IFunction::Attribute(0.3));
35}
36
41 // Ensure positive values for Height and Radius
42 auto HeightConstraint = std::make_unique<BConstraint>(this, "Height", std::numeric_limits<double>::epsilon(), true);
43 this->addConstraint(std::move(HeightConstraint));
44
45 auto RadiusConstraint = std::make_unique<BConstraint>(this, "Radius", std::numeric_limits<double>::epsilon(), true);
46 this->addConstraint(std::move(RadiusConstraint));
47}
48
53 const double R = this->getParameter("Radius");
54 const double Q = this->getAttribute("Q").asDouble();
55
56 // Penalize negative parameters
57 if (R < std::numeric_limits<double>::epsilon()) {
58 return std::numeric_limits<double>::infinity();
59 }
60
61 return pow(boost::math::sph_bessel(0, Q * R), 2);
62}
63
64} // namespace Mantid::CurveFitting::Functions
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
Attribute is a non-fitting parameter.
Definition IFunction.h:286
double asDouble() const
Returns double value if attribute is a double, throws exception otherwise.
virtual Attribute getAttribute(const std::string &name) const
Return a value of attribute attName.
virtual void addConstraint(std::unique_ptr< IConstraint > ic)
Add a constraint to function.
double getParameter(size_t i) const override
Get i-th parameter.
A boundary constraint is designed to be used to set either upper or lower (or both) boundaries on a s...
Elastic part of the DiffSphere function.
void init() override
overwrite IFunction base class method, which declare function parameters
double HeightPrefactor() const override
A rescaling of the peak intensity.
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition Logger.h:51