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 +
7// Mantid Coding standars <http://www.mantidproject.org/Coding_Standards>
8// Main Module Header
10// Mantid Headers from the same project
12// Mantid headers from other projects
14#include "MantidAPI/IFunction.h"
15
16// third party library headers
17#include <boost/math/special_functions/bessel.hpp>
18// standard library headers
19#include <cmath>
20#include <limits>
21
23
24namespace {
25Mantid::Kernel::Logger g_log("IsoRotDiff");
26}
27
29
30DECLARE_FUNCTION(ElasticIsoRotDiff)
31
32
36 // parameter "Height" declared in parent DeltaFunction constructor
37 // declareParameter("Height", 1.0);
38 declareParameter("Radius", 0.98, "Radius of rotation (Angstroms)");
39 declareAttribute("Q", API::IFunction::Attribute(0.3));
40}
41
46 // Ensure positive values for Height and Radius
47 auto HeightConstraint = std::make_unique<BConstraint>(this, "Height", std::numeric_limits<double>::epsilon(), true);
48 this->addConstraint(std::move(HeightConstraint));
49
50 auto RadiusConstraint = std::make_unique<BConstraint>(this, "Radius", std::numeric_limits<double>::epsilon(), true);
51 this->addConstraint(std::move(RadiusConstraint));
52}
53
58 const double R = this->getParameter("Radius");
59 const double Q = this->getAttribute("Q").asDouble();
60
61 // Penalize negative parameters
62 if (R < std::numeric_limits<double>::epsilon()) {
63 return std::numeric_limits<double>::infinity();
64 }
65
66 return pow(boost::math::sph_bessel(0, Q * R), 2);
67}
68
69} // 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:282
double asDouble() const
Returns double value if attribute is a double, throws exception otherwise.
Definition: IFunction.cpp:739
virtual Attribute getAttribute(const std::string &name) const
Return a value of attribute attName.
Definition: IFunction.cpp:1394
virtual void addConstraint(std::unique_ptr< IConstraint > ic)
Add a constraint to function.
Definition: IFunction.cpp:376
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:52