Mantid
Loading...
Searching...
No Matches
ElasticDiffRotDiscreteCircle.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 <cmath>
13#include <limits>
14
16
17namespace {
18Mantid::Kernel::Logger g_log("ElasticDiffRotDiscreteCircle");
19}
20
22
23DECLARE_FUNCTION(ElasticDiffRotDiscreteCircle)
24
25
29 // declareParameter("Height", 1.0); //parameter "Height" already declared in
30 // constructor of base class DeltaFunction
31 this->declareParameter("Radius", 1.0, "Circle radius [Angstroms] ");
32 this->declareAttribute("N", API::IFunction::Attribute(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 auto R = this->getParameter("Radius");
53 auto Q = this->getAttribute("Q").asDouble();
54 auto N = this->getAttribute("N").asInt();
55 double aN = 0;
56 for (int k = 1; k < N; k++) {
57 double x = 2 * Q * R * sin(M_PI * k / N);
58 aN += sin(x) / x; // spherical Besell function of order zero j0==sin(x)/x
59 }
60 aN += 1; // limit for j0 when k==N, or x==0
61 return aN / N;
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:285
int asInt() const
Returns int value if attribute is a int, throws exception otherwise.
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...
void init() override
overwrite IFunction base class method, which declare function parameters
double HeightPrefactor() const override
A rescaling of the peak intensity.
virtual void declareAttributes() override
declare commonattributes Q and WorkspaceIndex.
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition Logger.h:51