Mantid
Loading...
Searching...
No Matches
DiffSphere.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
13// Mantid headers from other projects
15#include "MantidAPI/IFunction.h"
17// third party library headers (N/A)
18// standard library headers (N/A)
19
20#include <boost/math/special_functions/bessel.hpp>
21
22#include <cmath>
23#include <limits>
24
25namespace {
26Mantid::Kernel::Logger g_log("DiffSphere");
27}
28
30
31DECLARE_FUNCTION(DiffSphere)
32
33
39void DiffSphere::trickleDownAttribute(const std::string &name) {
40 for (size_t iFun = 0; iFun < this->nFunctions(); iFun++) {
41 API::IFunction_sptr fun = this->getFunction(iFun);
42 if (fun->hasAttribute(name)) {
43 fun->setAttribute(name, this->getAttribute(name));
44 }
45 }
46}
47
51void DiffSphere::declareAttribute(const std::string &name, const API::IFunction::Attribute &defaultValue) {
53 this->trickleDownAttribute(name);
54}
55
61void DiffSphere::setAttribute(const std::string &name, const API::IFunction::Attribute &att) {
63 this->trickleDownAttribute(name);
64}
65
70 m_elastic = std::dynamic_pointer_cast<ElasticDiffSphere>(
71 API::FunctionFactory::Instance().createFunction("ElasticDiffSphere"));
73 m_inelastic = std::dynamic_pointer_cast<InelasticDiffSphere>(
74 API::FunctionFactory::Instance().createFunction("InelasticDiffSphere"));
76
77 this->setAttributeValue("NumDeriv", true);
79
80 // Set the ties between Elastic and Inelastic parameters
81 this->addDefaultTies("f0.Height=f1.Intensity,f0.Radius=f1.Radius,f0.Centre=0");
82 this->applyTies();
83}
84
85} // namespace Mantid::CurveFitting::Functions
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
void declareAttribute(const std::string &name, const API::IFunction::Attribute &defaultValue)
Declare a single attribute.
void setAttribute(const std::string &name, const API::IFunction::Attribute &value) override
Set a value of a named attribute.
void applyTies() override
Apply the ties.
Attribute is a non-fitting parameter.
Definition: IFunction.h:282
void setAttributeValue(const std::string &attName, const T &value)
Set an attribute value.
Definition: IFunction.h:597
void addDefaultTies(const std::string &ties)
Add default ties.
void addFunction(IFunction *fun)
Overload addFunction to take a bare pointer.
std::shared_ptr< Mantid::CurveFitting::Functions::ElasticDiffSphere > m_elastic
Definition: DiffSphere.h:53
virtual void trickleDownAttribute(const std::string &name)
Propagate an attribute to member functions.
Definition: DiffSphere.cpp:39
std::string name() const override
overwrite IFunction base class methods
Definition: DiffSphere.h:31
virtual void declareAttribute(const std::string &name, const API::IFunction::Attribute &defaultValue)
Override parent definition.
Definition: DiffSphere.cpp:51
void init() override
overwrite IFunction base class method, which declare function parameters
Definition: DiffSphere.cpp:69
std::shared_ptr< Mantid::CurveFitting::Functions::InelasticDiffSphere > m_inelastic
Definition: DiffSphere.h:55
void setAttribute(const std::string &name, const API::IFunction::Attribute &att) override
Override parent definition.
Definition: DiffSphere.cpp:61
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition: Logger.h:52
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition: IFunction.h:732
STL namespace.