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
12#include <boost/math/special_functions/bessel.hpp>
13#include <cmath>
14#include <limits>
15
17
18namespace {
19Mantid::Kernel::Logger g_log("IsoRotDiff");
20}
21
23
24DECLARE_FUNCTION(ElasticIsoRotDiff)
25
26
30 // parameter "Height" declared in parent DeltaFunction constructor
31 // declareParameter("Height", 1.0);
32 declareParameter("Radius", 0.98, "Radius of rotation (Angstroms)");
33 declareAttribute("Q", API::IFunction::Attribute(0.3));
34}
35
40 // Ensure positive values for Height and Radius
41 auto HeightConstraint = std::make_unique<BConstraint>(this, "Height", std::numeric_limits<double>::epsilon(), true);
42 this->addConstraint(std::move(HeightConstraint));
43
44 auto RadiusConstraint = std::make_unique<BConstraint>(this, "Radius", std::numeric_limits<double>::epsilon(), true);
45 this->addConstraint(std::move(RadiusConstraint));
46}
47
52 const double R = this->getParameter("Radius");
53 const double Q = this->getAttribute("Q").asDouble();
54
55 // Penalize negative parameters
56 if (R < std::numeric_limits<double>::epsilon()) {
57 return std::numeric_limits<double>::infinity();
58 }
59
60 return pow(boost::math::sph_bessel(0, Q * R), 2);
61}
62
63} // 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:285
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